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

Commit 14c1079b authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Make the most recent BT device selected while ringing" into main am: 3ccce24c

parents 69ccbc94 3ccce24c
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();