Merge "Catch failure to set screenshot sound" into tm-qpr-dev am: 077eafbad6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19416446

Change-Id: Ic43ddecdec2b86f363a7fa874d1d6f932ae1f818
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Miranda Kephart
2022-07-25 20:38:09 +00:00
committed by Automerger Merge Worker

View File

@@ -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";
}); });