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

Commit d62284ae authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Cleanup pending MO call when it disconnects before alerting.

Ensure that where a call is in the pending MO state and gets
disconnected prior to alerting that it will be cleaned up so that other
calls can be placed.

Test: Wrote new unit test for this case.
Fixes: 250229749
Change-Id: I4daa33915fcc3fa5b128175c19827fc332c05d1d
parent c0a5b0c9
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2806,6 +2806,12 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
            conn.getCall().detach(conn);
            removeConnection(conn);

            // If the call being disconnected was the pending MO call we should clear it.
            if (mPendingMO == conn) {
                mPendingMO.finalize();
                mPendingMO = null;
            }

            // remove conference participants from the cached list when call is disconnected
            List<ConferenceParticipant> cpList = imsCall.getConferenceParticipants();
            if (cpList != null) {
+24 −0
Original line number Diff line number Diff line
@@ -1902,6 +1902,30 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
        }
    }

    /**
     * Tests the case where a dialed call has not yet moved beyond the "pending MO" phase, but the
     * user then disconnects.  In such a case we need to ensure that the pending MO reference is
     * cleared so that another call can be placed.
     */
    @Test
    @SmallTest
    public void testCallDisconnectBeforeActive() {
        ImsPhoneConnection connection = placeCall();
        assertEquals(1, mCTUT.getConnections().size());
        // Call is the pending MO right now.
        assertEquals(connection, mCTUT.getPendingMO());
        assertEquals(Call.State.DIALING, mCTUT.mForegroundCall.getState());
        assertEquals(PhoneConstants.State.OFFHOOK, mCTUT.getState());

        mImsCallListener.onCallTerminated(connection.getImsCall(),
                new ImsReasonInfo(ImsReasonInfo.CODE_USER_TERMINATED_BY_REMOTE, 0));
        // Make sure pending MO got nulled out.
        assertNull(mCTUT.getPendingMO());

        // Try making another call; it should not fail.
        ImsPhoneConnection connection2 = placeCall();
    }

    private void sendCarrierConfigChanged() {
        Intent intent = new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
        intent.putExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX, mPhone.getSubId());