[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
This commit is contained in:
Etan Cohen
2021-01-20 21:04:02 -08:00
parent 9fcdc98215
commit dd295df643

View File

@@ -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;
mCurrentRecoveryCallback.onSubsystemRestartOperationEnd();
mCurrentRecoveryCallback = null;
if (mCurrentRecoveryCallback != null) {
mCurrentRecoveryCallback.onSubsystemRestartOperationEnd();
mCurrentRecoveryCallback = null;
}
}, RESTART_TIMEOUT_MS);
}
});