summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jean-Michel Trivi <jmtrivi@google.com> 2020-05-11 15:45:32 -0700
committer Jean-Michel Trivi <jmtrivi@google.com> 2020-05-11 16:46:16 -0700
commitdb56188f4d05f0270bb871d4737aa3234b4d5236 (patch)
tree0cf01f0933607a28f20cf26bac1b16437a7cebb7
parentff779f6d8e2588c64173b7087efe81214f9bb167 (diff)
AudioService: fix volume adjustment suppression
Fix regression introduced by aosp/1202609 to allow rapid media volume changes, which broke the ability to make changes to settings (i.e. ringer mode) without changing the volume. The change consists in: a/ reverting regression b/ when changing MUSIC volume, if media is active, do not suppress the adjustement. (c/ document intended behavior) Bug: 156010854 Test: see manual steps in bug Change-Id: I3e6a3f55f09c8bd2bde01696298c145c53a8d321
-rwxr-xr-xservices/core/java/com/android/server/audio/AudioService.java26
1 files changed, 24 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 17baead84f9d..8068e378f2e3 100755
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -7369,10 +7369,32 @@ public class AudioService extends IAudioService.Stub
return false;
}
boolean suppress = false;
- if (resolvedStream != AudioSystem.STREAM_MUSIC && mController != null) {
+ // Intended behavior:
+ // 1/ if the stream is not the default UI stream, do not suppress (as it is not involved
+ // in bringing up the UI)
+ // 2/ if the resolved and default stream is MUSIC, and media is playing, do not suppress
+ // 3/ otherwise suppress the first adjustments that occur during the "long press
+ // timeout" interval. Note this is true regardless of whether this is a "real long
+ // press" (where the user keeps pressing on the volume button), or repeated single
+ // presses (here we don't know if we are in a real long press, or repeated fast
+ // button presses).
+ // Once the long press timeout occurs (mNextLongPress reset to 0), do not suppress.
+ // Example: for a default and resolved stream of MUSIC, this allows modifying rapidly
+ // the volume when media is playing (whether by long press or repeated individual
+ // presses), or to bring up the volume UI when media is not playing, in order to make
+ // another change (e.g. switch ringer modes) without changing media volume.
+ if (resolvedStream == DEFAULT_VOL_STREAM_NO_PLAYBACK && mController != null) {
+ // never suppress media vol adjustement during media playback
+ if (resolvedStream == AudioSystem.STREAM_MUSIC
+ && AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, mLongPressTimeout))
+ {
+ // media is playing, adjust the volume right away
+ return false;
+ }
+
final long now = SystemClock.uptimeMillis();
if ((flags & AudioManager.FLAG_SHOW_UI) != 0 && !mVisible) {
- // ui will become visible
+ // UI is not visible yet, adjustment is ignored
if (mNextLongPress < now) {
mNextLongPress = now + mLongPressTimeout;
}