Snap for 7901677 from 81ffde49221b48cc89c0ce5bf205f421f0ed962a to sc-platform-release
Change-Id: Ia143ac67bd360d9e4e64febd3a741a3b18dc9685
diff --git a/src/com/android/systemui/car/keyguard/CarKeyguardViewController.java b/src/com/android/systemui/car/keyguard/CarKeyguardViewController.java
index 728e7d7..36f657b 100644
--- a/src/com/android/systemui/car/keyguard/CarKeyguardViewController.java
+++ b/src/com/android/systemui/car/keyguard/CarKeyguardViewController.java
@@ -87,6 +87,7 @@
private OnKeyguardCancelClickedListener mKeyguardCancelClickedListener;
private boolean mShowing;
private boolean mIsOccluded;
+ private boolean mIsSleeping;
@Inject
public CarKeyguardViewController(
@@ -155,7 +156,7 @@
@Override
public void hide(long startTime, long fadeoutDuration) {
- if (!mShowing) return;
+ if (!mShowing || mIsSleeping) return;
mViewMediatorCallback.readyForKeyguardDone();
mShowing = false;
@@ -170,6 +171,8 @@
@Override
public void reset(boolean hideBouncerWhenShowing) {
+ if (mIsSleeping) return;
+
mMainExecutor.execute(() -> {
if (mShowing) {
if (mBouncer != null) {
@@ -251,6 +254,17 @@
getOverlayViewGlobalStateController().setWindowNeedsInput(needsInput);
}
+ @Override
+ public void onStartedGoingToSleep() {
+ mIsSleeping = true;
+ }
+
+ @Override
+ public void onStartedWakingUp() {
+ mIsSleeping = false;
+ reset(/* hideBouncerWhenShowing= */ false);
+ }
+
/**
* Add listener for keyguard cancel clicked.
*/
@@ -293,16 +307,6 @@
}
@Override
- public void onStartedGoingToSleep() {
- // no-op
- }
-
- @Override
- public void onStartedWakingUp() {
- // no-op
- }
-
- @Override
public void onScreenTurningOn() {
// no-op
}
diff --git a/tests/src/com/android/systemui/car/keyguard/CarKeyguardViewControllerTest.java b/tests/src/com/android/systemui/car/keyguard/CarKeyguardViewControllerTest.java
index f8a5205..2d627f9 100644
--- a/tests/src/com/android/systemui/car/keyguard/CarKeyguardViewControllerTest.java
+++ b/tests/src/com/android/systemui/car/keyguard/CarKeyguardViewControllerTest.java
@@ -26,7 +26,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.os.Handler;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.LayoutInflater;
@@ -194,6 +193,39 @@
}
@Test
+ public void onEnterSleepModeAndThenShowKeyguard_bouncerNotSecure_keyguardIsVisible() {
+ when(mBouncer.isSecure()).thenReturn(false);
+ mCarKeyguardViewController.onStartedGoingToSleep();
+ mCarKeyguardViewController.show(/* options= */ null);
+ waitForDelayableExecutor();
+
+ // We want to make sure that showView is called beforehand and hideView is never called
+ // so that the Keyguard is visible as a result.
+ InOrder inOrder = inOrder(mOverlayViewGlobalStateController);
+ inOrder.verify(mOverlayViewGlobalStateController).showView(eq(mCarKeyguardViewController),
+ any());
+ inOrder.verify(mOverlayViewGlobalStateController, never()).hideView(
+ eq(mCarKeyguardViewController), any());
+ }
+
+ @Test
+ public void onDeviceWakeUpWhileKeyguardShown_bouncerNotSecure_keyguardIsNotVisible() {
+ when(mBouncer.isSecure()).thenReturn(false);
+ mCarKeyguardViewController.onStartedGoingToSleep();
+ mCarKeyguardViewController.show(/* options= */ null);
+ mCarKeyguardViewController.onStartedWakingUp();
+ waitForDelayableExecutor();
+
+ // We want to make sure that showView is called beforehand and then hideView is called so
+ // that the Keyguard is invisible as a result.
+ InOrder inOrder = inOrder(mOverlayViewGlobalStateController);
+ inOrder.verify(mOverlayViewGlobalStateController).showView(eq(mCarKeyguardViewController),
+ any());
+ inOrder.verify(mOverlayViewGlobalStateController).hideView(eq(mCarKeyguardViewController),
+ any());
+ }
+
+ @Test
public void onCancelClicked_hidesBouncerAndDestroysTheView() {
when(mBouncer.isSecure()).thenReturn(true);
mCarKeyguardViewController.show(/* options= */ null);