diff options
author | Grace Jia <xiaotonj@google.com> | 2023-12-01 08:42:58 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2023-12-01 08:42:58 +0000 |
commit | 36876c4214dd3afc7946698c7d72209799f74326 (patch) | |
tree | 1392ae43c68415aa9a634487ebb60bf3a5cb4778 | |
parent | 885d79344d58a23c11b16db29140f410ba0a2ef6 (diff) | |
parent | 1db78146d6cce042c2410b6b50ce4ca286679da2 (diff) | |
download | Telecomm-36876c4214dd3afc7946698c7d72209799f74326.tar.gz |
Merge "Revert^2 "Fix ringtone play issue via LE devices."" into main
3 files changed, 10 insertions, 9 deletions
diff --git a/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java b/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java index 9ae58b33d..c5e56b377 100644 --- a/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java +++ b/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java @@ -740,7 +740,9 @@ public class BluetoothDeviceManager { } public boolean isInbandRingingEnabled() { - BluetoothDevice activeDevice = mBluetoothRouteManager.getBluetoothAudioConnectedDevice(); + // Get the inband ringing enabled status of expected BT device to route call audio instead + // of using the address of currently connected device. + BluetoothDevice activeDevice = mBluetoothRouteManager.getMostRecentlyReportedActiveDevice(); Log.i(this, "isInbandRingingEnabled: activeDevice: " + activeDevice); if (mBluetoothRouteManager.isCachedLeAudioDevice(activeDevice)) { if (mBluetoothLeAudioService == null) { diff --git a/src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java b/src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java index ceabd669a..3cd64c61a 100644 --- a/src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java +++ b/src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java @@ -670,6 +670,10 @@ public class BluetoothRouteManager extends StateMachine { } } + public BluetoothDevice getMostRecentlyReportedActiveDevice() { + return mMostRecentlyReportedActiveDevice; + } + public boolean hasBtActiveDevice() { return mLeAudioActiveDeviceCache != null || mHearingAidActiveDeviceCache != null || diff --git a/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java b/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java index 977cef9b8..86d2beefb 100644 --- a/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java +++ b/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java @@ -739,19 +739,14 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase { when(mBluetoothLeAudio.isInbandRingtoneEnabled(1)).thenReturn(true); when(mBluetoothLeAudio.getGroupId(eq(device3))).thenReturn(1); receiverUnderTest.onReceive(mContext, - buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device1, - BluetoothDeviceManager.DEVICE_TYPE_HEADSET)); - receiverUnderTest.onReceive(mContext, - buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device2, - BluetoothDeviceManager.DEVICE_TYPE_HEADSET)); - receiverUnderTest.onReceive(mContext, buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device3, BluetoothDeviceManager.DEVICE_TYPE_LE_AUDIO)); leAudioCallbacksTest.getValue().onGroupNodeAdded(device3, 1); - when(mBluetoothLeAudio.getConnectedGroupLeadDevice(1)).thenReturn(device3); when(mRouteManager.getBluetoothAudioConnectedDevice()).thenReturn(device3); when(mRouteManager.isCachedLeAudioDevice(eq(device3))).thenReturn(true); - assertEquals(3, mBluetoothDeviceManager.getNumConnectedDevices()); + when(mBluetoothLeAudio.getConnectedGroupLeadDevice(1)).thenReturn(device3); + when(mRouteManager.getMostRecentlyReportedActiveDevice()).thenReturn(device3); + assertEquals(1, mBluetoothDeviceManager.getNumConnectedDevices()); assertTrue(mBluetoothDeviceManager.isInbandRingingEnabled()); } |