summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Matt Pietal <mpietal@google.com> 2021-07-29 14:41:41 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-07-29 14:41:41 +0000
commitc3915dcbe947d06a071c5d06f3db9bc7dc879bc8 (patch)
tree3274e36af0e57513c670a8874dacfd972a344be1
parent866753754bad5748207a2aeaa3f433a7eab68628 (diff)
parent7d938ee7f496c3502a3327021b78da5b19ceaaa5 (diff)
Merge "Make sure SIM PIN screen shows" into sc-dev
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java25
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java30
2 files changed, 52 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index c7c25903923a..84cb12cf5e49 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -399,6 +399,12 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
private boolean mPendingLock;
/**
+ * When starting to go away, flag a need to show the PIN lock so the keyguard can be brought
+ * back.
+ */
+ private boolean mPendingPinLock = false;
+
+ /**
* Whether a power button gesture (such as double tap for camera) has been detected. This is
* delivered directly from {@link KeyguardService}, immediately upon the gesture being detected.
* This is used in {@link #onStartedWakingUp} to decide whether to execute the pending lock, or
@@ -472,6 +478,19 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() {
@Override
+ public void onKeyguardVisibilityChanged(boolean showing) {
+ synchronized (KeyguardViewMediator.this) {
+ if (!showing && mPendingPinLock) {
+ Log.i(TAG, "PIN lock requested, starting keyguard");
+
+ // Bring the keyguard back in order to show the PIN lock
+ mPendingPinLock = false;
+ doKeyguardLocked(null);
+ }
+ }
+ }
+
+ @Override
public void onUserSwitching(int userId) {
if (DEBUG) Log.d(TAG, String.format("onUserSwitching %d", userId));
// Note that the mLockPatternUtils user has already been updated from setCurrentUser.
@@ -591,6 +610,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
+ "showing; need to show keyguard so user can enter sim pin");
doKeyguardLocked(null);
} else {
+ mPendingPinLock = true;
resetStateLocked();
}
}
@@ -739,6 +759,9 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
@Override
public void onBouncerVisiblityChanged(boolean shown) {
synchronized (KeyguardViewMediator.this) {
+ if (shown) {
+ mPendingPinLock = false;
+ }
adjustStatusBarLocked(shown, false);
}
}
@@ -2783,7 +2806,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
}
}
- private void setShowingLocked(boolean showing) {
+ void setShowingLocked(boolean showing) {
setShowingLocked(showing, false /* forceCallbacks */);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
index 1dacc6245d84..ad0878031679 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -33,8 +34,9 @@ import android.app.admin.DevicePolicyManager;
import android.app.trust.TrustManager;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
+import android.telephony.TelephonyManager;
import android.testing.AndroidTestingRunner;
-import android.testing.TestableLooper.RunWithLooper;
+import android.testing.TestableLooper;
import androidx.test.filters.SmallTest;
@@ -65,7 +67,7 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@RunWith(AndroidTestingRunner.class)
-@RunWithLooper
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
public class KeyguardViewMediatorTest extends SysuiTestCase {
private KeyguardViewMediator mViewMediator;
@@ -124,6 +126,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
mUnlockedScreenOffAnimationController,
() -> mNotificationShadeDepthController);
mViewMediator.start();
+ mViewMediator.onSystemReady();
}
@Test
@@ -160,4 +163,27 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
mViewMediator.onDozeAmountChanged(1f, 1f);
assertFalse(mViewMediator.isAnimatingScreenOff());
}
+
+ @Test
+ public void restoreBouncerWhenSimLockedAndKeyguardIsGoingAway() {
+ // When showing and provisioned
+ when(mUpdateMonitor.isDeviceProvisioned()).thenReturn(true);
+ mViewMediator.setShowingLocked(true);
+
+ // and a SIM becomes locked and requires a PIN
+ mViewMediator.mUpdateCallback.onSimStateChanged(
+ 1 /* subId */,
+ 0 /* slotId */,
+ TelephonyManager.SIM_STATE_PIN_REQUIRED);
+
+ // and the keyguard goes away
+ mViewMediator.setShowingLocked(false);
+ when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false);
+ mViewMediator.mUpdateCallback.onKeyguardVisibilityChanged(false);
+
+ TestableLooper.get(this).processAllMessages();
+
+ // then make sure it comes back
+ verify(mStatusBarKeyguardViewManager, atLeast(1)).show(null);
+ }
}