diff options
| author | 2022-07-25 20:23:50 +0000 | |
|---|---|---|
| committer | 2022-07-25 20:23:50 +0000 | |
| commit | 077eafbad6cb9e78868ca00d6b89c075dcbb14c1 (patch) | |
| tree | 891a82014fb31a9e09338eeaba6661794ed825ae | |
| parent | dc67d818ec18da5a93fb49f07c02aecf7e3b61cd (diff) | |
| parent | 527b2124a1ff8ba30552c959eb83c3dae18744ae (diff) | |
Merge "Catch failure to set screenshot sound" into tm-qpr-dev
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java index 89a15f65e98f..82de389060ae 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java @@ -843,14 +843,20 @@ public class ScreenshotController { // The media player creation is slow and needs on the background thread. return CallbackToFutureAdapter.getFuture((completer) -> { mBgExecutor.execute(() -> { - MediaPlayer player = MediaPlayer.create(mContext, - Uri.fromFile(new File(mContext.getResources().getString( - com.android.internal.R.string.config_cameraShutterSound))), null, - new AudioAttributes.Builder() - .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) - .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) - .build(), AudioSystem.newAudioSessionId()); - completer.set(player); + try { + MediaPlayer player = MediaPlayer.create(mContext, + Uri.fromFile(new File(mContext.getResources().getString( + com.android.internal.R.string.config_cameraShutterSound))), + null, + new AudioAttributes.Builder() + .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) + .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) + .build(), AudioSystem.newAudioSessionId()); + completer.set(player); + } catch (IllegalStateException e) { + Log.w(TAG, "Screenshot sound initialization failed", e); + completer.set(null); + } }); return "ScreenshotController#loadCameraSound"; }); |