Loading packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +10 −2 Original line number Diff line number Diff line Loading @@ -726,6 +726,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 @@ -1949,8 +1956,9 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, * Enable the keyguard if the settings are appropriate. */ private void doKeyguardLocked(Bundle options) { // if another app is disabling us, don't show if (!mExternallyEnabled) { // if another app is disabling us, don't show unless we're in lockdown mode 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 +27 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardDisplayManager; import com.android.keyguard.KeyguardSecurityView; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.keyguard.mediator.ScreenOnCoordinator; import com.android.systemui.DejankUtils; import com.android.systemui.SysuiTestCase; Loading Loading @@ -98,6 +99,8 @@ import com.android.systemui.util.time.FakeSystemClock; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; Loading Loading @@ -141,6 +144,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { private @Mock AuthController mAuthController; private @Mock ShadeExpansionStateManager mShadeExpansionStateManager; private @Mock ShadeWindowLogger mShadeWindowLogger; private @Captor ArgumentCaptor<KeyguardUpdateMonitorCallback> mKeyguardUpdateMonitorCallbackCaptor; private DeviceConfigProxy mDeviceConfig = new DeviceConfigProxyFake(); private FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock()); Loading Loading @@ -178,6 +183,24 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { createAndStartViewMediator(); } @Test 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 public void testOnGoingToSleep_UpdatesKeyguardGoingAway() { mViewMediator.onStartedGoingToSleep(OFF_BECAUSE_OF_USER); Loading Loading @@ -602,4 +625,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { mViewMediator.registerCentralSurfaces(mCentralSurfaces, null, null, null, null, null); } private void captureKeyguardUpdateMonitorCallback() { verify(mUpdateMonitor).registerCallback(mKeyguardUpdateMonitorCallbackCaptor.capture()); } } Loading
packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +10 −2 Original line number Diff line number Diff line Loading @@ -726,6 +726,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 @@ -1949,8 +1956,9 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, * Enable the keyguard if the settings are appropriate. */ private void doKeyguardLocked(Bundle options) { // if another app is disabling us, don't show if (!mExternallyEnabled) { // if another app is disabling us, don't show unless we're in lockdown mode 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 +27 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardDisplayManager; import com.android.keyguard.KeyguardSecurityView; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.keyguard.mediator.ScreenOnCoordinator; import com.android.systemui.DejankUtils; import com.android.systemui.SysuiTestCase; Loading Loading @@ -98,6 +99,8 @@ import com.android.systemui.util.time.FakeSystemClock; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; Loading Loading @@ -141,6 +144,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { private @Mock AuthController mAuthController; private @Mock ShadeExpansionStateManager mShadeExpansionStateManager; private @Mock ShadeWindowLogger mShadeWindowLogger; private @Captor ArgumentCaptor<KeyguardUpdateMonitorCallback> mKeyguardUpdateMonitorCallbackCaptor; private DeviceConfigProxy mDeviceConfig = new DeviceConfigProxyFake(); private FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock()); Loading Loading @@ -178,6 +183,24 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { createAndStartViewMediator(); } @Test 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 public void testOnGoingToSleep_UpdatesKeyguardGoingAway() { mViewMediator.onStartedGoingToSleep(OFF_BECAUSE_OF_USER); Loading Loading @@ -602,4 +625,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { mViewMediator.registerCentralSurfaces(mCentralSurfaces, null, null, null, null, null); } private void captureKeyguardUpdateMonitorCallback() { verify(mUpdateMonitor).registerCallback(mKeyguardUpdateMonitorCallbackCaptor.capture()); } }