Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 622def23 authored by jovanak's avatar jovanak Committed by Jovana Knezevic
Browse files

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
parent 0c7bac87
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -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 */);
    }