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

Commit 3b0cc100 authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Schedule IMS -> CS redial notification to happen on main thread

In the scenario where we are redialing from IMS -> CS, the
callSessionStartFailed response can happen on a Binder thread before
the dial command on the main thread completes. This creates a
scenario where the redial on CS starts before the previous IMS
redial operation completed and set up all associated callbacks.
This causes us to lose track of the correct instance to call
hangup() on.

Instead, the IMS -> CS redial indication should be scheduled to
happen on the main thread so that it will wait for the previous
IMS redial on the main thread to complete first.

Bug: 194896760
Test: manual
Change-Id: I32580b0bbb067e7de2e23b39989eb714a020500c
parent 5ace0b1e
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
@@ -1582,7 +1582,31 @@ public class ImsPhone extends ImsPhoneBase {
                                         new SilentRedialParam(mLastDialString, cause, dialArgs),
                                         null);
        if (ar != null) {
            // There is a race condition that can happen in some cases:
            // (Main thread) dial start
            // (Binder Thread) onCallSessionFailed
            // (Binder Thread) schedule a redial for CS on the main thread
            // (Main Thread) dial finish
            // (Main Thread) schedule to associate ImsPhoneConnection with
            //               GsmConnection on the main thread
            // If scheduling the CS redial occurs before the command to schedule the
            // ImsPhoneConnection to be  associated with the GsmConnection, the CS redial will occur
            // before GsmConnection has had callbacks to ImsPhone correctly updated. This will cause
            // Callbacks back to GsmCdmaPhone to never be set up correctly and we will lose track of
            // the instance.
            // Instead, schedule this redial to happen on the main thread, so that we know dial has
            // finished before scheduling a redial:
            // (Main thread) dial start
            // (Binder Thread) onCallSessionFailed -> move notify registrants to main thread
            // (Main Thread) dial finish
            // (Main Thread) schedule on main thread to associate ImsPhoneConnection with
            //               GsmConnection
            // (Main Thread) schedule a redial for CS
            mContext.getMainExecutor().execute(() -> {
                logd("initiateSilentRedial: notifying registrants, isEmergency=" + isEmergency
                        + ", eccCategory=" + eccCategory);
                mSilentRedialRegistrants.notifyRegistrants(ar);
            });
        }
    }