From 622def2335e5cb8ed1070720003c027ccfb07590 Mon Sep 17 00:00:00 2001 From: jovanak Date: Tue, 11 Jun 2019 11:51:54 -0700 Subject: [PATCH] Preventing keyguard dismissal when screen is off. For automotive, we dismiss keyguard to go straight to the home screen or the bouncer. However, when the screen is off, we want keyguard to remain to properly stop the applications. We dismiss keyguard when the screen comes back on. Fixes: 133324766 Bug: 133271311 Test: manual, turning screen on and off repeatedly, switching users while screen is off or on, reboots Change-Id: Iced146ad8753794bb766eb528dd198f886ccf3d7 --- .../systemui/statusbar/car/CarStatusBar.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java index 8373761962ac2..16b01252fb812 100644 --- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java +++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java @@ -63,6 +63,7 @@ import com.android.systemui.SystemUIFactory; import com.android.systemui.classifier.FalsingLog; import com.android.systemui.classifier.FalsingManagerFactory; import com.android.systemui.fragments.FragmentHostManager; +import com.android.systemui.keyguard.ScreenLifecycle; import com.android.systemui.plugins.qs.QS; import com.android.systemui.qs.car.CarQSFragment; import com.android.systemui.shared.system.ActivityManagerWrapper; @@ -127,6 +128,7 @@ public class CarStatusBar extends StatusBar implements private SwitchToGuestTimer mSwitchToGuestTimer; private NotificationDataManager mNotificationDataManager; private NotificationClickHandlerFactory mNotificationClickHandlerFactory; + private ScreenLifecycle mScreenLifecycle; // The container for the notifications. private CarNotificationView mNotificationView; @@ -230,6 +232,9 @@ public class CarStatusBar extends StatusBar implements mPowerManagerHelper.connectToCarService(); mSwitchToGuestTimer = new SwitchToGuestTimer(mContext); + + mScreenLifecycle = Dependency.get(ScreenLifecycle.class); + mScreenLifecycle.addObserver(mScreenObserver); } /** @@ -315,7 +320,6 @@ public class CarStatusBar extends StatusBar implements public void showKeyguard() { super.showKeyguard(); updateNavBarForKeyguardContent(); - dismissKeyguardWhenUserSwitcherNotDisplayed(); } /** @@ -978,6 +982,13 @@ public class CarStatusBar extends StatusBar implements } } + final ScreenLifecycle.Observer mScreenObserver = new ScreenLifecycle.Observer() { + @Override + public void onScreenTurnedOn() { + dismissKeyguardWhenUserSwitcherNotDisplayed(); + } + }; + // We automatically dismiss keyguard unless user switcher is being shown on the keyguard. private void dismissKeyguardWhenUserSwitcherNotDisplayed() { if (mFullscreenUserSwitcher == null) { @@ -1000,6 +1011,10 @@ public class CarStatusBar extends StatusBar implements * Dismisses the keyguard and shows bouncer if authentication is necessary. */ public void dismissKeyguard() { + // Don't dismiss keyguard when the screen is off. + if (mScreenLifecycle.getScreenState() == ScreenLifecycle.SCREEN_OFF) { + return; + } executeRunnableDismissingKeyguard(null/* runnable */, null /* cancelAction */, true /* dismissShade */, true /* afterKeyguardGone */, true /* deferred */); }