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

Commit d9c3a08d authored by Anju Mathapati's avatar Anju Mathapati Committed by Anthony Lee
Browse files

IMS: Do not update connection state for onCallUpdated callback.

onCallUpdated callback is to inform updates on parameters of ImsCall
other than the call state. Updating the call state during onCallUpdated
is sometimes corrupting the connection state, especially during
hold/resume operation. Hence refactored code to not update state
of connection for call updated callback.

Change-Id: I55ed948fe3b5b03f8836b84d7952a39f97cd2a8a
Bug: 22170586
parent c8582255
Loading
Loading
Loading
Loading
+29 −8
Original line number Diff line number Diff line
@@ -901,6 +901,19 @@ public final class ImsPhoneCallTracker extends CallTracker {

    private void processCallStateChange(ImsCall imsCall, ImsPhoneCall.State state, int cause) {
        if (DBG) log("processCallStateChange " + imsCall + " state=" + state + " cause=" + cause);
        // This method is called on onCallUpdate() where there is not necessarily a call state
        // change. In these situations, we'll ignore the state related updates and only process
        // the change in media capabilities (as expected).  The default is to not ignore state
        // changes so we do not change existing behavior.
        processCallStateChange(imsCall, state, cause, false /* do not ignore state update */);
    }

    private void processCallStateChange(ImsCall imsCall, ImsPhoneCall.State state, int cause,
            boolean ignoreState) {
        if (DBG) {
            log("processCallStateChange state=" + state + " cause=" + cause
                    + " ignoreState=" + ignoreState);
        }

        if (imsCall == null) return;

@@ -912,14 +925,22 @@ public final class ImsPhoneCallTracker extends CallTracker {
            return;
        }

        // processCallStateChange is triggered for onCallUpdated as well.
        // onCallUpdated should not modify the state of the call
        // It should modify only other capabilities of call through updateMediaCapabilities
        // State updates will be triggered through individual callbacks
        // i.e. onCallHeld, onCallResume, etc and conn.update will be responsible for the update
        if (ignoreState) {
            changed = conn.updateMediaCapabilities(imsCall);
        } else {
            changed = conn.update(imsCall, state);

            if (state == ImsPhoneCall.State.DISCONNECTED) {
                changed = conn.onDisconnect(cause) || changed;
                //detach the disconnected connections
                conn.getCall().detach(conn);
                removeConnection(conn);
            }
        }

        if (changed) {
            if (conn.getCall() == mHandoverCall) return;
@@ -1020,7 +1041,7 @@ public final class ImsPhoneCallTracker extends CallTracker {
            ImsPhoneConnection conn = findConnection(imsCall);
            if (conn != null) {
                processCallStateChange(imsCall, conn.getCall().mState,
                        DisconnectCause.NOT_DISCONNECTED);
                        DisconnectCause.NOT_DISCONNECTED, true /*ignore state update*/);
            }
        }

+8 −7
Original line number Diff line number Diff line
@@ -117,7 +117,8 @@ public class ImsPhoneConnection extends Connection {

    /** This is probably an MT call */
    /*package*/
    ImsPhoneConnection(Context context, ImsCall imsCall, ImsPhoneCallTracker ct, ImsPhoneCall parent) {
    ImsPhoneConnection(Context context, ImsCall imsCall, ImsPhoneCallTracker ct,
            ImsPhoneCall parent) {
        createWakeLock(context);
        acquireWakeLock();

@@ -152,7 +153,8 @@ public class ImsPhoneConnection extends Connection {

    /** This is an MO call, created when dialing */
    /*package*/
    ImsPhoneConnection(Context context, String dialString, ImsPhoneCallTracker ct, ImsPhoneCall parent) {
    ImsPhoneConnection(Context context, String dialString, ImsPhoneCallTracker ct,
            ImsPhoneCall parent) {
        createWakeLock(context);
        acquireWakeLock();

@@ -474,7 +476,8 @@ public class ImsPhoneConnection extends Connection {
            // arg1 is the character that was/is being processed
            notifyMessage.arg1 = c;

            //Rlog.v(LOG_TAG, "##### processNextPostDialChar: send msg to postDialHandler, arg1=" + c);
            //Rlog.v(LOG_TAG,
            //      "##### processNextPostDialChar: send msg to postDialHandler, arg1=" + c);
            notifyMessage.sendToTarget();
        }
    }
@@ -593,12 +596,10 @@ public class ImsPhoneConnection extends Connection {
        }

        boolean updateParent = mParent.update(this, imsCall, state);
        boolean updateMediaCapabilities = updateMediaCapabilities(imsCall);
        boolean updateWifiState = updateWifiState();
        boolean updateAddressDisplay = updateAddressDisplay(imsCall);

        return updateParent || updateMediaCapabilities || updateWifiState
            || updateAddressDisplay;
        return updateParent || updateWifiState || updateAddressDisplay;
    }

    @Override
@@ -701,7 +702,7 @@ public class ImsPhoneConnection extends Connection {
     * @param imsCall The call to check for changes in media capabilities.
     * @return Whether the media capabilities have been changed.
     */
    private boolean updateMediaCapabilities(ImsCall imsCall) {
    public boolean updateMediaCapabilities(ImsCall imsCall) {
        if (imsCall == null) {
            return false;
        }