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

Commit 3ccce24c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Make the most recent BT device selected while ringing" into main

parents 8e555b6a 34d7ede7
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();