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

Commit 4db10832 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
Change-Id: I482f056b62a8a3d7738a20e15ceb44050201464c
parent 6a51c683
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -2219,6 +2219,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);
@@ -3780,8 +3784,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
@@ -1114,6 +1114,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(