summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Robin Lee <rgl@google.com> 2020-06-04 20:29:16 +0000
committer Robin Lee <rgl@google.com> 2020-06-05 00:12:08 +0200
commit338a18daea9c86cbea895affce14a15232e6dc53 (patch)
tree279aefc06e9abf6c85b41d5e04b32e89db6c520e
parent2c99d907441245192e4932965d448a8e0f5cc36c (diff)
Don't send volume keys twice
Introduced by CEC VOL_ADJUST_* changes which send a volume change event for key up with the intent that this will be passed on to CEC. We want to ignore it if it's a KEY_UP event and we're not using CEC. Change-Id: Ib001b1f00bd1117f5e60aeb28df8461a00436678 Test: Manual: just press the MUTE button and release it (and the device mutes) Bug: 158119517
-rwxr-xr-xservices/core/java/com/android/server/audio/AudioService.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 27d9ba08e4a2..6d45abaf0234 100755
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -1893,7 +1893,7 @@ public class AudioService extends IAudioService.Stub
Binder.getCallingUid(), true, keyEventMode);
break;
case KeyEvent.KEYCODE_VOLUME_MUTE:
- if (event.getRepeatCount() == 0) {
+ if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
adjustSuggestedStreamVolume(AudioManager.ADJUST_TOGGLE_MUTE,
AudioManager.USE_DEFAULT_STREAM_TYPE, flags, callingPackage, caller,
Binder.getCallingUid(), true, VOL_ADJUST_NORMAL);
@@ -2155,7 +2155,8 @@ public class AudioService extends IAudioService.Stub
}
int oldIndex = mStreamStates[streamType].getIndex(device);
- if (adjustVolume && (direction != AudioManager.ADJUST_SAME)) {
+ if (adjustVolume
+ && (direction != AudioManager.ADJUST_SAME) && (keyEventMode != VOL_ADJUST_END)) {
mAudioHandler.removeMessages(MSG_UNMUTE_STREAM);
if (isMuteAdjust) {
@@ -2238,6 +2239,11 @@ public class AudioService extends IAudioService.Stub
if (streamTypeAlias == AudioSystem.STREAM_MUSIC) {
setSystemAudioVolume(oldIndex, newIndex, getStreamMaxVolume(streamType), flags);
}
+ }
+
+ final int newIndex = mStreamStates[streamType].getIndex(device);
+
+ if (adjustVolume) {
synchronized (mHdmiClientLock) {
if (mHdmiManager != null) {
// mHdmiCecSink true => mHdmiPlaybackClient != null
@@ -2290,8 +2296,7 @@ public class AudioService extends IAudioService.Stub
}
}
}
- int index = mStreamStates[streamType].getIndex(device);
- sendVolumeUpdate(streamType, oldIndex, index, flags, device);
+ sendVolumeUpdate(streamType, oldIndex, newIndex, flags, device);
}
// Called after a delay when volume down is pressed while muted