Make screenshot sound respect system mute
In some regions (e.g. Japan) we force the camera to make a sound regardless of the user settings. The screenshot used the same sound so inherited this behavior. This change forks the sound used for screenshots, so that it respects the system volume instead of being forced audible. Bug: 200767953 Fix: 200767953 Test: manual (made AudioService.readCameraSoundForced return true, then test before and after change to verify behavior fixed) Change-Id: I3c9cf2826b5c3f86e47b570f75189405845a7186
This commit is contained in:
@@ -4238,6 +4238,9 @@
|
||||
<!-- URI for in call notification sound -->
|
||||
<string translatable="false" name="config_inCallNotificationSound">/product/media/audio/ui/InCallNotification.ogg</string>
|
||||
|
||||
<!-- URI for camera shutter sound -->
|
||||
<string translatable="false" name="config_cameraShutterSound">/product/media/audio/ui/camera_click.ogg</string>
|
||||
|
||||
<!-- URI for default ringtone sound file to be used for silent ringer vibration -->
|
||||
<string translatable="false" name="config_defaultRingtoneVibrationSound"></string>
|
||||
|
||||
|
||||
@@ -3727,6 +3727,7 @@
|
||||
<java-symbol type="bool" name="config_handleVolumeAliasesUsingVolumeGroups" />
|
||||
<java-symbol type="dimen" name="config_inCallNotificationVolume" />
|
||||
<java-symbol type="string" name="config_inCallNotificationSound" />
|
||||
<java-symbol type="string" name="config_cameraShutterSound" />
|
||||
<java-symbol type="integer" name="config_autoGroupAtCount" />
|
||||
<java-symbol type="bool" name="config_dozeAlwaysOnDisplayAvailable" />
|
||||
<java-symbol type="bool" name="config_dozeAlwaysOnEnabled" />
|
||||
|
||||
@@ -51,7 +51,9 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.Insets;
|
||||
import android.graphics.Rect;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.media.MediaActionSound;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.AudioSystem;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
@@ -93,6 +95,7 @@ import com.android.systemui.screenshot.TakeScreenshotService.RequestCallback;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@@ -248,7 +251,7 @@ public class ScreenshotController {
|
||||
private final WindowManager mWindowManager;
|
||||
private final WindowManager.LayoutParams mWindowLayoutParams;
|
||||
private final AccessibilityManager mAccessibilityManager;
|
||||
private final MediaActionSound mCameraSound;
|
||||
private final MediaPlayer mCameraSound;
|
||||
private final ScrollCaptureClient mScrollCaptureClient;
|
||||
private final PhoneWindow mWindow;
|
||||
private final DisplayManager mDisplayManager;
|
||||
@@ -331,8 +334,13 @@ public class ScreenshotController {
|
||||
reloadAssets();
|
||||
|
||||
// Setup the Camera shutter sound
|
||||
mCameraSound = new MediaActionSound();
|
||||
mCameraSound.load(MediaActionSound.SHUTTER_CLICK);
|
||||
mCameraSound = 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());
|
||||
|
||||
mCopyBroadcastReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
@@ -430,7 +438,9 @@ public class ScreenshotController {
|
||||
void releaseContext() {
|
||||
mContext.unregisterReceiver(mCopyBroadcastReceiver);
|
||||
mContext.release();
|
||||
mCameraSound.release();
|
||||
if (mCameraSound != null) {
|
||||
mCameraSound.release();
|
||||
}
|
||||
mBgExecutor.shutdownNow();
|
||||
}
|
||||
|
||||
@@ -806,7 +816,9 @@ public class ScreenshotController {
|
||||
*/
|
||||
private void saveScreenshotAndToast(Consumer<Uri> finisher) {
|
||||
// Play the shutter sound to notify that we've taken a screenshot
|
||||
mCameraSound.play(MediaActionSound.SHUTTER_CLICK);
|
||||
if (mCameraSound != null) {
|
||||
mCameraSound.start();
|
||||
}
|
||||
|
||||
saveScreenshotInWorkerThread(
|
||||
/* onComplete */ finisher,
|
||||
@@ -840,7 +852,9 @@ public class ScreenshotController {
|
||||
mScreenshotView.createScreenshotDropInAnimation(screenRect, showFlash);
|
||||
|
||||
// Play the shutter sound to notify that we've taken a screenshot
|
||||
mCameraSound.play(MediaActionSound.SHUTTER_CLICK);
|
||||
if (mCameraSound != null) {
|
||||
mCameraSound.start();
|
||||
}
|
||||
|
||||
if (DEBUG_ANIM) {
|
||||
Log.d(TAG, "starting post-screenshot animation");
|
||||
|
||||
Reference in New Issue
Block a user