Loading packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +13 −1 Original line number Diff line number Diff line Loading @@ -763,6 +763,13 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, } } } @Override public void onStrongAuthStateChanged(int userId) { if (mLockPatternUtils.isUserInLockdown(KeyguardUpdateMonitor.getCurrentUser())) { doKeyguardLocked(null); } } }; ViewMediatorCallback mViewMediatorCallback = new ViewMediatorCallback() { Loading Loading @@ -1957,6 +1964,10 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, mExternallyEnabled = enabled; if (!enabled && mShowing) { if (mLockPatternUtils.isUserInLockdown(KeyguardUpdateMonitor.getCurrentUser())) { Log.d(TAG, "keyguardEnabled(false) overridden by user lockdown"); return; } // hiding keyguard that is showing, remember to reshow later if (DEBUG) Log.d(TAG, "remembering to reshow, hiding keyguard, " + "disabling status bar expansion"); Loading Loading @@ -2178,7 +2189,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, */ private void doKeyguardLocked(Bundle options) { // if another app is disabling us, don't show if (!mExternallyEnabled) { if (!mExternallyEnabled && !mLockPatternUtils.isUserInLockdown(KeyguardUpdateMonitor.getCurrentUser())) { if (DEBUG) Log.d(TAG, "doKeyguard: not showing because externally disabled"); mNeedToReshowWhenReenabled = true; Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +45 −0 Original line number Diff line number Diff line Loading @@ -177,6 +177,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { private @Mock ShadeWindowLogger mShadeWindowLogger; private @Captor ArgumentCaptor<KeyguardStateController.Callback> mKeyguardStateControllerCallback; private @Captor ArgumentCaptor<KeyguardUpdateMonitorCallback> mKeyguardUpdateMonitorCallbackCaptor; private DeviceConfigProxy mDeviceConfig = new DeviceConfigProxyFake(); private FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock()); Loading Loading @@ -236,6 +238,45 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { KeyguardUpdateMonitor.setCurrentUser(mInitialUserId); } @Test @TestableLooper.RunWithLooper(setAsMainLooper = true) public void onLockdown_showKeyguard_evenIfKeyguardIsNotEnabledExternally() { // GIVEN keyguard is not enabled and isn't showing mViewMediator.onSystemReady(); mViewMediator.setKeyguardEnabled(false); TestableLooper.get(this).processAllMessages(); captureKeyguardUpdateMonitorCallback(); assertFalse(mViewMediator.isShowingAndNotOccluded()); // WHEN lockdown occurs when(mLockPatternUtils.isUserInLockdown(anyInt())).thenReturn(true); mKeyguardUpdateMonitorCallbackCaptor.getValue().onStrongAuthStateChanged(0); // THEN keyguard is shown TestableLooper.get(this).processAllMessages(); assertTrue(mViewMediator.isShowingAndNotOccluded()); } @Test @TestableLooper.RunWithLooper(setAsMainLooper = true) public void doNotHideKeyguard_whenLockdown_onKeyguardNotEnabledExternally() { // GIVEN keyguard is enabled and lockdown occurred so the keyguard is showing mViewMediator.onSystemReady(); mViewMediator.setKeyguardEnabled(true); TestableLooper.get(this).processAllMessages(); captureKeyguardUpdateMonitorCallback(); when(mLockPatternUtils.isUserInLockdown(anyInt())).thenReturn(true); mKeyguardUpdateMonitorCallbackCaptor.getValue().onStrongAuthStateChanged(0); assertTrue(mViewMediator.isShowingAndNotOccluded()); // WHEN keyguard is externally not enabled anymore mViewMediator.setKeyguardEnabled(false); // THEN keyguard is NOT dismissed; it continues to show TestableLooper.get(this).processAllMessages(); assertTrue(mViewMediator.isShowingAndNotOccluded()); } @Test public void testOnGoingToSleep_UpdatesKeyguardGoingAway() { mViewMediator.onStartedGoingToSleep(OFF_BECAUSE_OF_USER); Loading Loading @@ -982,4 +1023,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { private void captureKeyguardStateControllerCallback() { verify(mKeyguardStateController).addCallback(mKeyguardStateControllerCallback.capture()); } private void captureKeyguardUpdateMonitorCallback() { verify(mUpdateMonitor).registerCallback(mKeyguardUpdateMonitorCallbackCaptor.capture()); } } Loading
packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +13 −1 Original line number Diff line number Diff line Loading @@ -763,6 +763,13 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, } } } @Override public void onStrongAuthStateChanged(int userId) { if (mLockPatternUtils.isUserInLockdown(KeyguardUpdateMonitor.getCurrentUser())) { doKeyguardLocked(null); } } }; ViewMediatorCallback mViewMediatorCallback = new ViewMediatorCallback() { Loading Loading @@ -1957,6 +1964,10 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, mExternallyEnabled = enabled; if (!enabled && mShowing) { if (mLockPatternUtils.isUserInLockdown(KeyguardUpdateMonitor.getCurrentUser())) { Log.d(TAG, "keyguardEnabled(false) overridden by user lockdown"); return; } // hiding keyguard that is showing, remember to reshow later if (DEBUG) Log.d(TAG, "remembering to reshow, hiding keyguard, " + "disabling status bar expansion"); Loading Loading @@ -2178,7 +2189,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, */ private void doKeyguardLocked(Bundle options) { // if another app is disabling us, don't show if (!mExternallyEnabled) { if (!mExternallyEnabled && !mLockPatternUtils.isUserInLockdown(KeyguardUpdateMonitor.getCurrentUser())) { if (DEBUG) Log.d(TAG, "doKeyguard: not showing because externally disabled"); mNeedToReshowWhenReenabled = true; Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +45 −0 Original line number Diff line number Diff line Loading @@ -177,6 +177,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { private @Mock ShadeWindowLogger mShadeWindowLogger; private @Captor ArgumentCaptor<KeyguardStateController.Callback> mKeyguardStateControllerCallback; private @Captor ArgumentCaptor<KeyguardUpdateMonitorCallback> mKeyguardUpdateMonitorCallbackCaptor; private DeviceConfigProxy mDeviceConfig = new DeviceConfigProxyFake(); private FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock()); Loading Loading @@ -236,6 +238,45 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { KeyguardUpdateMonitor.setCurrentUser(mInitialUserId); } @Test @TestableLooper.RunWithLooper(setAsMainLooper = true) public void onLockdown_showKeyguard_evenIfKeyguardIsNotEnabledExternally() { // GIVEN keyguard is not enabled and isn't showing mViewMediator.onSystemReady(); mViewMediator.setKeyguardEnabled(false); TestableLooper.get(this).processAllMessages(); captureKeyguardUpdateMonitorCallback(); assertFalse(mViewMediator.isShowingAndNotOccluded()); // WHEN lockdown occurs when(mLockPatternUtils.isUserInLockdown(anyInt())).thenReturn(true); mKeyguardUpdateMonitorCallbackCaptor.getValue().onStrongAuthStateChanged(0); // THEN keyguard is shown TestableLooper.get(this).processAllMessages(); assertTrue(mViewMediator.isShowingAndNotOccluded()); } @Test @TestableLooper.RunWithLooper(setAsMainLooper = true) public void doNotHideKeyguard_whenLockdown_onKeyguardNotEnabledExternally() { // GIVEN keyguard is enabled and lockdown occurred so the keyguard is showing mViewMediator.onSystemReady(); mViewMediator.setKeyguardEnabled(true); TestableLooper.get(this).processAllMessages(); captureKeyguardUpdateMonitorCallback(); when(mLockPatternUtils.isUserInLockdown(anyInt())).thenReturn(true); mKeyguardUpdateMonitorCallbackCaptor.getValue().onStrongAuthStateChanged(0); assertTrue(mViewMediator.isShowingAndNotOccluded()); // WHEN keyguard is externally not enabled anymore mViewMediator.setKeyguardEnabled(false); // THEN keyguard is NOT dismissed; it continues to show TestableLooper.get(this).processAllMessages(); assertTrue(mViewMediator.isShowingAndNotOccluded()); } @Test public void testOnGoingToSleep_UpdatesKeyguardGoingAway() { mViewMediator.onStartedGoingToSleep(OFF_BECAUSE_OF_USER); Loading Loading @@ -982,4 +1023,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { private void captureKeyguardStateControllerCallback() { verify(mKeyguardStateController).addCallback(mKeyguardStateControllerCallback.capture()); } private void captureKeyguardUpdateMonitorCallback() { verify(mUpdateMonitor).registerCallback(mKeyguardUpdateMonitorCallbackCaptor.capture()); } }