2021-06-04 15:35:46 -07:00
|
|
|
package com.android.launcher3.taskbar;
|
|
|
|
|
|
2022-03-07 18:05:55 -08:00
|
|
|
import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
|
2023-03-28 16:08:57 +02:00
|
|
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_AWAKE;
|
2021-08-16 20:01:45 -07:00
|
|
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BACK_DISABLED;
|
2021-06-04 15:35:46 -07:00
|
|
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BOUNCER_SHOWING;
|
|
|
|
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_DEVICE_DOZING;
|
2023-03-22 14:26:25 +01:00
|
|
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_DEVICE_DREAMING;
|
2021-08-16 20:01:45 -07:00
|
|
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_HOME_DISABLED;
|
|
|
|
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED;
|
2021-06-04 15:35:46 -07:00
|
|
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING;
|
2021-09-23 15:32:38 -07:00
|
|
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED;
|
2023-03-28 16:08:57 +02:00
|
|
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_WAKEFULNESS_MASK;
|
|
|
|
|
import static com.android.systemui.shared.system.QuickStepContract.WAKEFULNESS_ASLEEP;
|
2021-06-04 15:35:46 -07:00
|
|
|
|
|
|
|
|
import android.app.KeyguardManager;
|
|
|
|
|
|
2022-03-07 18:05:55 -08:00
|
|
|
import com.android.launcher3.AbstractFloatingView;
|
2021-12-15 13:09:39 -08:00
|
|
|
import com.android.systemui.shared.system.QuickStepContract;
|
|
|
|
|
|
|
|
|
|
import java.io.PrintWriter;
|
|
|
|
|
|
2021-06-04 15:35:46 -07:00
|
|
|
/**
|
|
|
|
|
* Controller for managing keyguard state for taskbar
|
|
|
|
|
*/
|
2021-12-15 13:09:39 -08:00
|
|
|
public class TaskbarKeyguardController implements TaskbarControllers.LoggableTaskbarController {
|
2021-06-04 15:35:46 -07:00
|
|
|
|
2023-03-02 15:39:33 +01:00
|
|
|
private static final int KEYGUARD_SYSUI_FLAGS = SYSUI_STATE_BOUNCER_SHOWING
|
|
|
|
|
| SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING | SYSUI_STATE_DEVICE_DOZING
|
|
|
|
|
| SYSUI_STATE_OVERVIEW_DISABLED | SYSUI_STATE_HOME_DISABLED
|
|
|
|
|
| SYSUI_STATE_BACK_DISABLED | SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED
|
2023-03-28 16:08:57 +02:00
|
|
|
| SYSUI_STATE_WAKEFULNESS_MASK;
|
2021-06-04 15:35:46 -07:00
|
|
|
|
2023-03-17 14:46:29 +01:00
|
|
|
// If any of these SysUi flags (via QuickstepContract) is set, the device to be considered
|
|
|
|
|
// locked.
|
|
|
|
|
public static final int MASK_ANY_SYSUI_LOCKED = SYSUI_STATE_BOUNCER_SHOWING
|
|
|
|
|
| SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING
|
2023-03-22 14:26:25 +01:00
|
|
|
| SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED
|
|
|
|
|
| SYSUI_STATE_DEVICE_DREAMING;
|
2023-03-17 14:46:29 +01:00
|
|
|
|
2021-06-04 15:35:46 -07:00
|
|
|
private final TaskbarActivityContext mContext;
|
|
|
|
|
private int mKeyguardSysuiFlags;
|
|
|
|
|
private boolean mBouncerShowing;
|
|
|
|
|
private NavbarButtonsViewController mNavbarButtonsViewController;
|
|
|
|
|
private final KeyguardManager mKeyguardManager;
|
|
|
|
|
|
|
|
|
|
public TaskbarKeyguardController(TaskbarActivityContext context) {
|
|
|
|
|
mContext = context;
|
|
|
|
|
mKeyguardManager = mContext.getSystemService(KeyguardManager.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void init(NavbarButtonsViewController navbarButtonUIController) {
|
|
|
|
|
mNavbarButtonsViewController = navbarButtonUIController;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateStateForSysuiFlags(int systemUiStateFlags) {
|
2023-03-02 15:39:33 +01:00
|
|
|
int interestingKeyguardFlags = systemUiStateFlags & KEYGUARD_SYSUI_FLAGS;
|
|
|
|
|
if (interestingKeyguardFlags == mKeyguardSysuiFlags) {
|
|
|
|
|
// No change in keyguard relevant flags
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
mKeyguardSysuiFlags = interestingKeyguardFlags;
|
|
|
|
|
|
2021-06-04 15:35:46 -07:00
|
|
|
boolean bouncerShowing = (systemUiStateFlags & SYSUI_STATE_BOUNCER_SHOWING) != 0;
|
|
|
|
|
boolean keyguardShowing = (systemUiStateFlags & SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING)
|
|
|
|
|
!= 0;
|
2021-09-23 15:32:38 -07:00
|
|
|
boolean keyguardOccluded =
|
|
|
|
|
(systemUiStateFlags & SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED) != 0;
|
2021-06-04 15:35:46 -07:00
|
|
|
boolean dozing = (systemUiStateFlags & SYSUI_STATE_DEVICE_DOZING) != 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mBouncerShowing = bouncerShowing;
|
|
|
|
|
|
2021-09-23 15:32:38 -07:00
|
|
|
mNavbarButtonsViewController.setKeyguardVisible(keyguardShowing || dozing,
|
|
|
|
|
keyguardOccluded);
|
2021-06-04 15:35:46 -07:00
|
|
|
updateIconsForBouncer();
|
2022-03-07 18:05:55 -08:00
|
|
|
|
2023-03-28 16:08:57 +02:00
|
|
|
boolean asleepOrGoingToSleep = (systemUiStateFlags & SYSUI_STATE_AWAKE) == 0;
|
|
|
|
|
boolean closeFloatingViews = keyguardShowing || asleepOrGoingToSleep;
|
2021-06-04 15:35:46 -07:00
|
|
|
|
2023-03-02 15:39:33 +01:00
|
|
|
if (closeFloatingViews) {
|
2023-03-28 16:08:57 +02:00
|
|
|
// animate the closing of the views, unless the screen is already asleep.
|
2023-03-02 15:39:33 +01:00
|
|
|
boolean animateViewClosing =
|
2023-03-28 16:08:57 +02:00
|
|
|
(systemUiStateFlags & SYSUI_STATE_WAKEFULNESS_MASK) != WAKEFULNESS_ASLEEP;
|
2023-03-02 15:39:33 +01:00
|
|
|
AbstractFloatingView.closeOpenViews(mContext, animateViewClosing, TYPE_ALL);
|
|
|
|
|
}
|
2021-06-04 15:35:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Hides/shows taskbar when keyguard is up
|
|
|
|
|
*/
|
|
|
|
|
private void updateIconsForBouncer() {
|
2021-08-16 20:01:45 -07:00
|
|
|
boolean disableBack = (mKeyguardSysuiFlags & SYSUI_STATE_BACK_DISABLED) != 0;
|
2023-01-30 17:25:32 +00:00
|
|
|
boolean showBackForBouncer =
|
|
|
|
|
!disableBack && mKeyguardManager.isDeviceSecure() && mBouncerShowing;
|
2021-06-04 15:35:46 -07:00
|
|
|
mNavbarButtonsViewController.setBackForBouncer(showBackForBouncer);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-15 13:09:39 -08:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void dumpLogs(String prefix, PrintWriter pw) {
|
|
|
|
|
pw.println(prefix + "TaskbarKeyguardController:");
|
|
|
|
|
|
2022-06-23 11:25:10 -07:00
|
|
|
pw.println(prefix + "\tmKeyguardSysuiFlags=" + QuickStepContract.getSystemUiStateString(
|
|
|
|
|
mKeyguardSysuiFlags));
|
|
|
|
|
pw.println(prefix + "\tmBouncerShowing=" + mBouncerShowing);
|
2021-12-15 13:09:39 -08:00
|
|
|
}
|
2021-06-04 15:35:46 -07:00
|
|
|
}
|