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

Commit a0b58d8d authored by Grace Jia's avatar Grace Jia Committed by Automerger Merge Worker
Browse files

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

Bypass inband ringing check for condition that le device is the active am: 7a6ea1d4 am: 897a5210 am: 89566625

Original change: https://android-review.googlesource.com/c/platform/packages/services/Telecomm/+/2239095



Change-Id: I747ce625c8179e33bdf7cfbe900b9f3795a16f47
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents f0295d4e 89566625
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -646,6 +646,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
@@ -850,12 +850,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;
@@ -517,6 +518,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;