Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36876c42 authored by Grace Jia's avatar Grace Jia Committed by Android (Google) Code Review
Browse files

Merge "Revert^2 "Fix ringtone play issue via LE devices."" into main

parents 885d7934 1db78146
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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) {
+4 −0
Original line number Diff line number Diff line
@@ -670,6 +670,10 @@ public class BluetoothRouteManager extends StateMachine {
        }
    }

    public BluetoothDevice getMostRecentlyReportedActiveDevice() {
        return mMostRecentlyReportedActiveDevice;
    }

    public boolean hasBtActiveDevice() {
        return mLeAudioActiveDeviceCache != null ||
                mHearingAidActiveDeviceCache != null ||
+3 −8
Original line number Diff line number Diff line
@@ -738,20 +738,15 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase {
        when(mBluetoothHeadset.isInbandRingingEnabled()).thenReturn(false);
        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());
    }