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

Commit 7a6ea1d4 authored by Grace Jia's avatar Grace Jia Committed by Łukasz Rymanowski
Browse files

Bypass inband ringing check for condition that le device is the active

bt device.

Bug: 242685105
Test: BluetoothDeviceManagerTest, manual test
Change-Id: I330c8f11ffe269c14648243177a1594fe839cf4d
parent e05579ec
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -637,6 +637,20 @@ public class BluetoothDeviceManager {
        }
    }

    public boolean isInbandRingingEnabled() {
        BluetoothDevice activeDevice = mBluetoothRouteManager.getBluetoothAudioConnectedDevice();
        Log.i(this, "isInbandRingingEnabled: activeDevice: " + activeDevice);
        if (mBluetoothRouteManager.isCachedLeAudioDevice(activeDevice)) {
            return true;
        } else {
            if (mBluetoothHeadset == null) {
                Log.i(this, "isInbandRingingEnabled: no headset service available.");
                return false;
            }
            return mBluetoothHeadset.isInbandRingingEnabled();
        }
    }

    public void dump(IndentingPrintWriter pw) {
        mLocalLog.dump(pw);
    }
+1 −6
Original line number Diff line number Diff line
@@ -849,12 +849,7 @@ public class BluetoothRouteManager extends StateMachine {
     */
    @VisibleForTesting
    public boolean isInbandRingingEnabled() {
        BluetoothHeadset bluetoothHeadset = mDeviceManager.getBluetoothHeadset();
        if (bluetoothHeadset == null) {
            Log.i(this, "isInbandRingingEnabled: no headset service available.");
            return false;
        }
        return bluetoothHeadset.isInbandRingingEnabled();
        return mDeviceManager.isInbandRingingEnabled();
    }

    private boolean addDevice(String address) {
+22 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import org.mockito.Mock;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
@@ -513,6 +514,27 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase {
        assertFalse(mBluetoothDeviceManager.isHearingAidSetAsCommunicationDevice());
    }

    @SmallTest
    @Test
    public void testInBandRingingEnabledForLeDevice() {
        when(mBluetoothHeadset.isInbandRingingEnabled()).thenReturn(false);
        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());
        assertTrue(mBluetoothDeviceManager.isInbandRingingEnabled());
    }

    private Intent buildConnectionActionIntent(int state, BluetoothDevice device, int deviceType) {
        String intentString;