AudioDeviceInventory: reset SCO active device upon restore failure
BtHelper holds mBluetoothHeadsetDevice as the SCO active device, which
may fall out of sync with mConnectedDevices in AudioDeviceInventory
during audio server crash if it's not reset to null. In that situation
SCO audio ports can no longer transition to connected state even after
BT headset disconnect then reconnect.
Bug: 380772841
Flag: com.android.media.audio.as_device_connection_failure
Test: Connect BT headset, trigger audio HAL crash, reconnect BT headset
and verify SCO audio ports are back
Change-Id: Ie38f5e3e6d9707e4a2f04d78eb23b09641c71d9e
diff --git a/services/core/java/com/android/server/audio/AudioDeviceInventory.java b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
index 34d4fb0..acb46d9 100644
--- a/services/core/java/com/android/server/audio/AudioDeviceInventory.java
+++ b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
@@ -793,6 +793,7 @@
* (see AudioService.onAudioServerDied() method)
*/
// Always executed on AudioDeviceBroker message queue
+ @GuardedBy("mDeviceBroker.mDeviceStateLock")
/*package*/ void onRestoreDevices() {
synchronized (mDevicesLock) {
int res;
@@ -815,6 +816,9 @@
"Device inventory restore failed to reconnect " + di,
EventLogger.Event.ALOGE, TAG);
mConnectedDevices.remove(di.getKey(), di);
+ if (AudioSystem.isBluetoothScoDevice(di.mDeviceType)) {
+ mDeviceBroker.onSetBtScoActiveDevice(null);
+ }
}
}
mAppliedStrategyRolesInt.clear();