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

Commit dd295df6 authored by Etan Cohen's avatar Etan Cohen
Browse files

[Provider Model] Check against race condition

There can be a race condition of the timeout and operation
completion both getting executed - both setting the callback
to null - which causes the other one to have an NPE.

Bug: 175084231
Test: Testing rapid succession recovery operations
Change-Id: If9d8418f1535d0e075c4abf2723c4b2734e8fa1a
parent 9fcdc982
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -210,7 +210,8 @@ public class ConnectivitySubsystemsRecoveryManager {
    }

    private void checkIfAllSubsystemsRestartsAreDone() {
        if (!mWifiRestartInProgress && !mTelephonyRestartInProgress) {
        if (!mWifiRestartInProgress && !mTelephonyRestartInProgress
                && mCurrentRecoveryCallback != null) {
            mCurrentRecoveryCallback.onSubsystemRestartOperationEnd();
            mCurrentRecoveryCallback = null;
        }
@@ -283,8 +284,10 @@ public class ConnectivitySubsystemsRecoveryManager {
                    stopTrackingTelephonyRestart();
                    mWifiRestartInProgress = false;
                    mTelephonyRestartInProgress = false;
                    if (mCurrentRecoveryCallback != null) {
                        mCurrentRecoveryCallback.onSubsystemRestartOperationEnd();
                        mCurrentRecoveryCallback = null;
                    }
                }, RESTART_TIMEOUT_MS);
            }
        });