Merge "AudioService: Fix setting LeAudio volume after VoIP call" am: 6622922b3c am: c81eb8bfc9

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2430592

Change-Id: I33f8e48cb3b9362d370b0b40f4780dd1ba97c433
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2023-02-21 15:46:57 +00:00
committed by Automerger Merge Worker

View File

@@ -4234,7 +4234,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:
@@ -4252,16 +4253,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");
@@ -5647,10 +5647,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);
@@ -5658,7 +5666,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