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

Commit 2fd2d727 authored by Hall Liu's avatar Hall Liu Committed by android-build-merger
Browse files

Merge "Make headset buttons work with simulated ringing"

am: 091fcc1b

Change-Id: I1f34233bc2a11b34d46e3fe3a6f07a586f4f0056
parents 625d0847 091fcc1b
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -2755,7 +2755,8 @@ public class CallsManager extends Call.ListenerBase
    @VisibleForTesting
    public boolean onMediaButton(int type) {
        if (hasAnyCalls()) {
            Call ringingCall = getFirstCallWithState(CallState.RINGING);
            Call ringingCall = getFirstCallWithState(CallState.RINGING,
                    CallState.SIMULATED_RINGING);
            if (HeadsetMediaButton.SHORT_PRESS == type) {
                if (ringingCall == null) {
                    Call activeCall = getFirstCallWithState(CallState.ACTIVE);
@@ -2777,7 +2778,7 @@ public class CallsManager extends Call.ListenerBase
                        return true;
                    }
                } else {
                    ringingCall.answer(VideoProfile.STATE_AUDIO_ONLY);
                    answerCall(ringingCall, VideoProfile.STATE_AUDIO_ONLY);
                    return true;
                }
            } else if (HeadsetMediaButton.LONG_PRESS == type) {
+4 −0
Original line number Diff line number Diff line
@@ -894,6 +894,10 @@ public class CallsManagerTest extends TelecomTestCase {
        mCallsManager.onMediaButton(HeadsetMediaButton.SHORT_PRESS);

        // THEN the incoming call is answered
        ArgumentCaptor<CallsManager.RequestCallback> captor = ArgumentCaptor.forClass(
                CallsManager.RequestCallback.class);
        verify(mConnectionSvrFocusMgr).requestFocus(eq(incomingCall), captor.capture());
        captor.getValue().onRequestFocusDone(incomingCall);
        verify(incomingCall).answer(VideoProfile.STATE_AUDIO_ONLY);
    }