From 7130675c53713058304d9fa5964878f5b908492c Mon Sep 17 00:00:00 2001 From: Brad Ebinger Date: Thu, 5 Oct 2017 11:39:06 -0700 Subject: [PATCH] Fix NPE when removing PIN locked SIM during E911 call There is the possibility of mCallback being null while the Keyguard still has a PhoneStateListener registered for onSimStateChanged callback. This can cause a NPE. Bug: 66986066 Test: Manual, PIN/PUK locked SIM Change-Id: I799c9521f787e800e259c3bdce9edee3f844f5f3 --- .../src/com/android/keyguard/KeyguardSimPinView.java | 6 +++++- .../src/com/android/keyguard/KeyguardSimPukView.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java index fe03fba5bfda9..16a0e5af1e0af 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java @@ -64,7 +64,11 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView { // again when the PUK locked SIM is re-entered. case ABSENT: { KeyguardUpdateMonitor.getInstance(getContext()).reportSimUnlocked(mSubId); - mCallback.dismiss(true, KeyguardUpdateMonitor.getCurrentUser()); + // onSimStateChanged callback can fire when the SIM PIN lock is not currently + // active and mCallback is null. + if (mCallback != null) { + mCallback.dismiss(true, KeyguardUpdateMonitor.getCurrentUser()); + } break; } default: diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java index 826a03d1b6587..fddb12d0f7653 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java @@ -70,7 +70,11 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView { // move into the READY state and the PUK lock keyguard should be removed. case READY: { KeyguardUpdateMonitor.getInstance(getContext()).reportSimUnlocked(mSubId); - mCallback.dismiss(true, KeyguardUpdateMonitor.getCurrentUser()); + // mCallback can be null if onSimStateChanged callback is called when keyguard + // isn't active. + if (mCallback != null) { + mCallback.dismiss(true, KeyguardUpdateMonitor.getCurrentUser()); + } break; } default: