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

Commit 0fc2f4d7 authored by Dennis Choi's avatar Dennis Choi
Browse files

Fix abnormal state of ImsPhoneCall after hangup

Since there is no synchronization between the main thread
and a binder thread in which ImsCall.Lister's callback is running,
it's possible ImsPhoneCall reamins in DISCONNECTING state
when local and remote parties hangup simultaneously.

Test: aTest FrameworksTelephonyTests
Bug: 141812757
Change-Id: Ie9c666d09a12814596dc5776e45d963b96585c4d
parent 7251af1f
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -199,7 +199,9 @@ public class ImsPhoneCall extends Call {
            }

            if (hasOnlyDisconnectedConnections) {
                synchronized(this) {
                    mState = State.DISCONNECTED;
                }
                if (VDBG) {
                    Rlog.v(LOG_TAG, "connectionDisconnected : " + mCallContext + " state = " +
                            mState);
@@ -235,13 +237,17 @@ public class ImsPhoneCall extends Call {
     * Called when this Call is being hung up locally (eg, user pressed "end")
     */
    @UnsupportedAppUsage
    void
    onHangupLocal() {
    @VisibleForTesting
    public void onHangupLocal() {
        for (int i = 0, s = mConnections.size(); i < s; i++) {
            ImsPhoneConnection cn = (ImsPhoneConnection)mConnections.get(i);
            cn.onHangupLocal();
        }
        synchronized(this) {
            if (mState.isAlive()) {
                mState = State.DISCONNECTING;
            }
        }
        if (VDBG) {
            Rlog.v(LOG_TAG, "onHangupLocal : " + mCallContext + " state = " + mState);
        }
+2 −1
Original line number Diff line number Diff line
@@ -90,7 +90,6 @@ public class ImsPhoneCallTest extends TelephonyTest {
    }

    @FlakyTest
    @Ignore
    @Test
    @SmallTest
    public void testConnectionDisconnected() {
@@ -106,6 +105,8 @@ public class ImsPhoneCallTest extends TelephonyTest {
        doReturn(Call.State.DISCONNECTED).when(mConnection2).getState();
        mImsCallUT.connectionDisconnected(null);
        assertEquals(Call.State.DISCONNECTED, mImsCallUT.getState());
        mImsCallUT.onHangupLocal();
        assertEquals(Call.State.DISCONNECTED, mImsCallUT.getState());
    }

    @FlakyTest