Loading packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java +4 −2 Original line number Original line Diff line number Diff line Loading @@ -1477,8 +1477,10 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene @Override @Override public boolean shouldShow() { public boolean shouldShow() { // Only show the lock button when the device can show a lock screen. // Only show the lock button when the device can show a lock screen and the device is return mKeyguardStateController.isMethodSecure(); // unlocked. return mKeyguardStateController.isMethodSecure() && mKeyguardStateController.isUnlocked(); } } } } Loading packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java +32 −1 Original line number Original line Diff line number Diff line Loading @@ -1006,6 +1006,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(true).when(mKeyguardStateController).isMethodSecure(); doReturn(true).when(mKeyguardStateController).isMethodSecure(); doReturn(true).when(mKeyguardStateController).isUnlocked(); doCallRealMethod() doCallRealMethod() .when(mGlobalActionsDialogLite) .when(mGlobalActionsDialogLite) .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); Loading Loading @@ -1036,6 +1037,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(true).when(mKeyguardStateController).isMethodSecure(); doReturn(true).when(mKeyguardStateController).isMethodSecure(); doReturn(true).when(mKeyguardStateController).isUnlocked(); doCallRealMethod() doCallRealMethod() .when(mGlobalActionsDialogLite) .when(mGlobalActionsDialogLite) .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); Loading Loading @@ -1063,6 +1065,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(true).when(mKeyguardStateController).isMethodSecure(); doReturn(true).when(mKeyguardStateController).isMethodSecure(); doReturn(true).when(mKeyguardStateController).isUnlocked(); doCallRealMethod() doCallRealMethod() .when(mGlobalActionsDialogLite) .when(mGlobalActionsDialogLite) .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); Loading Loading @@ -1090,6 +1093,35 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(false).when(mKeyguardStateController).isMethodSecure(); doReturn(false).when(mKeyguardStateController).isMethodSecure(); doReturn(true).when(mKeyguardStateController).isUnlocked(); doCallRealMethod() .when(mGlobalActionsDialogLite) .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); String[] actions = { GlobalActionsDialogLite.GLOBAL_ACTION_KEY_EMERGENCY, GlobalActionsDialogLite.GLOBAL_ACTION_KEY_LOCK, GlobalActionsDialogLite.GLOBAL_ACTION_KEY_POWER, GlobalActionsDialogLite.GLOBAL_ACTION_KEY_RESTART, }; doReturn(actions).when(mGlobalActionsDialogLite).getDefaultActions(); mGlobalActionsDialogLite.showOrHideDialog( /* keyguardShowing= */ false, /* isDeviceProvisioned= */ true, /* expandable= */ null, /* displayId= */ Display.DEFAULT_DISPLAY); assertNoItemsOfType(mGlobalActionsDialogLite.mItems, GlobalActionsDialogLite.LockAction.class); } @Test public void testCreateActionItems_deviceLocked_doesNotShowLock() { mGlobalActionsDialogLite = spy(mGlobalActionsDialogLite); doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(true).when(mKeyguardStateController).isMethodSecure(); doReturn(false).when(mKeyguardStateController).isUnlocked(); doCallRealMethod() doCallRealMethod() .when(mGlobalActionsDialogLite) .when(mGlobalActionsDialogLite) .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); Loading @@ -1113,6 +1145,5 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { private UserInfo mockCurrentUser(int flags) { private UserInfo mockCurrentUser(int flags) { return new UserInfo(10, "A User", flags); return new UserInfo(10, "A User", flags); } } } } Loading
packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java +4 −2 Original line number Original line Diff line number Diff line Loading @@ -1477,8 +1477,10 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene @Override @Override public boolean shouldShow() { public boolean shouldShow() { // Only show the lock button when the device can show a lock screen. // Only show the lock button when the device can show a lock screen and the device is return mKeyguardStateController.isMethodSecure(); // unlocked. return mKeyguardStateController.isMethodSecure() && mKeyguardStateController.isUnlocked(); } } } } Loading
packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java +32 −1 Original line number Original line Diff line number Diff line Loading @@ -1006,6 +1006,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(true).when(mKeyguardStateController).isMethodSecure(); doReturn(true).when(mKeyguardStateController).isMethodSecure(); doReturn(true).when(mKeyguardStateController).isUnlocked(); doCallRealMethod() doCallRealMethod() .when(mGlobalActionsDialogLite) .when(mGlobalActionsDialogLite) .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); Loading Loading @@ -1036,6 +1037,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(true).when(mKeyguardStateController).isMethodSecure(); doReturn(true).when(mKeyguardStateController).isMethodSecure(); doReturn(true).when(mKeyguardStateController).isUnlocked(); doCallRealMethod() doCallRealMethod() .when(mGlobalActionsDialogLite) .when(mGlobalActionsDialogLite) .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); Loading Loading @@ -1063,6 +1065,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(true).when(mKeyguardStateController).isMethodSecure(); doReturn(true).when(mKeyguardStateController).isMethodSecure(); doReturn(true).when(mKeyguardStateController).isUnlocked(); doCallRealMethod() doCallRealMethod() .when(mGlobalActionsDialogLite) .when(mGlobalActionsDialogLite) .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); Loading Loading @@ -1090,6 +1093,35 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(false).when(mKeyguardStateController).isMethodSecure(); doReturn(false).when(mKeyguardStateController).isMethodSecure(); doReturn(true).when(mKeyguardStateController).isUnlocked(); doCallRealMethod() .when(mGlobalActionsDialogLite) .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); String[] actions = { GlobalActionsDialogLite.GLOBAL_ACTION_KEY_EMERGENCY, GlobalActionsDialogLite.GLOBAL_ACTION_KEY_LOCK, GlobalActionsDialogLite.GLOBAL_ACTION_KEY_POWER, GlobalActionsDialogLite.GLOBAL_ACTION_KEY_RESTART, }; doReturn(actions).when(mGlobalActionsDialogLite).getDefaultActions(); mGlobalActionsDialogLite.showOrHideDialog( /* keyguardShowing= */ false, /* isDeviceProvisioned= */ true, /* expandable= */ null, /* displayId= */ Display.DEFAULT_DISPLAY); assertNoItemsOfType(mGlobalActionsDialogLite.mItems, GlobalActionsDialogLite.LockAction.class); } @Test public void testCreateActionItems_deviceLocked_doesNotShowLock() { mGlobalActionsDialogLite = spy(mGlobalActionsDialogLite); doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayEmergency(); doReturn(true).when(mKeyguardStateController).isMethodSecure(); doReturn(false).when(mKeyguardStateController).isUnlocked(); doCallRealMethod() doCallRealMethod() .when(mGlobalActionsDialogLite) .when(mGlobalActionsDialogLite) .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); .shouldShowAction(any(GlobalActionsDialogLite.LockAction.class)); Loading @@ -1113,6 +1145,5 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { private UserInfo mockCurrentUser(int flags) { private UserInfo mockCurrentUser(int flags) { return new UserInfo(10, "A User", flags); return new UserInfo(10, "A User", flags); } } } }