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

Commit 20f8e6f5 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Ensure handover calls can be hung up.

It was previously not possible to hang up a call which was in the midst of
SRVCC.  This CL ensures that while the handover is in process we can still
send a hangup request to the ImsCall.

Test: Added new unit text for this case.
Fixes: 152801865
Merged-In: Ib4e98c41f0f5307dab1dd3cb8fe11f9ee98618b8
Change-Id: I482f056b62a8a3d7738a20e15ceb44050201464c
parent 7289eab2
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -2196,6 +2196,10 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
            if (Phone.DEBUG_PHONE) {
                log("(backgnd) hangup waiting or background");
            }
        } else if (call == mHandoverCall) {
            if (Phone.DEBUG_PHONE) {
                log("(handover) hangup handover (SRVCC) call");
            }
        } else {
            throw new CallStateException ("ImsPhoneCall " + call +
                    "does not belong to ImsPhoneCallTracker " + this);
@@ -3741,8 +3745,11 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        }
    }

    /* package */
    void notifySrvccState(Call.SrvccState state) {
    /**
     * Notify of a change to SRVCC state
     * @param state the new SRVCC state.
     */
    public void notifySrvccState(Call.SrvccState state) {
        if (DBG) log("notifySrvccState state=" + state);

        mSrvccState = state;
+33 −0
Original line number Diff line number Diff line
@@ -1064,6 +1064,39 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
        assertVtDataUsageUpdated(13, 19, 19);
    }

    @Test
    @SmallTest
    public void testHangupHandoverCall() throws RemoteException {
        doReturn("1").when(mImsCallSession).getCallId();
        assertEquals(PhoneConstants.State.IDLE, mCTUT.getState());
        assertFalse(mCTUT.mRingingCall.isRinging());
        // mock a MT call
        mMmTelListener.onIncomingCall(mock(IImsCallSession.class), Bundle.EMPTY);
        verify(mImsPhone, times(1)).notifyNewRingingConnection((Connection) any());
        verify(mImsPhone, times(1)).notifyIncomingRing();
        assertEquals(PhoneConstants.State.RINGING, mCTUT.getState());
        assertTrue(mCTUT.mRingingCall.isRinging());
        assertEquals(1, mCTUT.mRingingCall.getConnections().size());
        ImsPhoneConnection connection =
                (ImsPhoneConnection) mCTUT.mRingingCall.getConnections().get(0);
        connection.addListener(mImsPhoneConnectionListener);

        // Move the connection to the handover state.
        mCTUT.notifySrvccState(Call.SrvccState.COMPLETED);
        assertEquals(1, mCTUT.mHandoverCall.getConnections().size());

        // No need to go through all the rigamarole of the mocked termination we normally do; we
        // can confirm the hangup gets processed without all that.
        doNothing().when(mImsCall).terminate(anyInt());

        try {
            mCTUT.hangup(mCTUT.mHandoverCall);
        } catch (CallStateException e) {
            Assert.fail("CallStateException not expected");
        }
        assertEquals(DisconnectCause.LOCAL, connection.getDisconnectCause());
    }

    private void assertVtDataUsageUpdated(int expectedToken, long rxBytes, long txBytes)
            throws RemoteException {
        final ArgumentCaptor<NetworkStats> ifaceStatsCaptor = ArgumentCaptor.forClass(