From 8e2e80350cadcf15f4882413870b03d8da45584a Mon Sep 17 00:00:00 2001 From: Pulkit077 Date: Thu, 10 Jun 2021 21:39:20 +0530 Subject: [PATCH] Revert "base: Allow disabling screenshot shutter sound [1/2]" This reverts commit 2e57676ad7f0f392ddd2e856caa9857dbfcfae4e. --- core/java/android/provider/Settings.java | 6 ----- .../settings/backup/SystemSettings.java | 1 - .../validators/SystemSettingsValidators.java | 1 - .../systemui/screenshot/GlobalScreenshot.java | 22 +++++-------------- 4 files changed, 6 insertions(+), 24 deletions(-) diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 6e591cf6fec..2913e11febd 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -5034,12 +5034,6 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean public static final String[] LEGACY_RESTORE_SETTINGS = { }; - /** - * Whether to enable screenshot sound - * @hide - */ - public static final String SCREENSHOT_SOUND = "screenshot_sound"; - /** * These are all public system settings * diff --git a/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java b/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java index e5ef46c1bf5..60e272a8054 100644 --- a/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java +++ b/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java @@ -89,6 +89,5 @@ public class SystemSettings { Settings.System.VOLUME_ROCKER_WAKE, Settings.System.VOLUME_BUTTON_MUSIC_CONTROL, Settings.System.LOCKSCREEN_MEDIA_ART, - Settings.System.SCREENSHOT_SOUND, }; } diff --git a/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java index e8d2a2ec5c3..35284e691c5 100644 --- a/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java @@ -221,6 +221,5 @@ public boolean validate(@Nullable String value) { VALIDATORS.put(System.KEY_APP_SWITCH_ACTION, new InclusiveIntegerRangeValidator(0, 9)); VALIDATORS.put(System.KEY_APP_SWITCH_LONG_PRESS_ACTION, new InclusiveIntegerRangeValidator(0, 9)); VALIDATORS.put(System.LOCKSCREEN_MEDIA_ART, BOOLEAN_VALIDATOR); - VALIDATORS.put(System.SCREENSHOT_SOUND, BOOLEAN_VALIDATOR); } } diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java index 2a04b9955f5..2956e88955c 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java @@ -51,8 +51,6 @@ import android.graphics.drawable.InsetDrawable; import android.graphics.drawable.LayerDrawable; import android.media.MediaActionSound; -import android.media.Ringtone; -import android.media.RingtoneManager; import android.net.Uri; import android.os.Handler; import android.os.Looper; @@ -223,7 +221,7 @@ abstract static class ActionsReadyListener { private float mCornerSizeX; private float mDismissDeltaY; - private Ringtone mScreenshotSound; + private MediaActionSound mCameraSound; private int mNavMode; private int mLeftInset; @@ -317,9 +315,9 @@ public GlobalScreenshot( mFastOutSlowIn = AnimationUtils.loadInterpolator(mContext, android.R.interpolator.fast_out_slow_in); - // Setup the Screenshot sound - mScreenshotSound = RingtoneManager.getRingtone(mContext, - Uri.parse("file://" + "/product/media/audio/ui/camera_click.ogg")); + // Setup the Camera shutter sound + mCameraSound = new MediaActionSound(); + mCameraSound.load(MediaActionSound.SHUTTER_CLICK); // Store UI background executor mUiBgExecutor = uiBgExecutor; @@ -684,11 +682,7 @@ private void saveScreenshot(Bitmap screenshot, Consumer finisher, Rect scre private void saveScreenshotAndToast(Consumer finisher) { // Play the shutter sound to notify that we've taken a screenshot mScreenshotHandler.post(() -> { - if (Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.SCREENSHOT_SOUND, 1, UserHandle.USER_CURRENT) == 1) { - if (mScreenshotSound != null) { - mScreenshotSound.play(); - } - } + mCameraSound.play(MediaActionSound.SHUTTER_CLICK); }); saveScreenshotInWorkerThread(finisher, new ActionsReadyListener() { @@ -744,11 +738,7 @@ void onActionsReady(SavedImageData imageData) { }); // Play the shutter sound to notify that we've taken a screenshot - if (Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.SCREENSHOT_SOUND, 1, UserHandle.USER_CURRENT) == 1) { - if (mScreenshotSound != null) { - mScreenshotSound.play(); - } - } + mCameraSound.play(MediaActionSound.SHUTTER_CLICK); mScreenshotPreview.setLayerType(View.LAYER_TYPE_HARDWARE, null); mScreenshotPreview.buildLayer();