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

Commit c2116567 authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Clean up pending MO Connection when ImsService Crash

When the ImsService crashes, also cleanup the pending MO so we
do not get into a state where the device thinks that there is a
pending MO call and blocks new outgoing calls.

Fixes: 188625845
Test: atest FrameworksTelephonyTests:ImsPhoneCallTrackerTest
Change-Id: Idda3a6c5f67ee4b43c7f818c34b20dd62bb38b9f
parent 9f4843e4
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1123,6 +1123,9 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
            connection.getCall().detach(connection);
        }
        mConnections.clear();
        // Pending MO was added to mConnections previously, so it has already been disconnected
        // above. Remove all references to it.
        mPendingMO = null;
        updatePhoneState();
    }

+25 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static junit.framework.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.any;
@@ -569,6 +570,12 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
        // Now fake the ImsService crashing
        mCTUT.hangupAllOrphanedConnections(DisconnectCause.LOST_SIGNAL);
        assertEquals(PhoneConstants.State.IDLE, mCTUT.getState());
        try {
            // ensure new calls are not blocked by any lingering state after crash.
            mCTUT.checkForDialIssues();
        } catch (CallStateException e) {
            fail("checkForDialIssues should not generate a CallStateException: " + e.getMessage());
        }
    }

    /**
@@ -635,17 +642,32 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
        }
    }

    @FlakyTest
    @Ignore
    @Test
    @SmallTest
    public void testImsMOCallDial() {
        startOutgoingCall();
        //call established
        mImsCallListener.onCallProgressing(mSecondImsCall);
        processAllMessages();
        assertEquals(Call.State.ALERTING, mCTUT.mForegroundCall.getState());
    }

    @Test
    @SmallTest
    public void testImsMoCallCrash() {
        startOutgoingCall();
        // Now fake the ImsService crashing
        mCTUT.hangupAllOrphanedConnections(DisconnectCause.LOST_SIGNAL);
        processAllMessages();
        assertEquals(PhoneConstants.State.IDLE, mCTUT.getState());
        try {
            // ensure new calls are not blocked by any lingering state after crash.
            mCTUT.checkForDialIssues();
        } catch (CallStateException e) {
            fail("checkForDialIssues should not generate a CallStateException: " + e.getMessage());
        }
    }

    private void startOutgoingCall() {
        assertEquals(Call.State.IDLE, mCTUT.mForegroundCall.getState());
        assertEquals(PhoneConstants.State.IDLE, mCTUT.getState());
@@ -658,6 +680,7 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
            ex.printStackTrace();
            Assert.fail("unexpected exception thrown" + ex.getMessage());
        }
        processAllMessages();
        assertEquals(PhoneConstants.State.OFFHOOK, mCTUT.getState());
        assertEquals(Call.State.DIALING, mCTUT.mForegroundCall.getState());
    }