BleAudioVolume: Fix calculation for the activated device

Fixes the following:
 - invalid volume level value set for the newly activated BLE device
   (additional patch for Bluetooth is also provided)
 - audio FW not being notified about the new volume level when
   switching to phone call mode

Bug: 243334827
Bug: 241501978
Tag: #feature
Test: tested manually
Change-Id: I46b2004d205ecdec470b84d1403cbd99af734626
Merged-In: I46b2004d205ecdec470b84d1403cbd99af734626
(cherry picked from commit 0be0ffc86d)
This commit is contained in:
Jakub Tyszkowski
2022-09-21 22:13:15 +00:00
parent 7ceaa5ce07
commit 0cc6f636ae
2 changed files with 5 additions and 5 deletions

View File

@@ -377,7 +377,8 @@ public class AudioDeviceInventory {
makeLeAudioDeviceUnavailable(address, btInfo.mAudioSystemDevice);
} else if (switchToAvailable) {
makeLeAudioDeviceAvailable(address, BtHelper.getName(btInfo.mDevice),
streamType, btInfo.mVolume, btInfo.mAudioSystemDevice,
streamType, btInfo.mVolume == -1 ? -1 : btInfo.mVolume * 10,
btInfo.mAudioSystemDevice,
"onSetBtActiveDevice");
}
break;

View File

@@ -4011,7 +4011,7 @@ public class AudioService extends IAudioService.Stub
}
}
private void setLeAudioVolumeOnModeUpdate(int mode) {
private void setLeAudioVolumeOnModeUpdate(int mode, int streamType, int device) {
switch (mode) {
case AudioSystem.MODE_IN_COMMUNICATION:
case AudioSystem.MODE_IN_CALL:
@@ -4025,8 +4025,6 @@ public class AudioService extends IAudioService.Stub
return;
}
int streamType = getBluetoothContextualVolumeStream(mode);
// Currently, DEVICE_OUT_BLE_HEADSET is the only output type for LE_AUDIO profile.
// (See AudioDeviceBroker#createBtDeviceInfo())
int index = mStreamStates[streamType].getIndex(AudioSystem.DEVICE_OUT_BLE_HEADSET);
@@ -4037,6 +4035,7 @@ public class AudioService extends IAudioService.Stub
+ index + " maxIndex=" + maxIndex + " streamType=" + streamType);
}
mDeviceBroker.postSetLeAudioVolumeIndex(index, maxIndex, streamType);
mDeviceBroker.postApplyVolumeOnDevice(streamType, device, "setLeAudioVolumeOnModeUpdate");
}
private void setStreamVolume(int streamType, int index, int flags,
@@ -5417,7 +5416,7 @@ public class AudioService extends IAudioService.Stub
// Forcefully set LE audio volume as a workaround, since the value of 'device'
// is not DEVICE_OUT_BLE_* even when BLE is connected.
setLeAudioVolumeOnModeUpdate(mode);
setLeAudioVolumeOnModeUpdate(mode, streamType, device);
// when entering RINGTONE, IN_CALL or IN_COMMUNICATION mode, clear all SCO
// connections not started by the application changing the mode when pid changes