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

Commit ccb7b30c authored by Mengjun Leng's avatar Mengjun Leng
Browse files

Fix logging two call records for emergency call

When making one emergency call, the lower layer may return unspecific
error, so that Telecom continues performing the call in next phone
account. Due logging the call record is later than changing the call
state, so the phone account is replaced with next phone account before
recording the call log for previous phone account. After retry, even
Telephony redirects phone to same phone object, but actually Telecom
also records two call logs for different phone account.

To fix it, when continuing to try emergency call in next phone account,
do not trigger callback for call state change to avoid logging an
incorrect call record, also avoid abandoning audio focus.

Bug: 67567571
Change-Id: I53675173548b7320735cd8e7d60e2564bf97c124
parent 12ea9653
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -875,15 +875,17 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
     * (see {@link CallState}), in practice those expectations break down when cellular systems
     * misbehave and they do this very often. The result is that we do not enforce state transitions
     * and instead keep the code resilient to unexpected state changes.
     * @return true indicates if setState succeeded in setting the state to newState,
     * else it is failed, and the call is still in its original state.
     */
    public void setState(int newState, String tag) {
    public boolean setState(int newState, String tag) {
        if (mState != newState) {
            Log.v(this, "setState %s -> %s", mState, newState);

            if (newState == CallState.DISCONNECTED && shouldContinueProcessingAfterDisconnect()) {
                Log.w(this, "continuing processing disconnected call with another service");
                mCreateConnectionProcessor.continueProcessingIfPossible(this, mDisconnectCause);
                return;
                return false;
            }

            updateVideoHistoryViaState(mState, newState);
@@ -962,6 +964,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
            StatsLog.write(StatsLog.CALL_STATE_CHANGED, newState, statsdDisconnectCause,
                    isSelfManaged(), isExternalCall());
        }
        return true;
    }

    void setRingbackRequested(boolean ringbackRequested) {
+22 −18
Original line number Diff line number Diff line
@@ -2504,7 +2504,7 @@ public class CallsManager extends Call.ListenerBase
            // into a well-defined state machine.
            // TODO: Define expected state transitions here, and log when an
            // unexpected transition occurs.
            call.setState(newState, tag);
            if (call.setState(newState, tag)) {
                maybeShowErrorDialogOnDisconnect(call);

                Trace.beginSection("onCallStateChanged");
@@ -2516,7 +2516,8 @@ public class CallsManager extends Call.ListenerBase
                    updateCanAddCall();
                    for (CallsManagerListener listener : mListeners) {
                        if (LogUtils.SYSTRACE_DEBUG) {
                        Trace.beginSection(listener.getClass().toString() + " onCallStateChanged");
                            Trace.beginSection(listener.getClass().toString() +
                                    " onCallStateChanged");
                        }
                        listener.onCallStateChanged(call, oldState, newState);
                        if (LogUtils.SYSTRACE_DEBUG) {
@@ -2525,6 +2526,9 @@ public class CallsManager extends Call.ListenerBase
                    }
                }
                Trace.endSection();
            } else {
                Log.i(this, "failed in setting the state to new state");
            }
        }
    }