Loading packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +4 −0 Original line number Diff line number Diff line Loading @@ -870,6 +870,10 @@ public class KeyguardViewMediator implements CoreStartable, @Override public void onStrongAuthStateChanged(int userId) { // Do not react to strong auth changes of users that aren't the current user if (userId != mSelectedUserInteractor.getSelectedUserId()) { return; } if (mLockPatternUtils.isUserInLockdown(mSelectedUserInteractor.getSelectedUserId())) { doKeyguardLocked(null); } Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +32 −1 Original line number Diff line number Diff line Loading @@ -490,7 +490,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { captureKeyguardUpdateMonitorCallback(); assertFalse(mViewMediator.isShowingAndNotOccluded()); // WHEN lockdown occurs // WHEN lockdown occurs for current user when(mSelectedUserInteractor.getSelectedUserId()).thenReturn(0); when(mLockPatternUtils.isUserInLockdown(anyInt())).thenReturn(true); mKeyguardUpdateMonitorCallbackCaptor.getValue().onStrongAuthStateChanged(0); Loading @@ -499,6 +500,36 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { assertTrue(mViewMediator.isShowingAndNotOccluded()); } @Test @TestableLooper.RunWithLooper(setAsMainLooper = true) public void onLockdown_onlyShowKeyguardIfMainUserHadStrongAuthChanged() { // GIVEN main user is in lockdown mViewMediator.onSystemReady(); mViewMediator.setKeyguardEnabled(false); TestableLooper.get(this).processAllMessages(); captureKeyguardUpdateMonitorCallback(); assertFalse(mViewMediator.isShowingAndNotOccluded()); int currentUserId = 0; int otherUserId = 10; when(mSelectedUserInteractor.getSelectedUserId()).thenReturn(currentUserId); when(mLockPatternUtils.isUserInLockdown(currentUserId)).thenReturn(true); // WHEN a different user's strong auth changes mKeyguardUpdateMonitorCallbackCaptor.getValue().onStrongAuthStateChanged(otherUserId); // THEN keyguard is not shown TestableLooper.get(this).processAllMessages(); assertFalse(mViewMediator.isShowingAndNotOccluded()); // when the current user's strong auth changes mKeyguardUpdateMonitorCallbackCaptor.getValue().onStrongAuthStateChanged(currentUserId); // THEN keyguard is shown TestableLooper.get(this).processAllMessages(); assertTrue(mViewMediator.isShowingAndNotOccluded()); } @Test @TestableLooper.RunWithLooper(setAsMainLooper = true) public void showKeyguardAfterKeyguardNotEnabled() { Loading Loading
packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +4 −0 Original line number Diff line number Diff line Loading @@ -870,6 +870,10 @@ public class KeyguardViewMediator implements CoreStartable, @Override public void onStrongAuthStateChanged(int userId) { // Do not react to strong auth changes of users that aren't the current user if (userId != mSelectedUserInteractor.getSelectedUserId()) { return; } if (mLockPatternUtils.isUserInLockdown(mSelectedUserInteractor.getSelectedUserId())) { doKeyguardLocked(null); } Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +32 −1 Original line number Diff line number Diff line Loading @@ -490,7 +490,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { captureKeyguardUpdateMonitorCallback(); assertFalse(mViewMediator.isShowingAndNotOccluded()); // WHEN lockdown occurs // WHEN lockdown occurs for current user when(mSelectedUserInteractor.getSelectedUserId()).thenReturn(0); when(mLockPatternUtils.isUserInLockdown(anyInt())).thenReturn(true); mKeyguardUpdateMonitorCallbackCaptor.getValue().onStrongAuthStateChanged(0); Loading @@ -499,6 +500,36 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { assertTrue(mViewMediator.isShowingAndNotOccluded()); } @Test @TestableLooper.RunWithLooper(setAsMainLooper = true) public void onLockdown_onlyShowKeyguardIfMainUserHadStrongAuthChanged() { // GIVEN main user is in lockdown mViewMediator.onSystemReady(); mViewMediator.setKeyguardEnabled(false); TestableLooper.get(this).processAllMessages(); captureKeyguardUpdateMonitorCallback(); assertFalse(mViewMediator.isShowingAndNotOccluded()); int currentUserId = 0; int otherUserId = 10; when(mSelectedUserInteractor.getSelectedUserId()).thenReturn(currentUserId); when(mLockPatternUtils.isUserInLockdown(currentUserId)).thenReturn(true); // WHEN a different user's strong auth changes mKeyguardUpdateMonitorCallbackCaptor.getValue().onStrongAuthStateChanged(otherUserId); // THEN keyguard is not shown TestableLooper.get(this).processAllMessages(); assertFalse(mViewMediator.isShowingAndNotOccluded()); // when the current user's strong auth changes mKeyguardUpdateMonitorCallbackCaptor.getValue().onStrongAuthStateChanged(currentUserId); // THEN keyguard is shown TestableLooper.get(this).processAllMessages(); assertTrue(mViewMediator.isShowingAndNotOccluded()); } @Test @TestableLooper.RunWithLooper(setAsMainLooper = true) public void showKeyguardAfterKeyguardNotEnabled() { Loading