summaryrefslogtreecommitdiffstats
path: root/services/core/java/com/android/server/audio/AudioService.java
diff options
context:
space:
mode:
authorLiejun Tao <baibai@motorola.com>2016-01-20 17:52:20 -0600
committerThe Android Automerger <android-build@google.com>2016-02-24 13:21:15 -0800
commitd60d0078d8a8a54ef898d936413321a085abff0d (patch)
treed80fbbfa3663fc48efb4254eabf1c0a0ad5126ae /services/core/java/com/android/server/audio/AudioService.java
parent3a8f0cf7612b5ebd0710a424a437f5540a72b279 (diff)
downloadframeworks_base-d60d0078d8a8a54ef898d936413321a085abff0d.zip
frameworks_base-d60d0078d8a8a54ef898d936413321a085abff0d.tar.gz
frameworks_base-d60d0078d8a8a54ef898d936413321a085abff0d.tar.bz2
DO NOT MERGE Bluetooth: Restrict gain for Absolute volume case
For the lowest music volume steps 1 and 2, restrict the gain to 50% and 75%. This will avoid the lowest volume steps being too loud for some accessories. For music volume 0, set phone gain to 0 as some accessories won't mute on their end. Change-Id: I24e0fa7be8c8635b428a11c91ea153aad7cec55f Signed-off-by: Liejun Tao <baibai@motorola.com>
Diffstat (limited to 'services/core/java/com/android/server/audio/AudioService.java')
-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 152ff30..0f957db 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;