Skip to content

Commit d60d007

Browse files
Liejun TaoThe Android Automerger
authored andcommitted
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>
1 parent 3a8f0cf commit d60d007

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

services/core/java/com/android/server/audio/AudioService.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3737,8 +3737,29 @@ public void applyDeviceVolume_syncVSS(int device) {
37373737
int index;
37383738
if (mIsMuted) {
37393739
index = 0;
3740-
} else if (((device & AudioSystem.DEVICE_OUT_ALL_A2DP) != 0 && mAvrcpAbsVolSupported)
3741-
|| ((device & mFullVolumeDevices) != 0)) {
3740+
} else if ((device & AudioSystem.DEVICE_OUT_ALL_A2DP) != 0 && mAvrcpAbsVolSupported) {
3741+
/* Special handling for Bluetooth Absolute Volume scenario
3742+
* If we send full audio gain, some accessories are too loud even at its lowest
3743+
* volume. We are not able to enumerate all such accessories, so here is the
3744+
* workaround from phone side.
3745+
* For the lowest volume steps 1 and 2, restrict audio gain to 50% and 75%.
3746+
* For volume step 0, set audio gain to 0 as some accessories won't mute on their end.
3747+
*/
3748+
int i = (getIndex(device) + 5)/10;
3749+
if (i == 0) {
3750+
// 0% for volume 0
3751+
index = 0;
3752+
} else if (i == 1) {
3753+
// 50% for volume 1
3754+
index = (int)(mIndexMax * 0.5) /10;
3755+
} else if (i == 2) {
3756+
// 75% for volume 2
3757+
index = (int)(mIndexMax * 0.75) /10;
3758+
} else {
3759+
// otherwise, full gain
3760+
index = (mIndexMax + 5)/10;
3761+
}
3762+
} else if ((device & mFullVolumeDevices) != 0) {
37423763
index = (mIndexMax + 5)/10;
37433764
} else {
37443765
index = (getIndex(device) + 5)/10;

0 commit comments

Comments
 (0)