Add wakefullness calls on main thread

To avoid the possibility of modifying an ArrayList on multiple threads

Fixes: 203128669
Test: manual
Change-Id: I4da5897d1fa15669e8f4292a780b623457bf20b8
This commit is contained in:
Matt Pietal
2021-11-09 08:39:57 -05:00
parent 61569f50fb
commit c35d18f7d0

View File

@@ -261,8 +261,10 @@ public class CarrierTextManager {
mCarrierTextCallback = callback;
if (mNetworkSupported.get()) {
// Keyguard update monitor expects callbacks from main thread
mMainExecutor.execute(() -> mKeyguardUpdateMonitor.registerCallback(mCallback));
mWakefulnessLifecycle.addObserver(mWakefulnessObserver);
mMainExecutor.execute(() -> {
mKeyguardUpdateMonitor.registerCallback(mCallback);
mWakefulnessLifecycle.addObserver(mWakefulnessObserver);
});
mTelephonyListenerManager.addActiveDataSubscriptionIdListener(mPhoneStateListener);
} else {
// Don't listen and clear out the text when the device isn't a phone.
@@ -272,8 +274,10 @@ public class CarrierTextManager {
}
} else {
mCarrierTextCallback = null;
mMainExecutor.execute(() -> mKeyguardUpdateMonitor.removeCallback(mCallback));
mWakefulnessLifecycle.removeObserver(mWakefulnessObserver);
mMainExecutor.execute(() -> {
mKeyguardUpdateMonitor.removeCallback(mCallback);
mWakefulnessLifecycle.removeObserver(mWakefulnessObserver);
});
mTelephonyListenerManager.removeActiveDataSubscriptionIdListener(mPhoneStateListener);
}
}