summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jean-Michel Trivi <jmtrivi@google.com> 2023-06-04 12:36:42 -0700
committer Jean-Michel Trivi <jmtrivi@google.com> 2023-06-04 12:36:42 -0700
commitbe657aa975d4b0f6124bf3df7ee297ea931f0ca5 (patch)
tree531c2db78c86dabe32e51c0d184b6009f15b7ebd
parent79d9f58d95f42f409c09d449a301a66cae7479c0 (diff)
AudioService: prevent unmute on vol raise when muted by ringer/zen
Handle raising volume from muted when the stream is muted by the ringer or zend mode, just like unmute commands, and prevent the unmute. This fixes an issue where in silent/vibrate mode where STREAM_NOTIFICATION is muted, pressing the volume up button while a notification is silently playing, would cause notifications to become unmuted. Bug: 284257295 Test: atest CtsMediaAudioTestCases:android.media.audio.cts.AudioManagerTest Change-Id: I0ebc15c6b4430db0737b8dcbeba9346211ddcf0d
-rw-r--r--services/core/java/com/android/server/audio/AudioService.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index d0b6cdce037f..336f0fb5699f 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -3277,6 +3277,7 @@ public class AudioService extends IAudioService.Stub
if (mUserSelectedVolumeControlStream) { // implies mVolumeControlStream != -1
streamType = mVolumeControlStream;
} else {
+ // TODO discard activity on a muted stream?
final int maybeActiveStreamType = getActiveStreamType(suggestedStreamType);
final boolean activeForReal;
if (maybeActiveStreamType == AudioSystem.STREAM_RING
@@ -3480,9 +3481,10 @@ public class AudioService extends IAudioService.Stub
}
} else if (isStreamMutedByRingerOrZenMode(streamTypeAlias) && streamState.mIsMuted) {
// if the stream is currently muted streams by ringer/zen mode
- // then it cannot be unmuted (without FLAG_ALLOW_RINGER_MODES)
+ // then it cannot be unmuted (without FLAG_ALLOW_RINGER_MODES) with an unmute or raise
if (direction == AudioManager.ADJUST_TOGGLE_MUTE
- || direction == AudioManager.ADJUST_UNMUTE) {
+ || direction == AudioManager.ADJUST_UNMUTE
+ || direction == AudioManager.ADJUST_RAISE) {
adjustVolume = false;
}
}