1 package com.android.launcher3.taskbar; 2 3 import static com.android.launcher3.AbstractFloatingView.TYPE_ALL; 4 import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_AWAKE; 5 import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BACK_DISABLED; 6 import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BOUNCER_SHOWING; 7 import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_DEVICE_DOZING; 8 import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING; 9 import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED; 10 import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_WAKEFULNESS_MASK; 11 import static com.android.systemui.shared.system.QuickStepContract.WAKEFULNESS_ASLEEP; 12 13 import android.app.KeyguardManager; 14 15 import com.android.launcher3.AbstractFloatingView; 16 import com.android.quickstep.util.SystemUiFlagUtils; 17 import com.android.systemui.shared.system.QuickStepContract; 18 import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags; 19 20 import java.io.PrintWriter; 21 22 /** 23 * Controller for managing keyguard state for taskbar 24 */ 25 public class TaskbarKeyguardController implements TaskbarControllers.LoggableTaskbarController { 26 27 private final TaskbarActivityContext mContext; 28 private long mKeyguardSysuiFlags; 29 private boolean mBouncerShowing; 30 private NavbarButtonsViewController mNavbarButtonsViewController; 31 private final KeyguardManager mKeyguardManager; 32 TaskbarKeyguardController(TaskbarActivityContext context)33 public TaskbarKeyguardController(TaskbarActivityContext context) { 34 mContext = context; 35 mKeyguardManager = mContext.getSystemService(KeyguardManager.class); 36 } 37 init(NavbarButtonsViewController navbarButtonUIController)38 public void init(NavbarButtonsViewController navbarButtonUIController) { 39 mNavbarButtonsViewController = navbarButtonUIController; 40 } 41 updateStateForSysuiFlags(@ystemUiStateFlags long systemUiStateFlags)42 public void updateStateForSysuiFlags(@SystemUiStateFlags long systemUiStateFlags) { 43 long interestingKeyguardFlags = systemUiStateFlags & SystemUiFlagUtils.KEYGUARD_SYSUI_FLAGS; 44 if (interestingKeyguardFlags == mKeyguardSysuiFlags) { 45 // No change in keyguard relevant flags 46 return; 47 } 48 mKeyguardSysuiFlags = interestingKeyguardFlags; 49 50 boolean bouncerShowing = (systemUiStateFlags & SYSUI_STATE_BOUNCER_SHOWING) != 0; 51 boolean keyguardShowing = (systemUiStateFlags & SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING) 52 != 0; 53 boolean keyguardOccluded = 54 (systemUiStateFlags & SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED) != 0; 55 boolean dozing = (systemUiStateFlags & SYSUI_STATE_DEVICE_DOZING) != 0; 56 57 58 mBouncerShowing = bouncerShowing; 59 60 mNavbarButtonsViewController.setKeyguardVisible(keyguardShowing || dozing, 61 keyguardOccluded); 62 updateIconsForBouncer(); 63 64 boolean asleepOrGoingToSleep = (systemUiStateFlags & SYSUI_STATE_AWAKE) == 0; 65 boolean closeFloatingViews = keyguardShowing || asleepOrGoingToSleep; 66 67 if (closeFloatingViews) { 68 // animate the closing of the views, unless the screen is already asleep. 69 boolean animateViewClosing = 70 (systemUiStateFlags & SYSUI_STATE_WAKEFULNESS_MASK) != WAKEFULNESS_ASLEEP; 71 AbstractFloatingView.closeOpenViews(mContext, animateViewClosing, TYPE_ALL); 72 } 73 } 74 75 /** 76 * Hides/shows taskbar when keyguard is up 77 */ updateIconsForBouncer()78 private void updateIconsForBouncer() { 79 boolean disableBack = (mKeyguardSysuiFlags & SYSUI_STATE_BACK_DISABLED) != 0; 80 boolean showBackForBouncer = 81 !disableBack && mKeyguardManager.isDeviceSecure() && mBouncerShowing; 82 mNavbarButtonsViewController.setBackForBouncer(showBackForBouncer); 83 } 84 85 86 @Override dumpLogs(String prefix, PrintWriter pw)87 public void dumpLogs(String prefix, PrintWriter pw) { 88 pw.println(prefix + "TaskbarKeyguardController:"); 89 90 pw.println(prefix + "\tmKeyguardSysuiFlags=" + QuickStepContract.getSystemUiStateString( 91 mKeyguardSysuiFlags)); 92 pw.println(prefix + "\tmBouncerShowing=" + mBouncerShowing); 93 } 94 } 95