summaryrefslogtreecommitdiff
path: root/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-10-03 21:02:34 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-10-03 21:02:34 +0000
commit817ab3f192ae5ff8dc708ade67b9559e582f2b9d (patch)
tree2092420cfb808019d4a148160617f23399da9a77 /packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
parentb93899a461bab3bdd7f72de414ad368371649439 (diff)
parentba46d1cab4326967840d3076e154b321f92f9386 (diff)
Merge "Enforce calls to KUM are done on main thread"
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/CarrierTextController.java')
-rw-r--r--packages/SystemUI/src/com/android/keyguard/CarrierTextController.java19
1 files changed, 15 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
index 949941bc0d84..a97ec6442e14 100644
--- a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
+++ b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
@@ -57,6 +57,7 @@ public class CarrierTextController {
private static final String TAG = "CarrierTextController";
private final boolean mIsEmergencyCallCapable;
+ private final Handler mMainHandler;
private boolean mTelephonyCapable;
private boolean mShowMissingSim;
private boolean mShowAirplaneMode;
@@ -169,6 +170,7 @@ public class CarrierTextController {
mSimSlotsNumber = ((TelephonyManager) context.getSystemService(
Context.TELEPHONY_SERVICE)).getMaxPhoneCount();
mSimErrorState = new boolean[mSimSlotsNumber];
+ mMainHandler = Dependency.get(Dependency.MAIN_HANDLER);
}
/**
@@ -227,7 +229,12 @@ public class CarrierTextController {
if (whitelistIpcs(() -> ConnectivityManager.from(mContext).isNetworkSupported(
ConnectivityManager.TYPE_MOBILE))) {
mKeyguardUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
- mKeyguardUpdateMonitor.registerCallback(mCallback);
+ // Keyguard update monitor expects callbacks from main thread
+ mMainHandler.post(() -> {
+ if (mKeyguardUpdateMonitor != null) {
+ mKeyguardUpdateMonitor.registerCallback(mCallback);
+ }
+ });
mWakefulnessLifecycle.addObserver(mWakefulnessObserver);
telephonyManager.listen(mPhoneStateListener,
LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE);
@@ -239,7 +246,12 @@ public class CarrierTextController {
} else {
mCarrierTextCallback = null;
if (mKeyguardUpdateMonitor != null) {
- mKeyguardUpdateMonitor.removeCallback(mCallback);
+ // Keyguard update monitor expects callbacks from main thread
+ mMainHandler.post(() -> {
+ if (mKeyguardUpdateMonitor != null) {
+ mKeyguardUpdateMonitor.removeCallback(mCallback);
+ }
+ });
mWakefulnessLifecycle.removeObserver(mWakefulnessObserver);
}
telephonyManager.listen(mPhoneStateListener, LISTEN_NONE);
@@ -364,10 +376,9 @@ public class CarrierTextController {
@VisibleForTesting
protected void postToCallback(CarrierTextCallbackInfo info) {
- Handler handler = Dependency.get(Dependency.MAIN_HANDLER);
final CarrierTextCallback callback = mCarrierTextCallback;
if (callback != null) {
- handler.post(() -> callback.updateCarrierInfo(info));
+ mMainHandler.post(() -> callback.updateCarrierInfo(info));
}
}