summaryrefslogtreecommitdiff
path: root/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
diff options
context:
space:
mode:
authorFabian Kozynski <kozynski@google.com>2019-10-07 09:45:50 -0400
committerFabian Kozynski <kozynski@google.com>2019-10-07 09:59:22 -0400
commitd4c84afff048cfe355b8d9fc1d61e62ac9efef09 (patch)
tree4d5e9ba36a898def6c785ef1a3db0944699801f3 /packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
parent0cfa891678740efb4f8e432dbd39eb00738ef969 (diff)
Fix race condition in CarrierTextController
If WakefulnessLifcecycle dispatches to CarrierTextController after the CarrierTextCallback has been cleared but the observer has not been removed, there will be an NPE. This change guards the callback against dispatching to a null object. Test: build and unlock Fixes: 142130321 Change-Id: I5da46a0d5c8308870f2b67ae4622daf8e2d53b2f
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/CarrierTextController.java')
-rw-r--r--packages/SystemUI/src/com/android/keyguard/CarrierTextController.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
index a97ec6442e14..ef9538dbef38 100644
--- a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
+++ b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
@@ -35,6 +35,7 @@ import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
+import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.android.internal.telephony.IccCardConstants;
@@ -66,6 +67,7 @@ public class CarrierTextController {
private WifiManager mWifiManager;
private boolean[] mSimErrorState;
private final int mSimSlotsNumber;
+ @Nullable // Check for nullability before dispatching
private CarrierTextCallback mCarrierTextCallback;
private Context mContext;
private CharSequence mSeparator;
@@ -74,12 +76,12 @@ public class CarrierTextController {
new WakefulnessLifecycle.Observer() {
@Override
public void onFinishedWakingUp() {
- mCarrierTextCallback.finishedWakingUp();
+ if (mCarrierTextCallback != null) mCarrierTextCallback.finishedWakingUp();
}
@Override
public void onStartedGoingToSleep() {
- mCarrierTextCallback.startedGoingToSleep();
+ if (mCarrierTextCallback != null) mCarrierTextCallback.startedGoingToSleep();
}
};