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

Commit 34d7ede7 authored by Sungsoo Lim's avatar Sungsoo Lim
Browse files

Make the most recent BT device selected while ringing

Bug: 301373675
Test: atest BluetoothInstrumentationTests:AudioRoutingManager
Change-Id: I4d8f4719b1e6e2522a1a061da2b033e2458f4d26
parent d765c99e
Loading
Loading
Loading
Loading
+4 −12
Original line number Diff line number Diff line
@@ -684,17 +684,9 @@ public class AudioRoutingManager extends ActiveDeviceManager {
        List<BluetoothDevice> fallbackCandidates = new ArrayList<>();
        fallbackCandidates.addAll(mLeAudioConnectedDevices);

        HeadsetService headsetService = mFactory.getHeadsetService();
        switch (mAudioManager.getMode()) {
            case AudioManager.MODE_NORMAL:
        if (mAudioManager.getMode() == AudioManager.MODE_NORMAL) {
            fallbackCandidates.addAll(mA2dpConnectedDevices);
                break;
            case AudioManager.MODE_RINGTONE:
                if (headsetService.isInbandRingingEnabled()) {
                    fallbackCandidates.addAll(hfpFallbackCandidates);
                }
                break;
            default:
        } else {
            fallbackCandidates.addAll(hfpFallbackCandidates);
        }
        BluetoothDevice device =
+15 −0
Original line number Diff line number Diff line
@@ -318,6 +318,21 @@ public class AudioRoutingManagerTest {
        verify(mHeadsetService, timeout(TIMEOUT_MS)).setActiveDevice(mHeadsetDevice);
    }

    @Test
    public void headsetSecondDeviceDisconnected_fallbackDeviceActiveWhileRinging() {
        when(mAudioManager.getMode()).thenReturn(AudioManager.MODE_RINGTONE);

        headsetConnected(mHeadsetDevice, false);
        verify(mHeadsetService, timeout(TIMEOUT_MS)).setActiveDevice(mHeadsetDevice);

        headsetConnected(mSecondaryAudioDevice, false);
        verify(mHeadsetService, timeout(TIMEOUT_MS)).setActiveDevice(mSecondaryAudioDevice);

        Mockito.clearInvocations(mHeadsetService);
        headsetDisconnected(mSecondaryAudioDevice);
        verify(mHeadsetService, timeout(TIMEOUT_MS)).setActiveDevice(mHeadsetDevice);
    }

    @Test
    public void a2dpConnectedButHeadsetNotConnected_setA2dpActive() {
        mTestLooper.stopAutoDispatchAndIgnoreExceptions();