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

Commit 8d67e012 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Partially ignore hearing aid changes when not in call am: 07c1b0fe am: f3e4e318 am: 3e7af2d9

Change-Id: Idb6adc82f46cb34af182349b344487dc2467c163
parents 7f3b15c7 3e7af2d9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -146,6 +146,10 @@ public class BluetoothStateReceiver extends BroadcastReceiver {
            if (device == null) {
                mBluetoothRouteManager.sendMessage(BT_AUDIO_LOST, args);
            } else {
                if (!mIsInCall) {
                    Log.i(LOG_TAG, "Ignoring hearing aid audio on since we're not in a call");
                    return;
                }
                args.arg2 = device.getAddress();
                mBluetoothRouteManager.sendMessage(BT_AUDIO_IS_ON, args);
            }
+17 −3
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase {

    BluetoothDeviceManager mBluetoothDeviceManager;
    BluetoothProfile.ServiceListener serviceListenerUnderTest;
    BroadcastReceiver receiverUnderTest;
    BluetoothStateReceiver receiverUnderTest;

    private BluetoothDevice device1;
    private BluetoothDevice device2;
@@ -90,8 +90,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase {
                serviceCaptor.capture(), eq(BluetoothProfile.HEADSET));
        serviceListenerUnderTest = serviceCaptor.getValue();

        receiverUnderTest = new BluetoothStateReceiver(mBluetoothDeviceManager,
                null /* route mgr not needed here */);
        receiverUnderTest = new BluetoothStateReceiver(mBluetoothDeviceManager, mRouteManager);

        mBluetoothDeviceManager.setHeadsetServiceForTesting(mHeadsetProxy);
        mBluetoothDeviceManager.setHearingAidServiceForTesting(mBluetoothHearingAid);
@@ -196,6 +195,21 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase {
        assertEquals(2, mBluetoothDeviceManager.getNumConnectedDevices());
    }

    @SmallTest
    @Test
    public void testHearingAidChangesIgnoredWhenNotInCall() {
        receiverUnderTest.setIsInCall(false);
        receiverUnderTest.onReceive(mContext,
                buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device2, true));
        Intent activeDeviceChangedIntent =
                new Intent(BluetoothHearingAid.ACTION_ACTIVE_DEVICE_CHANGED);
        activeDeviceChangedIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, device2);
        receiverUnderTest.onReceive(mContext, activeDeviceChangedIntent);

        verify(mRouteManager).onActiveDeviceChanged(device2, true);
        verify(mRouteManager, never()).sendMessage(BluetoothRouteManager.BT_AUDIO_IS_ON);
    }

    @SmallTest
    @Test
    public void testConnectDisconnectAudioHeadset() {