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

Commit 9f13848d authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Speculative DISCONNECTING fix for ImsPhoneCallTracker

There is an issue occuring that causes an ImsPhoneConnection to
be left in the ImsPhoneCall without ever being cleaned up. This
causes the ImsPhoneCall never move into the IDLE state and blocks
new outgoing calls from being made.

Through speculation and code observation, it looks as though
this case may happen when the ImsService never responds to a
terminate request and telephony never receives the onDisconnect
callback. This change adds a new timeout that will expire after
some time and verify that the ImsPhoneConnection did indeed
eventually disconnect. If it did not, then we can assume that
the modem is not still tracking the call and we can call
onDisconnect ourselves.

Bug: 35012199
Test: Manual
Change-Id: I288d2950cd245ed6e40dd364e68d739a7d122d6c
parent b86e4558
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -212,9 +212,14 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
    private static final int EVENT_DATA_ENABLED_CHANGED = 23;
    private static final int EVENT_GET_IMS_SERVICE = 24;
    private static final int EVENT_CHECK_FOR_WIFI_HANDOVER = 25;
    private static final int EVENT_CLEAR_DISCONNECTING_CONN = 26;

    private static final int TIMEOUT_HANGUP_PENDINGMO = 500;

    // The number of milliseconds the CallTracker will wait before manually disconnecting the
    // connection due to the modem not responding.
    private static final int TIMEOUT_CLEAR_DISCONNECTING_CONN = 5000;

    // The number of times we will try to connect to the ImsService before giving up.
    private static final int NUM_IMS_SERVICE_RETRIES = 10;
    // The number of milliseconds in between each try.
@@ -1079,6 +1084,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        }

        ImsCall imsCall = call.getImsCall();
        // Get first connection that is associated with imsCall.
        ImsPhoneConnection imsPhoneConnection = call.getFirstConnection();
        boolean rejectCall = false;

        if (call == mRingingCall) {
@@ -1105,6 +1112,12 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        }

        call.onHangupLocal();
        // Schedule a cleaning event for the ImsPhoneCall. If the modem has not responded in
        // TIMEOUT_CLEAR_DISCONNECTING_CONN milliseconds, manually disconnect the connection.
        if (!hasMessages(EVENT_CLEAR_DISCONNECTING_CONN, imsPhoneConnection)) {
            sendMessageDelayed(obtainMessage(EVENT_CLEAR_DISCONNECTING_CONN, imsPhoneConnection),
                    TIMEOUT_CLEAR_DISCONNECTING_CONN);
        }

        try {
            if (imsCall != null) {
@@ -2413,6 +2426,20 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                    }
                }
                break;
            case EVENT_CLEAR_DISCONNECTING_CONN:
                if (msg.obj instanceof ImsPhoneConnection) {
                    ImsPhoneConnection imsPhoneConnection = (ImsPhoneConnection) msg.obj;
                    removeMessages(EVENT_CLEAR_DISCONNECTING_CONN, imsPhoneConnection);

                    // We have timed out waiting for the modem while disconnecting this connection.
                    // Manually disconnect to avoid tracking an invalid call.
                    if (imsPhoneConnection != null && imsPhoneConnection.isDisconnecting()) {
                        Rlog.e(LOG_TAG, "No response from modem. Manually disconnecting: " +
                                imsPhoneConnection);
                        imsPhoneConnection.onDisconnect();
                    }
                }
                break;
        }
    }

+11 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ public class ImsPhoneConnection extends Connection implements
    private Bundle mExtras = new Bundle();

    private boolean mDisconnected;
    private boolean mDisconnecting = false;

    /*
    int mIndex;          // index in ImsPhoneCallTracker.connections[], -1 if unassigned
@@ -388,9 +389,18 @@ public class ImsPhoneConnection extends Connection implements
     */
    void
    onHangupLocal() {
        mDisconnecting = true;
        mCause = DisconnectCause.LOCAL;
    }

    /**
     * Return whether or not this connection is DISCONNECTING and waiting for a signal from the
     * modem to disconnect.
     */
    boolean isDisconnecting() {
        return mDisconnecting;
    }

    /** Called when the connection has been disconnected */
    @Override
    public boolean onDisconnect(int cause) {
@@ -409,6 +419,7 @@ public class ImsPhoneConnection extends Connection implements

            mDisconnectTime = System.currentTimeMillis();
            mDuration = SystemClock.elapsedRealtime() - mConnectTimeReal;
            mDisconnecting = false;
            mDisconnected = true;

            mOwner.mPhone.notifyDisconnect(this);