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

Commit 851f3a87 authored by Hall Liu's avatar Hall Liu
Browse files

Make headset buttons work with simulated ringing

Add code to let wired headset media buttons answer a call via short
press when the call is in the simulated ringing state.

Fixes: 143237951
Test: manual
Change-Id: I2465807f393fd8d5ecde046affc31687ec49ac08
parent 72cf4fb0
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -2754,7 +2754,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);
@@ -2776,7 +2777,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);
    }