Merge "Catch failure to set screenshot sound" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
077eafbad6
@@ -843,14 +843,20 @@ public class ScreenshotController {
|
|||||||
// The media player creation is slow and needs on the background thread.
|
// The media player creation is slow and needs on the background thread.
|
||||||
return CallbackToFutureAdapter.getFuture((completer) -> {
|
return CallbackToFutureAdapter.getFuture((completer) -> {
|
||||||
mBgExecutor.execute(() -> {
|
mBgExecutor.execute(() -> {
|
||||||
|
try {
|
||||||
MediaPlayer player = MediaPlayer.create(mContext,
|
MediaPlayer player = MediaPlayer.create(mContext,
|
||||||
Uri.fromFile(new File(mContext.getResources().getString(
|
Uri.fromFile(new File(mContext.getResources().getString(
|
||||||
com.android.internal.R.string.config_cameraShutterSound))), null,
|
com.android.internal.R.string.config_cameraShutterSound))),
|
||||||
|
null,
|
||||||
new AudioAttributes.Builder()
|
new AudioAttributes.Builder()
|
||||||
.setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
|
.setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
|
||||||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
||||||
.build(), AudioSystem.newAudioSessionId());
|
.build(), AudioSystem.newAudioSessionId());
|
||||||
completer.set(player);
|
completer.set(player);
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
Log.w(TAG, "Screenshot sound initialization failed", e);
|
||||||
|
completer.set(null);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return "ScreenshotController#loadCameraSound";
|
return "ScreenshotController#loadCameraSound";
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user