From 9d5f970c7638d9951bf95d9aed6a0f627fb20da0 Mon Sep 17 00:00:00 2001 From: Josh Tsuji Date: Tue, 11 Jan 2022 14:06:05 -0500 Subject: [PATCH] Check if the SIM is secure before dispatching swipe to unlock. Due to an existing bug, KeyguardStateController#canDismissLockScreen returns true even if the device is SIM-locked, if there is no device lock set. This caused the new sc-v2 unlock code to believe we could dismiss the lock screen via swiping. Since the panel expansion is used to drive swipe to unlock on the lock screen, this meant that swiping the notification panel over the emergency dialer was interpreted as a swipe to unlock, so we unlocked. We'll fix the underlying issue with canDismissLockScreen in T: b/214057466. This method is used 25+ times all over the code, and it would be extremely risky to add the SIM-lock check there at this point. Fixes: 214057466 Test: insert locked SIM, emergency dialer, pull down shade, try to go back/home Change-Id: Iee86cadc8c4903c703d4fab515dc4f6f73953467 --- .../systemui/keyguard/KeyguardViewMediator.java | 15 +++++++++++++++ .../systemui/statusbar/phone/StatusBar.java | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 7a53fd1152fe7..e9f288d51317b 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -1727,6 +1727,21 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable, || mUpdateMonitor.isSimPinSecure(); } + /** + * Whether any of the SIMs on the device are secured with a PIN. If so, the keyguard should not + * be dismissable until the PIN is entered, even if the device itself has no lock set. + */ + public boolean isAnySimPinSecure() { + for (int i = 0; i < mLastSimStates.size(); i++) { + final int key = mLastSimStates.keyAt(i); + if (KeyguardUpdateMonitor.isSimPinSecure(mLastSimStates.get(key))) { + return true; + } + } + + return false; + } + public void setSwitchingUser(boolean switching) { mUpdateMonitor.setSwitchingUser(switching); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 7a68b9616fa35..778a1e36392e1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -1354,10 +1354,14 @@ public class StatusBar extends SystemUI implements // Things that mean we're not dismissing the keyguard, and should ignore this expansion: // - Keyguard isn't even visible. // - Keyguard is visible, but can't be dismissed (swiping up will show PIN/password prompt). + // - The SIM is locked, you can't swipe to unlock. If the SIM is locked but there is no + // device lock set, canDismissLockScreen returns true even though you should not be able + // to dismiss the lock screen until entering the SIM PIN. // - QS is expanded and we're swiping - swiping up now will hide QS, not dismiss the // keyguard. if (!isKeyguardShowing() || !mKeyguardStateController.canDismissLockScreen() + || mKeyguardViewMediator.isAnySimPinSecure() || (mNotificationPanelViewController.isQsExpanded() && trackingTouch)) { return; }