summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Liejun Tao <baibai@motorola.com> 2016-02-23 22:00:37 +0000
committer android-build-merger <android-build-merger@google.com> 2016-02-23 22:00:37 +0000
commit2fb16b066b3e4e22ee489f31f75170ebc052f0ec (patch)
tree1e198c339897a38523d15d2bd4d9cd4d97b95c83
parent7e65e5c681cc67dab31762cfce7dada402491f2e (diff)
parentd46bd9153144f905138e0b609c3d8252a5d5505e (diff)
DO NOT MERGE Bluetooth: Restrict gain for Absolute volume case am: 9ef7634fa9
am: d46bd91531 * commit 'd46bd9153144f905138e0b609c3d8252a5d5505e': DO NOT MERGE Bluetooth: Restrict gain for Absolute volume case
-rw-r--r--services/core/java/com/android/server/audio/AudioService.java25
1 files changed, 23 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 152ff303c1e7..0f957dba225f 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -3737,8 +3737,29 @@ public class AudioService extends IAudioService.Stub {
int index;
if (mIsMuted) {
index = 0;
- } else if (((device & AudioSystem.DEVICE_OUT_ALL_A2DP) != 0 && mAvrcpAbsVolSupported)
- || ((device & mFullVolumeDevices) != 0)) {
+ } else if ((device & AudioSystem.DEVICE_OUT_ALL_A2DP) != 0 && mAvrcpAbsVolSupported) {
+ /* Special handling for Bluetooth Absolute Volume scenario
+ * If we send full audio gain, some accessories are too loud even at its lowest
+ * volume. We are not able to enumerate all such accessories, so here is the
+ * workaround from phone side.
+ * For the lowest volume steps 1 and 2, restrict audio gain to 50% and 75%.
+ * For volume step 0, set audio gain to 0 as some accessories won't mute on their end.
+ */
+ int i = (getIndex(device) + 5)/10;
+ if (i == 0) {
+ // 0% for volume 0
+ index = 0;
+ } else if (i == 1) {
+ // 50% for volume 1
+ index = (int)(mIndexMax * 0.5) /10;
+ } else if (i == 2) {
+ // 75% for volume 2
+ index = (int)(mIndexMax * 0.75) /10;
+ } else {
+ // otherwise, full gain
+ index = (mIndexMax + 5)/10;
+ }
+ } else if ((device & mFullVolumeDevices) != 0) {
index = (mIndexMax + 5)/10;
} else {
index = (getIndex(device) + 5)/10;