Merge "AudioService: Fix setting LeAudio volume after VoIP call"

This commit is contained in:
Treehugger Robot
2023-02-21 13:18:51 +00:00
committed by Gerrit Code Review

View File

@@ -4005,7 +4005,8 @@ public class AudioService extends IAudioService.Stub
}
}
private void setLeAudioVolumeOnModeUpdate(int mode, int device) {
private void setLeAudioVolumeOnModeUpdate(int mode, int device, int streamType, int index,
int maxIndex) {
switch (mode) {
case AudioSystem.MODE_IN_COMMUNICATION:
case AudioSystem.MODE_IN_CALL:
@@ -4023,16 +4024,15 @@ public class AudioService extends IAudioService.Stub
// (like the outgoing call) the value of 'device' is not DEVICE_OUT_BLE_*
// even when BLE is connected.
if (!AudioSystem.isLeAudioDeviceType(device)) {
Log.w(TAG, "setLeAudioVolumeOnModeUpdate got unexpected device=" + device
+ ", forcing to device=" + AudioSystem.DEVICE_OUT_BLE_HEADSET);
device = AudioSystem.DEVICE_OUT_BLE_HEADSET;
}
final int streamType = getBluetoothContextualVolumeStream(mode);
final int index = mStreamStates[streamType].getIndex(device);
final int maxIndex = mStreamStates[streamType].getMaxIndex();
if (DEBUG_VOL) {
Log.d(TAG, "setLeAudioVolumeOnModeUpdate postSetLeAudioVolumeIndex index="
+ index + " maxIndex=" + maxIndex + " streamType=" + streamType);
Log.d(TAG, "setLeAudioVolumeOnModeUpdate postSetLeAudioVolumeIndex device="
+ device + ", mode=" + mode + ", index=" + index + " maxIndex=" + maxIndex
+ " streamType=" + streamType);
}
mDeviceBroker.postSetLeAudioVolumeIndex(index, maxIndex, streamType);
mDeviceBroker.postApplyVolumeOnDevice(streamType, device, "setLeAudioVolumeOnModeUpdate");
@@ -5403,10 +5403,18 @@ public class AudioService extends IAudioService.Stub
mModeLogger.log(new PhoneStateEvent(requesterPackage, requesterPid,
requestedMode, pid, mode));
int streamType = getActiveStreamType(AudioManager.USE_DEFAULT_STREAM_TYPE);
int device = getDeviceForStream(streamType);
int index = mStreamStates[mStreamVolumeAlias[streamType]].getIndex(device);
setStreamVolumeInt(mStreamVolumeAlias[streamType], index, device, true,
final int streamType = getActiveStreamType(AudioManager.USE_DEFAULT_STREAM_TYPE);
final int device = getDeviceForStream(streamType);
final int streamAlias = mStreamVolumeAlias[streamType];
if (DEBUG_MODE) {
Log.v(TAG, "onUpdateAudioMode: streamType=" + streamType
+ ", streamAlias=" + streamAlias);
}
final int index = mStreamStates[streamAlias].getIndex(device);
final int maxIndex = mStreamStates[streamAlias].getMaxIndex();
setStreamVolumeInt(streamAlias, index, device, true,
requesterPackage, true /*hasModifyAudioSettings*/);
updateStreamVolumeAlias(true /*updateVolumes*/, requesterPackage);
@@ -5414,7 +5422,7 @@ public class AudioService extends IAudioService.Stub
// change of mode may require volume to be re-applied on some devices
updateAbsVolumeMultiModeDevices(previousMode, mode);
setLeAudioVolumeOnModeUpdate(mode, device);
setLeAudioVolumeOnModeUpdate(mode, device, streamAlias, index, maxIndex);
// when entering RINGTONE, IN_CALL or IN_COMMUNICATION mode, clear all SCO
// connections not started by the application changing the mode when pid changes