From a3bcac58cf1c5ddeca0addc1edfba0412da4768a Mon Sep 17 00:00:00 2001 From: Caitlin Cassidy Date: Fri, 25 Feb 2022 16:17:55 +0000 Subject: [Status Bar] Re-name StatusBar.java -> CentralSurfaces.java. Also add some javadoc to CentralSurfaces.java to make its purpose slightly clearer. Bug: 197137564 Test: compiles Test: atest SystemUITests Change-Id: Id06e7ba7641d6d2bc276cce57101c9c7236bc758 Merged-In: Id06e7ba7641d6d2bc276cce57101c9c7236bc758 --- packages/SystemUI/AndroidManifest.xml | 2 +- packages/SystemUI/proguard.flags | 2 +- .../android/keyguard/KeyguardViewController.java | 6 +- .../android/keyguard/LockIconViewController.java | 4 +- .../keyguard/dagger/KeyguardBouncerScope.java | 2 +- .../dagger/KeyguardStatusBarViewScope.java | 2 +- .../keyguard/dagger/KeyguardStatusViewScope.java | 2 +- .../android/systemui/ActivityStarterDelegate.java | 10 +- .../systemui/accessibility/SystemActions.java | 25 +- .../android/systemui/assist/PhoneStateMonitor.java | 12 +- .../systemui/biometrics/AuthRippleController.kt | 18 +- .../android/systemui/dagger/SystemUIBinder.java | 4 +- .../systemui/dagger/SystemUIDefaultModule.java | 4 +- .../android/systemui/dagger/SystemUIModule.java | 8 +- .../dreams/touch/BouncerSwipeTouchHandler.java | 17 +- .../globalactions/GlobalActionsComponent.java | 2 +- .../globalactions/GlobalActionsDialogLite.java | 45 +- .../systemui/keyguard/KeyguardViewMediator.java | 12 +- .../systemui/keyguard/dagger/KeyguardModule.java | 4 +- .../systemui/navigationbar/NavBarHelper.java | 13 +- .../systemui/navigationbar/NavigationBar.java | 40 +- .../systemui/navigationbar/NavigationBarView.java | 4 +- .../src/com/android/systemui/power/PowerUI.java | 14 +- .../src/com/android/systemui/qs/QSTileHost.java | 14 +- .../systemui/recents/OverviewProxyRecentsImpl.java | 15 +- .../systemui/recents/OverviewProxyService.java | 26 +- .../systemui/recents/ScreenPinningRequest.java | 15 +- .../systemui/screenshot/ActionProxyReceiver.java | 14 +- .../settings/brightness/BrightnessController.java | 2 +- .../android/systemui/statusbar/CommandQueue.java | 2 +- .../LockscreenShadeTransitionController.kt | 14 +- .../systemui/statusbar/NotificationListener.java | 8 +- .../statusbar/NotificationMediaManager.java | 23 +- .../systemui/statusbar/NotificationPresenter.java | 2 +- .../statusbar/NotificationRemoteInputManager.java | 16 +- .../NotificationViewHierarchyManager.java | 4 +- .../statusbar/QsFrameTranslateController.java | 8 +- .../systemui/statusbar/QsFrameTranslateImpl.java | 6 +- .../systemui/statusbar/SmartReplyController.java | 4 +- .../statusbar/StatusBarStateControllerImpl.java | 5 +- .../statusbar/SysuiStatusBarStateController.java | 11 +- .../connectivity/MobileSignalController.java | 2 +- .../statusbar/core/StatusBarInitializer.kt | 14 +- .../dagger/CentralSurfacesDependenciesModule.java | 322 ++ .../statusbar/dagger/CentralSurfacesModule.java | 29 + .../statusbar/dagger/StartCentralSurfacesModule.kt | 33 + .../statusbar/dagger/StartStatusBarModule.kt | 33 - .../dagger/StatusBarDependenciesModule.java | 321 -- .../systemui/statusbar/dagger/StatusBarModule.java | 29 - .../notification/NotificationClicker.java | 14 +- .../notification/NotificationEntryManager.java | 2 +- .../NotificationLaunchAnimatorController.kt | 4 +- .../notification/collection/TargetSdkResolver.kt | 4 +- .../LegacyNotificationPresenterExtensions.java | 2 +- .../collection/render/NotifPanelEventSource.kt | 16 +- .../notification/dagger/NotificationsModule.java | 6 +- .../init/NotificationsControllerImpl.kt | 6 +- .../notification/logging/NotificationLogger.java | 2 +- .../row/ExpandableNotificationRow.java | 4 +- .../row/NotificationContentInflater.java | 4 +- .../notification/row/NotificationGutsManager.java | 25 +- .../dagger/ExpandableNotificationRowComponent.java | 4 +- .../row/dagger/NotificationRowScope.java | 2 +- .../stack/NotificationStackScrollLayout.java | 12 +- .../NotificationStackScrollLayoutController.java | 26 +- ...cationStackScrollLayoutListContainerModule.java | 4 +- .../statusbar/phone/BiometricUnlockController.java | 2 +- .../systemui/statusbar/phone/CentralSurfaces.java | 4455 ++++++++++++++++++++ .../CentralSurfacesCommandQueueCallbacks.java | 593 +++ .../systemui/statusbar/phone/DozeServiceHost.java | 22 +- .../statusbar/phone/KeyguardBottomAreaView.java | 15 +- .../statusbar/phone/KeyguardEnvironmentImpl.java | 4 +- .../phone/NotificationPanelViewController.java | 78 +- .../NotificationShadeWindowControllerImpl.java | 2 +- .../phone/NotificationShadeWindowView.java | 2 +- .../NotificationShadeWindowViewController.java | 10 +- .../systemui/statusbar/phone/PanelView.java | 2 +- .../statusbar/phone/PanelViewController.java | 35 +- .../phone/ScreenOffAnimationController.kt | 8 +- .../systemui/statusbar/phone/ScrimController.java | 4 +- .../systemui/statusbar/phone/ScrimState.java | 2 +- .../systemui/statusbar/phone/ShadeController.java | 8 +- .../statusbar/phone/ShadeControllerImpl.java | 34 +- .../statusbar/phone/SplitShadeHeaderController.kt | 4 +- .../systemui/statusbar/phone/StatusBar.java | 4439 ------------------- .../phone/StatusBarCommandQueueCallbacks.java | 591 --- .../phone/StatusBarHeadsUpChangeListener.java | 8 +- .../phone/StatusBarIconControllerImpl.java | 4 +- .../phone/StatusBarKeyguardViewManager.java | 98 +- .../phone/StatusBarLaunchAnimatorController.kt | 18 +- .../StatusBarNotificationActivityStarter.java | 38 +- .../phone/StatusBarNotificationPresenter.java | 27 +- .../statusbar/phone/StatusBarSignalPolicy.java | 4 +- .../phone/StatusBarTouchableRegionManager.java | 8 +- .../statusbar/phone/TapAgainViewController.java | 4 +- .../phone/UnlockedScreenOffAnimationController.kt | 34 +- .../phone/dagger/CentralSurfacesComponent.java | 165 + .../statusbar/phone/dagger/StatusBarComponent.java | 166 - .../phone/dagger/StatusBarPhoneModule.java | 12 +- .../phone/dagger/StatusBarViewModule.java | 34 +- .../dagger/StatusBarFragmentComponent.java | 8 +- .../window/StatusBarWindowStateController.kt | 6 +- .../systemui/unfold/FoldAodAnimationController.kt | 20 +- .../biometrics/AuthRippleControllerTest.kt | 8 +- .../systemui/biometrics/UdfpsControllerTest.java | 4 +- .../dreams/touch/BouncerSwipeTouchHandlerTest.java | 8 +- .../globalactions/GlobalActionsDialogLiteTest.java | 16 +- .../systemui/navigationbar/NavBarHelperTest.java | 5 +- .../systemui/navigationbar/NavigationBarTest.java | 14 +- .../com/android/systemui/power/PowerUITest.java | 10 +- .../com/android/systemui/qs/QSFragmentTest.java | 4 +- .../com/android/systemui/qs/QSTileHostTest.java | 14 +- .../systemui/qs/external/TileServicesTest.java | 6 +- .../screenshot/ActionProxyReceiverTest.java | 14 +- .../LockscreenShadeTransitionControllerTest.kt | 14 +- .../systemui/statusbar/NonPhoneDependencyTest.java | 4 +- .../NotificationRemoteInputManagerTest.java | 8 +- .../statusbar/SmartReplyControllerTest.java | 4 +- .../row/NotificationGutsManagerTest.java | 6 +- ...otificationStackScrollLayoutControllerTest.java | 6 +- .../stack/NotificationStackScrollLayoutTest.java | 8 +- .../CentralSurfacesCommandQueueCallbacksTest.java | 172 + .../statusbar/phone/CentralSurfacesTest.java | 1001 +++++ .../statusbar/phone/DozeServiceHostTest.java | 16 +- .../statusbar/phone/HeadsUpManagerPhoneTest.java | 1 - .../statusbar/phone/KeyguardBottomAreaTest.kt | 4 +- .../phone/NotificationPanelViewControllerTest.java | 4 +- .../NotificationShadeWindowViewControllerTest.kt | 4 +- .../phone/NotificationShadeWindowViewTest.java | 4 +- .../phone/StatusBarCommandQueueCallbacksTest.java | 171 - .../phone/StatusBarKeyguardViewManagerTest.java | 20 +- .../StatusBarNotificationActivityStarterTest.java | 12 +- .../phone/StatusBarNotificationPresenterTest.java | 8 +- .../systemui/statusbar/phone/StatusBarTest.java | 1001 ----- .../UnlockedScreenOffAnimationControllerTest.kt | 6 +- .../com/android/systemui/wmshell/BubblesTest.java | 2 +- 136 files changed, 7472 insertions(+), 7432 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesDependenciesModule.java create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesModule.java create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/dagger/StartCentralSurfacesModule.kt delete mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/dagger/StartStatusBarModule.kt delete mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarDependenciesModule.java delete mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarModule.java create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java delete mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java delete mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarCommandQueueCallbacks.java create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/CentralSurfacesComponent.java delete mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java create mode 100644 packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java create mode 100644 packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesTest.java delete mode 100644 packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarCommandQueueCallbacksTest.java delete mode 100644 packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java (limited to 'packages/SystemUI') diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 4b1d00bb18e3..7f8b2f51754c 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -154,7 +154,7 @@ - + diff --git a/packages/SystemUI/proguard.flags b/packages/SystemUI/proguard.flags index 6352f81b4474..c97ebe8d5559 100644 --- a/packages/SystemUI/proguard.flags +++ b/packages/SystemUI/proguard.flags @@ -3,7 +3,7 @@ -keep class com.android.systemui.recents.OverviewProxyRecentsImpl -keep class com.android.systemui.statusbar.car.CarStatusBar --keep class com.android.systemui.statusbar.phone.StatusBar +-keep class com.android.systemui.statusbar.phone.CentralSurfaces -keep class com.android.systemui.statusbar.tv.TvStatusBar -keep class com.android.systemui.car.CarSystemUIFactory -keep class com.android.systemui.SystemUIFactory diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardViewController.java index 122f3d7f23f1..295d77d55b56 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardViewController.java @@ -24,9 +24,9 @@ import androidx.annotation.Nullable; import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.statusbar.phone.BiometricUnlockController; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.NotificationPanelViewController; -import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager; /** @@ -176,9 +176,9 @@ public interface KeyguardViewController { // achieving complete abstraction away from where the Keyguard View is mounted. /** - * Registers the StatusBar to which this Keyguard View is mounted. + * Registers the CentralSurfaces to which this Keyguard View is mounted. */ - void registerStatusBar(StatusBar statusBar, + void registerCentralSurfaces(CentralSurfaces centralSurfaces, NotificationPanelViewController notificationPanelViewController, @Nullable PanelExpansionStateManager panelExpansionStateManager, BiometricUnlockController biometricUnlockController, diff --git a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java index 4ad51835687f..370686a1e682 100644 --- a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java @@ -60,7 +60,7 @@ import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.VibratorHelper; -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.util.ViewController; @@ -78,7 +78,7 @@ import javax.inject.Inject; * For devices with UDFPS, the lock icon will show at the sensor location. Else, the lock * icon will show a set distance from the bottom of the device. */ -@StatusBarComponent.StatusBarScope +@CentralSurfacesComponent.CentralSurfacesScope public class LockIconViewController extends ViewController implements Dumpable { private static final String TAG = "LockIconViewController"; private static final float sDefaultDensity = diff --git a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardBouncerScope.java b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardBouncerScope.java index 207ac2852f2f..8dbe5e00ab7e 100644 --- a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardBouncerScope.java +++ b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardBouncerScope.java @@ -24,7 +24,7 @@ import java.lang.annotation.Retention; import javax.inject.Scope; /** - * Scope annotation for singleton items within the StatusBarComponent. + * Scope annotation for singleton items within the CentralSurfacesComponent. */ @Documented @Retention(RUNTIME) diff --git a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusBarViewScope.java b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusBarViewScope.java index ba0642f57a88..f498ef3466ef 100644 --- a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusBarViewScope.java +++ b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusBarViewScope.java @@ -24,7 +24,7 @@ import java.lang.annotation.Retention; import javax.inject.Scope; /** - * Scope annotation for singleton items within the StatusBarComponent. + * Scope annotation for singleton items within the CentralSurfacesComponent. */ @Documented @Retention(RUNTIME) diff --git a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewScope.java b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewScope.java index 880822aa7343..aeae8e3d4b27 100644 --- a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewScope.java +++ b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewScope.java @@ -24,7 +24,7 @@ import java.lang.annotation.Retention; import javax.inject.Scope; /** - * Scope annotation for singleton items within the StatusBarComponent. + * Scope annotation for singleton items within the CentralSurfacesComponent. */ @Documented @Retention(RUNTIME) diff --git a/packages/SystemUI/src/com/android/systemui/ActivityStarterDelegate.java b/packages/SystemUI/src/com/android/systemui/ActivityStarterDelegate.java index cc166c210078..5bd620e873b0 100644 --- a/packages/SystemUI/src/com/android/systemui/ActivityStarterDelegate.java +++ b/packages/SystemUI/src/com/android/systemui/ActivityStarterDelegate.java @@ -23,7 +23,7 @@ import androidx.annotation.Nullable; import com.android.systemui.animation.ActivityLaunchAnimator; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.plugins.ActivityStarter; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import java.util.Optional; @@ -33,17 +33,17 @@ import dagger.Lazy; /** * Single common instance of ActivityStarter that can be gotten and referenced from anywhere, but - * delegates to an actual implementation (StatusBar). + * delegates to an actual implementation (CentralSurfaces). */ @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @SysUISingleton public class ActivityStarterDelegate implements ActivityStarter { - private Lazy> mActualStarterOptionalLazy; + private Lazy> mActualStarterOptionalLazy; @Inject - public ActivityStarterDelegate(Lazy> statusBarOptionalLazy) { - mActualStarterOptionalLazy = statusBarOptionalLazy; + public ActivityStarterDelegate(Lazy> centralSurfacesOptionalLazy) { + mActualStarterOptionalLazy = centralSurfacesOptionalLazy; } @Override diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java b/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java index 881e6a917a45..bd8e44ceab80 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java @@ -54,7 +54,7 @@ import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.recents.Recents; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.NotificationShadeWindowController; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.StatusBarWindowCallback; import com.android.systemui.util.Assert; @@ -180,7 +180,7 @@ public class SystemActions extends CoreStartable { private final Optional mRecentsOptional; private Locale mLocale; private final AccessibilityManager mA11yManager; - private final Lazy> mStatusBarOptionalLazy; + private final Lazy> mCentralSurfacesOptionalLazy; private final NotificationShadeWindowController mNotificationShadeController; private final StatusBarWindowCallback mNotificationShadeCallback; private boolean mDismissNotificationShadeActionRegistered; @@ -188,7 +188,7 @@ public class SystemActions extends CoreStartable { @Inject public SystemActions(Context context, NotificationShadeWindowController notificationShadeController, - Lazy> statusBarOptionalLazy, + Lazy> centralSurfacesOptionalLazy, Optional recentsOptional) { super(context); mRecentsOptional = recentsOptional; @@ -201,7 +201,7 @@ public class SystemActions extends CoreStartable { // NotificationShadeWindowController.registerCallback() only keeps weak references. mNotificationShadeCallback = (keyguardShowing, keyguardOccluded, bouncerShowing, mDozing) -> registerOrUnregisterDismissNotificationShadeAction(); - mStatusBarOptionalLazy = statusBarOptionalLazy; + mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy; } @Override @@ -311,9 +311,10 @@ public class SystemActions extends CoreStartable { // Saving state in instance variable since this callback is called quite often to avoid // binder calls - final Optional statusBarOptional = mStatusBarOptionalLazy.get(); - if (statusBarOptional.map(StatusBar::isPanelExpanded).orElse(false) - && !statusBarOptional.get().isKeyguardShowing()) { + final Optional centralSurfacesOptional = + mCentralSurfacesOptionalLazy.get(); + if (centralSurfacesOptional.map(CentralSurfaces::isPanelExpanded).orElse(false) + && !centralSurfacesOptional.get().isKeyguardShowing()) { if (!mDismissNotificationShadeActionRegistered) { mA11yManager.registerSystemAction( createRemoteAction( @@ -466,12 +467,12 @@ public class SystemActions extends CoreStartable { } private void handleNotifications() { - mStatusBarOptionalLazy.get().ifPresent(StatusBar::animateExpandNotificationsPanel); + mCentralSurfacesOptionalLazy.get().ifPresent(CentralSurfaces::animateExpandNotificationsPanel); } private void handleQuickSettings() { - mStatusBarOptionalLazy.get().ifPresent( - statusBar -> statusBar.animateExpandSettingsPanel(null)); + mCentralSurfacesOptionalLazy.get().ifPresent( + centralSurfaces -> centralSurfaces.animateExpandSettingsPanel(null)); } private void handlePowerDialog() { @@ -524,8 +525,8 @@ public class SystemActions extends CoreStartable { } private void handleAccessibilityDismissNotificationShade() { - mStatusBarOptionalLazy.get().ifPresent( - statusBar -> statusBar.animateCollapsePanels( + mCentralSurfacesOptionalLazy.get().ifPresent( + centralSurfaces -> centralSurfaces.animateCollapsePanels( CommandQueue.FLAG_EXCLUDE_NONE, false /* force */)); } diff --git a/packages/SystemUI/src/com/android/systemui/assist/PhoneStateMonitor.java b/packages/SystemUI/src/com/android/systemui/assist/PhoneStateMonitor.java index aedaf968ac7d..dfff00b90ef2 100644 --- a/packages/SystemUI/src/com/android/systemui/assist/PhoneStateMonitor.java +++ b/packages/SystemUI/src/com/android/systemui/assist/PhoneStateMonitor.java @@ -36,7 +36,7 @@ import com.android.systemui.shared.system.PackageManagerWrapper; import com.android.systemui.shared.system.TaskStackChangeListener; import com.android.systemui.shared.system.TaskStackChangeListeners; import com.android.systemui.statusbar.StatusBarState; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import java.util.ArrayList; import java.util.List; @@ -69,7 +69,7 @@ public final class PhoneStateMonitor { }; private final Context mContext; - private final Lazy> mStatusBarOptionalLazy; + private final Lazy> mCentralSurfacesOptionalLazy; private final StatusBarStateController mStatusBarStateController; private boolean mLauncherShowing; @@ -77,10 +77,11 @@ public final class PhoneStateMonitor { @Inject PhoneStateMonitor(Context context, BroadcastDispatcher broadcastDispatcher, - Lazy> statusBarOptionalLazy, BootCompleteCache bootCompleteCache, + Lazy> centralSurfacesOptionalLazy, + BootCompleteCache bootCompleteCache, StatusBarStateController statusBarStateController) { mContext = context; - mStatusBarOptionalLazy = statusBarOptionalLazy; + mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy; mStatusBarStateController = statusBarStateController; mDefaultHome = getCurrentDefaultHome(); @@ -180,7 +181,8 @@ public final class PhoneStateMonitor { } private boolean isBouncerShowing() { - return mStatusBarOptionalLazy.get().map(StatusBar::isBouncerShowing).orElse(false); + return mCentralSurfacesOptionalLazy.get() + .map(CentralSurfaces::isBouncerShowing).orElse(false); } private boolean isKeyguardLocked() { diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt index f82ea790bb64..99f27d7f48e7 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt @@ -40,8 +40,8 @@ import com.android.systemui.statusbar.commandline.Command import com.android.systemui.statusbar.commandline.CommandRegistry import com.android.systemui.statusbar.phone.BiometricUnlockController import com.android.systemui.statusbar.phone.KeyguardBypassController -import com.android.systemui.statusbar.phone.StatusBar -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent.StatusBarScope +import com.android.systemui.statusbar.phone.CentralSurfaces +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent.CentralSurfacesScope import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.ViewController @@ -54,9 +54,9 @@ import javax.inject.Provider * Controls the ripple effect that shows when authentication is successful. * The ripple uses the accent color of the current theme. */ -@StatusBarScope +@CentralSurfacesScope class AuthRippleController @Inject constructor( - private val statusBar: StatusBar, + private val centralSurfaces: CentralSurfaces, private val sysuiContext: Context, private val authController: AuthController, private val configurationController: ConfigurationController, @@ -137,7 +137,7 @@ class AuthRippleController @Inject constructor( private fun showUnlockedRipple() { notificationShadeWindowController.setForcePluginOpen(true, this) - val lightRevealScrim = statusBar.lightRevealScrim + val lightRevealScrim = centralSurfaces.lightRevealScrim if (statusBarStateController.isDozing || biometricUnlockController.isWakeAndUnlock) { circleReveal?.let { lightRevealScrim?.revealEffect = it @@ -155,7 +155,7 @@ class AuthRippleController @Inject constructor( override fun onKeyguardFadingAwayChanged() { if (keyguardStateController.isKeyguardFadingAway) { - val lightRevealScrim = statusBar.lightRevealScrim + val lightRevealScrim = centralSurfaces.lightRevealScrim if (startLightRevealScrimOnKeyguardFadingAway && lightRevealScrim != null) { ValueAnimator.ofFloat(.1f, 1f).apply { interpolator = Interpolators.LINEAR_OUT_SLOW_IN @@ -170,7 +170,7 @@ class AuthRippleController @Inject constructor( } addListener(object : AnimatorListenerAdapter() { override fun onAnimationEnd(animation: Animator?) { - // Reset light reveal scrim to the default, so the StatusBar + // Reset light reveal scrim to the default, so the CentralSurfaces // can handle any subsequent light reveal changes // (ie: from dozing changes) if (lightRevealScrim.revealEffect == circleReveal) { @@ -199,8 +199,8 @@ class AuthRippleController @Inject constructor( it.y, 0f, Math.max( - Math.max(it.x, statusBar.displayWidth - it.x), - Math.max(it.y, statusBar.displayHeight - it.y) + Math.max(it.x, centralSurfaces.displayWidth - it.x), + Math.max(it.y, centralSurfaces.displayHeight - it.y) ) ) } diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java index b32f8786899a..2f041acb649d 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java @@ -18,7 +18,7 @@ package com.android.systemui.dagger; import com.android.systemui.keyguard.dagger.KeyguardModule; import com.android.systemui.recents.RecentsModule; -import com.android.systemui.statusbar.dagger.StatusBarModule; +import com.android.systemui.statusbar.dagger.CentralSurfacesModule; import dagger.Module; @@ -27,7 +27,7 @@ import dagger.Module; */ @Module(includes = { RecentsModule.class, - StatusBarModule.class, + CentralSurfacesModule.class, KeyguardModule.class, }) public abstract class SystemUIBinder { diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java index a4da6b422bde..5d154c3b4f6b 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java @@ -48,7 +48,7 @@ import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.NotificationLockscreenUserManager; import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl; import com.android.systemui.statusbar.NotificationShadeWindowController; -import com.android.systemui.statusbar.dagger.StartStatusBarModule; +import com.android.systemui.statusbar.dagger.StartCentralSurfacesModule; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.provider.VisualStabilityProvider; import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager; @@ -87,7 +87,7 @@ import dagger.Provides; MediaModule.class, PowerModule.class, QSModule.class, - StartStatusBarModule.class, + StartCentralSurfacesModule.class, VolumeModule.class }) public abstract class SystemUIDefaultModule { diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index 13067bf71165..27993010c917 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -67,8 +67,8 @@ import com.android.systemui.statusbar.notification.row.dagger.ExpandableNotifica import com.android.systemui.statusbar.notification.row.dagger.NotificationRowComponent; import com.android.systemui.statusbar.notification.row.dagger.NotificationShelfComponent; import com.android.systemui.statusbar.phone.ShadeController; -import com.android.systemui.statusbar.phone.StatusBar; -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; +import com.android.systemui.statusbar.phone.CentralSurfaces; +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.HeadsUpManager; import com.android.systemui.statusbar.policy.ZenModeController; @@ -131,7 +131,7 @@ import dagger.Provides; WalletModule.class }, subcomponents = { - StatusBarComponent.class, + CentralSurfacesComponent.class, NotificationRowComponent.class, DozeComponent.class, ExpandableNotificationRowComponent.class, @@ -175,7 +175,7 @@ public abstract class SystemUIModule { abstract Recents optionalRecents(); @BindsOptionalOf - abstract StatusBar optionalStatusBar(); + abstract CentralSurfaces optionalCentralSurfaces(); @BindsOptionalOf abstract UdfpsHbmProvider optionalUdfpsHbmProvider(); diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java b/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java index 0509c66f2cb6..e140f6b0faa2 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java @@ -32,7 +32,7 @@ import android.view.VelocityTracker; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.KeyguardBouncer; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.wm.shell.animation.FlingAnimationUtils; @@ -71,7 +71,7 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler { private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; private float mCurrentExpansion; - private final StatusBar mStatusBar; + private final CentralSurfaces mCentralSurfaces; private VelocityTracker mVelocityTracker; @@ -114,10 +114,9 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler { // is fully hidden at full expansion (1) and fully visible when fully collapsed // (0). final float screenTravelPercentage = - Math.abs((e1.getY() - e2.getY()) / mStatusBar.getDisplayHeight()); - setPanelExpansion(mStatusBar.isBouncerShowing() + Math.abs((e1.getY() - e2.getY()) / mCentralSurfaces.getDisplayHeight()); + setPanelExpansion(mCentralSurfaces.isBouncerShowing() ? screenTravelPercentage : 1 - screenTravelPercentage); - return true; } }; @@ -131,7 +130,7 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler { public BouncerSwipeTouchHandler( DisplayMetrics displayMetrics, StatusBarKeyguardViewManager statusBarKeyguardViewManager, - StatusBar statusBar, + CentralSurfaces centralSurfaces, NotificationShadeWindowController notificationShadeWindowController, ValueAnimatorCreator valueAnimatorCreator, VelocityTrackerFactory velocityTrackerFactory, @@ -141,7 +140,7 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler { FlingAnimationUtils flingAnimationUtilsClosing, @Named(SWIPE_TO_BOUNCER_START_REGION) float swipeRegionPercentage) { mDisplayMetrics = displayMetrics; - mStatusBar = statusBar; + mCentralSurfaces = centralSurfaces; mStatusBarKeyguardViewManager = statusBarKeyguardViewManager; mNotificationShadeWindowController = notificationShadeWindowController; mBouncerZoneScreenPercentage = swipeRegionPercentage; @@ -153,7 +152,7 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler { @Override public void getTouchInitiationRegion(Region region) { - if (mStatusBar.isBouncerShowing()) { + if (mCentralSurfaces.isBouncerShowing()) { region.op(new Rect(0, 0, mDisplayMetrics.widthPixels, Math.round(mDisplayMetrics.heightPixels * mBouncerZoneScreenPercentage)), Region.Op.UNION); @@ -247,7 +246,7 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler { } protected void flingToExpansion(float velocity, float expansion) { - final float viewHeight = mStatusBar.getDisplayHeight(); + final float viewHeight = mCentralSurfaces.getDisplayHeight(); final float currentHeight = viewHeight * mCurrentExpansion; final float targetHeight = viewHeight * expansion; diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsComponent.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsComponent.java index e746cafb5ea0..74d5bd577cf4 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsComponent.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsComponent.java @@ -33,7 +33,7 @@ import javax.inject.Inject; import javax.inject.Provider; /** - * Manages power menu plugins and communicates power menu actions to the StatusBar. + * Manages power menu plugins and communicates power menu actions to the CentralSurfaces. */ @SysUISingleton public class GlobalActionsComponent extends CoreStartable diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java index e3886cd80a42..7a278f786a67 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java @@ -121,7 +121,7 @@ import com.android.systemui.plugins.GlobalActionsPanelPlugin; import com.android.systemui.scrim.ScrimDrawable; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.VibratorHelper; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.SystemUIDialog; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.KeyguardStateController; @@ -236,7 +236,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene private int mDialogPressDelay = DIALOG_PRESS_DELAY; // ms protected Handler mMainHandler; private int mSmallestScreenWidthDp; - private final Optional mStatusBarOptional; + private final Optional mCentralSurfacesOptional; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final DialogLaunchAnimator mDialogLaunchAnimator; @@ -344,7 +344,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene RingerModeTracker ringerModeTracker, @Main Handler handler, PackageManager packageManager, - Optional statusBarOptional, + Optional centralSurfacesOptional, KeyguardUpdateMonitor keyguardUpdateMonitor, DialogLaunchAnimator dialogLaunchAnimator) { mContext = context; @@ -374,7 +374,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene mRingerModeTracker = ringerModeTracker; mMainHandler = handler; mSmallestScreenWidthDp = resources.getConfiguration().smallestScreenWidthDp; - mStatusBarOptional = statusBarOptional; + mCentralSurfacesOptional = centralSurfacesOptional; mKeyguardUpdateMonitor = keyguardUpdateMonitor; mDialogLaunchAnimator = dialogLaunchAnimator; @@ -426,8 +426,8 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene return mUiEventLogger; } - protected Optional getStatusBar() { - return mStatusBarOptional; + protected Optional getCentralSurfaces() { + return mCentralSurfacesOptional; } protected KeyguardUpdateMonitor getKeyguardUpdateMonitor() { @@ -675,7 +675,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene com.android.systemui.R.style.Theme_SystemUI_Dialog_GlobalActionsLite, mAdapter, mOverflowAdapter, mSysuiColorExtractor, mStatusBarService, mNotificationShadeWindowController, this::onRefresh, mKeyguardShowing, - mPowerAdapter, mUiEventLogger, mStatusBarOptional, mKeyguardUpdateMonitor, + mPowerAdapter, mUiEventLogger, mCentralSurfacesOptional, mKeyguardUpdateMonitor, mLockPatternUtils); dialog.setOnDismissListener(this); @@ -866,7 +866,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene mUiEventLogger.log(GlobalActionsEvent.GA_EMERGENCY_DIALER_PRESS); if (mTelecomManager != null) { // Close shade so user sees the activity - mStatusBarOptional.ifPresent(StatusBar::collapseShade); + mCentralSurfacesOptional.ifPresent(CentralSurfaces::collapseShade); Intent intent = mTelecomManager.createLaunchEmergencyDialerIntent( null /* number */); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK @@ -998,7 +998,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene mIActivityManager.requestInteractiveBugReport(); } // Close shade so user sees the activity - mStatusBarOptional.ifPresent(StatusBar::collapseShade); + mCentralSurfacesOptional.ifPresent(CentralSurfaces::collapseShade); } catch (RemoteException e) { } } @@ -1018,7 +1018,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene mUiEventLogger.log(GlobalActionsEvent.GA_BUGREPORT_LONG_PRESS); mIActivityManager.requestFullBugReport(); // Close shade so user sees the activity - mStatusBarOptional.ifPresent(StatusBar::collapseShade); + mCentralSurfacesOptional.ifPresent(CentralSurfaces::collapseShade); } catch (RemoteException e) { } return false; @@ -2160,7 +2160,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene protected final Runnable mOnRefreshCallback; private UiEventLogger mUiEventLogger; private GestureDetector mGestureDetector; - private Optional mStatusBarOptional; + private Optional mCentralSurfacesOptional; private KeyguardUpdateMonitor mKeyguardUpdateMonitor; private LockPatternUtils mLockPatternUtils; private float mWindowDimAmount; @@ -2188,8 +2188,8 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { if (distanceY < 0 && distanceY > distanceX - && e1.getY() <= mStatusBarOptional.map( - StatusBar::getStatusBarHeight).orElse(0)) { + && e1.getY() <= mCentralSurfacesOptional.map( + CentralSurfaces::getStatusBarHeight).orElse(0)) { // Downwards scroll from top openShadeAndDismiss(); return true; @@ -2201,8 +2201,8 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (velocityY > 0 && Math.abs(velocityY) > Math.abs(velocityX) - && e1.getY() <= mStatusBarOptional.map( - StatusBar::getStatusBarHeight).orElse(0)) { + && e1.getY() <= mCentralSurfacesOptional.map( + CentralSurfaces::getStatusBarHeight).orElse(0)) { // Downwards fling from top openShadeAndDismiss(); return true; @@ -2217,7 +2217,8 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene NotificationShadeWindowController notificationShadeWindowController, Runnable onRefreshCallback, boolean keyguardShowing, MyPowerOptionsAdapter powerAdapter, UiEventLogger uiEventLogger, - Optional statusBarOptional, KeyguardUpdateMonitor keyguardUpdateMonitor, + Optional centralSurfacesOptional, + KeyguardUpdateMonitor keyguardUpdateMonitor, LockPatternUtils lockPatternUtils) { // We set dismissOnDeviceLock to false because we have a custom broadcast receiver to // dismiss this dialog when the device is locked. @@ -2232,7 +2233,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene mOnRefreshCallback = onRefreshCallback; mKeyguardShowing = keyguardShowing; mUiEventLogger = uiEventLogger; - mStatusBarOptional = statusBarOptional; + mCentralSurfacesOptional = centralSurfacesOptional; mKeyguardUpdateMonitor = keyguardUpdateMonitor; mLockPatternUtils = lockPatternUtils; mGestureDetector = new GestureDetector(mContext, mGestureListener); @@ -2262,14 +2263,14 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene private void openShadeAndDismiss() { mUiEventLogger.log(GlobalActionsEvent.GA_CLOSE_TAP_OUTSIDE); - if (mStatusBarOptional.map(StatusBar::isKeyguardShowing).orElse(false)) { + if (mCentralSurfacesOptional.map(CentralSurfaces::isKeyguardShowing).orElse(false)) { // match existing lockscreen behavior to open QS when swiping from status bar - mStatusBarOptional.ifPresent( - statusBar -> statusBar.animateExpandSettingsPanel(null)); + mCentralSurfacesOptional.ifPresent( + centralSurfaces -> centralSurfaces.animateExpandSettingsPanel(null)); } else { // otherwise, swiping down should expand notification shade - mStatusBarOptional.ifPresent( - statusBar -> statusBar.animateExpandNotificationsPanel()); + mCentralSurfacesOptional.ifPresent( + centralSurfaces -> centralSurfaces.animateExpandNotificationsPanel()); } dismiss(); } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index ae7147ecae03..07dfa33620a0 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -127,7 +127,7 @@ import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.NotificationPanelViewController; import com.android.systemui.statusbar.phone.ScreenOffAnimationController; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.statusbar.policy.UserSwitcherController; @@ -2717,22 +2717,22 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable, } /** - * Registers the StatusBar to which the Keyguard View is mounted. + * Registers the CentralSurfaces to which the Keyguard View is mounted. * - * @param statusBar + * @param centralSurfaces * @param panelView * @param biometricUnlockController * @param notificationContainer * @param bypassController * @return the View Controller for the Keyguard View this class is mediating. */ - public KeyguardViewController registerStatusBar(StatusBar statusBar, + public KeyguardViewController registerCentralSurfaces(CentralSurfaces centralSurfaces, NotificationPanelViewController panelView, @Nullable PanelExpansionStateManager panelExpansionStateManager, BiometricUnlockController biometricUnlockController, View notificationContainer, KeyguardBypassController bypassController) { - mKeyguardViewControllerLazy.get().registerStatusBar( - statusBar, + mKeyguardViewControllerLazy.get().registerCentralSurfaces( + centralSurfaces, panelView, panelExpansionStateManager, biometricUnlockController, diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java b/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java index 195ef1a84c43..c69f947f5f3f 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java @@ -48,10 +48,10 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.NotificationShadeDepthController; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.SysuiStatusBarStateController; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.statusbar.phone.KeyguardLiftController; import com.android.systemui.statusbar.phone.ScreenOffAnimationController; -import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.statusbar.policy.UserSwitcherController; import com.android.systemui.util.DeviceConfigProxy; @@ -64,7 +64,7 @@ import dagger.Module; import dagger.Provides; /** - * Dagger Module providing {@link StatusBar}. + * Dagger Module providing keyguard. */ @Module(subcomponents = { KeyguardQsUserSwitchComponent.class, diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavBarHelper.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavBarHelper.java index 5e9edb7c906e..a1a319814269 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavBarHelper.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavBarHelper.java @@ -49,8 +49,7 @@ import com.android.systemui.dump.DumpManager; import com.android.systemui.recents.OverviewProxyService; import com.android.systemui.settings.UserTracker; import com.android.systemui.shared.system.QuickStepContract; -import com.android.systemui.statusbar.phone.StatusBar; -import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper; +import com.android.systemui.statusbar.phone.CentralSurfaces; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -79,7 +78,7 @@ public final class NavBarHelper implements Dumpable { private final AccessibilityManager mAccessibilityManager; private final Lazy mAssistManagerLazy; - private final Lazy> mStatusBarOptionalLazy; + private final Lazy> mCentralSurfacesOptionalLazy; private final UserTracker mUserTracker; private final SystemActions mSystemActions; private final AccessibilityButtonModeObserver mAccessibilityButtonModeObserver; @@ -113,7 +112,7 @@ public final class NavBarHelper implements SystemActions systemActions, OverviewProxyService overviewProxyService, Lazy assistManagerLazy, - Lazy> statusBarOptionalLazy, + Lazy> centralSurfacesOptionalLazy, NavigationModeController navigationModeController, UserTracker userTracker, DumpManager dumpManager) { @@ -121,7 +120,7 @@ public final class NavBarHelper implements mContentResolver = mContext.getContentResolver(); mAccessibilityManager = accessibilityManager; mAssistManagerLazy = assistManagerLazy; - mStatusBarOptionalLazy = statusBarOptionalLazy; + mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy; mUserTracker = userTracker; mSystemActions = systemActions; accessibilityManager.addAccessibilityServicesStateChangeListener( @@ -295,8 +294,8 @@ public final class NavBarHelper implements * {@link InputMethodService} and the keyguard states. */ public boolean isImeShown(int vis) { - View shadeWindowView = mStatusBarOptionalLazy.get().get().getNotificationShadeWindowView(); - boolean isKeyguardShowing = mStatusBarOptionalLazy.get().get().isKeyguardShowing(); + View shadeWindowView = mCentralSurfacesOptionalLazy.get().get().getNotificationShadeWindowView(); + boolean isKeyguardShowing = mCentralSurfacesOptionalLazy.get().get().isKeyguardShowing(); boolean imeVisibleOnShade = shadeWindowView != null && shadeWindowView.isAttachedToWindow() && shadeWindowView.getRootWindowInsets().isVisible(WindowInsets.Type.ime()); return imeVisibleOnShade diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java index 76914f3fd8ee..3ab1216777e9 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java @@ -53,8 +53,8 @@ import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE; import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT; import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT; import static com.android.systemui.statusbar.phone.BarTransitions.TransitionMode; -import static com.android.systemui.statusbar.phone.StatusBar.DEBUG_WINDOW_STATE; -import static com.android.systemui.statusbar.phone.StatusBar.dumpBarTransitions; +import static com.android.systemui.statusbar.phone.CentralSurfaces.DEBUG_WINDOW_STATE; +import static com.android.systemui.statusbar.phone.CentralSurfaces.dumpBarTransitions; import android.annotation.IdRes; import android.app.ActivityTaskManager; @@ -134,9 +134,9 @@ import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.notification.stack.StackStateAnimator; import com.android.systemui.statusbar.phone.AutoHideController; import com.android.systemui.statusbar.phone.BarTransitions; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.LightBarController; import com.android.systemui.statusbar.phone.ShadeController; -import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.wm.shell.back.BackAnimation; import com.android.wm.shell.pip.Pip; @@ -176,7 +176,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener, private final MetricsLogger mMetricsLogger; private final Lazy mAssistManagerLazy; private final SysUiState mSysUiFlagsContainer; - private final Lazy> mStatusBarOptionalLazy; + private final Lazy> mCentralSurfacesOptionalLazy; private final ShadeController mShadeController; private final NotificationRemoteInputManager mNotificationRemoteInputManager; private final OverviewProxyService mOverviewProxyService; @@ -486,7 +486,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener, CommandQueue commandQueue, Optional pipOptional, Optional recentsOptional, - Lazy> statusBarOptionalLazy, + Lazy> centralSurfacesOptionalLazy, ShadeController shadeController, NotificationRemoteInputManager notificationRemoteInputManager, NotificationShadeDepthController notificationShadeDepthController, @@ -509,7 +509,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener, mMetricsLogger = metricsLogger; mAssistManagerLazy = assistManagerLazy; mSysUiFlagsContainer = sysUiFlagsContainer; - mStatusBarOptionalLazy = statusBarOptionalLazy; + mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy; mShadeController = shadeController; mNotificationRemoteInputManager = notificationRemoteInputManager; mOverviewProxyService = overviewProxyService; @@ -611,7 +611,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener, public void onViewAttachedToWindow(View v) { final Display display = v.getDisplay(); mNavigationBarView.setComponents(mRecentsOptional); - mNavigationBarView.setComponents(mStatusBarOptionalLazy.get().get().getPanelController()); + mNavigationBarView.setComponents(mCentralSurfacesOptionalLazy.get().get().getPanelController()); mNavigationBarView.setDisabledFlags(mDisabledFlags1); mNavigationBarView.setOnVerticalChangedListener(this::onVerticalChanged); mNavigationBarView.setOnTouchListener(this::onNavigationTouch); @@ -1165,13 +1165,14 @@ public class NavigationBar implements View.OnAttachStateChangeListener, // If an incoming call is ringing, HOME is totally disabled. // (The user is already on the InCallUI at this point, // and their ONLY options are to answer or reject the call.) - final Optional statusBarOptional = mStatusBarOptionalLazy.get(); + final Optional centralSurfacesOptional = mCentralSurfacesOptionalLazy.get(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mHomeBlockedThisTouch = false; if (mTelecomManagerOptional.isPresent() && mTelecomManagerOptional.get().isRinging()) { - if (statusBarOptional.map(StatusBar::isKeyguardShowing).orElse(false)) { + if (centralSurfacesOptional.map(CentralSurfaces::isKeyguardShowing) + .orElse(false)) { Log.i(TAG, "Ignoring HOME; there's a ringing incoming call. " + "No heads up"); mHomeBlockedThisTouch = true; @@ -1187,14 +1188,14 @@ public class NavigationBar implements View.OnAttachStateChangeListener, case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mHandler.removeCallbacks(mOnVariableDurationHomeLongClick); - statusBarOptional.ifPresent(StatusBar::awakenDreams); + centralSurfacesOptional.ifPresent(CentralSurfaces::awakenDreams); break; } return false; } private void onVerticalChanged(boolean isVertical) { - mStatusBarOptionalLazy.get().ifPresent( + mCentralSurfacesOptionalLazy.get().ifPresent( statusBar -> statusBar.setQsScrimEnabled(!isVertical)); } @@ -1221,7 +1222,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener, AssistManager.INVOCATION_TYPE_KEY, AssistManager.INVOCATION_TYPE_HOME_BUTTON_LONG_PRESS); mAssistManagerLazy.get().startAssist(args); - mStatusBarOptionalLazy.get().ifPresent(StatusBar::awakenDreams); + mCentralSurfacesOptionalLazy.get().ifPresent(CentralSurfaces::awakenDreams); mNavigationBarView.abortCurrentGesture(); return true; } @@ -1247,7 +1248,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener, LatencyTracker.getInstance(mContext).onActionStart( LatencyTracker.ACTION_TOGGLE_RECENTS); } - mStatusBarOptionalLazy.get().ifPresent(StatusBar::awakenDreams); + mCentralSurfacesOptionalLazy.get().ifPresent(CentralSurfaces::awakenDreams); mCommandQueue.toggleRecentApps(); } @@ -1431,7 +1432,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener, private void checkBarModes() { // We only have status bar on default display now. if (mIsOnDefaultDisplay) { - mStatusBarOptionalLazy.get().ifPresent(StatusBar::checkBarModes); + mCentralSurfacesOptionalLazy.get().ifPresent(CentralSurfaces::checkBarModes); } else { checkNavBarModes(); } @@ -1450,7 +1451,8 @@ public class NavigationBar implements View.OnAttachStateChangeListener, */ public void checkNavBarModes() { final boolean anim = - mStatusBarOptionalLazy.get().map(StatusBar::isDeviceInteractive).orElse(false) + mCentralSurfacesOptionalLazy.get().map(CentralSurfaces::isDeviceInteractive) + .orElse(false) && mNavigationBarWindowState != WINDOW_STATE_HIDDEN; mNavigationBarView.getBarTransitions().transitionTo(mNavigationBarMode, anim); } @@ -1626,7 +1628,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener, private final CommandQueue mCommandQueue; private final Optional mPipOptional; private final Optional mRecentsOptional; - private final Lazy> mStatusBarOptionalLazy; + private final Lazy> mCentralSurfacesOptionalLazy; private final ShadeController mShadeController; private final NotificationRemoteInputManager mNotificationRemoteInputManager; private final NotificationShadeDepthController mNotificationShadeDepthController; @@ -1657,7 +1659,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener, CommandQueue commandQueue, Optional pipOptional, Optional recentsOptional, - Lazy> statusBarOptionalLazy, + Lazy> centralSurfacesOptionalLazy, ShadeController shadeController, NotificationRemoteInputManager notificationRemoteInputManager, NotificationShadeDepthController notificationShadeDepthController, @@ -1685,7 +1687,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener, mCommandQueue = commandQueue; mPipOptional = pipOptional; mRecentsOptional = recentsOptional; - mStatusBarOptionalLazy = statusBarOptionalLazy; + mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy; mShadeController = shadeController; mNotificationRemoteInputManager = notificationRemoteInputManager; mNotificationShadeDepthController = notificationShadeDepthController; @@ -1710,7 +1712,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener, mOverviewProxyService, mNavigationModeController, mAccessibilityButtonModeObserver, mStatusBarStateController, mSysUiFlagsContainer, mBroadcastDispatcher, mCommandQueue, mPipOptional, - mRecentsOptional, mStatusBarOptionalLazy, + mRecentsOptional, mCentralSurfacesOptionalLazy, mShadeController, mNotificationRemoteInputManager, mNotificationShadeDepthController, mMainHandler, mNavbarOverlayController, mUiEventLogger, mNavBarHelper, diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java index ede10a5f2f18..017bbdffdc4f 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java @@ -90,7 +90,7 @@ import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.phone.AutoHideController; import com.android.systemui.statusbar.phone.LightBarTransitionsController; import com.android.systemui.statusbar.phone.NotificationPanelViewController; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.wm.shell.back.BackAnimation; import com.android.wm.shell.pip.Pip; @@ -1362,7 +1362,7 @@ public class NavigationBarView extends FrameLayout implements getContextDisplay().getRealSize(size); pw.println("NavigationBarView:"); - pw.println(String.format(" this: " + StatusBar.viewInfo(this) + pw.println(String.format(" this: " + CentralSurfaces.viewInfo(this) + " " + visibilityToString(getVisibility()))); getWindowVisibleDisplayFrame(r); diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java index 642af593c211..a7ed871b9fbb 100644 --- a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java +++ b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java @@ -47,7 +47,7 @@ import com.android.systemui.R; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.statusbar.CommandQueue; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -108,17 +108,17 @@ public class PowerUI extends CoreStartable implements CommandQueue.Callbacks { private IThermalEventListener mUsbThermalEventListener; private final BroadcastDispatcher mBroadcastDispatcher; private final CommandQueue mCommandQueue; - private final Lazy> mStatusBarOptionalLazy; + private final Lazy> mCentralSurfacesOptionalLazy; @Inject public PowerUI(Context context, BroadcastDispatcher broadcastDispatcher, - CommandQueue commandQueue, Lazy> statusBarOptionalLazy, + CommandQueue commandQueue, Lazy> centralSurfacesOptionalLazy, WarningsUI warningsUI, EnhancedEstimates enhancedEstimates, PowerManager powerManager) { super(context); mBroadcastDispatcher = broadcastDispatcher; mCommandQueue = commandQueue; - mStatusBarOptionalLazy = statusBarOptionalLazy; + mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy; mWarnings = warningsUI; mEnhancedEstimates = enhancedEstimates; mPowerManager = powerManager; @@ -712,8 +712,10 @@ public class PowerUI extends CoreStartable implements CommandQueue.Callbacks { int status = temp.getStatus(); if (status >= Temperature.THROTTLING_EMERGENCY) { - final Optional statusBarOptional = mStatusBarOptionalLazy.get(); - if (!statusBarOptional.map(StatusBar::isDeviceInVrMode).orElse(false)) { + final Optional centralSurfacesOptional = + mCentralSurfacesOptionalLazy.get(); + if (!centralSurfacesOptional.map(CentralSurfaces::isDeviceInVrMode) + .orElse(false)) { mWarnings.showHighTemperatureWarning(); Slog.d(TAG, "SkinThermalEventListener: notifyThrottling was called " + ", current skin status = " + status diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java index c69307548b6e..47af7de9118d 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java @@ -53,7 +53,7 @@ import com.android.systemui.qs.logging.QSLogger; import com.android.systemui.settings.UserTracker; import com.android.systemui.shared.plugins.PluginManager; import com.android.systemui.statusbar.phone.AutoTileManager; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.StatusBarIconController; import com.android.systemui.tuner.TunerService; import com.android.systemui.tuner.TunerService.Tunable; @@ -102,7 +102,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener, D private final StatusBarIconController mIconController; private final ArrayList mQsFactories = new ArrayList<>(); private int mCurrentUser; - private final Optional mStatusBarOptional; + private final Optional mCentralSurfacesOptional; private Context mUserContext; private UserTracker mUserTracker; private SecureSettings mSecureSettings; @@ -121,7 +121,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener, D Provider autoTiles, DumpManager dumpManager, BroadcastDispatcher broadcastDispatcher, - Optional statusBarOptional, + Optional centralSurfacesOptional, QSLogger qsLogger, UiEventLogger uiEventLogger, UserTracker userTracker, @@ -143,7 +143,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener, D mTileLifeCycleManagerFactory = tileLifecycleManagerFactory; mInstanceIdSequence = new InstanceIdSequence(MAX_QS_INSTANCE_ID); - mStatusBarOptional = statusBarOptional; + mCentralSurfacesOptional = centralSurfacesOptional; mQsFactories.add(defaultFactory); pluginManager.addPluginListener(this, QSFactory.class, true); @@ -227,17 +227,17 @@ public class QSTileHost implements QSHost, Tunable, PluginListener, D @Override public void collapsePanels() { - mStatusBarOptional.ifPresent(StatusBar::postAnimateCollapsePanels); + mCentralSurfacesOptional.ifPresent(CentralSurfaces::postAnimateCollapsePanels); } @Override public void forceCollapsePanels() { - mStatusBarOptional.ifPresent(StatusBar::postAnimateForceCollapsePanels); + mCentralSurfacesOptional.ifPresent(CentralSurfaces::postAnimateForceCollapsePanels); } @Override public void openPanels() { - mStatusBarOptional.ifPresent(StatusBar::postAnimateOpenPanels); + mCentralSurfacesOptional.ifPresent(CentralSurfaces::postAnimateOpenPanels); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyRecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyRecentsImpl.java index 597f7b7053a2..f389df097d7d 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyRecentsImpl.java +++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyRecentsImpl.java @@ -26,7 +26,7 @@ import android.util.Log; import com.android.systemui.Dependency; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.shared.recents.IOverviewProxy; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import java.util.Optional; @@ -42,7 +42,7 @@ public class OverviewProxyRecentsImpl implements RecentsImplementation { private final static String TAG = "OverviewProxyRecentsImpl"; @Nullable - private final Lazy> mStatusBarOptionalLazy; + private final Lazy> mCentralSurfacesOptionalLazy; private Context mContext; private Handler mHandler; @@ -51,8 +51,8 @@ public class OverviewProxyRecentsImpl implements RecentsImplementation { @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @Inject - public OverviewProxyRecentsImpl(Lazy> statusBarOptionalLazy) { - mStatusBarOptionalLazy = statusBarOptionalLazy; + public OverviewProxyRecentsImpl(Lazy> centralSurfacesOptionalLazy) { + mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy; } @Override @@ -109,9 +109,10 @@ public class OverviewProxyRecentsImpl implements RecentsImplementation { } }; // Preload only if device for current user is unlocked - final Optional statusBarOptional = mStatusBarOptionalLazy.get(); - if (statusBarOptional.map(StatusBar::isKeyguardShowing).orElse(false)) { - statusBarOptional.get().executeRunnableDismissingKeyguard(() -> { + final Optional centralSurfacesOptional = + mCentralSurfacesOptionalLazy.get(); + if (centralSurfacesOptional.map(CentralSurfaces::isKeyguardShowing).orElse(false)) { + centralSurfacesOptional.get().executeRunnableDismissingKeyguard(() -> { mHandler.post(toggleRecents); }, null, true /* dismissShade */, false /* afterKeyguardGone */, true /* deferred */); diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java index 7ceaee5fb7bb..a3dea1c68b14 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java @@ -102,7 +102,7 @@ import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.NotificationPanelViewController; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.StatusBarWindowCallback; import com.android.systemui.statusbar.policy.CallbackController; import com.android.wm.shell.back.BackAnimation; @@ -146,7 +146,7 @@ public class OverviewProxyService extends CurrentUserTracker implements private final Context mContext; private final Optional mPipOptional; - private final Lazy> mStatusBarOptionalLazy; + private final Lazy> mCentralSurfacesOptionalLazy; private final Optional mSplitScreenOptional; private SysUiState mSysUiState; private final Handler mHandler; @@ -186,7 +186,7 @@ public class OverviewProxyService extends CurrentUserTracker implements @Override public void startScreenPinning(int taskId) { verifyCallerAndClearCallingIdentityPostMain("startScreenPinning", () -> - mStatusBarOptionalLazy.get().ifPresent( + mCentralSurfacesOptionalLazy.get().ifPresent( statusBar -> statusBar.showScreenPinningRequest(taskId, false /* allowCancel */))); } @@ -207,9 +207,9 @@ public class OverviewProxyService extends CurrentUserTracker implements public void onStatusBarMotionEvent(MotionEvent event) { verifyCallerAndClearCallingIdentity("onStatusBarMotionEvent", () -> { // TODO move this logic to message queue - mStatusBarOptionalLazy.get().ifPresent(statusBar -> { + mCentralSurfacesOptionalLazy.get().ifPresent(centralSurfaces -> { if (event.getActionMasked() == ACTION_DOWN) { - statusBar.getPanelController().startExpandLatencyTracking(); + centralSurfaces.getPanelController().startExpandLatencyTracking(); } mHandler.post(() -> { int action = event.getActionMasked(); @@ -217,7 +217,7 @@ public class OverviewProxyService extends CurrentUserTracker implements mInputFocusTransferStarted = true; mInputFocusTransferStartY = event.getY(); mInputFocusTransferStartMillis = event.getEventTime(); - statusBar.onInputFocusTransfer( + centralSurfaces.onInputFocusTransfer( mInputFocusTransferStarted, false /* cancel */, 0 /* velocity */); } @@ -225,7 +225,7 @@ public class OverviewProxyService extends CurrentUserTracker implements mInputFocusTransferStarted = false; float velocity = (event.getY() - mInputFocusTransferStartY) / (event.getEventTime() - mInputFocusTransferStartMillis); - statusBar.onInputFocusTransfer(mInputFocusTransferStarted, + centralSurfaces.onInputFocusTransfer(mInputFocusTransferStarted, action == ACTION_CANCEL, velocity); } @@ -401,7 +401,7 @@ public class OverviewProxyService extends CurrentUserTracker implements @Override public void toggleNotificationPanel() { verifyCallerAndClearCallingIdentityPostMain("toggleNotificationPanel", () -> - mStatusBarOptionalLazy.get().ifPresent(StatusBar::togglePanel)); + mCentralSurfacesOptionalLazy.get().ifPresent(CentralSurfaces::togglePanel)); } @@ -555,7 +555,7 @@ public class OverviewProxyService extends CurrentUserTracker implements @Inject public OverviewProxyService(Context context, CommandQueue commandQueue, Lazy navBarControllerLazy, - Lazy> statusBarOptionalLazy, + Lazy> centralSurfacesOptionalLazy, NavigationModeController navModeController, NotificationShadeWindowController statusBarWinController, SysUiState sysUiState, Optional pipOptional, @@ -573,7 +573,7 @@ public class OverviewProxyService extends CurrentUserTracker implements super(broadcastDispatcher); mContext = context; mPipOptional = pipOptional; - mStatusBarOptionalLazy = statusBarOptionalLazy; + mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy; mHandler = new Handler(); mNavBarControllerLazy = navBarControllerLazy; mStatusBarWinController = statusBarWinController; @@ -665,7 +665,7 @@ public class OverviewProxyService extends CurrentUserTracker implements final NavigationBarView navBarView = mNavBarControllerLazy.get().getNavigationBarView(mContext.getDisplayId()); final NotificationPanelViewController panelController = - mStatusBarOptionalLazy.get().get().getPanelController(); + mCentralSurfacesOptionalLazy.get().get().getPanelController(); if (SysUiState.DEBUG) { Log.d(TAG_OPS, "Updating sysui state flags: navBarFragment=" + navBarFragment + " navBarView=" + navBarView + " panelController=" + panelController); @@ -731,9 +731,9 @@ public class OverviewProxyService extends CurrentUserTracker implements public void cleanupAfterDeath() { if (mInputFocusTransferStarted) { mHandler.post(() -> { - mStatusBarOptionalLazy.get().ifPresent(statusBar -> { + mCentralSurfacesOptionalLazy.get().ifPresent(centralSurfaces -> { mInputFocusTransferStarted = false; - statusBar.onInputFocusTransfer(false, true /* cancel */, 0 /* velocity */); + centralSurfaces.onInputFocusTransfer(false, true /* cancel */, 0 /* velocity */); }); }); } diff --git a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java index 7f130cb203c0..15ad7798b3a3 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java +++ b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java @@ -56,7 +56,7 @@ import com.android.systemui.navigationbar.NavigationBarView; import com.android.systemui.navigationbar.NavigationModeController; import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.shared.system.WindowManagerWrapper; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.util.leak.RotationUtils; import java.util.ArrayList; @@ -70,7 +70,7 @@ public class ScreenPinningRequest implements View.OnClickListener, NavigationModeController.ModeChangedListener { private final Context mContext; - private final Lazy> mStatusBarOptionalLazy; + private final Lazy> mCentralSurfacesOptionalLazy; private final AccessibilityManager mAccessibilityService; private final WindowManager mWindowManager; @@ -83,9 +83,11 @@ public class ScreenPinningRequest implements View.OnClickListener, private int taskId; @Inject - public ScreenPinningRequest(Context context, Lazy> statusBarOptionalLazy) { + public ScreenPinningRequest( + Context context, + Lazy> centralSurfacesOptionalLazy) { mContext = context; - mStatusBarOptionalLazy = statusBarOptionalLazy; + mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy; mAccessibilityService = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); mWindowManager = (WindowManager) @@ -267,9 +269,10 @@ public class ScreenPinningRequest implements View.OnClickListener, .setVisibility(View.INVISIBLE); } - final Optional statusBarOptional = mStatusBarOptionalLazy.get(); + final Optional centralSurfacesOptional = + mCentralSurfacesOptionalLazy.get(); NavigationBarView navigationBarView = - statusBarOptional.map(StatusBar::getNavigationBarView).orElse(null); + centralSurfacesOptional.map(CentralSurfaces::getNavigationBarView).orElse(null); final boolean recentsVisible = navigationBarView != null && navigationBarView.isRecentsButtonVisible(); boolean touchExplorationEnabled = mAccessibilityService.isTouchExplorationEnabled(); diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ActionProxyReceiver.java b/packages/SystemUI/src/com/android/systemui/screenshot/ActionProxyReceiver.java index f14044682b61..daaa897374cb 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ActionProxyReceiver.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ActionProxyReceiver.java @@ -24,7 +24,7 @@ import static com.android.systemui.screenshot.ScreenshotController.EXTRA_ACTION_ import static com.android.systemui.screenshot.ScreenshotController.EXTRA_DISALLOW_ENTER_PIP; import static com.android.systemui.screenshot.ScreenshotController.EXTRA_ID; import static com.android.systemui.screenshot.ScreenshotController.EXTRA_SMART_ACTIONS_ENABLED; -import static com.android.systemui.statusbar.phone.StatusBar.SYSTEM_DIALOG_REASON_SCREENSHOT; +import static com.android.systemui.statusbar.phone.CentralSurfaces.SYSTEM_DIALOG_REASON_SCREENSHOT; import android.app.ActivityOptions; import android.app.PendingIntent; @@ -36,7 +36,7 @@ import android.view.RemoteAnimationAdapter; import android.view.WindowManagerGlobal; import com.android.systemui.shared.system.ActivityManagerWrapper; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import java.util.Optional; @@ -49,15 +49,15 @@ import javax.inject.Inject; public class ActionProxyReceiver extends BroadcastReceiver { private static final String TAG = "ActionProxyReceiver"; - private final StatusBar mStatusBar; + private final CentralSurfaces mCentralSurfaces; private final ActivityManagerWrapper mActivityManagerWrapper; private final ScreenshotSmartActions mScreenshotSmartActions; @Inject - public ActionProxyReceiver(Optional statusBar, + public ActionProxyReceiver(Optional centralSurfacesOptional, ActivityManagerWrapper activityManagerWrapper, ScreenshotSmartActions screenshotSmartActions) { - mStatusBar = statusBar.orElse(null); + mCentralSurfaces = centralSurfacesOptional.orElse(null); mActivityManagerWrapper = activityManagerWrapper; mScreenshotSmartActions = screenshotSmartActions; } @@ -89,8 +89,8 @@ public class ActionProxyReceiver extends BroadcastReceiver { }; - if (mStatusBar != null) { - mStatusBar.executeRunnableDismissingKeyguard(startActivityRunnable, null, + if (mCentralSurfaces != null) { + mCentralSurfaces.executeRunnableDismissingKeyguard(startActivityRunnable, null, true /* dismissShade */, true /* afterKeyguardGone */, true /* deferred */); } else { diff --git a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessController.java b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessController.java index 991a68fb056a..7801c68586f1 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessController.java +++ b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessController.java @@ -54,7 +54,7 @@ import com.android.systemui.statusbar.policy.BrightnessMirrorController; import javax.inject.Inject; public class BrightnessController implements ToggleSlider.Listener, MirroredBrightnessController { - private static final String TAG = "StatusBar.BrightnessController"; + private static final String TAG = "CentralSurfaces.BrightnessController"; private static final int SLIDER_ANIMATION_DURATION = 3000; private static final int MSG_UPDATE_SLIDER = 1; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java index 645c5accb541..8a02e5952659 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java @@ -23,7 +23,7 @@ import static android.inputmethodservice.InputMethodService.IME_INVISIBLE; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.INVALID_DISPLAY; -import static com.android.systemui.statusbar.phone.StatusBar.ONLY_CORE_APPS; +import static com.android.systemui.statusbar.phone.CentralSurfaces.ONLY_CORE_APPS; import android.annotation.Nullable; import android.app.ITransientNotificationCallback; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt index 8a9d6ddb2e14..17f42b1a3a43 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt @@ -38,7 +38,7 @@ import com.android.systemui.statusbar.phone.KeyguardBypassController import com.android.systemui.statusbar.phone.LSShadeTransitionLogger import com.android.systemui.statusbar.phone.NotificationPanelViewController import com.android.systemui.statusbar.phone.ScrimController -import com.android.systemui.statusbar.phone.StatusBar +import com.android.systemui.statusbar.phone.CentralSurfaces import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.util.Utils import java.io.FileDescriptor @@ -73,7 +73,7 @@ class LockscreenShadeTransitionController @Inject constructor( private var useSplitShade: Boolean = false private lateinit var nsslController: NotificationStackScrollLayoutController lateinit var notificationPanelController: NotificationPanelViewController - lateinit var statusbar: StatusBar + lateinit var centralSurfaces: CentralSurfaces lateinit var qS: QS /** @@ -197,7 +197,7 @@ class LockscreenShadeTransitionController @Inject constructor( // Bind the click listener of the shelf to go to the full shade notificationShelfController.setOnClickListener { if (statusBarStateController.state == StatusBarState.KEYGUARD) { - statusbar.wakeUpIfDozing(SystemClock.uptimeMillis(), it, "SHADE_CLICK") + centralSurfaces.wakeUpIfDozing(SystemClock.uptimeMillis(), it, "SHADE_CLICK") goToLockedShade(it) } } @@ -224,7 +224,7 @@ class LockscreenShadeTransitionController @Inject constructor( if (nsslController.isInLockedDownShade()) { logger.logDraggedDownLockDownShade(startingChild) statusBarStateController.setLeaveOpenOnKeyguardHide(true) - statusbar.dismissKeyguardThenExecute(OnDismissAction { + centralSurfaces.dismissKeyguardThenExecute(OnDismissAction { nextHideKeyguardNeedsNoAnimation = true false }, cancelRunnable, false /* afterKeyguardGone */) @@ -361,7 +361,7 @@ class LockscreenShadeTransitionController @Inject constructor( notificationPanelController.setKeyguardOnlyContentAlpha(1.0f - scrimProgress) depthController.transitionToFullShadeProgress = scrimProgress udfpsKeyguardViewController?.setTransitionToFullShadeProgress(scrimProgress) - statusbar.setTransitionToFullShadeProgress(scrimProgress) + centralSurfaces.setTransitionToFullShadeProgress(scrimProgress) } private fun setDragDownAmountAnimated( @@ -461,7 +461,7 @@ class LockscreenShadeTransitionController @Inject constructor( animationHandler: ((Long) -> Unit)? = null, cancelAction: Runnable? = null ) { - if (statusbar.isShadeDisabled) { + if (centralSurfaces.isShadeDisabled) { cancelAction?.run() logger.logShadeDisabledOnGoToLockedShade() return @@ -503,7 +503,7 @@ class LockscreenShadeTransitionController @Inject constructor( cancelAction?.run() } logger.logShowBouncerOnGoToLockedShade() - statusbar.showBouncerWithDimissAndCancelIfKeyguard(onDismissAction, cancelHandler) + centralSurfaces.showBouncerWithDimissAndCancelIfKeyguard(onDismissAction, cancelHandler) draggedDownEntry = entry } else { logger.logGoingToLockedShade(animationHandler != null) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java index 01bdb401e00c..68d35f9679ed 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java @@ -32,10 +32,10 @@ import android.util.Log; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.shared.plugins.PluginManager; -import com.android.systemui.statusbar.dagger.StatusBarModule; +import com.android.systemui.statusbar.dagger.CentralSurfacesModule; import com.android.systemui.statusbar.notification.collection.NotifCollection; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.NotificationListenerWithPlugins; -import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.util.time.SystemClock; import java.util.ArrayList; @@ -54,7 +54,7 @@ import javax.inject.Inject; @SuppressLint("OverrideAbstract") public class NotificationListener extends NotificationListenerWithPlugins { private static final String TAG = "NotificationListener"; - private static final boolean DEBUG = StatusBar.DEBUG; + private static final boolean DEBUG = CentralSurfaces.DEBUG; private static final long MAX_RANKING_DELAY_MILLIS = 500L; private final Context mContext; @@ -69,7 +69,7 @@ public class NotificationListener extends NotificationListenerWithPlugins { private long mSkippingRankingUpdatesSince = -1; /** - * Injected constructor. See {@link StatusBarModule}. + * Injected constructor. See {@link CentralSurfacesModule}. */ @Inject public NotificationListener( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java index 3730d123021b..052c57e768fe 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java @@ -16,9 +16,9 @@ package com.android.systemui.statusbar; import static com.android.systemui.statusbar.StatusBarState.KEYGUARD; -import static com.android.systemui.statusbar.phone.StatusBar.DEBUG_MEDIA_FAKE_ARTWORK; -import static com.android.systemui.statusbar.phone.StatusBar.ENABLE_LOCKSCREEN_WALLPAPER; -import static com.android.systemui.statusbar.phone.StatusBar.SHOW_LOCKSCREEN_MEDIA_ARTWORK; +import static com.android.systemui.statusbar.phone.CentralSurfaces.DEBUG_MEDIA_FAKE_ARTWORK; +import static com.android.systemui.statusbar.phone.CentralSurfaces.ENABLE_LOCKSCREEN_WALLPAPER; +import static com.android.systemui.statusbar.phone.CentralSurfaces.SHOW_LOCKSCREEN_MEDIA_ARTWORK; import android.annotation.MainThread; import android.annotation.NonNull; @@ -55,7 +55,7 @@ import com.android.systemui.media.MediaData; import com.android.systemui.media.MediaDataManager; import com.android.systemui.media.SmartspaceMediaData; import com.android.systemui.plugins.statusbar.StatusBarStateController; -import com.android.systemui.statusbar.dagger.StatusBarModule; +import com.android.systemui.statusbar.dagger.CentralSurfacesModule; import com.android.systemui.statusbar.notification.NotifPipelineFlags; import com.android.systemui.statusbar.notification.NotificationEntryListener; import com.android.systemui.statusbar.notification.NotificationEntryManager; @@ -66,11 +66,11 @@ import com.android.systemui.statusbar.notification.collection.notifcollection.Di import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener; import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; import com.android.systemui.statusbar.phone.BiometricUnlockController; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.LockscreenWallpaper; import com.android.systemui.statusbar.phone.ScrimController; import com.android.systemui.statusbar.phone.ScrimState; -import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.util.Utils; import com.android.systemui.util.concurrency.DelayableExecutor; @@ -131,7 +131,7 @@ public class NotificationMediaManager implements Dumpable { private final Context mContext; private final ArrayList mMediaListeners; - private final Lazy> mStatusBarOptionalLazy; + private final Lazy> mCentralSurfacesOptionalLazy; private final MediaArtworkProcessor mMediaArtworkProcessor; private final Set> mProcessArtworkTasks = new ArraySet<>(); @@ -172,11 +172,11 @@ public class NotificationMediaManager implements Dumpable { }; /** - * Injected constructor. See {@link StatusBarModule}. + * Injected constructor. See {@link CentralSurfacesModule}. */ public NotificationMediaManager( Context context, - Lazy> statusBarOptionalLazy, + Lazy> centralSurfacesOptionalLazy, Lazy notificationShadeWindowController, NotificationVisibilityProvider visibilityProvider, NotificationEntryManager notificationEntryManager, @@ -193,7 +193,7 @@ public class NotificationMediaManager implements Dumpable { mKeyguardBypassController = keyguardBypassController; mMediaListeners = new ArrayList<>(); // TODO: use KeyguardStateController#isOccluded to remove this dependency - mStatusBarOptionalLazy = statusBarOptionalLazy; + mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy; mNotificationShadeWindowController = notificationShadeWindowController; mVisibilityProvider = visibilityProvider; mEntryManager = notificationEntryManager; @@ -575,7 +575,7 @@ public class NotificationMediaManager implements Dumpable { * Refresh or remove lockscreen artwork from media metadata or the lockscreen wallpaper. */ public void updateMediaMetaData(boolean metaDataChanged, boolean allowEnterAnimation) { - Trace.beginSection("StatusBar#updateMediaMetaData"); + Trace.beginSection("CentralSurfaces#updateMediaMetaData"); if (!SHOW_LOCKSCREEN_MEDIA_ARTWORK) { Trace.endSection(); return; @@ -653,7 +653,8 @@ public class NotificationMediaManager implements Dumpable { NotificationShadeWindowController windowController = mNotificationShadeWindowController.get(); boolean hideBecauseOccluded = - mStatusBarOptionalLazy.get().map(StatusBar::isOccluded).orElse(false); + mCentralSurfacesOptionalLazy.get() + .map(CentralSurfaces::isOccluded).orElse(false); final boolean hasArtwork = artworkDrawable != null; mColorExtractor.setHasMediaArtwork(hasMediaArtwork); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationPresenter.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationPresenter.java index 17bf346fa22b..3b3b5a2d05f9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationPresenter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationPresenter.java @@ -19,7 +19,7 @@ import com.android.systemui.statusbar.notification.row.ActivatableNotificationVi import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; /** - * An abstraction of something that presents notifications, e.g. StatusBar. Contains methods + * An abstraction of something that presents notifications, e.g. CentralSurfaces. Contains methods * for both querying the state of the system (some modularised piece of functionality may * want to act differently based on e.g. whether the presenter is visible to the user or not) and * for affecting the state of the system (e.g. starting an intent, given that the presenter may diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java index 2b5453a56434..94a6d3e99842 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java @@ -55,7 +55,7 @@ import com.android.systemui.R; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dump.DumpManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; -import com.android.systemui.statusbar.dagger.StatusBarDependenciesModule; +import com.android.systemui.statusbar.dagger.CentralSurfacesDependenciesModule; import com.android.systemui.statusbar.notification.NotifPipelineFlags; import com.android.systemui.statusbar.notification.NotificationEntryListener; import com.android.systemui.statusbar.notification.NotificationEntryManager; @@ -64,7 +64,7 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry. import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; import com.android.systemui.statusbar.notification.logging.NotificationLogger; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.policy.RemoteInputUriController; import com.android.systemui.statusbar.policy.RemoteInputView; import com.android.systemui.util.DumpUtilsKt; @@ -103,7 +103,7 @@ public class NotificationRemoteInputManager implements Dumpable { private final Handler mMainHandler; private final ActionClickLogger mLogger; - private final Lazy> mStatusBarOptionalLazy; + private final Lazy> mCentralSurfacesOptionalLazy; protected final Context mContext; protected final NotifPipelineFlags mNotifPipelineFlags; @@ -125,8 +125,8 @@ public class NotificationRemoteInputManager implements Dumpable { @Override public boolean onInteraction( View view, PendingIntent pendingIntent, RemoteViews.RemoteResponse response) { - mStatusBarOptionalLazy.get().ifPresent( - statusBar -> statusBar.wakeUpIfDozing( + mCentralSurfacesOptionalLazy.get().ifPresent( + centralSurfaces -> centralSurfaces.wakeUpIfDozing( SystemClock.uptimeMillis(), view, "NOTIFICATION_CLICK")); final NotificationEntry entry = getNotificationForParent(view.getParent()); @@ -253,7 +253,7 @@ public class NotificationRemoteInputManager implements Dumpable { }; /** - * Injected constructor. See {@link StatusBarDependenciesModule}. + * Injected constructor. See {@link CentralSurfacesDependenciesModule}. */ public NotificationRemoteInputManager( Context context, @@ -263,7 +263,7 @@ public class NotificationRemoteInputManager implements Dumpable { NotificationVisibilityProvider visibilityProvider, NotificationEntryManager notificationEntryManager, RemoteInputNotificationRebuilder rebuilder, - Lazy> statusBarOptionalLazy, + Lazy> centralSurfacesOptionalLazy, StatusBarStateController statusBarStateController, @Main Handler mainHandler, RemoteInputUriController remoteInputUriController, @@ -276,7 +276,7 @@ public class NotificationRemoteInputManager implements Dumpable { mSmartReplyController = smartReplyController; mVisibilityProvider = visibilityProvider; mEntryManager = notificationEntryManager; - mStatusBarOptionalLazy = statusBarOptionalLazy; + mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy; mMainHandler = mainHandler; mLogger = logger; mBarService = IStatusBarService.Stub.asInterface( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java index 3f101bb7cfd8..054543c7d2b1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java @@ -32,7 +32,7 @@ import com.android.systemui.R; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.plugins.statusbar.StatusBarStateController; -import com.android.systemui.statusbar.dagger.StatusBarModule; +import com.android.systemui.statusbar.dagger.CentralSurfacesModule; import com.android.systemui.statusbar.notification.AssistantFeedbackController; import com.android.systemui.statusbar.notification.DynamicChildBindController; import com.android.systemui.statusbar.notification.DynamicPrivacyController; @@ -113,7 +113,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle private boolean mIsHandleDynamicPrivacyChangeScheduled; /** - * Injected constructor. See {@link StatusBarModule}. + * Injected constructor. See {@link CentralSurfacesModule}. */ public NotificationViewHierarchyManager( Context context, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateController.java b/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateController.java index 2e1762a26b7e..78077386179a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateController.java @@ -20,17 +20,17 @@ import android.view.View; import com.android.systemui.plugins.qs.QS; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; /** * Calculates and moves the QS frame vertically. */ public abstract class QsFrameTranslateController { - protected StatusBar mStatusBar; + protected CentralSurfaces mCentralSurfaces; - public QsFrameTranslateController(StatusBar statusBar) { - mStatusBar = statusBar; + public QsFrameTranslateController(CentralSurfaces centralSurfaces) { + mCentralSurfaces = centralSurfaces; } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateImpl.java index c15679709c3d..33e224579bef 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateImpl.java @@ -21,7 +21,7 @@ import android.view.View; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.plugins.qs.QS; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import javax.inject.Inject; @@ -32,8 +32,8 @@ import javax.inject.Inject; public class QsFrameTranslateImpl extends QsFrameTranslateController { @Inject - public QsFrameTranslateImpl(StatusBar statusBar) { - super(statusBar); + public QsFrameTranslateImpl(CentralSurfaces centralSurfaces) { + super(centralSurfaces); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java b/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java index 4ad01aab98a7..058edda20971 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java @@ -25,7 +25,7 @@ import com.android.internal.statusbar.IStatusBarService; import com.android.internal.statusbar.NotificationVisibility; import com.android.systemui.Dumpable; import com.android.systemui.dump.DumpManager; -import com.android.systemui.statusbar.dagger.StatusBarModule; +import com.android.systemui.statusbar.dagger.CentralSurfacesModule; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; @@ -45,7 +45,7 @@ public class SmartReplyController implements Dumpable { private Callback mCallback; /** - * Injected constructor. See {@link StatusBarModule}. + * Injected constructor. See {@link CentralSurfacesModule}. */ public SmartReplyController( DumpManager dumpManager, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java index 02870a382056..2763bd711338 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java @@ -420,8 +420,9 @@ public class StatusBarStateControllerImpl implements * notified before unranked, and we will sort ranked listeners from low to high * * @deprecated This method exists only to solve latent inter-dependencies from refactoring - * StatusBarState out of StatusBar.java. Any new listeners should be built not to need ranking - * (i.e., they are non-dependent on the order of operations of StatusBarState listeners). + * StatusBarState out of CentralSurfaces.java. Any new listeners should be built not to need + * ranking (i.e., they are non-dependent on the order of operations of StatusBarState + * listeners). */ @Deprecated @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SysuiStatusBarStateController.java b/packages/SystemUI/src/com/android/systemui/statusbar/SysuiStatusBarStateController.java index f0b2c2d54dbe..2b3190159ecd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/SysuiStatusBarStateController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/SysuiStatusBarStateController.java @@ -25,7 +25,7 @@ import android.view.WindowInsetsController.Appearance; import android.view.WindowInsetsController.Behavior; import com.android.systemui.plugins.statusbar.StatusBarStateController; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import java.lang.annotation.Retention; @@ -51,8 +51,9 @@ public interface SysuiStatusBarStateController extends StatusBarStateController * notified before unranked, and we will sort ranked listeners from low to high * * @deprecated This method exists only to solve latent inter-dependencies from refactoring - * StatusBarState out of StatusBar.java. Any new listeners should be built not to need ranking - * (i.e., they are non-dependent on the order of operations of StatusBarState listeners). + * StatusBarState out of CentralSurfaces.java. Any new listeners should be built not to need + * ranking (i.e., they are non-dependent on the order of operations of StatusBarState + * listeners). */ @Deprecated void addCallback(StateListener listener, int rank); @@ -91,7 +92,7 @@ public interface SysuiStatusBarStateController extends StatusBarStateController int getCurrentOrUpcomingState(); /** - * Update the dozing state from {@link StatusBar}'s perspective + * Update the dozing state from {@link CentralSurfaces}'s perspective * @param isDozing well, are we dozing? * @return {@code true} if the state changed, else {@code false} */ @@ -116,7 +117,7 @@ public interface SysuiStatusBarStateController extends StatusBarStateController void setAndInstrumentDozeAmount(View view, float dozeAmount, boolean animated); /** - * Update the expanded state from {@link StatusBar}'s perspective + * Update the expanded state from {@link CentralSurfaces}'s perspective * @param expanded are we expanded? * @return {@code true} if the state changed, else {@code false} */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileSignalController.java index fe5a69996eb7..41d2b655d805 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileSignalController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileSignalController.java @@ -843,7 +843,7 @@ public class MobileSignalController extends SignalController> centralSurfacesOptionalLazy, + StatusBarStateController statusBarStateController, + Handler mainHandler, + RemoteInputUriController remoteInputUriController, + NotificationClickNotifier clickNotifier, + ActionClickLogger actionClickLogger, + DumpManager dumpManager) { + return new NotificationRemoteInputManager( + context, + notifPipelineFlags, + lockscreenUserManager, + smartReplyController, + visibilityProvider, + notificationEntryManager, + rebuilder, + centralSurfacesOptionalLazy, + statusBarStateController, + mainHandler, + remoteInputUriController, + clickNotifier, + actionClickLogger, + dumpManager); + } + + /** */ + @SysUISingleton + @Provides + static NotificationMediaManager provideNotificationMediaManager( + Context context, + Lazy> centralSurfacesOptionalLazy, + Lazy notificationShadeWindowController, + NotificationVisibilityProvider visibilityProvider, + NotificationEntryManager notificationEntryManager, + MediaArtworkProcessor mediaArtworkProcessor, + KeyguardBypassController keyguardBypassController, + NotifPipeline notifPipeline, + NotifCollection notifCollection, + NotifPipelineFlags notifPipelineFlags, + @Main DelayableExecutor mainExecutor, + MediaDataManager mediaDataManager, + DumpManager dumpManager) { + return new NotificationMediaManager( + context, + centralSurfacesOptionalLazy, + notificationShadeWindowController, + visibilityProvider, + notificationEntryManager, + mediaArtworkProcessor, + keyguardBypassController, + notifPipeline, + notifCollection, + notifPipelineFlags, + mainExecutor, + mediaDataManager, + dumpManager); + } + + /** */ + @SysUISingleton + @Provides + static SmartReplyController provideSmartReplyController( + DumpManager dumpManager, + NotificationVisibilityProvider visibilityProvider, + IStatusBarService statusBarService, + NotificationClickNotifier clickNotifier) { + return new SmartReplyController( + dumpManager, + visibilityProvider, + statusBarService, + clickNotifier); + } + + + /** */ + @Binds + NotificationRemoteInputManager.Callback provideNotificationRemoteInputManagerCallback( + StatusBarRemoteInputCallback callbackImpl); + + /** */ + @SysUISingleton + @Provides + static NotificationViewHierarchyManager provideNotificationViewHierarchyManager( + Context context, + @Main Handler mainHandler, + FeatureFlags featureFlags, + NotificationLockscreenUserManager notificationLockscreenUserManager, + NotificationGroupManagerLegacy groupManager, + VisualStabilityManager visualStabilityManager, + StatusBarStateController statusBarStateController, + NotificationEntryManager notificationEntryManager, + KeyguardBypassController bypassController, + Optional bubblesOptional, + DynamicPrivacyController privacyController, + DynamicChildBindController dynamicChildBindController, + LowPriorityInflationHelper lowPriorityInflationHelper, + AssistantFeedbackController assistantFeedbackController, + NotifPipelineFlags notifPipelineFlags, + KeyguardUpdateMonitor keyguardUpdateMonitor, + KeyguardStateController keyguardStateController) { + return new NotificationViewHierarchyManager( + context, + mainHandler, + featureFlags, + notificationLockscreenUserManager, + groupManager, + visualStabilityManager, + statusBarStateController, + notificationEntryManager, + bypassController, + bubblesOptional, + privacyController, + dynamicChildBindController, + lowPriorityInflationHelper, + assistantFeedbackController, + notifPipelineFlags, + keyguardUpdateMonitor, + keyguardStateController); + } + + /** + * Provides our instance of CommandQueue which is considered optional. + */ + @Provides + @SysUISingleton + static CommandQueue provideCommandQueue( + Context context, + ProtoTracer protoTracer, + CommandRegistry registry) { + return new CommandQueue(context, protoTracer, registry); + } + + /** + */ + @Binds + ManagedProfileController provideManagedProfileController( + ManagedProfileControllerImpl controllerImpl); + + /** + */ + @Binds + SysuiStatusBarStateController providesSysuiStatusBarStateController( + StatusBarStateControllerImpl statusBarStateControllerImpl); + + /** + */ + @Binds + StatusBarIconController provideStatusBarIconController( + StatusBarIconControllerImpl controllerImpl); + + /** + */ + @Provides + @SysUISingleton + static OngoingCallController provideOngoingCallController( + Context context, + CommonNotifCollection notifCollection, + SystemClock systemClock, + ActivityStarter activityStarter, + @Main Executor mainExecutor, + IActivityManager iActivityManager, + OngoingCallLogger logger, + DumpManager dumpManager, + StatusBarWindowController statusBarWindowController, + SwipeStatusBarAwayGestureHandler swipeStatusBarAwayGestureHandler, + StatusBarStateController statusBarStateController, + OngoingCallFlags ongoingCallFlags) { + + boolean ongoingCallInImmersiveEnabled = ongoingCallFlags.isInImmersiveEnabled(); + Optional windowController = + ongoingCallInImmersiveEnabled + ? Optional.of(statusBarWindowController) + : Optional.empty(); + Optional gestureHandler = + ongoingCallInImmersiveEnabled + ? Optional.of(swipeStatusBarAwayGestureHandler) + : Optional.empty(); + OngoingCallController ongoingCallController = + new OngoingCallController( + context, + notifCollection, + ongoingCallFlags, + systemClock, + activityStarter, + mainExecutor, + iActivityManager, + logger, + dumpManager, + windowController, + gestureHandler, + statusBarStateController); + ongoingCallController.init(); + return ongoingCallController; + } + + /** */ + @Binds + QSCarrierGroupController.SlotIndexResolver provideSlotIndexResolver( + QSCarrierGroupController.SubscriptionManagerSlotIndexResolver impl); + + /** + */ + @Provides + @SysUISingleton + static ActivityLaunchAnimator provideActivityLaunchAnimator() { + return new ActivityLaunchAnimator(); + } + + /** + */ + @Provides + @SysUISingleton + static DialogLaunchAnimator provideDialogLaunchAnimator(IDreamManager dreamManager) { + return new DialogLaunchAnimator(dreamManager); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesModule.java new file mode 100644 index 000000000000..99d4b2e525d1 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesModule.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.dagger; + +import com.android.systemui.statusbar.notification.dagger.NotificationsModule; +import com.android.systemui.statusbar.notification.row.NotificationRowModule; +import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneModule; + +import dagger.Module; + +/** */ +@Module(includes = {StatusBarPhoneModule.class, CentralSurfacesDependenciesModule.class, + NotificationsModule.class, NotificationRowModule.class}) +public interface CentralSurfacesModule { +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StartCentralSurfacesModule.kt b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StartCentralSurfacesModule.kt new file mode 100644 index 000000000000..fe55dea7333a --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StartCentralSurfacesModule.kt @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.dagger + +import com.android.systemui.CoreStartable +import com.android.systemui.statusbar.phone.CentralSurfaces +import dagger.Binds +import dagger.Module +import dagger.multibindings.ClassKey +import dagger.multibindings.IntoMap + +@Module +interface StartCentralSurfacesModule { + /** Start the CentralSurfaces */ + @Binds + @IntoMap + @ClassKey(CentralSurfaces::class) + abstract fun bindsCentralSurfaces(centralSurfaces: CentralSurfaces): CoreStartable +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StartStatusBarModule.kt b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StartStatusBarModule.kt deleted file mode 100644 index 46c1abb859b3..000000000000 --- a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StartStatusBarModule.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.statusbar.dagger - -import com.android.systemui.CoreStartable -import com.android.systemui.statusbar.phone.StatusBar -import dagger.Binds -import dagger.Module -import dagger.multibindings.ClassKey -import dagger.multibindings.IntoMap - -@Module -interface StartStatusBarModule { - /** Start the StatusBar */ - @Binds - @IntoMap - @ClassKey(StatusBar::class) - abstract fun bindsStatusBar(statusBar: StatusBar): CoreStartable -} \ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarDependenciesModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarDependenciesModule.java deleted file mode 100644 index 364f36a388c6..000000000000 --- a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarDependenciesModule.java +++ /dev/null @@ -1,321 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.statusbar.dagger; - -import android.app.IActivityManager; -import android.content.Context; -import android.os.Handler; -import android.service.dreams.IDreamManager; - -import com.android.internal.statusbar.IStatusBarService; -import com.android.keyguard.KeyguardUpdateMonitor; -import com.android.systemui.animation.ActivityLaunchAnimator; -import com.android.systemui.animation.DialogLaunchAnimator; -import com.android.systemui.dagger.SysUISingleton; -import com.android.systemui.dagger.qualifiers.Main; -import com.android.systemui.dump.DumpManager; -import com.android.systemui.flags.FeatureFlags; -import com.android.systemui.media.MediaDataManager; -import com.android.systemui.plugins.ActivityStarter; -import com.android.systemui.plugins.statusbar.StatusBarStateController; -import com.android.systemui.qs.carrier.QSCarrierGroupController; -import com.android.systemui.statusbar.ActionClickLogger; -import com.android.systemui.statusbar.CommandQueue; -import com.android.systemui.statusbar.MediaArtworkProcessor; -import com.android.systemui.statusbar.NotificationClickNotifier; -import com.android.systemui.statusbar.NotificationLockscreenUserManager; -import com.android.systemui.statusbar.NotificationMediaManager; -import com.android.systemui.statusbar.NotificationRemoteInputManager; -import com.android.systemui.statusbar.NotificationShadeWindowController; -import com.android.systemui.statusbar.NotificationViewHierarchyManager; -import com.android.systemui.statusbar.RemoteInputNotificationRebuilder; -import com.android.systemui.statusbar.SmartReplyController; -import com.android.systemui.statusbar.StatusBarStateControllerImpl; -import com.android.systemui.statusbar.SysuiStatusBarStateController; -import com.android.systemui.statusbar.commandline.CommandRegistry; -import com.android.systemui.statusbar.gesture.SwipeStatusBarAwayGestureHandler; -import com.android.systemui.statusbar.notification.AssistantFeedbackController; -import com.android.systemui.statusbar.notification.DynamicChildBindController; -import com.android.systemui.statusbar.notification.DynamicPrivacyController; -import com.android.systemui.statusbar.notification.NotifPipelineFlags; -import com.android.systemui.statusbar.notification.NotificationEntryManager; -import com.android.systemui.statusbar.notification.collection.NotifCollection; -import com.android.systemui.statusbar.notification.collection.NotifPipeline; -import com.android.systemui.statusbar.notification.collection.legacy.LowPriorityInflationHelper; -import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy; -import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager; -import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; -import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; -import com.android.systemui.statusbar.phone.KeyguardBypassController; -import com.android.systemui.statusbar.phone.ManagedProfileController; -import com.android.systemui.statusbar.phone.ManagedProfileControllerImpl; -import com.android.systemui.statusbar.phone.StatusBar; -import com.android.systemui.statusbar.phone.StatusBarIconController; -import com.android.systemui.statusbar.phone.StatusBarIconControllerImpl; -import com.android.systemui.statusbar.phone.StatusBarRemoteInputCallback; -import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallController; -import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallFlags; -import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallLogger; -import com.android.systemui.statusbar.policy.KeyguardStateController; -import com.android.systemui.statusbar.policy.RemoteInputUriController; -import com.android.systemui.statusbar.window.StatusBarWindowController; -import com.android.systemui.tracing.ProtoTracer; -import com.android.systemui.util.concurrency.DelayableExecutor; -import com.android.systemui.util.time.SystemClock; -import com.android.wm.shell.bubbles.Bubbles; - -import java.util.Optional; -import java.util.concurrent.Executor; - -import dagger.Binds; -import dagger.Lazy; -import dagger.Module; -import dagger.Provides; - -/** - * This module provides instances needed to construct {@link StatusBar}. These are moved to this - * separate from {@link StatusBarModule} module so that components that wish to build their own - * version of StatusBar can include just dependencies, without injecting StatusBar itself. - */ -@Module -public interface StatusBarDependenciesModule { - /** */ - @SysUISingleton - @Provides - static NotificationRemoteInputManager provideNotificationRemoteInputManager( - Context context, - NotifPipelineFlags notifPipelineFlags, - NotificationLockscreenUserManager lockscreenUserManager, - SmartReplyController smartReplyController, - NotificationVisibilityProvider visibilityProvider, - NotificationEntryManager notificationEntryManager, - RemoteInputNotificationRebuilder rebuilder, - Lazy> statusBarOptionalLazy, - StatusBarStateController statusBarStateController, - Handler mainHandler, - RemoteInputUriController remoteInputUriController, - NotificationClickNotifier clickNotifier, - ActionClickLogger actionClickLogger, - DumpManager dumpManager) { - return new NotificationRemoteInputManager( - context, - notifPipelineFlags, - lockscreenUserManager, - smartReplyController, - visibilityProvider, - notificationEntryManager, - rebuilder, - statusBarOptionalLazy, - statusBarStateController, - mainHandler, - remoteInputUriController, - clickNotifier, - actionClickLogger, - dumpManager); - } - - /** */ - @SysUISingleton - @Provides - static NotificationMediaManager provideNotificationMediaManager( - Context context, - Lazy> statusBarOptionalLazy, - Lazy notificationShadeWindowController, - NotificationVisibilityProvider visibilityProvider, - NotificationEntryManager notificationEntryManager, - MediaArtworkProcessor mediaArtworkProcessor, - KeyguardBypassController keyguardBypassController, - NotifPipeline notifPipeline, - NotifCollection notifCollection, - NotifPipelineFlags notifPipelineFlags, - @Main DelayableExecutor mainExecutor, - MediaDataManager mediaDataManager, - DumpManager dumpManager) { - return new NotificationMediaManager( - context, - statusBarOptionalLazy, - notificationShadeWindowController, - visibilityProvider, - notificationEntryManager, - mediaArtworkProcessor, - keyguardBypassController, - notifPipeline, - notifCollection, - notifPipelineFlags, - mainExecutor, - mediaDataManager, - dumpManager); - } - - /** */ - @SysUISingleton - @Provides - static SmartReplyController provideSmartReplyController( - DumpManager dumpManager, - NotificationVisibilityProvider visibilityProvider, - IStatusBarService statusBarService, - NotificationClickNotifier clickNotifier) { - return new SmartReplyController( - dumpManager, - visibilityProvider, - statusBarService, - clickNotifier); - } - - - /** */ - @Binds - NotificationRemoteInputManager.Callback provideNotificationRemoteInputManagerCallback( - StatusBarRemoteInputCallback callbackImpl); - - /** */ - @SysUISingleton - @Provides - static NotificationViewHierarchyManager provideNotificationViewHierarchyManager( - Context context, - @Main Handler mainHandler, - FeatureFlags featureFlags, - NotificationLockscreenUserManager notificationLockscreenUserManager, - NotificationGroupManagerLegacy groupManager, - VisualStabilityManager visualStabilityManager, - StatusBarStateController statusBarStateController, - NotificationEntryManager notificationEntryManager, - KeyguardBypassController bypassController, - Optional bubblesOptional, - DynamicPrivacyController privacyController, - DynamicChildBindController dynamicChildBindController, - LowPriorityInflationHelper lowPriorityInflationHelper, - AssistantFeedbackController assistantFeedbackController, - NotifPipelineFlags notifPipelineFlags, - KeyguardUpdateMonitor keyguardUpdateMonitor, - KeyguardStateController keyguardStateController) { - return new NotificationViewHierarchyManager( - context, - mainHandler, - featureFlags, - notificationLockscreenUserManager, - groupManager, - visualStabilityManager, - statusBarStateController, - notificationEntryManager, - bypassController, - bubblesOptional, - privacyController, - dynamicChildBindController, - lowPriorityInflationHelper, - assistantFeedbackController, - notifPipelineFlags, - keyguardUpdateMonitor, - keyguardStateController); - } - - /** - * Provides our instance of CommandQueue which is considered optional. - */ - @Provides - @SysUISingleton - static CommandQueue provideCommandQueue( - Context context, - ProtoTracer protoTracer, - CommandRegistry registry) { - return new CommandQueue(context, protoTracer, registry); - } - - /** - */ - @Binds - ManagedProfileController provideManagedProfileController( - ManagedProfileControllerImpl controllerImpl); - - /** - */ - @Binds - SysuiStatusBarStateController providesSysuiStatusBarStateController( - StatusBarStateControllerImpl statusBarStateControllerImpl); - - /** - */ - @Binds - StatusBarIconController provideStatusBarIconController( - StatusBarIconControllerImpl controllerImpl); - - /** - */ - @Provides - @SysUISingleton - static OngoingCallController provideOngoingCallController( - Context context, - CommonNotifCollection notifCollection, - SystemClock systemClock, - ActivityStarter activityStarter, - @Main Executor mainExecutor, - IActivityManager iActivityManager, - OngoingCallLogger logger, - DumpManager dumpManager, - StatusBarWindowController statusBarWindowController, - SwipeStatusBarAwayGestureHandler swipeStatusBarAwayGestureHandler, - StatusBarStateController statusBarStateController, - OngoingCallFlags ongoingCallFlags) { - - boolean ongoingCallInImmersiveEnabled = ongoingCallFlags.isInImmersiveEnabled(); - Optional windowController = - ongoingCallInImmersiveEnabled - ? Optional.of(statusBarWindowController) - : Optional.empty(); - Optional gestureHandler = - ongoingCallInImmersiveEnabled - ? Optional.of(swipeStatusBarAwayGestureHandler) - : Optional.empty(); - OngoingCallController ongoingCallController = - new OngoingCallController( - context, - notifCollection, - ongoingCallFlags, - systemClock, - activityStarter, - mainExecutor, - iActivityManager, - logger, - dumpManager, - windowController, - gestureHandler, - statusBarStateController); - ongoingCallController.init(); - return ongoingCallController; - } - - /** */ - @Binds - QSCarrierGroupController.SlotIndexResolver provideSlotIndexResolver( - QSCarrierGroupController.SubscriptionManagerSlotIndexResolver impl); - - /** - */ - @Provides - @SysUISingleton - static ActivityLaunchAnimator provideActivityLaunchAnimator() { - return new ActivityLaunchAnimator(); - } - - /** - */ - @Provides - @SysUISingleton - static DialogLaunchAnimator provideDialogLaunchAnimator(IDreamManager dreamManager) { - return new DialogLaunchAnimator(dreamManager); - } -} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarModule.java deleted file mode 100644 index ad5ef2043ccd..000000000000 --- a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarModule.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.statusbar.dagger; - -import com.android.systemui.statusbar.notification.dagger.NotificationsModule; -import com.android.systemui.statusbar.notification.row.NotificationRowModule; -import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneModule; - -import dagger.Module; - -/** */ -@Module(includes = {StatusBarPhoneModule.class, StatusBarDependenciesModule.class, - NotificationsModule.class, NotificationRowModule.class}) -public interface StatusBarModule { -} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationClicker.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationClicker.java index da706215863e..392145ad306a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationClicker.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationClicker.java @@ -24,7 +24,7 @@ import android.view.View; import com.android.systemui.DejankUtils; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.wm.shell.bubbles.Bubbles; import java.util.Optional; @@ -39,7 +39,7 @@ public final class NotificationClicker implements View.OnClickListener { private static final String TAG = "NotificationClicker"; private final NotificationClickerLogger mLogger; - private final Optional mStatusBarOptional; + private final Optional mCentralSurfacesOptional; private final Optional mBubblesOptional; private final NotificationActivityStarter mNotificationActivityStarter; @@ -53,11 +53,11 @@ public final class NotificationClicker implements View.OnClickListener { private NotificationClicker( NotificationClickerLogger logger, - Optional statusBarOptional, + Optional centralSurfacesOptional, Optional bubblesOptional, NotificationActivityStarter notificationActivityStarter) { mLogger = logger; - mStatusBarOptional = statusBarOptional; + mCentralSurfacesOptional = centralSurfacesOptional; mBubblesOptional = bubblesOptional; mNotificationActivityStarter = notificationActivityStarter; } @@ -69,7 +69,7 @@ public final class NotificationClicker implements View.OnClickListener { return; } - mStatusBarOptional.ifPresent(statusBar -> statusBar.wakeUpIfDozing( + mCentralSurfacesOptional.ifPresent(centralSurfaces -> centralSurfaces.wakeUpIfDozing( SystemClock.uptimeMillis(), v, "NOTIFICATION_CLICK")); final ExpandableNotificationRow row = (ExpandableNotificationRow) v; @@ -137,13 +137,13 @@ public final class NotificationClicker implements View.OnClickListener { /** Builds an instance. */ public NotificationClicker build( - Optional statusBarOptional, + Optional centralSurfacesOptional, Optional bubblesOptional, NotificationActivityStarter notificationActivityStarter ) { return new NotificationClicker( mLogger, - statusBarOptional, + centralSurfacesOptional, bubblesOptional, notificationActivityStarter); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java index 1d96de733eb6..ac5beece880e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java @@ -955,7 +955,7 @@ public class NotificationEntryManager implements Trace.endSection(); } - /** dump the current active notification list. Called from StatusBar */ + /** dump the current active notification list. Called from CentralSurfaces */ public void dump(PrintWriter pw, String indent) { pw.println("NotificationEntryManager (Legacy)"); int filteredLen = mSortedAndFiltered.size(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorController.kt index 92073669e1b5..2c1296f34a42 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorController.kt @@ -8,14 +8,14 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.statusbar.notification.stack.NotificationListContainer import com.android.systemui.statusbar.phone.HeadsUpManagerPhone import com.android.systemui.statusbar.phone.NotificationShadeWindowViewController -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent import com.android.systemui.statusbar.policy.HeadsUpUtil import javax.inject.Inject import kotlin.math.ceil import kotlin.math.max /** A provider of [NotificationLaunchAnimatorController]. */ -@StatusBarComponent.StatusBarScope +@CentralSurfacesComponent.CentralSurfacesScope class NotificationLaunchAnimatorControllerProvider @Inject constructor( private val notificationShadeWindowViewController: NotificationShadeWindowViewController, private val notificationListContainer: NotificationListContainer, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/TargetSdkResolver.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/TargetSdkResolver.kt index 5dc0dcc4d717..c71eade79cdf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/TargetSdkResolver.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/TargetSdkResolver.kt @@ -23,7 +23,7 @@ import android.util.Log import com.android.systemui.dagger.SysUISingleton import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener -import com.android.systemui.statusbar.phone.StatusBar +import com.android.systemui.statusbar.phone.CentralSurfaces import javax.inject.Inject @SysUISingleton @@ -39,7 +39,7 @@ class TargetSdkResolver @Inject constructor( } private fun resolveNotificationSdk(sbn: StatusBarNotification): Int { - val pmUser = StatusBar.getPackageManagerForUser(context, sbn.user.identifier) + val pmUser = CentralSurfaces.getPackageManagerForUser(context, sbn.user.identifier) var targetSdk = 0 // Extract target SDK version. try { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/legacy/LegacyNotificationPresenterExtensions.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/legacy/LegacyNotificationPresenterExtensions.java index 4ee08ed4899f..bdbb0eb48e8a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/legacy/LegacyNotificationPresenterExtensions.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/legacy/LegacyNotificationPresenterExtensions.java @@ -16,7 +16,7 @@ package com.android.systemui.statusbar.notification.collection.legacy; -import static com.android.systemui.statusbar.phone.StatusBar.SPEW; +import static com.android.systemui.statusbar.phone.CentralSurfaces.SPEW; import android.service.notification.StatusBarNotification; import android.util.Log; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/NotifPanelEventSource.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/NotifPanelEventSource.kt index 920d3c4cbe55..470737e3b772 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/NotifPanelEventSource.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/NotifPanelEventSource.kt @@ -17,8 +17,8 @@ package com.android.systemui.statusbar.notification.collection.render import com.android.systemui.dagger.SysUISingleton import com.android.systemui.statusbar.phone.NotificationPanelViewController -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent.StatusBarScope +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent.CentralSurfacesScope import com.android.systemui.util.ListenerSet import dagger.Binds import dagger.Module @@ -67,18 +67,18 @@ object StatusBarNotifPanelEventSourceModule { @JvmStatic @Provides @IntoSet - @StatusBarScope + @CentralSurfacesScope fun bindStartable( manager: NotifPanelEventSourceManager, notifPanelController: NotificationPanelViewController - ): StatusBarComponent.Startable = + ): CentralSurfacesComponent.Startable = EventSourceStatusBarStartableImpl(manager, notifPanelController) } /** - * Management layer that bridges [SysUiSingleton] and [StatusBarScope]. Necessary because code that - * wants to listen to [NotifPanelEventSource] lives in [SysUiSingleton], but the events themselves - * come from [NotificationPanelViewController] in [StatusBarScope]. + * Management layer that bridges [SysUiSingleton] and [CentralSurfacesScope]. Necessary because code + * that wants to listen to [NotifPanelEventSource] lives in [SysUiSingleton], but the events + * themselves come from [NotificationPanelViewController] in [CentralSurfacesScope]. */ interface NotifPanelEventSourceManager : NotifPanelEventSource { var eventSource: NotifPanelEventSource? @@ -116,7 +116,7 @@ private class NotifPanelEventSourceManagerImpl private class EventSourceStatusBarStartableImpl( private val manager: NotifPanelEventSourceManager, private val notifPanelController: NotificationPanelViewController -) : StatusBarComponent.Startable { +) : CentralSurfacesComponent.Startable { override fun start() { manager.eventSource = notifPanelController diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java index 1576f96debc6..51bbf1c80478 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java @@ -86,7 +86,7 @@ import com.android.systemui.statusbar.notification.stack.NotificationSectionsMan import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.ShadeController; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.policy.HeadsUpManager; import com.android.systemui.util.leak.LeakDetector; import com.android.systemui.wmshell.BubblesManager; @@ -149,7 +149,7 @@ public interface NotificationsModule { @Provides static NotificationGutsManager provideNotificationGutsManager( Context context, - Lazy> statusBarOptionalLazy, + Lazy> centralSurfacesOptionalLazy, @Main Handler mainHandler, @Background Handler bgHandler, AccessibilityManager accessibilityManager, @@ -169,7 +169,7 @@ public interface NotificationsModule { DumpManager dumpManager) { return new NotificationGutsManager( context, - statusBarOptionalLazy, + centralSurfacesOptionalLazy, mainHandler, bgHandler, accessibilityManager, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/init/NotificationsControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/init/NotificationsControllerImpl.kt index 5926cf05f880..98f45fa070c9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/init/NotificationsControllerImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/init/NotificationsControllerImpl.kt @@ -44,7 +44,7 @@ import com.android.systemui.statusbar.notification.interruption.HeadsUpViewBinde import com.android.systemui.statusbar.notification.row.NotifBindPipelineInitializer import com.android.systemui.statusbar.notification.stack.NotificationListContainer import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper -import com.android.systemui.statusbar.phone.StatusBar +import com.android.systemui.statusbar.phone.CentralSurfaces import com.android.systemui.statusbar.policy.DeviceProvisionedController import com.android.systemui.statusbar.policy.HeadsUpManager import com.android.systemui.statusbar.policy.RemoteInputUriController @@ -64,7 +64,7 @@ import javax.inject.Inject */ @SysUISingleton class NotificationsControllerImpl @Inject constructor( - private val statusBar: Lazy, + private val centralSurfaces: Lazy, private val notifPipelineFlags: NotifPipelineFlags, private val notificationListener: NotificationListener, private val entryManager: NotificationEntryManager, @@ -109,7 +109,7 @@ class NotificationsControllerImpl @Inject constructor( notificationRowBinder.setNotificationClicker( clickerBuilder.build( - Optional.of(statusBar.get()), bubblesOptional, notificationActivityStarter)) + Optional.of(centralSurfaces.get()), bubblesOptional, notificationActivityStarter)) notificationRowBinder.setUpWithPresenter( presenter, listContainer, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java index dc3941332f0b..9fbd5c39dedd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java @@ -468,7 +468,7 @@ public class NotificationLogger implements StateListener { } /** - * Called by StatusBar to notify the logger that the panel expansion has changed. + * Called by CentralSurfaces to notify the logger that the panel expansion has changed. * The panel may be showing any of the normal notification panel, the AOD, or the bouncer. * @param isExpanded True if the panel is expanded. */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index 1f7d93012e39..c237e1deeae3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -112,7 +112,7 @@ import com.android.systemui.statusbar.notification.stack.NotificationChildrenCon import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; import com.android.systemui.statusbar.notification.stack.SwipeableView; import com.android.systemui.statusbar.phone.KeyguardBypassController; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.policy.HeadsUpManager; import com.android.systemui.statusbar.policy.InflatedSmartReplyState; import com.android.systemui.statusbar.policy.dagger.RemoteInputViewSubcomponent; @@ -388,7 +388,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView } return false; } else { - PackageManager packageManager = StatusBar.getPackageManagerForUser( + PackageManager packageManager = CentralSurfaces.getPackageManagerForUser( context, sbn.getUser().getIdentifier()); Boolean isSystemNotification = null; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java index 1530e5238c67..4c693045bc88 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java @@ -47,7 +47,7 @@ import com.android.systemui.statusbar.notification.ConversationNotificationProce import com.android.systemui.statusbar.notification.InflationException; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.row.wrapper.NotificationViewWrapper; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.policy.InflatedSmartReplyState; import com.android.systemui.statusbar.policy.InflatedSmartReplyViewHolder; import com.android.systemui.statusbar.policy.SmartReplyStateInflater; @@ -841,7 +841,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder StatusBarNotification sbn = mEntry.getSbn(); final String ident = sbn.getPackageName() + "/0x" + Integer.toHexString(sbn.getId()); - Log.e(StatusBar.TAG, "couldn't inflate view for notification " + ident, e); + Log.e(CentralSurfaces.TAG, "couldn't inflate view for notification " + ident, e); if (mCallback != null) { mCallback.handleInflationException(mRow.getEntry(), new InflationException("Couldn't inflate contentViews" + e)); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java index 6d13024e5489..ebe6f03c44e1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java @@ -70,8 +70,8 @@ import com.android.systemui.statusbar.notification.collection.render.NotifGutsVi import com.android.systemui.statusbar.notification.dagger.NotificationsModule; import com.android.systemui.statusbar.notification.row.NotificationInfo.CheckSaveListener; import com.android.systemui.statusbar.notification.stack.NotificationListContainer; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.ShadeController; -import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.systemui.wmshell.BubblesManager; @@ -120,7 +120,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx @VisibleForTesting protected String mKeyToRemoveOnGutsClosed; - private final Lazy> mStatusBarOptionalLazy; + private final Lazy> mCentralSurfacesOptionalLazy; private final Handler mMainHandler; private final Handler mBgHandler; private final Optional mBubblesManagerOptional; @@ -139,7 +139,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx * Injected constructor. See {@link NotificationsModule}. */ public NotificationGutsManager(Context context, - Lazy> statusBarOptionalLazy, + Lazy> centralSurfacesOptionalLazy, @Main Handler mainHandler, @Background Handler bgHandler, AccessibilityManager accessibilityManager, @@ -158,7 +158,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx ShadeController shadeController, DumpManager dumpManager) { mContext = context; - mStatusBarOptionalLazy = statusBarOptionalLazy; + mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy; mMainHandler = mainHandler; mBgHandler = bgHandler; mAccessibilityManager = accessibilityManager; @@ -342,7 +342,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx } StatusBarNotification sbn = row.getEntry().getSbn(); UserHandle userHandle = sbn.getUser(); - PackageManager pmUser = StatusBar.getPackageManagerForUser(mContext, + PackageManager pmUser = CentralSurfaces.getPackageManagerForUser(mContext, userHandle.getIdentifier()); feedbackInfo.bindGuts(pmUser, sbn, row.getEntry(), row, mAssistantFeedbackController); @@ -363,7 +363,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx // Settings link is only valid for notifications that specify a non-system user NotificationInfo.OnSettingsClickListener onSettingsClick = null; UserHandle userHandle = sbn.getUser(); - PackageManager pmUser = StatusBar.getPackageManagerForUser( + PackageManager pmUser = CentralSurfaces.getPackageManagerForUser( mContext, userHandle.getIdentifier()); final NotificationInfo.OnAppSettingsClickListener onAppSettingsClick = (View v, Intent intent) -> { @@ -416,7 +416,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx // Settings link is only valid for notifications that specify a non-system user NotificationInfo.OnSettingsClickListener onSettingsClick = null; UserHandle userHandle = sbn.getUser(); - PackageManager pmUser = StatusBar.getPackageManagerForUser( + PackageManager pmUser = CentralSurfaces.getPackageManagerForUser( mContext, userHandle.getIdentifier()); if (!userHandle.equals(UserHandle.ALL) @@ -458,7 +458,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx // Settings link is only valid for notifications that specify a non-system user NotificationConversationInfo.OnSettingsClickListener onSettingsClick = null; UserHandle userHandle = sbn.getUser(); - PackageManager pmUser = StatusBar.getPackageManagerForUser( + PackageManager pmUser = CentralSurfaces.getPackageManagerForUser( mContext, userHandle.getIdentifier()); final NotificationConversationInfo.OnAppSettingsClickListener onAppSettingsClick = (View v, Intent intent) -> { @@ -571,11 +571,12 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx .setLeaveOpenOnKeyguardHide(true); } - Optional statusBarOptional = mStatusBarOptionalLazy.get(); - if (statusBarOptional.isPresent()) { + Optional centralSurfacesOptional = + mCentralSurfacesOptionalLazy.get(); + if (centralSurfacesOptional.isPresent()) { Runnable r = () -> mMainHandler.post( () -> openGutsInternal(view, x, y, menuItem)); - statusBarOptional.get().executeRunnableDismissingKeyguard( + centralSurfacesOptional.get().executeRunnableDismissingKeyguard( r, null /* cancelAction */, false /* dismissShade */, @@ -584,7 +585,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx return true; } /** - * When {@link StatusBar} doesn't exist, falling through to call + * When {@link CentralSurfaces} doesn't exist, falling through to call * {@link #openGutsInternal(View,int,int,NotificationMenuRowPlugin.MenuItem)}. */ } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/dagger/ExpandableNotificationRowComponent.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/dagger/ExpandableNotificationRowComponent.java index a12d0073ef57..1a7417a78186 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/dagger/ExpandableNotificationRowComponent.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/dagger/ExpandableNotificationRowComponent.java @@ -26,7 +26,7 @@ import com.android.systemui.statusbar.notification.row.ActivatableNotificationVi import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRowController; import com.android.systemui.statusbar.notification.stack.NotificationListContainer; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import dagger.Binds; import dagger.BindsInstance; @@ -100,7 +100,7 @@ public interface ExpandableNotificationRowComponent { // but since this field is used in the guts, it must be accurate. // Therefore we will only show the application label, or, failing that, the // package name. No substitutions. - PackageManager pmUser = StatusBar.getPackageManagerForUser( + PackageManager pmUser = CentralSurfaces.getPackageManagerForUser( context, statusBarNotification.getUser().getIdentifier()); final String pkg = statusBarNotification.getPackageName(); try { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/dagger/NotificationRowScope.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/dagger/NotificationRowScope.java index 4555b839a3f2..fa14123df11f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/dagger/NotificationRowScope.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/dagger/NotificationRowScope.java @@ -24,7 +24,7 @@ import java.lang.annotation.Retention; import javax.inject.Scope; /** - * Scope annotation for singleton items within the StatusBarComponent. + * Scope annotation for singleton items within the CentralSurfacesComponent. */ @Documented @Retention(RUNTIME) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index f8096437a18e..efe559a64cc4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -101,11 +101,11 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.statusbar.notification.row.ExpandableView; import com.android.systemui.statusbar.notification.row.FooterView; import com.android.systemui.statusbar.notification.row.StackScrollerDecorView; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.HeadsUpAppearanceController; import com.android.systemui.statusbar.phone.HeadsUpTouchHelper; import com.android.systemui.statusbar.phone.ScreenOffAnimationController; import com.android.systemui.statusbar.phone.ShadeController; -import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.policy.HeadsUpUtil; import com.android.systemui.statusbar.policy.ScrollAdapter; import com.android.systemui.util.Assert; @@ -308,7 +308,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable } }; private NotificationStackScrollLogger mLogger; - private StatusBar mStatusBar; + private CentralSurfaces mCentralSurfaces; private int[] mTempInt2 = new int[2]; private boolean mGenerateChildOrderChangedEvent; private HashSet mAnimationFinishedRunnables = new HashSet<>(); @@ -3959,7 +3959,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable mAmbientState.setExpansionChanging(false); if (!mIsExpanded) { resetScrollPosition(); - mStatusBar.resetUserExpandedStates(); + mCentralSurfaces.resetUserExpandedStates(); clearTemporaryViews(); clearUserLockedViews(); if (mSwipeHelper.isSwiping()) { @@ -4591,8 +4591,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable } @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) - public void setStatusBar(StatusBar statusBar) { - this.mStatusBar = statusBar; + public void setCentralSurfaces(CentralSurfaces centralSurfaces) { + this.mCentralSurfaces = centralSurfaces; } @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) @@ -5260,7 +5260,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable Intent intent = showHistory ? new Intent(Settings.ACTION_NOTIFICATION_HISTORY) : new Intent(Settings.ACTION_NOTIFICATION_SETTINGS); - mStatusBar.startActivity(intent, true, true, Intent.FLAG_ACTIVITY_SINGLE_TOP); + mCentralSurfaces.startActivity(intent, true, true, Intent.FLAG_ACTIVITY_SINGLE_TOP); }); setEmptyShadeView(view); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java index a352859eb216..df6b8f59fc36 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java @@ -117,8 +117,8 @@ import com.android.systemui.statusbar.phone.HeadsUpTouchHelper; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.ScrimController; import com.android.systemui.statusbar.phone.ShadeController; -import com.android.systemui.statusbar.phone.StatusBar; -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; +import com.android.systemui.statusbar.phone.CentralSurfaces; +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; import com.android.systemui.statusbar.policy.DeviceProvisionedController; @@ -141,7 +141,7 @@ import kotlin.Unit; /** * Controller for {@link NotificationStackScrollLayout}. */ -@StatusBarComponent.StatusBarScope +@CentralSurfacesComponent.CentralSurfacesScope public class NotificationStackScrollLayoutController { private static final String TAG = "StackScrollerController"; private static final boolean DEBUG = Compile.IS_DEBUG && Log.isLoggable(TAG, Log.DEBUG); @@ -176,8 +176,8 @@ public class NotificationStackScrollLayoutController { private final SysuiStatusBarStateController mStatusBarStateController; private final KeyguardBypassController mKeyguardBypassController; private final NotificationLockscreenUserManager mLockscreenUserManager; - // TODO: StatusBar should be encapsulated behind a Controller - private final StatusBar mStatusBar; + // TODO: CentralSurfaces should be encapsulated behind a Controller + private final CentralSurfaces mCentralSurfaces; private final SectionHeaderController mSilentHeaderController; private final LockscreenShadeTransitionController mLockscreenShadeTransitionController; private final InteractionJankMonitor mJankMonitor; @@ -330,7 +330,7 @@ public class NotificationStackScrollLayoutController { mView.updateSensitiveness(mStatusBarStateController.goingToFullShade(), mLockscreenUserManager.isAnyProfilePublicMode()); mView.onStatePostChange(mStatusBarStateController.fromShadeLocked()); - mNotificationEntryManager.updateNotifications("StatusBar state changed"); + mNotificationEntryManager.updateNotifications("CentralSurfaces state changed"); } }; @@ -431,7 +431,7 @@ public class NotificationStackScrollLayoutController { @Override public void onSnooze(StatusBarNotification sbn, NotificationSwipeActionHelper.SnoozeOption snoozeOption) { - mStatusBar.setNotificationSnoozed(sbn, snoozeOption); + mCentralSurfaces.setNotificationSnoozed(sbn, snoozeOption); } @Override @@ -484,7 +484,7 @@ public class NotificationStackScrollLayoutController { mView.addSwipedOutView(view); mFalsingCollector.onNotificationDismissed(); if (mFalsingCollector.shouldEnforceBouncer()) { - mStatusBar.executeRunnableDismissingKeyguard( + mCentralSurfaces.executeRunnableDismissingKeyguard( null, null /* cancelAction */, false /* dismissShade */, @@ -557,7 +557,7 @@ public class NotificationStackScrollLayoutController { @Override public float getFalsingThresholdFactor() { - return mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f; + return mCentralSurfaces.isWakeUpComingFromTouch() ? 1.5f : 1.0f; } @Override @@ -644,7 +644,7 @@ public class NotificationStackScrollLayoutController { FalsingManager falsingManager, @Main Resources resources, NotificationSwipeHelper.Builder notificationSwipeHelperBuilder, - StatusBar statusBar, + CentralSurfaces centralSurfaces, ScrimController scrimController, NotificationGroupManagerLegacy legacyGroupManager, GroupExpansionManager groupManager, @@ -685,7 +685,7 @@ public class NotificationStackScrollLayoutController { mFalsingManager = falsingManager; mResources = resources; mNotificationSwipeHelperBuilder = notificationSwipeHelperBuilder; - mStatusBar = statusBar; + mCentralSurfaces = centralSurfaces; mScrimController = scrimController; mJankMonitor = jankMonitor; groupManager.registerGroupExpansionChangeListener( @@ -693,7 +693,7 @@ public class NotificationStackScrollLayoutController { legacyGroupManager.registerGroupChangeListener(new OnGroupChangeListener() { @Override public void onGroupsChanged() { - mStatusBar.requestNotificationUpdate("onGroupsChanged"); + mCentralSurfaces.requestNotificationUpdate("onGroupsChanged"); } }); mNotifPipelineFlags = notifPipelineFlags; @@ -716,7 +716,7 @@ public class NotificationStackScrollLayoutController { mView.setController(this); mView.setLogger(mLogger); mView.setTouchHandler(new TouchHandler()); - mView.setStatusBar(mStatusBar); + mView.setCentralSurfaces(mCentralSurfaces); mView.setClearAllAnimationListener(this::onAnimationEnd); mView.setClearAllListener((selection) -> mUiEventLogger.log( NotificationPanelEvent.fromSelection(selection))); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutListContainerModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutListContainerModule.java index ef5b7269f785..3dcaae28e181 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutListContainerModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutListContainerModule.java @@ -16,7 +16,7 @@ package com.android.systemui.statusbar.notification.stack; -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent; import dagger.Module; import dagger.Provides; @@ -24,7 +24,7 @@ import dagger.Provides; @Module public abstract class NotificationStackScrollLayoutListContainerModule { @Provides - @StatusBarComponent.StatusBarScope + @CentralSurfacesComponent.CentralSurfacesScope static NotificationListContainer provideListContainer( NotificationStackScrollLayoutController nsslController) { return nsslController.getNotificationListContainer(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java index d5d1ceada88a..fe637c14ee33 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java @@ -717,7 +717,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp public void run() { mNotificationShadeWindowController.setForceDozeBrightness(false); } - }, StatusBar.FADE_KEYGUARD_DURATION_PULSING); + }, CentralSurfaces.FADE_KEYGUARD_DURATION_PULSING); } public void finishKeyguardFadingAway() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java new file mode 100644 index 000000000000..5642744d3390 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java @@ -0,0 +1,4455 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.phone; + +import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN; +import static android.app.StatusBarManager.WINDOW_STATE_SHOWING; +import static android.app.StatusBarManager.WindowVisibleState; +import static android.app.StatusBarManager.windowStateToString; +import static android.view.InsetsState.ITYPE_STATUS_BAR; +import static android.view.InsetsState.containsType; +import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS; +import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_STATUS_BARS; +import static android.view.WindowInsetsController.APPEARANCE_SEMI_TRANSPARENT_STATUS_BARS; + +import static androidx.core.view.ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO; +import static androidx.core.view.ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS; +import static androidx.lifecycle.Lifecycle.State.RESUMED; + +import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME; +import static com.android.systemui.charging.WirelessChargingLayout.UNKNOWN_BATTERY_LEVEL; +import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_ASLEEP; +import static com.android.systemui.statusbar.NotificationLockscreenUserManager.PERMISSION_SELF; +import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT; +import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT_TRANSPARENT; +import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE; +import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT; +import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT; +import static com.android.systemui.statusbar.phone.BarTransitions.TransitionMode; +import static com.android.wm.shell.transition.Transitions.ENABLE_SHELL_TRANSITIONS; + +import android.annotation.Nullable; +import android.app.ActivityManager; +import android.app.ActivityOptions; +import android.app.ActivityTaskManager; +import android.app.IWallpaperManager; +import android.app.KeyguardManager; +import android.app.Notification; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.app.StatusBarManager; +import android.app.TaskInfo; +import android.app.TaskStackBuilder; +import android.app.UiModeManager; +import android.app.WallpaperInfo; +import android.app.WallpaperManager; +import android.app.admin.DevicePolicyManager; +import android.content.BroadcastReceiver; +import android.content.ComponentCallbacks2; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.pm.IPackageManager; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.content.pm.ResolveInfo; +import android.content.res.Configuration; +import android.graphics.Point; +import android.graphics.PointF; +import android.hardware.devicestate.DeviceStateManager; +import android.metrics.LogMaker; +import android.net.Uri; +import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.os.PowerManager; +import android.os.RemoteException; +import android.os.ServiceManager; +import android.os.SystemClock; +import android.os.SystemProperties; +import android.os.Trace; +import android.os.UserHandle; +import android.provider.Settings; +import android.service.dreams.DreamService; +import android.service.dreams.IDreamManager; +import android.service.notification.StatusBarNotification; +import android.text.TextUtils; +import android.util.ArraySet; +import android.util.DisplayMetrics; +import android.util.EventLog; +import android.util.IndentingPrintWriter; +import android.util.Log; +import android.util.MathUtils; +import android.util.Slog; +import android.view.Display; +import android.view.IRemoteAnimationRunner; +import android.view.IWindowManager; +import android.view.KeyEvent; +import android.view.MotionEvent; +import android.view.RemoteAnimationAdapter; +import android.view.ThreadedRenderer; +import android.view.View; +import android.view.ViewGroup; +import android.view.WindowInsetsController.Appearance; +import android.view.WindowManager; +import android.view.WindowManagerGlobal; +import android.view.accessibility.AccessibilityManager; +import android.widget.DateTimeView; + +import androidx.annotation.NonNull; +import androidx.lifecycle.Lifecycle; +import androidx.lifecycle.LifecycleOwner; +import androidx.lifecycle.LifecycleRegistry; + +import com.android.internal.annotations.VisibleForTesting; +import com.android.internal.colorextraction.ColorExtractor; +import com.android.internal.jank.InteractionJankMonitor; +import com.android.internal.logging.MetricsLogger; +import com.android.internal.logging.UiEvent; +import com.android.internal.logging.UiEventLogger; +import com.android.internal.logging.UiEventLoggerImpl; +import com.android.internal.logging.nano.MetricsProto.MetricsEvent; +import com.android.internal.statusbar.IStatusBarService; +import com.android.internal.statusbar.RegisterStatusBarResult; +import com.android.keyguard.KeyguardUpdateMonitor; +import com.android.keyguard.KeyguardUpdateMonitorCallback; +import com.android.keyguard.ViewMediatorCallback; +import com.android.systemui.ActivityIntentHelper; +import com.android.systemui.AutoReinflateContainer; +import com.android.systemui.CoreStartable; +import com.android.systemui.DejankUtils; +import com.android.systemui.EventLogTags; +import com.android.systemui.InitController; +import com.android.systemui.Prefs; +import com.android.systemui.R; +import com.android.systemui.accessibility.floatingmenu.AccessibilityFloatingMenuController; +import com.android.systemui.animation.ActivityLaunchAnimator; +import com.android.systemui.animation.DelegateLaunchAnimatorController; +import com.android.systemui.animation.RemoteTransitionAdapter; +import com.android.systemui.assist.AssistManager; +import com.android.systemui.biometrics.AuthRippleController; +import com.android.systemui.broadcast.BroadcastDispatcher; +import com.android.systemui.camera.CameraIntents; +import com.android.systemui.charging.WirelessChargingAnimation; +import com.android.systemui.classifier.FalsingCollector; +import com.android.systemui.colorextraction.SysuiColorExtractor; +import com.android.systemui.dagger.qualifiers.Main; +import com.android.systemui.dagger.qualifiers.UiBackground; +import com.android.systemui.demomode.DemoMode; +import com.android.systemui.demomode.DemoModeController; +import com.android.systemui.dreams.DreamOverlayStateController; +import com.android.systemui.emergency.EmergencyGesture; +import com.android.systemui.flags.FeatureFlags; +import com.android.systemui.flags.Flags; +import com.android.systemui.fragments.ExtensionFragmentListener; +import com.android.systemui.fragments.FragmentHostManager; +import com.android.systemui.fragments.FragmentService; +import com.android.systemui.keyguard.KeyguardService; +import com.android.systemui.keyguard.KeyguardUnlockAnimationController; +import com.android.systemui.keyguard.KeyguardViewMediator; +import com.android.systemui.keyguard.ScreenLifecycle; +import com.android.systemui.keyguard.WakefulnessLifecycle; +import com.android.systemui.navigationbar.NavigationBarController; +import com.android.systemui.navigationbar.NavigationBarView; +import com.android.systemui.plugins.ActivityStarter; +import com.android.systemui.plugins.DarkIconDispatcher; +import com.android.systemui.plugins.FalsingManager; +import com.android.systemui.plugins.OverlayPlugin; +import com.android.systemui.plugins.PluginDependencyProvider; +import com.android.systemui.plugins.PluginListener; +import com.android.systemui.plugins.qs.QS; +import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper.SnoozeOption; +import com.android.systemui.plugins.statusbar.StatusBarStateController; +import com.android.systemui.qs.QSFragment; +import com.android.systemui.qs.QSPanelController; +import com.android.systemui.recents.ScreenPinningRequest; +import com.android.systemui.scrim.ScrimView; +import com.android.systemui.settings.brightness.BrightnessSliderController; +import com.android.systemui.shared.plugins.PluginManager; +import com.android.systemui.statusbar.AutoHideUiElement; +import com.android.systemui.statusbar.BackDropView; +import com.android.systemui.statusbar.CircleReveal; +import com.android.systemui.statusbar.CommandQueue; +import com.android.systemui.statusbar.GestureRecorder; +import com.android.systemui.statusbar.KeyboardShortcuts; +import com.android.systemui.statusbar.KeyguardIndicationController; +import com.android.systemui.statusbar.LiftReveal; +import com.android.systemui.statusbar.LightRevealScrim; +import com.android.systemui.statusbar.LockscreenShadeTransitionController; +import com.android.systemui.statusbar.NotificationLockscreenUserManager; +import com.android.systemui.statusbar.NotificationMediaManager; +import com.android.systemui.statusbar.NotificationPresenter; +import com.android.systemui.statusbar.NotificationRemoteInputManager; +import com.android.systemui.statusbar.NotificationShadeDepthController; +import com.android.systemui.statusbar.NotificationShadeWindowController; +import com.android.systemui.statusbar.NotificationShelfController; +import com.android.systemui.statusbar.NotificationViewHierarchyManager; +import com.android.systemui.statusbar.PowerButtonReveal; +import com.android.systemui.statusbar.PulseExpansionHandler; +import com.android.systemui.statusbar.StatusBarState; +import com.android.systemui.statusbar.SysuiStatusBarStateController; +import com.android.systemui.statusbar.charging.WiredChargingRippleController; +import com.android.systemui.statusbar.connectivity.NetworkController; +import com.android.systemui.statusbar.core.StatusBarInitializer; +import com.android.systemui.statusbar.notification.DynamicPrivacyController; +import com.android.systemui.statusbar.notification.NotifPipelineFlags; +import com.android.systemui.statusbar.notification.NotificationActivityStarter; +import com.android.systemui.statusbar.notification.NotificationEntryManager; +import com.android.systemui.statusbar.notification.NotificationLaunchAnimatorControllerProvider; +import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; +import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager; +import com.android.systemui.statusbar.notification.collection.render.NotifShadeEventSource; +import com.android.systemui.statusbar.notification.init.NotificationsController; +import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider; +import com.android.systemui.statusbar.notification.logging.NotificationLogger; +import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; +import com.android.systemui.statusbar.notification.row.NotificationGutsManager; +import com.android.systemui.statusbar.notification.stack.NotificationListContainer; +import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; +import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent; +import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneModule; +import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallController; +import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager; +import com.android.systemui.statusbar.policy.BatteryController; +import com.android.systemui.statusbar.policy.BrightnessMirrorController; +import com.android.systemui.statusbar.policy.ConfigurationController; +import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; +import com.android.systemui.statusbar.policy.DeviceProvisionedController; +import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener; +import com.android.systemui.statusbar.policy.ExtensionController; +import com.android.systemui.statusbar.policy.KeyguardStateController; +import com.android.systemui.statusbar.policy.UserInfoControllerImpl; +import com.android.systemui.statusbar.policy.UserSwitcherController; +import com.android.systemui.statusbar.window.StatusBarWindowController; +import com.android.systemui.statusbar.window.StatusBarWindowStateController; +import com.android.systemui.util.DumpUtilsKt; +import com.android.systemui.util.WallpaperController; +import com.android.systemui.util.concurrency.DelayableExecutor; +import com.android.systemui.util.concurrency.MessageRouter; +import com.android.systemui.volume.VolumeComponent; +import com.android.systemui.wmshell.BubblesManager; +import com.android.wm.shell.bubbles.Bubbles; +import com.android.wm.shell.startingsurface.SplashscreenContentDrawer; +import com.android.wm.shell.startingsurface.StartingSurface; + +import java.io.FileDescriptor; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.Executor; + +import javax.inject.Named; + +import dagger.Lazy; + +/** + * A class handling initialization and coordination between some of the key central surfaces in + * System UI: The notification shade, the keyguard (lockscreen), and the status bar. + * + * This class is not our ideal architecture because it doesn't enforce much isolation between these + * three mostly disparate surfaces. In an ideal world, this class would not exist. Instead, we would + * break it up into three modules -- one for each of those three surfaces -- and we would define any + * APIs that are needed for these surfaces to communicate with each other when necessary. + * + * If at all possible, please avoid adding additional code to this monstrous class! Our goal is + * to break up this class into many small classes, and any code added here will slow down that goal. + * + */ +public class CentralSurfaces extends CoreStartable implements + ActivityStarter, + LifecycleOwner { + public static final boolean MULTIUSER_DEBUG = false; + + protected static final int MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU = 1027; + + // Should match the values in PhoneWindowManager + public static final String SYSTEM_DIALOG_REASON_KEY = "reason"; + public static final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; + public static final String SYSTEM_DIALOG_REASON_DREAM = "dream"; + static public final String SYSTEM_DIALOG_REASON_SCREENSHOT = "screenshot"; + + private static final String BANNER_ACTION_CANCEL = + "com.android.systemui.statusbar.banner_action_cancel"; + private static final String BANNER_ACTION_SETUP = + "com.android.systemui.statusbar.banner_action_setup"; + public static final String TAG = "CentralSurfaces"; + public static final boolean DEBUG = false; + public static final boolean SPEW = false; + public static final boolean DUMPTRUCK = true; // extra dumpsys info + public static final boolean DEBUG_GESTURES = false; + public static final boolean DEBUG_MEDIA_FAKE_ARTWORK = false; + public static final boolean DEBUG_CAMERA_LIFT = false; + + public static final boolean DEBUG_WINDOW_STATE = false; + + // additional instrumentation for testing purposes; intended to be left on during development + public static final boolean CHATTY = DEBUG; + + public static final boolean SHOW_LOCKSCREEN_MEDIA_ARTWORK = true; + + public static final String ACTION_FAKE_ARTWORK = "fake_artwork"; + + private static final int MSG_OPEN_SETTINGS_PANEL = 1002; + private static final int MSG_LAUNCH_TRANSITION_TIMEOUT = 1003; + // 1020-1040 reserved for BaseStatusBar + + // Time after we abort the launch transition. + static final long LAUNCH_TRANSITION_TIMEOUT_MS = 5000; + + protected static final boolean CLOSE_PANEL_WHEN_EMPTIED = true; + + /** + * The delay to reset the hint text when the hint animation is finished running. + */ + private static final int HINT_RESET_DELAY_MS = 1200; + + public static final int FADE_KEYGUARD_START_DELAY = 100; + public static final int FADE_KEYGUARD_DURATION = 300; + public static final int FADE_KEYGUARD_DURATION_PULSING = 96; + + public static final long[] CAMERA_LAUNCH_GESTURE_VIBRATION_TIMINGS = + new long[]{20, 20, 20, 20, 100, 20}; + public static final int[] CAMERA_LAUNCH_GESTURE_VIBRATION_AMPLITUDES = + new int[]{39, 82, 139, 213, 0, 127}; + + /** + * If true, the system is in the half-boot-to-decryption-screen state. + * Prudently disable QS and notifications. + */ + public static final boolean ONLY_CORE_APPS; + + /** If true, the lockscreen will show a distinct wallpaper */ + public static final boolean ENABLE_LOCKSCREEN_WALLPAPER = true; + + private static final UiEventLogger sUiEventLogger = new UiEventLoggerImpl(); + + static { + boolean onlyCoreApps; + try { + IPackageManager packageManager = + IPackageManager.Stub.asInterface(ServiceManager.getService("package")); + onlyCoreApps = packageManager != null && packageManager.isOnlyCoreApps(); + } catch (RemoteException e) { + onlyCoreApps = false; + } + ONLY_CORE_APPS = onlyCoreApps; + } + + private final LockscreenShadeTransitionController mLockscreenShadeTransitionController; + private final DreamOverlayStateController mDreamOverlayStateController; + private CentralSurfacesCommandQueueCallbacks mCommandQueueCallbacks; + private float mTransitionToFullShadeProgress = 0f; + private NotificationListContainer mNotifListContainer; + + void onStatusBarWindowStateChanged(@WindowVisibleState int state) { + updateBubblesVisibility(); + mStatusBarWindowState = state; + } + + void acquireGestureWakeLock(long time) { + mGestureWakeLock.acquire(time); + } + + boolean setAppearance(int appearance) { + if (mAppearance != appearance) { + mAppearance = appearance; + return updateBarMode(barMode(isTransientShown(), appearance)); + } + + return false; + } + + int getBarMode() { + return mStatusBarMode; + } + + void resendMessage(int msg) { + mMessageRouter.cancelMessages(msg); + mMessageRouter.sendMessage(msg); + } + + void resendMessage(Object msg) { + mMessageRouter.cancelMessages(msg.getClass()); + mMessageRouter.sendMessage(msg); + } + + int getDisabled1() { + return mDisabled1; + } + + void setDisabled1(int disabled) { + mDisabled1 = disabled; + } + + int getDisabled2() { + return mDisabled2; + } + + void setDisabled2(int disabled) { + mDisabled2 = disabled; + } + + void setLastCameraLaunchSource(int source) { + mLastCameraLaunchSource = source; + } + + void setLaunchCameraOnFinishedGoingToSleep(boolean launch) { + mLaunchCameraOnFinishedGoingToSleep = launch; + } + + void setLaunchCameraOnFinishedWaking(boolean launch) { + mLaunchCameraWhenFinishedWaking = launch; + } + + void setLaunchEmergencyActionOnFinishedGoingToSleep(boolean launch) { + mLaunchEmergencyActionOnFinishedGoingToSleep = launch; + } + + void setLaunchEmergencyActionOnFinishedWaking(boolean launch) { + mLaunchEmergencyActionWhenFinishedWaking = launch; + } + + void setTopHidesStatusBar(boolean hides) { + mTopHidesStatusBar = hides; + } + + QSPanelController getQSPanelController() { + return mQSPanelController; + } + + /** */ + public void animateExpandNotificationsPanel() { + mCommandQueueCallbacks.animateExpandNotificationsPanel(); + } + + /** */ + public void animateExpandSettingsPanel(@Nullable String subpanel) { + mCommandQueueCallbacks.animateExpandSettingsPanel(subpanel); + } + + /** */ + public void animateCollapsePanels(int flags, boolean force) { + mCommandQueueCallbacks.animateCollapsePanels(flags, force); + } + + /** */ + public void togglePanel() { + mCommandQueueCallbacks.togglePanel(); + } + /** + * The {@link StatusBarState} of the status bar. + */ + protected int mState; // TODO: remove this. Just use StatusBarStateController + protected boolean mBouncerShowing; + + private final PhoneStatusBarPolicy mIconPolicy; + + private final VolumeComponent mVolumeComponent; + private BrightnessMirrorController mBrightnessMirrorController; + private boolean mBrightnessMirrorVisible; + private BiometricUnlockController mBiometricUnlockController; + private final LightBarController mLightBarController; + private final Lazy mLockscreenWallpaperLazy; + private final LockscreenGestureLogger mLockscreenGestureLogger; + @Nullable + protected LockscreenWallpaper mLockscreenWallpaper; + private final AutoHideController mAutoHideController; + + private final Point mCurrentDisplaySize = new Point(); + + protected NotificationShadeWindowView mNotificationShadeWindowView; + protected PhoneStatusBarView mStatusBarView; + private PhoneStatusBarViewController mPhoneStatusBarViewController; + private PhoneStatusBarTransitions mStatusBarTransitions; + private AuthRippleController mAuthRippleController; + @WindowVisibleState private int mStatusBarWindowState = WINDOW_STATE_SHOWING; + protected final NotificationShadeWindowController mNotificationShadeWindowController; + private final StatusBarWindowController mStatusBarWindowController; + private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; + @VisibleForTesting + DozeServiceHost mDozeServiceHost; + private boolean mWakeUpComingFromTouch; + private PointF mWakeUpTouchLocation; + private LightRevealScrim mLightRevealScrim; + private PowerButtonReveal mPowerButtonReveal; + + private final Object mQueueLock = new Object(); + + private final PulseExpansionHandler mPulseExpansionHandler; + private final NotificationWakeUpCoordinator mWakeUpCoordinator; + private final KeyguardBypassController mKeyguardBypassController; + private final KeyguardStateController mKeyguardStateController; + private final HeadsUpManagerPhone mHeadsUpManager; + private final StatusBarTouchableRegionManager mStatusBarTouchableRegionManager; + private final DynamicPrivacyController mDynamicPrivacyController; + private final FalsingCollector mFalsingCollector; + private final FalsingManager mFalsingManager; + private final BroadcastDispatcher mBroadcastDispatcher; + private final ConfigurationController mConfigurationController; + protected NotificationShadeWindowViewController mNotificationShadeWindowViewController; + private final DozeParameters mDozeParameters; + private final Lazy mBiometricUnlockControllerLazy; + private final CentralSurfacesComponent.Factory mCentralSurfacesComponentFactory; + private final PluginManager mPluginManager; + private final ShadeController mShadeController; + private final InitController mInitController; + + private final PluginDependencyProvider mPluginDependencyProvider; + private final KeyguardDismissUtil mKeyguardDismissUtil; + private final ExtensionController mExtensionController; + private final UserInfoControllerImpl mUserInfoControllerImpl; + private final DemoModeController mDemoModeController; + private final NotificationsController mNotificationsController; + private final OngoingCallController mOngoingCallController; + private final StatusBarSignalPolicy mStatusBarSignalPolicy; + private final StatusBarHideIconsForBouncerManager mStatusBarHideIconsForBouncerManager; + + // expanded notifications + // the sliding/resizing panel within the notification window + protected NotificationPanelViewController mNotificationPanelViewController; + + // settings + private QSPanelController mQSPanelController; + + KeyguardIndicationController mKeyguardIndicationController; + + private View mReportRejectedTouch; + + private boolean mExpandedVisible; + + private final int[] mAbsPos = new int[2]; + + private final NotifShadeEventSource mNotifShadeEventSource; + protected final NotificationEntryManager mEntryManager; + private final NotificationGutsManager mGutsManager; + private final NotificationLogger mNotificationLogger; + private final NotificationViewHierarchyManager mViewHierarchyManager; + private final PanelExpansionStateManager mPanelExpansionStateManager; + private final KeyguardViewMediator mKeyguardViewMediator; + protected final NotificationInterruptStateProvider mNotificationInterruptStateProvider; + private final BrightnessSliderController.Factory mBrightnessSliderFactory; + private final FeatureFlags mFeatureFlags; + private final FragmentService mFragmentService; + private final ScreenOffAnimationController mScreenOffAnimationController; + private final WallpaperController mWallpaperController; + private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController; + private final MessageRouter mMessageRouter; + private final WallpaperManager mWallpaperManager; + + private CentralSurfacesComponent mCentralSurfacesComponent; + + // Flags for disabling the status bar + // Two variables becaseu the first one evidently ran out of room for new flags. + private int mDisabled1 = 0; + private int mDisabled2 = 0; + + /** @see android.view.WindowInsetsController#setSystemBarsAppearance(int, int) */ + private @Appearance int mAppearance; + + private boolean mTransientShown; + + private final DisplayMetrics mDisplayMetrics; + + // XXX: gesture research + private final GestureRecorder mGestureRec = DEBUG_GESTURES + ? new GestureRecorder("/sdcard/statusbar_gestures.dat") + : null; + + private final ScreenPinningRequest mScreenPinningRequest; + + private final MetricsLogger mMetricsLogger; + + // ensure quick settings is disabled until the current user makes it through the setup wizard + @VisibleForTesting + protected boolean mUserSetup = false; + + @VisibleForTesting + public enum StatusBarUiEvent implements UiEventLogger.UiEventEnum { + @UiEvent(doc = "Secured lockscreen is opened.") + LOCKSCREEN_OPEN_SECURE(405), + + @UiEvent(doc = "Lockscreen without security is opened.") + LOCKSCREEN_OPEN_INSECURE(406), + + @UiEvent(doc = "Secured lockscreen is closed.") + LOCKSCREEN_CLOSE_SECURE(407), + + @UiEvent(doc = "Lockscreen without security is closed.") + LOCKSCREEN_CLOSE_INSECURE(408), + + @UiEvent(doc = "Secured bouncer is opened.") + BOUNCER_OPEN_SECURE(409), + + @UiEvent(doc = "Bouncer without security is opened.") + BOUNCER_OPEN_INSECURE(410), + + @UiEvent(doc = "Secured bouncer is closed.") + BOUNCER_CLOSE_SECURE(411), + + @UiEvent(doc = "Bouncer without security is closed.") + BOUNCER_CLOSE_INSECURE(412); + + private final int mId; + + StatusBarUiEvent(int id) { + mId = id; + } + + @Override + public int getId() { + return mId; + } + } + + private Handler mMainHandler; + private final DelayableExecutor mMainExecutor; + + private int mInteractingWindows; + private @TransitionMode int mStatusBarMode; + + private final ViewMediatorCallback mKeyguardViewMediatorCallback; + private final ScrimController mScrimController; + protected DozeScrimController mDozeScrimController; + private final Executor mUiBgExecutor; + + protected boolean mDozing; + private boolean mIsFullscreen; + + boolean mCloseQsBeforeScreenOff; + + private final NotificationMediaManager mMediaManager; + private final NotificationLockscreenUserManager mLockscreenUserManager; + private final NotificationRemoteInputManager mRemoteInputManager; + private boolean mWallpaperSupported; + + private Runnable mLaunchTransitionEndRunnable; + private boolean mLaunchCameraWhenFinishedWaking; + private boolean mLaunchCameraOnFinishedGoingToSleep; + private boolean mLaunchEmergencyActionWhenFinishedWaking; + private boolean mLaunchEmergencyActionOnFinishedGoingToSleep; + private int mLastCameraLaunchSource; + protected PowerManager.WakeLock mGestureWakeLock; + + private final int[] mTmpInt2 = new int[2]; + + // Fingerprint (as computed by getLoggingFingerprint() of the last logged state. + private int mLastLoggedStateFingerprint; + private boolean mTopHidesStatusBar; + private boolean mStatusBarWindowHidden; + private boolean mIsOccluded; + private boolean mIsLaunchingActivityOverLockscreen; + + private final UserSwitcherController mUserSwitcherController; + private final NetworkController mNetworkController; + private final LifecycleRegistry mLifecycle = new LifecycleRegistry(this); + protected final BatteryController mBatteryController; + protected boolean mPanelExpanded; + private UiModeManager mUiModeManager; + protected boolean mIsKeyguard; + private LogMaker mStatusBarStateLog; + protected final NotificationIconAreaController mNotificationIconAreaController; + @Nullable private View mAmbientIndicationContainer; + private final SysuiColorExtractor mColorExtractor; + private final ScreenLifecycle mScreenLifecycle; + private final WakefulnessLifecycle mWakefulnessLifecycle; + + private boolean mNoAnimationOnNextBarModeChange; + private final SysuiStatusBarStateController mStatusBarStateController; + + private final ActivityLaunchAnimator mActivityLaunchAnimator; + private NotificationLaunchAnimatorControllerProvider mNotificationAnimationProvider; + protected NotificationPresenter mPresenter; + private NotificationActivityStarter mNotificationActivityStarter; + private final Lazy mNotificationShadeDepthControllerLazy; + private final Optional mBubblesManagerOptional; + private final Optional mBubblesOptional; + private final Bubbles.BubbleExpandListener mBubbleExpandListener; + private final Optional mStartingSurfaceOptional; + private final NotifPipelineFlags mNotifPipelineFlags; + + private final ActivityIntentHelper mActivityIntentHelper; + private NotificationStackScrollLayoutController mStackScrollerController; + + private final ColorExtractor.OnColorsChangedListener mOnColorsChangedListener = + (extractor, which) -> updateTheme(); + + private final InteractionJankMonitor mJankMonitor; + + + /** + * Public constructor for CentralSurfaces. + * + * CentralSurfaces is considered optional, and therefore can not be marked as @Inject directly. + * Instead, an @Provide method is included. See {@link StatusBarPhoneModule}. + */ + @SuppressWarnings("OptionalUsedAsFieldOrParameterType") + public CentralSurfaces( + Context context, + NotificationsController notificationsController, + FragmentService fragmentService, + LightBarController lightBarController, + AutoHideController autoHideController, + StatusBarWindowController statusBarWindowController, + StatusBarWindowStateController statusBarWindowStateController, + KeyguardUpdateMonitor keyguardUpdateMonitor, + StatusBarSignalPolicy statusBarSignalPolicy, + PulseExpansionHandler pulseExpansionHandler, + NotificationWakeUpCoordinator notificationWakeUpCoordinator, + KeyguardBypassController keyguardBypassController, + KeyguardStateController keyguardStateController, + HeadsUpManagerPhone headsUpManagerPhone, + DynamicPrivacyController dynamicPrivacyController, + FalsingManager falsingManager, + FalsingCollector falsingCollector, + BroadcastDispatcher broadcastDispatcher, + NotifShadeEventSource notifShadeEventSource, + NotificationEntryManager notificationEntryManager, + NotificationGutsManager notificationGutsManager, + NotificationLogger notificationLogger, + NotificationInterruptStateProvider notificationInterruptStateProvider, + NotificationViewHierarchyManager notificationViewHierarchyManager, + PanelExpansionStateManager panelExpansionStateManager, + KeyguardViewMediator keyguardViewMediator, + DisplayMetrics displayMetrics, + MetricsLogger metricsLogger, + @UiBackground Executor uiBgExecutor, + NotificationMediaManager notificationMediaManager, + NotificationLockscreenUserManager lockScreenUserManager, + NotificationRemoteInputManager remoteInputManager, + UserSwitcherController userSwitcherController, + NetworkController networkController, + BatteryController batteryController, + SysuiColorExtractor colorExtractor, + ScreenLifecycle screenLifecycle, + WakefulnessLifecycle wakefulnessLifecycle, + SysuiStatusBarStateController statusBarStateController, + Optional bubblesManagerOptional, + Optional bubblesOptional, + VisualStabilityManager visualStabilityManager, + DeviceProvisionedController deviceProvisionedController, + NavigationBarController navigationBarController, + AccessibilityFloatingMenuController accessibilityFloatingMenuController, + Lazy assistManagerLazy, + ConfigurationController configurationController, + NotificationShadeWindowController notificationShadeWindowController, + DozeParameters dozeParameters, + ScrimController scrimController, + Lazy lockscreenWallpaperLazy, + LockscreenGestureLogger lockscreenGestureLogger, + Lazy biometricUnlockControllerLazy, + DozeServiceHost dozeServiceHost, + PowerManager powerManager, + ScreenPinningRequest screenPinningRequest, + DozeScrimController dozeScrimController, + VolumeComponent volumeComponent, + CommandQueue commandQueue, + CentralSurfacesComponent.Factory centralSurfacesComponentFactory, + PluginManager pluginManager, + ShadeController shadeController, + StatusBarKeyguardViewManager statusBarKeyguardViewManager, + ViewMediatorCallback viewMediatorCallback, + InitController initController, + @Named(TIME_TICK_HANDLER_NAME) Handler timeTickHandler, + PluginDependencyProvider pluginDependencyProvider, + KeyguardDismissUtil keyguardDismissUtil, + ExtensionController extensionController, + UserInfoControllerImpl userInfoControllerImpl, + PhoneStatusBarPolicy phoneStatusBarPolicy, + KeyguardIndicationController keyguardIndicationController, + DemoModeController demoModeController, + Lazy notificationShadeDepthControllerLazy, + StatusBarTouchableRegionManager statusBarTouchableRegionManager, + NotificationIconAreaController notificationIconAreaController, + BrightnessSliderController.Factory brightnessSliderFactory, + ScreenOffAnimationController screenOffAnimationController, + WallpaperController wallpaperController, + OngoingCallController ongoingCallController, + StatusBarHideIconsForBouncerManager statusBarHideIconsForBouncerManager, + LockscreenShadeTransitionController lockscreenShadeTransitionController, + FeatureFlags featureFlags, + KeyguardUnlockAnimationController keyguardUnlockAnimationController, + @Main Handler mainHandler, + @Main DelayableExecutor delayableExecutor, + @Main MessageRouter messageRouter, + WallpaperManager wallpaperManager, + Optional startingSurfaceOptional, + ActivityLaunchAnimator activityLaunchAnimator, + NotifPipelineFlags notifPipelineFlags, + InteractionJankMonitor jankMonitor, + DeviceStateManager deviceStateManager, + DreamOverlayStateController dreamOverlayStateController, + WiredChargingRippleController wiredChargingRippleController) { + super(context); + mNotificationsController = notificationsController; + mFragmentService = fragmentService; + mLightBarController = lightBarController; + mAutoHideController = autoHideController; + mStatusBarWindowController = statusBarWindowController; + mKeyguardUpdateMonitor = keyguardUpdateMonitor; + mPulseExpansionHandler = pulseExpansionHandler; + mWakeUpCoordinator = notificationWakeUpCoordinator; + mKeyguardBypassController = keyguardBypassController; + mKeyguardStateController = keyguardStateController; + mHeadsUpManager = headsUpManagerPhone; + mKeyguardIndicationController = keyguardIndicationController; + mStatusBarTouchableRegionManager = statusBarTouchableRegionManager; + mDynamicPrivacyController = dynamicPrivacyController; + mFalsingCollector = falsingCollector; + mFalsingManager = falsingManager; + mBroadcastDispatcher = broadcastDispatcher; + mNotifShadeEventSource = notifShadeEventSource; + mEntryManager = notificationEntryManager; + mGutsManager = notificationGutsManager; + mNotificationLogger = notificationLogger; + mNotificationInterruptStateProvider = notificationInterruptStateProvider; + mViewHierarchyManager = notificationViewHierarchyManager; + mPanelExpansionStateManager = panelExpansionStateManager; + mKeyguardViewMediator = keyguardViewMediator; + mDisplayMetrics = displayMetrics; + mMetricsLogger = metricsLogger; + mUiBgExecutor = uiBgExecutor; + mMediaManager = notificationMediaManager; + mLockscreenUserManager = lockScreenUserManager; + mRemoteInputManager = remoteInputManager; + mUserSwitcherController = userSwitcherController; + mNetworkController = networkController; + mBatteryController = batteryController; + mColorExtractor = colorExtractor; + mScreenLifecycle = screenLifecycle; + mWakefulnessLifecycle = wakefulnessLifecycle; + mStatusBarStateController = statusBarStateController; + mBubblesManagerOptional = bubblesManagerOptional; + mBubblesOptional = bubblesOptional; + mVisualStabilityManager = visualStabilityManager; + mDeviceProvisionedController = deviceProvisionedController; + mNavigationBarController = navigationBarController; + mAccessibilityFloatingMenuController = accessibilityFloatingMenuController; + mAssistManagerLazy = assistManagerLazy; + mConfigurationController = configurationController; + mNotificationShadeWindowController = notificationShadeWindowController; + mDozeServiceHost = dozeServiceHost; + mPowerManager = powerManager; + mDozeParameters = dozeParameters; + mScrimController = scrimController; + mLockscreenWallpaperLazy = lockscreenWallpaperLazy; + mLockscreenGestureLogger = lockscreenGestureLogger; + mScreenPinningRequest = screenPinningRequest; + mDozeScrimController = dozeScrimController; + mBiometricUnlockControllerLazy = biometricUnlockControllerLazy; + mNotificationShadeDepthControllerLazy = notificationShadeDepthControllerLazy; + mVolumeComponent = volumeComponent; + mCommandQueue = commandQueue; + mCentralSurfacesComponentFactory = centralSurfacesComponentFactory; + mPluginManager = pluginManager; + mShadeController = shadeController; + mStatusBarKeyguardViewManager = statusBarKeyguardViewManager; + mKeyguardViewMediatorCallback = viewMediatorCallback; + mInitController = initController; + mPluginDependencyProvider = pluginDependencyProvider; + mKeyguardDismissUtil = keyguardDismissUtil; + mExtensionController = extensionController; + mUserInfoControllerImpl = userInfoControllerImpl; + mIconPolicy = phoneStatusBarPolicy; + mDemoModeController = demoModeController; + mNotificationIconAreaController = notificationIconAreaController; + mBrightnessSliderFactory = brightnessSliderFactory; + mWallpaperController = wallpaperController; + mOngoingCallController = ongoingCallController; + mStatusBarSignalPolicy = statusBarSignalPolicy; + mStatusBarHideIconsForBouncerManager = statusBarHideIconsForBouncerManager; + mFeatureFlags = featureFlags; + mKeyguardUnlockAnimationController = keyguardUnlockAnimationController; + mMainHandler = mainHandler; + mMainExecutor = delayableExecutor; + mMessageRouter = messageRouter; + mWallpaperManager = wallpaperManager; + mJankMonitor = jankMonitor; + mDreamOverlayStateController = dreamOverlayStateController; + + mLockscreenShadeTransitionController = lockscreenShadeTransitionController; + mStartingSurfaceOptional = startingSurfaceOptional; + mNotifPipelineFlags = notifPipelineFlags; + lockscreenShadeTransitionController.setCentralSurfaces(this); + statusBarWindowStateController.addListener(this::onStatusBarWindowStateChanged); + + mScreenOffAnimationController = screenOffAnimationController; + + mPanelExpansionStateManager.addExpansionListener(this::onPanelExpansionChanged); + + mBubbleExpandListener = + (isExpanding, key) -> mContext.getMainExecutor().execute(() -> { + mNotificationsController.requestNotificationUpdate("onBubbleExpandChanged"); + updateScrimController(); + }); + + mActivityIntentHelper = new ActivityIntentHelper(mContext); + mActivityLaunchAnimator = activityLaunchAnimator; + + // The status bar background may need updating when the ongoing call status changes. + mOngoingCallController.addCallback((animate) -> maybeUpdateBarMode()); + + // TODO(b/190746471): Find a better home for this. + DateTimeView.setReceiverHandler(timeTickHandler); + + mMessageRouter.subscribeTo(KeyboardShortcutsMessage.class, + data -> toggleKeyboardShortcuts(data.mDeviceId)); + mMessageRouter.subscribeTo(MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU, + id -> dismissKeyboardShortcuts()); + mMessageRouter.subscribeTo(AnimateExpandSettingsPanelMessage.class, + data -> mCommandQueueCallbacks.animateExpandSettingsPanel(data.mSubpanel)); + mMessageRouter.subscribeTo(MSG_LAUNCH_TRANSITION_TIMEOUT, + id -> onLaunchTransitionTimeout()); + + deviceStateManager.registerCallback(mMainExecutor, + new FoldStateListener(mContext, this::onFoldedStateChanged)); + wiredChargingRippleController.registerCallbacks(); + } + + @Override + public void start() { + mScreenLifecycle.addObserver(mScreenObserver); + mWakefulnessLifecycle.addObserver(mWakefulnessObserver); + mUiModeManager = mContext.getSystemService(UiModeManager.class); + if (mBubblesOptional.isPresent()) { + mBubblesOptional.get().setExpandListener(mBubbleExpandListener); + } + + mStatusBarSignalPolicy.init(); + mKeyguardIndicationController.init(); + + mColorExtractor.addOnColorsChangedListener(mOnColorsChangedListener); + mStatusBarStateController.addCallback(mStateListener, + SysuiStatusBarStateController.RANK_STATUS_BAR); + + mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); + mDreamManager = IDreamManager.Stub.asInterface( + ServiceManager.checkService(DreamService.DREAM_SERVICE)); + + mDisplay = mContext.getDisplay(); + mDisplayId = mDisplay.getDisplayId(); + updateDisplaySize(); + mStatusBarHideIconsForBouncerManager.setDisplayId(mDisplayId); + + // start old BaseStatusBar.start(). + mWindowManagerService = WindowManagerGlobal.getWindowManagerService(); + mDevicePolicyManager = (DevicePolicyManager) mContext.getSystemService( + Context.DEVICE_POLICY_SERVICE); + + mAccessibilityManager = (AccessibilityManager) + mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); + + mKeyguardUpdateMonitor.setKeyguardBypassController(mKeyguardBypassController); + mBarService = IStatusBarService.Stub.asInterface( + ServiceManager.getService(Context.STATUS_BAR_SERVICE)); + + mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); + mWallpaperSupported = mWallpaperManager.isWallpaperSupported(); + + RegisterStatusBarResult result = null; + try { + result = mBarService.registerStatusBar(mCommandQueue); + } catch (RemoteException ex) { + ex.rethrowFromSystemServer(); + } + + createAndAddWindows(result); + + if (mWallpaperSupported) { + // Make sure we always have the most current wallpaper info. + IntentFilter wallpaperChangedFilter = new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED); + mBroadcastDispatcher.registerReceiver(mWallpaperChangedReceiver, wallpaperChangedFilter, + null /* handler */, UserHandle.ALL); + mWallpaperChangedReceiver.onReceive(mContext, null); + } else if (DEBUG) { + Log.v(TAG, "start(): no wallpaper service "); + } + + // Set up the initial notification state. This needs to happen before CommandQueue.disable() + setUpPresenter(); + + if (containsType(result.mTransientBarTypes, ITYPE_STATUS_BAR)) { + showTransientUnchecked(); + } + mCommandQueueCallbacks.onSystemBarAttributesChanged(mDisplayId, result.mAppearance, + result.mAppearanceRegions, result.mNavbarColorManagedByIme, result.mBehavior, + result.mRequestedVisibilities, result.mPackageName); + + // StatusBarManagerService has a back up of IME token and it's restored here. + mCommandQueueCallbacks.setImeWindowStatus(mDisplayId, result.mImeToken, + result.mImeWindowVis, result.mImeBackDisposition, result.mShowImeSwitcher); + + // Set up the initial icon state + int numIcons = result.mIcons.size(); + for (int i = 0; i < numIcons; i++) { + mCommandQueue.setIcon(result.mIcons.keyAt(i), result.mIcons.valueAt(i)); + } + + + if (DEBUG) { + Log.d(TAG, String.format( + "init: icons=%d disabled=0x%08x lights=0x%08x imeButton=0x%08x", + numIcons, + result.mDisabledFlags1, + result.mAppearance, + result.mImeWindowVis)); + } + + IntentFilter internalFilter = new IntentFilter(); + internalFilter.addAction(BANNER_ACTION_CANCEL); + internalFilter.addAction(BANNER_ACTION_SETUP); + mContext.registerReceiver(mBannerActionBroadcastReceiver, internalFilter, PERMISSION_SELF, + null, Context.RECEIVER_EXPORTED_UNAUDITED); + + if (mWallpaperSupported) { + IWallpaperManager wallpaperManager = IWallpaperManager.Stub.asInterface( + ServiceManager.getService(Context.WALLPAPER_SERVICE)); + try { + wallpaperManager.setInAmbientMode(false /* ambientMode */, 0L /* duration */); + } catch (RemoteException e) { + // Just pass, nothing critical. + } + } + + // end old BaseStatusBar.start(). + + // Lastly, call to the icon policy to install/update all the icons. + mIconPolicy.init(); + + mKeyguardStateController.addCallback(new KeyguardStateController.Callback() { + @Override + public void onUnlockedChanged() { + updateKeyguardState(); + logStateToEventlog(); + } + }); + startKeyguard(); + + mKeyguardUpdateMonitor.registerCallback(mUpdateCallback); + mDozeServiceHost.initialize( + this, + mStatusBarKeyguardViewManager, + mNotificationShadeWindowViewController, + mNotificationPanelViewController, + mAmbientIndicationContainer); + updateLightRevealScrimVisibility(); + + mConfigurationController.addCallback(mConfigurationListener); + + mBatteryController.observe(mLifecycle, mBatteryStateChangeCallback); + mLifecycle.setCurrentState(RESUMED); + + mAccessibilityFloatingMenuController.init(); + + // set the initial view visibility + int disabledFlags1 = result.mDisabledFlags1; + int disabledFlags2 = result.mDisabledFlags2; + mInitController.addPostInitTask( + () -> setUpDisableFlags(disabledFlags1, disabledFlags2)); + + mFalsingManager.addFalsingBeliefListener(mFalsingBeliefListener); + + mPluginManager.addPluginListener( + new PluginListener() { + private final ArraySet mOverlays = new ArraySet<>(); + + @Override + public void onPluginConnected(OverlayPlugin plugin, Context pluginContext) { + mMainExecutor.execute( + () -> plugin.setup(getNotificationShadeWindowView(), + getNavigationBarView(), + new Callback(plugin), mDozeParameters)); + } + + @Override + public void onPluginDisconnected(OverlayPlugin plugin) { + mMainExecutor.execute(() -> { + mOverlays.remove(plugin); + mNotificationShadeWindowController + .setForcePluginOpen(mOverlays.size() != 0, this); + }); + } + + class Callback implements OverlayPlugin.Callback { + private final OverlayPlugin mPlugin; + + Callback(OverlayPlugin plugin) { + mPlugin = plugin; + } + + @Override + public void onHoldStatusBarOpenChange() { + if (mPlugin.holdStatusBarOpen()) { + mOverlays.add(mPlugin); + } else { + mOverlays.remove(mPlugin); + } + mMainExecutor.execute(() -> { + mNotificationShadeWindowController + .setStateListener(b -> mOverlays.forEach( + o -> o.setCollapseDesired(b))); + mNotificationShadeWindowController + .setForcePluginOpen(mOverlays.size() != 0, this); + }); + } + } + }, OverlayPlugin.class, true /* Allow multiple plugins */); + + mStartingSurfaceOptional.ifPresent(startingSurface -> startingSurface.setSysuiProxy( + (requestTopUi, componentTag) -> mMainExecutor.execute(() -> + mNotificationShadeWindowController.setRequestTopUi( + requestTopUi, componentTag)))); + } + + private void onFoldedStateChanged(boolean isFolded, boolean willGoToSleep) { + Trace.beginSection("CentralSurfaces#onFoldedStateChanged"); + onFoldedStateChangedInternal(isFolded, willGoToSleep); + Trace.endSection(); + } + + private void onFoldedStateChangedInternal(boolean isFolded, boolean willGoToSleep) { + // Folded state changes are followed by a screen off event. + // By default turning off the screen also closes the shade. + // We want to make sure that the shade status is kept after + // folding/unfolding. + boolean isShadeOpen = mShadeController.isShadeOpen(); + boolean leaveOpen = isShadeOpen && !willGoToSleep; + if (DEBUG) { + Log.d(TAG, String.format( + "#onFoldedStateChanged(): " + + "isFolded=%s, " + + "willGoToSleep=%s, " + + "isShadeOpen=%s, " + + "leaveOpen=%s", + isFolded, willGoToSleep, isShadeOpen, leaveOpen)); + } + if (leaveOpen) { + mStatusBarStateController.setLeaveOpenOnKeyguardHide(true); + if (mIsKeyguard) { + // When device state changes on keyguard we don't want to keep the state of + // the shade and instead we open clean state of keyguard with shade closed. + // Normally some parts of QS state (like expanded/collapsed) are persisted and + // that causes incorrect UI rendering, especially when changing state with QS + // expanded. To prevent that we can close QS which resets QS and some parts of + // the shade to its default state. Read more in b/201537421 + mCloseQsBeforeScreenOff = true; + } + } + } + + // ================================================================================ + // Constructing the view + // ================================================================================ + protected void makeStatusBarView(@Nullable RegisterStatusBarResult result) { + updateDisplaySize(); // populates mDisplayMetrics + updateResources(); + updateTheme(); + + inflateStatusBarWindow(); + mNotificationShadeWindowView.setOnTouchListener(getStatusBarWindowTouchListener()); + mWallpaperController.setRootView(mNotificationShadeWindowView); + + // TODO: Deal with the ugliness that comes from having some of the status bar broken out + // into fragments, but the rest here, it leaves some awkward lifecycle and whatnot. + mNotificationLogger.setUpWithContainer(mNotifListContainer); + mNotificationIconAreaController.setupShelf(mNotificationShelfController); + mPanelExpansionStateManager.addExpansionListener(mWakeUpCoordinator); + mUserSwitcherController.init(mNotificationShadeWindowView); + + // Allow plugins to reference DarkIconDispatcher and StatusBarStateController + mPluginDependencyProvider.allowPluginDependency(DarkIconDispatcher.class); + mPluginDependencyProvider.allowPluginDependency(StatusBarStateController.class); + + // Set up CollapsedStatusBarFragment and PhoneStatusBarView + StatusBarInitializer initializer = mCentralSurfacesComponent.getStatusBarInitializer(); + initializer.setStatusBarViewUpdatedListener( + (statusBarView, statusBarViewController, statusBarTransitions) -> { + mStatusBarView = statusBarView; + mPhoneStatusBarViewController = statusBarViewController; + mStatusBarTransitions = statusBarTransitions; + mNotificationShadeWindowViewController + .setStatusBarViewController(mPhoneStatusBarViewController); + // Ensure we re-propagate panel expansion values to the panel controller and + // any listeners it may have, such as PanelBar. This will also ensure we + // re-display the notification panel if necessary (for example, if + // a heads-up notification was being displayed and should continue being + // displayed). + mNotificationPanelViewController.updatePanelExpansionAndVisibility(); + setBouncerShowingForStatusBarComponents(mBouncerShowing); + checkBarModes(); + }); + initializer.initializeStatusBar(mCentralSurfacesComponent); + + mStatusBarTouchableRegionManager.setup(this, mNotificationShadeWindowView); + mHeadsUpManager.addListener(mNotificationPanelViewController.getOnHeadsUpChangedListener()); + if (!mNotifPipelineFlags.isNewPipelineEnabled()) { + mHeadsUpManager.addListener(mVisualStabilityManager); + } + mNotificationPanelViewController.setHeadsUpManager(mHeadsUpManager); + + createNavigationBar(result); + + if (ENABLE_LOCKSCREEN_WALLPAPER && mWallpaperSupported) { + mLockscreenWallpaper = mLockscreenWallpaperLazy.get(); + } + + mNotificationPanelViewController.setKeyguardIndicationController( + mKeyguardIndicationController); + + mAmbientIndicationContainer = mNotificationShadeWindowView.findViewById( + R.id.ambient_indication_container); + + mAutoHideController.setStatusBar(new AutoHideUiElement() { + @Override + public void synchronizeState() { + checkBarModes(); + } + + @Override + public boolean shouldHideOnTouch() { + return !mRemoteInputManager.isRemoteInputActive(); + } + + @Override + public boolean isVisible() { + return isTransientShown(); + } + + @Override + public void hide() { + clearTransient(); + } + }); + + ScrimView scrimBehind = mNotificationShadeWindowView.findViewById(R.id.scrim_behind); + ScrimView notificationsScrim = mNotificationShadeWindowView + .findViewById(R.id.scrim_notifications); + ScrimView scrimInFront = mNotificationShadeWindowView.findViewById(R.id.scrim_in_front); + + mScrimController.setScrimVisibleListener(scrimsVisible -> { + mNotificationShadeWindowController.setScrimsVisibility(scrimsVisible); + }); + mScrimController.attachViews(scrimBehind, notificationsScrim, scrimInFront); + + mLightRevealScrim = mNotificationShadeWindowView.findViewById(R.id.light_reveal_scrim); + mLightRevealScrim.setScrimOpaqueChangedListener((opaque) -> { + Runnable updateOpaqueness = () -> { + mNotificationShadeWindowController.setLightRevealScrimOpaque( + mLightRevealScrim.isScrimOpaque()); + mScreenOffAnimationController + .onScrimOpaqueChanged(mLightRevealScrim.isScrimOpaque()); + }; + if (opaque) { + // Delay making the view opaque for a frame, because it needs some time to render + // otherwise this can lead to a flicker where the scrim doesn't cover the screen + mLightRevealScrim.post(updateOpaqueness); + } else { + updateOpaqueness.run(); + } + }); + + mScreenOffAnimationController.initialize(this, mLightRevealScrim); + updateLightRevealScrimVisibility(); + + mNotificationPanelViewController.initDependencies( + this, + this::makeExpandedInvisible, + mNotificationShelfController); + + BackDropView backdrop = mNotificationShadeWindowView.findViewById(R.id.backdrop); + mMediaManager.setup(backdrop, backdrop.findViewById(R.id.backdrop_front), + backdrop.findViewById(R.id.backdrop_back), mScrimController, mLockscreenWallpaper); + float maxWallpaperZoom = mContext.getResources().getFloat( + com.android.internal.R.dimen.config_wallpaperMaxScale); + mNotificationShadeDepthControllerLazy.get().addListener(depth -> { + float scale = MathUtils.lerp(maxWallpaperZoom, 1f, depth); + backdrop.setPivotX(backdrop.getWidth() / 2f); + backdrop.setPivotY(backdrop.getHeight() / 2f); + backdrop.setScaleX(scale); + backdrop.setScaleY(scale); + }); + + mNotificationPanelViewController.setUserSetupComplete(mUserSetup); + + // Set up the quick settings tile panel + final View container = mNotificationShadeWindowView.findViewById(R.id.qs_frame); + if (container != null) { + FragmentHostManager fragmentHostManager = FragmentHostManager.get(container); + ExtensionFragmentListener.attachExtensonToFragment(container, QS.TAG, R.id.qs_frame, + mExtensionController + .newExtension(QS.class) + .withPlugin(QS.class) + .withDefault(this::createDefaultQSFragment) + .build()); + mBrightnessMirrorController = new BrightnessMirrorController( + mNotificationShadeWindowView, + mNotificationPanelViewController, + mNotificationShadeDepthControllerLazy.get(), + mBrightnessSliderFactory, + (visible) -> { + mBrightnessMirrorVisible = visible; + updateScrimController(); + }); + fragmentHostManager.addTagListener(QS.TAG, (tag, f) -> { + QS qs = (QS) f; + if (qs instanceof QSFragment) { + mQSPanelController = ((QSFragment) qs).getQSPanelController(); + ((QSFragment) qs).setBrightnessMirrorController(mBrightnessMirrorController); + } + }); + } + + mReportRejectedTouch = mNotificationShadeWindowView + .findViewById(R.id.report_rejected_touch); + if (mReportRejectedTouch != null) { + updateReportRejectedTouchVisibility(); + mReportRejectedTouch.setOnClickListener(v -> { + Uri session = mFalsingManager.reportRejectedTouch(); + if (session == null) { return; } + + StringWriter message = new StringWriter(); + message.write("Build info: "); + message.write(SystemProperties.get("ro.build.description")); + message.write("\nSerial number: "); + message.write(SystemProperties.get("ro.serialno")); + message.write("\n"); + + startActivityDismissingKeyguard(Intent.createChooser(new Intent(Intent.ACTION_SEND) + .setType("*/*") + .putExtra(Intent.EXTRA_SUBJECT, "Rejected touch report") + .putExtra(Intent.EXTRA_STREAM, session) + .putExtra(Intent.EXTRA_TEXT, message.toString()), + "Share rejected touch report") + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), + true /* onlyProvisioned */, true /* dismissShade */); + }); + } + + if (!mPowerManager.isInteractive()) { + mBroadcastReceiver.onReceive(mContext, new Intent(Intent.ACTION_SCREEN_OFF)); + } + mGestureWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, + "sysui:GestureWakeLock"); + + // receive broadcasts + registerBroadcastReceiver(); + + IntentFilter demoFilter = new IntentFilter(); + if (DEBUG_MEDIA_FAKE_ARTWORK) { + demoFilter.addAction(ACTION_FAKE_ARTWORK); + } + mContext.registerReceiverAsUser(mDemoReceiver, UserHandle.ALL, demoFilter, + android.Manifest.permission.DUMP, null, + Context.RECEIVER_EXPORTED_UNAUDITED); + + // listen for USER_SETUP_COMPLETE setting (per-user) + mDeviceProvisionedController.addCallback(mUserSetupObserver); + mUserSetupObserver.onUserSetupChanged(); + + // disable profiling bars, since they overlap and clutter the output on app windows + ThreadedRenderer.overrideProperty("disableProfileBars", "true"); + + // Private API call to make the shadows look better for Recents + ThreadedRenderer.overrideProperty("ambientRatio", String.valueOf(1.5f)); + } + + + /** + * When swiping up to dismiss the lock screen, the panel expansion fraction goes from 1f to 0f. + * This results in the clock/notifications/other content disappearing off the top of the screen. + * + * We also use the expansion fraction to animate in the app/launcher surface from the bottom of + * the screen, 'pushing' off the notifications and other content. To do this, we dispatch the + * expansion fraction to the KeyguardViewMediator if we're in the process of dismissing the + * keyguard. + */ + private void dispatchPanelExpansionForKeyguardDismiss(float fraction, boolean trackingTouch) { + // Things that mean we're not dismissing the keyguard, and should ignore this expansion: + // - Keyguard isn't even visible. + // - Keyguard is visible, but can't be dismissed (swiping up will show PIN/password prompt). + // - The SIM is locked, you can't swipe to unlock. If the SIM is locked but there is no + // device lock set, canDismissLockScreen returns true even though you should not be able + // to dismiss the lock screen until entering the SIM PIN. + // - QS is expanded and we're swiping - swiping up now will hide QS, not dismiss the + // keyguard. + if (!isKeyguardShowing() + || !mKeyguardStateController.canDismissLockScreen() + || mKeyguardViewMediator.isAnySimPinSecure() + || (mNotificationPanelViewController.isQsExpanded() && trackingTouch)) { + return; + } + + // Otherwise, we should let the keyguard know about this if we're tracking touch, or if we + // are already animating the keyguard dismiss (since we will need to either finish or cancel + // the animation). + if (trackingTouch + || mKeyguardViewMediator.isAnimatingBetweenKeyguardAndSurfaceBehindOrWillBe() + || mKeyguardUnlockAnimationController.isUnlockingWithSmartSpaceTransition()) { + mKeyguardStateController.notifyKeyguardDismissAmountChanged( + 1f - fraction, trackingTouch); + } + } + + private void onPanelExpansionChanged(float fraction, boolean expanded, boolean tracking) { + dispatchPanelExpansionForKeyguardDismiss(fraction, tracking); + + if (fraction == 0 || fraction == 1) { + if (getNavigationBarView() != null) { + getNavigationBarView().onStatusBarPanelStateChanged(); + } + if (getNotificationPanelViewController() != null) { + getNotificationPanelViewController().updateSystemUiStateFlags(); + } + } + } + + @NonNull + @Override + public Lifecycle getLifecycle() { + return mLifecycle; + } + + @VisibleForTesting + protected void registerBroadcastReceiver() { + IntentFilter filter = new IntentFilter(); + filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); + filter.addAction(Intent.ACTION_SCREEN_OFF); + filter.addAction(DevicePolicyManager.ACTION_SHOW_DEVICE_MONITORING_DIALOG); + mBroadcastDispatcher.registerReceiver(mBroadcastReceiver, filter, null, UserHandle.ALL); + } + + protected QS createDefaultQSFragment() { + return FragmentHostManager.get(mNotificationShadeWindowView).create(QSFragment.class); + } + + private void setUpPresenter() { + // Set up the initial notification state. + mActivityLaunchAnimator.setCallback(mActivityLaunchAnimatorCallback); + mActivityLaunchAnimator.addListener(mActivityLaunchAnimatorListener); + mNotificationAnimationProvider = new NotificationLaunchAnimatorControllerProvider( + mNotificationShadeWindowViewController, + mNotifListContainer, + mHeadsUpManager, + mJankMonitor); + mNotificationShelfController.setOnActivatedListener(mPresenter); + mRemoteInputManager.addControllerCallback(mNotificationShadeWindowController); + mStackScrollerController.setNotificationActivityStarter(mNotificationActivityStarter); + mGutsManager.setNotificationActivityStarter(mNotificationActivityStarter); + mNotificationsController.initialize( + mPresenter, + mNotifListContainer, + mStackScrollerController.getNotifStackController(), + mNotificationActivityStarter, + mCentralSurfacesComponent.getBindRowCallback()); + } + + /** + * Post-init task of {@link #start()} + * @param state1 disable1 flags + * @param state2 disable2 flags + */ + protected void setUpDisableFlags(int state1, int state2) { + mCommandQueue.disable(mDisplayId, state1, state2, false /* animate */); + } + + /** + * Ask the display to wake up if currently dozing, else do nothing + * + * @param time when to wake up + * @param where the view requesting the wakeup + * @param why the reason for the wake up + */ + public void wakeUpIfDozing(long time, View where, String why) { + if (mDozing && mScreenOffAnimationController.allowWakeUpIfDozing()) { + mPowerManager.wakeUp( + time, PowerManager.WAKE_REASON_GESTURE, "com.android.systemui:" + why); + mWakeUpComingFromTouch = true; + where.getLocationInWindow(mTmpInt2); + + // NOTE, the incoming view can sometimes be the entire container... unsure if + // this location is valuable enough + mWakeUpTouchLocation = new PointF(mTmpInt2[0] + where.getWidth() / 2, + mTmpInt2[1] + where.getHeight() / 2); + mFalsingCollector.onScreenOnFromTouch(); + } + } + + // TODO(b/117478341): This was left such that CarStatusBar can override this method. + // Try to remove this. + protected void createNavigationBar(@Nullable RegisterStatusBarResult result) { + mNavigationBarController.createNavigationBars(true /* includeDefaultDisplay */, result); + } + + /** + * Returns the {@link android.view.View.OnTouchListener} that will be invoked when the + * background window of the status bar is clicked. + */ + protected View.OnTouchListener getStatusBarWindowTouchListener() { + return (v, event) -> { + mAutoHideController.checkUserAutoHide(event); + mRemoteInputManager.checkRemoteInputOutside(event); + if (event.getAction() == MotionEvent.ACTION_DOWN) { + if (mExpandedVisible) { + mShadeController.animateCollapsePanels(); + } + } + return mNotificationShadeWindowView.onTouchEvent(event); + }; + } + + private void inflateStatusBarWindow() { + if (mCentralSurfacesComponent != null) { + // Tear down + for (CentralSurfacesComponent.Startable s : mCentralSurfacesComponent.getStartables()) { + s.stop(); + } + } + mCentralSurfacesComponent = mCentralSurfacesComponentFactory.create(); + mFragmentService.addFragmentInstantiationProvider(mCentralSurfacesComponent); + + mNotificationShadeWindowView = mCentralSurfacesComponent.getNotificationShadeWindowView(); + mNotificationShadeWindowViewController = mCentralSurfacesComponent + .getNotificationShadeWindowViewController(); + mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView); + mNotificationShadeWindowViewController.setupExpandedStatusBar(); + mNotificationPanelViewController = + mCentralSurfacesComponent.getNotificationPanelViewController(); + mCentralSurfacesComponent.getLockIconViewController().init(); + mStackScrollerController = + mCentralSurfacesComponent.getNotificationStackScrollLayoutController(); + mStackScroller = mStackScrollerController.getView(); + mNotifListContainer = mCentralSurfacesComponent.getNotificationListContainer(); + mPresenter = mCentralSurfacesComponent.getNotificationPresenter(); + mNotificationActivityStarter = mCentralSurfacesComponent.getNotificationActivityStarter(); + mNotificationShelfController = mCentralSurfacesComponent.getNotificationShelfController(); + mAuthRippleController = mCentralSurfacesComponent.getAuthRippleController(); + mAuthRippleController.init(); + + mHeadsUpManager.addListener(mCentralSurfacesComponent.getStatusBarHeadsUpChangeListener()); + + // Listen for demo mode changes + mDemoModeController.addCallback(mDemoModeCallback); + + if (mCommandQueueCallbacks != null) { + mCommandQueue.removeCallback(mCommandQueueCallbacks); + } + mCommandQueueCallbacks = + mCentralSurfacesComponent.getCentralSurfacesCommandQueueCallbacks(); + // Connect in to the status bar manager service + mCommandQueue.addCallback(mCommandQueueCallbacks); + + // Perform all other initialization for CentralSurfacesScope + for (CentralSurfacesComponent.Startable s : mCentralSurfacesComponent.getStartables()) { + s.start(); + } + } + + protected void startKeyguard() { + Trace.beginSection("CentralSurfaces#startKeyguard"); + mBiometricUnlockController = mBiometricUnlockControllerLazy.get(); + mBiometricUnlockController.setBiometricModeListener( + new BiometricUnlockController.BiometricModeListener() { + @Override + public void onResetMode() { + setWakeAndUnlocking(false); + } + + @Override + public void onModeChanged(int mode) { + switch (mode) { + case BiometricUnlockController.MODE_WAKE_AND_UNLOCK_FROM_DREAM: + case BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING: + case BiometricUnlockController.MODE_WAKE_AND_UNLOCK: + setWakeAndUnlocking(true); + } + } + + @Override + public void notifyBiometricAuthModeChanged() { + CentralSurfaces.this.notifyBiometricAuthModeChanged(); + } + + private void setWakeAndUnlocking(boolean wakeAndUnlocking) { + if (getNavigationBarView() != null) { + getNavigationBarView().setWakeAndUnlocking(wakeAndUnlocking); + } + } + }); + mStatusBarKeyguardViewManager.registerCentralSurfaces( + /* statusBar= */ this, + mNotificationPanelViewController, + mPanelExpansionStateManager, + mBiometricUnlockController, + mStackScroller, + mKeyguardBypassController); + mKeyguardIndicationController + .setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); + mBiometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager); + mRemoteInputManager.addControllerCallback(mStatusBarKeyguardViewManager); + mDynamicPrivacyController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); + + mLightBarController.setBiometricUnlockController(mBiometricUnlockController); + mMediaManager.setBiometricUnlockController(mBiometricUnlockController); + mKeyguardDismissUtil.setDismissHandler(this::executeWhenUnlocked); + Trace.endSection(); + } + + public NotificationShadeWindowView getNotificationShadeWindowView() { + return mNotificationShadeWindowView; + } + + public NotificationShadeWindowViewController getNotificationShadeWindowViewController() { + return mNotificationShadeWindowViewController; + } + + public NotificationPanelViewController getNotificationPanelViewController() { + return mNotificationPanelViewController; + } + + public ViewGroup getBouncerContainer() { + return mNotificationShadeWindowViewController.getBouncerContainer(); + } + + public int getStatusBarHeight() { + return mStatusBarWindowController.getStatusBarHeight(); + } + + /** + * Disable QS if device not provisioned. + * If the user switcher is simple then disable QS during setup because + * the user intends to use the lock screen user switcher, QS in not needed. + */ + void updateQsExpansionEnabled() { + final boolean expandEnabled = mDeviceProvisionedController.isDeviceProvisioned() + && (mUserSetup || mUserSwitcherController == null + || !mUserSwitcherController.isSimpleUserSwitcher()) + && !isShadeDisabled() + && ((mDisabled2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) == 0) + && !mDozing + && !ONLY_CORE_APPS; + mNotificationPanelViewController.setQsExpansionEnabledPolicy(expandEnabled); + Log.d(TAG, "updateQsExpansionEnabled - QS Expand enabled: " + expandEnabled); + } + + public boolean isShadeDisabled() { + return (mDisabled2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE) != 0; + } + + /** + * Request a notification update + * @param reason why we're requesting a notification update + */ + public void requestNotificationUpdate(String reason) { + mNotificationsController.requestNotificationUpdate(reason); + } + + /** + * Asks {@link KeyguardUpdateMonitor} to run face auth. + */ + public void requestFaceAuth(boolean userInitiatedRequest) { + if (!mKeyguardStateController.canDismissLockScreen()) { + mKeyguardUpdateMonitor.requestFaceAuth(userInitiatedRequest); + } + } + + private void updateReportRejectedTouchVisibility() { + if (mReportRejectedTouch == null) { + return; + } + mReportRejectedTouch.setVisibility(mState == StatusBarState.KEYGUARD && !mDozing + && mFalsingCollector.isReportingEnabled() ? View.VISIBLE : View.INVISIBLE); + } + + boolean areNotificationAlertsDisabled() { + return (mDisabled1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0; + } + + @Override + public void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade, + int flags) { + startActivityDismissingKeyguard(intent, onlyProvisioned, dismissShade, flags); + } + + @Override + public void startActivity(Intent intent, boolean dismissShade) { + startActivityDismissingKeyguard(intent, false /* onlyProvisioned */, dismissShade); + } + + @Override + public void startActivity(Intent intent, boolean dismissShade, + @Nullable ActivityLaunchAnimator.Controller animationController, + boolean showOverLockscreenWhenLocked) { + // Make sure that we dismiss the keyguard if it is directly dismissable or when we don't + // want to show the activity above it. + if (mKeyguardStateController.isUnlocked() || !showOverLockscreenWhenLocked) { + startActivityDismissingKeyguard(intent, false, dismissShade, + false /* disallowEnterPictureInPictureWhileLaunching */, null /* callback */, + 0 /* flags */, animationController); + return; + } + + boolean animate = + animationController != null && shouldAnimateLaunch(true /* isActivityIntent */, + showOverLockscreenWhenLocked); + + ActivityLaunchAnimator.Controller controller = null; + if (animate) { + // Wrap the animation controller to dismiss the shade and set + // mIsLaunchingActivityOverLockscreen during the animation. + ActivityLaunchAnimator.Controller delegate = wrapAnimationController( + animationController, dismissShade); + controller = new DelegateLaunchAnimatorController(delegate) { + @Override + public void onIntentStarted(boolean willAnimate) { + getDelegate().onIntentStarted(willAnimate); + + if (willAnimate) { + CentralSurfaces.this.mIsLaunchingActivityOverLockscreen = true; + } + } + + @Override + public void onLaunchAnimationEnd(boolean isExpandingFullyAbove) { + // Set mIsLaunchingActivityOverLockscreen to false before actually finishing the + // animation so that we can assume that mIsLaunchingActivityOverLockscreen + // being true means that we will collapse the shade (or at least run the + // post collapse runnables) later on. + CentralSurfaces.this.mIsLaunchingActivityOverLockscreen = false; + getDelegate().onLaunchAnimationEnd(isExpandingFullyAbove); + } + + @Override + public void onLaunchAnimationCancelled() { + // Set mIsLaunchingActivityOverLockscreen to false before actually finishing the + // animation so that we can assume that mIsLaunchingActivityOverLockscreen + // being true means that we will collapse the shade (or at least run the + // post collapse runnables) later on. + CentralSurfaces.this.mIsLaunchingActivityOverLockscreen = false; + getDelegate().onLaunchAnimationCancelled(); + } + }; + } else if (dismissShade) { + // The animation will take care of dismissing the shade at the end of the animation. If + // we don't animate, collapse it directly. + collapseShade(); + } + + mActivityLaunchAnimator.startIntentWithAnimation(controller, animate, + intent.getPackage(), showOverLockscreenWhenLocked, (adapter) -> TaskStackBuilder + .create(mContext) + .addNextIntent(intent) + .startActivities(getActivityOptions(getDisplayId(), adapter), + UserHandle.CURRENT)); + } + + /** + * Whether we are currently animating an activity launch above the lockscreen (occluding + * activity). + */ + public boolean isLaunchingActivityOverLockscreen() { + return mIsLaunchingActivityOverLockscreen; + } + + @Override + public void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade) { + startActivityDismissingKeyguard(intent, onlyProvisioned, dismissShade); + } + + @Override + public void startActivity(Intent intent, boolean dismissShade, Callback callback) { + startActivityDismissingKeyguard(intent, false, dismissShade, + false /* disallowEnterPictureInPictureWhileLaunching */, callback, 0, + null /* animationController */); + } + + public void setQsExpanded(boolean expanded) { + mNotificationShadeWindowController.setQsExpanded(expanded); + mNotificationPanelViewController.setStatusAccessibilityImportance(expanded + ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS + : View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); + mNotificationPanelViewController.updateSystemUiStateFlags(); + if (getNavigationBarView() != null) { + getNavigationBarView().onStatusBarPanelStateChanged(); + } + } + + public boolean isWakeUpComingFromTouch() { + return mWakeUpComingFromTouch; + } + + public boolean isFalsingThresholdNeeded() { + return true; + } + + /** + * To be called when there's a state change in StatusBarKeyguardViewManager. + */ + public void onKeyguardViewManagerStatesUpdated() { + logStateToEventlog(); + } + + public void setPanelExpanded(boolean isExpanded) { + if (mPanelExpanded != isExpanded) { + mNotificationLogger.onPanelExpandedChanged(isExpanded); + } + mPanelExpanded = isExpanded; + mStatusBarHideIconsForBouncerManager.setPanelExpandedAndTriggerUpdate(isExpanded); + mNotificationShadeWindowController.setPanelExpanded(isExpanded); + mStatusBarStateController.setPanelExpanded(isExpanded); + if (isExpanded && mStatusBarStateController.getState() != StatusBarState.KEYGUARD) { + if (DEBUG) { + Log.v(TAG, "clearing notification effects from Height"); + } + clearNotificationEffects(); + } + + if (!isExpanded) { + mRemoteInputManager.onPanelCollapsed(); + } + } + + public ViewGroup getNotificationScrollLayout() { + return mStackScroller; + } + + public boolean isPulsing() { + return mDozeServiceHost.isPulsing(); + } + + @Nullable + public View getAmbientIndicationContainer() { + return mAmbientIndicationContainer; + } + + /** + * When the keyguard is showing and covered by a "showWhenLocked" activity it + * is occluded. This is controlled by {@link com.android.server.policy.PhoneWindowManager} + * + * @return whether the keyguard is currently occluded + */ + public boolean isOccluded() { + return mIsOccluded; + } + + public void setOccluded(boolean occluded) { + mIsOccluded = occluded; + mStatusBarHideIconsForBouncerManager.setIsOccludedAndTriggerUpdate(occluded); + mScrimController.setKeyguardOccluded(occluded); + } + + /** A launch animation was cancelled. */ + //TODO: These can / should probably be moved to NotificationPresenter or ShadeController + public void onLaunchAnimationCancelled(boolean isLaunchForActivity) { + if (mPresenter.isPresenterFullyCollapsed() && !mPresenter.isCollapsing() + && isLaunchForActivity) { + onClosingFinished(); + } else { + mShadeController.collapsePanel(true /* animate */); + } + } + + /** A launch animation ended. */ + public void onLaunchAnimationEnd(boolean launchIsFullScreen) { + if (!mPresenter.isCollapsing()) { + onClosingFinished(); + } + if (launchIsFullScreen) { + instantCollapseNotificationPanel(); + } + } + + /** + * Whether we should animate an activity launch. + * + * Note: This method must be called *before* dismissing the keyguard. + */ + public boolean shouldAnimateLaunch(boolean isActivityIntent, boolean showOverLockscreen) { + // TODO(b/184121838): Support launch animations when occluded. + if (isOccluded()) { + return false; + } + + // Always animate if we are not showing the keyguard or if we animate over the lockscreen + // (without unlocking it). + if (showOverLockscreen || !mKeyguardStateController.isShowing()) { + return true; + } + + // If we are locked and have to dismiss the keyguard, only animate if remote unlock + // animations are enabled. We also don't animate non-activity launches as they can break the + // animation. + // TODO(b/184121838): Support non activity launches on the lockscreen. + return isActivityIntent && KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation; + } + + /** Whether we should animate an activity launch. */ + public boolean shouldAnimateLaunch(boolean isActivityIntent) { + return shouldAnimateLaunch(isActivityIntent, false /* showOverLockscreen */); + } + + public boolean isDeviceInVrMode() { + return mPresenter.isDeviceInVrMode(); + } + + public NotificationPresenter getPresenter() { + return mPresenter; + } + + @VisibleForTesting + void setBarStateForTest(int state) { + mState = state; + } + + static class KeyboardShortcutsMessage { + final int mDeviceId; + + KeyboardShortcutsMessage(int deviceId) { + mDeviceId = deviceId; + } + } + + static class AnimateExpandSettingsPanelMessage { + final String mSubpanel; + + AnimateExpandSettingsPanelMessage(String subpanel) { + mSubpanel = subpanel; + } + } + + private void maybeEscalateHeadsUp() { + mHeadsUpManager.getAllEntries().forEach(entry -> { + final StatusBarNotification sbn = entry.getSbn(); + final Notification notification = sbn.getNotification(); + if (notification.fullScreenIntent != null) { + if (DEBUG) { + Log.d(TAG, "converting a heads up to fullScreen"); + } + try { + EventLog.writeEvent(EventLogTags.SYSUI_HEADS_UP_ESCALATION, + sbn.getKey()); + wakeUpForFullScreenIntent(); + notification.fullScreenIntent.send(); + entry.notifyFullScreenIntentLaunched(); + } catch (PendingIntent.CanceledException e) { + } + } + }); + mHeadsUpManager.releaseAllImmediately(); + } + + void wakeUpForFullScreenIntent() { + if (isGoingToSleep() || mDozing) { + mPowerManager.wakeUp( + SystemClock.uptimeMillis(), + PowerManager.WAKE_REASON_APPLICATION, + "com.android.systemui:full_screen_intent"); + mWakeUpComingFromTouch = false; + mWakeUpTouchLocation = null; + } + } + + void makeExpandedVisible(boolean force) { + if (SPEW) Log.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible); + if (!force && (mExpandedVisible || !mCommandQueue.panelsEnabled())) { + return; + } + + mExpandedVisible = true; + + // Expand the window to encompass the full screen in anticipation of the drag. + // This is only possible to do atomically because the status bar is at the top of the screen! + mNotificationShadeWindowController.setPanelVisible(true); + + visibilityChanged(true); + mCommandQueue.recomputeDisableFlags(mDisplayId, !force /* animate */); + setInteracting(StatusBarManager.WINDOW_STATUS_BAR, true); + } + + public void postAnimateCollapsePanels() { + mMainExecutor.execute(mShadeController::animateCollapsePanels); + } + + public void postAnimateForceCollapsePanels() { + mMainExecutor.execute( + () -> mShadeController.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, + true /* force */)); + } + + public void postAnimateOpenPanels() { + mMessageRouter.sendMessage(MSG_OPEN_SETTINGS_PANEL); + } + + public boolean isExpandedVisible() { + return mExpandedVisible; + } + + public boolean isPanelExpanded() { + return mPanelExpanded; + } + + /** + * Called when another window is about to transfer it's input focus. + */ + public void onInputFocusTransfer(boolean start, boolean cancel, float velocity) { + if (!mCommandQueue.panelsEnabled()) { + return; + } + + if (start) { + mNotificationPanelViewController.startWaitingForOpenPanelGesture(); + } else { + mNotificationPanelViewController.stopWaitingForOpenPanelGesture(cancel, velocity); + } + } + + public void animateCollapseQuickSettings() { + if (mState == StatusBarState.SHADE) { + mNotificationPanelViewController.collapsePanel( + true, false /* delayed */, 1.0f /* speedUpFactor */); + } + } + + void makeExpandedInvisible() { + if (SPEW) Log.d(TAG, "makeExpandedInvisible: mExpandedVisible=" + mExpandedVisible + + " mExpandedVisible=" + mExpandedVisible); + + if (!mExpandedVisible || mNotificationShadeWindowView == null) { + return; + } + + // Ensure the panel is fully collapsed (just in case; bug 6765842, 7260868) + mNotificationPanelViewController.collapsePanel(/*animate=*/ false, false /* delayed*/, + 1.0f /* speedUpFactor */); + + mNotificationPanelViewController.closeQs(); + + mExpandedVisible = false; + visibilityChanged(false); + + // Update the visibility of notification shade and status bar window. + mNotificationShadeWindowController.setPanelVisible(false); + mStatusBarWindowController.setForceStatusBarVisible(false); + + // Close any guts that might be visible + mGutsManager.closeAndSaveGuts(true /* removeLeavebehind */, true /* force */, + true /* removeControls */, -1 /* x */, -1 /* y */, true /* resetMenu */); + + mShadeController.runPostCollapseRunnables(); + setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false); + if (!mNotificationActivityStarter.isCollapsingToShowActivityOverLockscreen()) { + showBouncerOrLockScreenIfKeyguard(); + } else if (DEBUG) { + Log.d(TAG, "Not showing bouncer due to activity showing over lockscreen"); + } + mCommandQueue.recomputeDisableFlags( + mDisplayId, + mNotificationPanelViewController.hideStatusBarIconsWhenExpanded() /* animate */); + + // Trimming will happen later if Keyguard is showing - doing it here might cause a jank in + // the bouncer appear animation. + if (!mStatusBarKeyguardViewManager.isShowing()) { + WindowManagerGlobal.getInstance().trimMemory(ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN); + } + } + + /** Called when a touch event occurred on {@link PhoneStatusBarView}. */ + public void onTouchEvent(MotionEvent event) { + // TODO(b/202981994): Move this touch debugging to a central location. (Right now, it's + // split between NotificationPanelViewController and here.) + if (DEBUG_GESTURES) { + if (event.getActionMasked() != MotionEvent.ACTION_MOVE) { + EventLog.writeEvent(EventLogTags.SYSUI_STATUSBAR_TOUCH, + event.getActionMasked(), (int) event.getX(), (int) event.getY(), + mDisabled1, mDisabled2); + } + + } + + if (SPEW) { + Log.d(TAG, "Touch: rawY=" + event.getRawY() + " event=" + event + " mDisabled1=" + + mDisabled1 + " mDisabled2=" + mDisabled2); + } else if (CHATTY) { + if (event.getAction() != MotionEvent.ACTION_MOVE) { + Log.d(TAG, String.format( + "panel: %s at (%f, %f) mDisabled1=0x%08x mDisabled2=0x%08x", + MotionEvent.actionToString(event.getAction()), + event.getRawX(), event.getRawY(), mDisabled1, mDisabled2)); + } + } + + if (DEBUG_GESTURES) { + mGestureRec.add(event); + } + + if (mStatusBarWindowState == WINDOW_STATE_SHOWING) { + final boolean upOrCancel = + event.getAction() == MotionEvent.ACTION_UP || + event.getAction() == MotionEvent.ACTION_CANCEL; + setInteracting(StatusBarManager.WINDOW_STATUS_BAR, !upOrCancel || mExpandedVisible); + } + } + + public GestureRecorder getGestureRecorder() { + return mGestureRec; + } + + public BiometricUnlockController getBiometricUnlockController() { + return mBiometricUnlockController; + } + + void showTransientUnchecked() { + if (!mTransientShown) { + mTransientShown = true; + mNoAnimationOnNextBarModeChange = true; + maybeUpdateBarMode(); + } + } + + + void clearTransient() { + if (mTransientShown) { + mTransientShown = false; + maybeUpdateBarMode(); + } + } + + private void maybeUpdateBarMode() { + final int barMode = barMode(mTransientShown, mAppearance); + if (updateBarMode(barMode)) { + mLightBarController.onStatusBarModeChanged(barMode); + updateBubblesVisibility(); + } + } + + private boolean updateBarMode(int barMode) { + if (mStatusBarMode != barMode) { + mStatusBarMode = barMode; + checkBarModes(); + mAutoHideController.touchAutoHide(); + return true; + } + return false; + } + + private @TransitionMode int barMode(boolean isTransient, int appearance) { + final int lightsOutOpaque = APPEARANCE_LOW_PROFILE_BARS | APPEARANCE_OPAQUE_STATUS_BARS; + if (mOngoingCallController.hasOngoingCall() && mIsFullscreen) { + return MODE_SEMI_TRANSPARENT; + } else if (isTransient) { + return MODE_SEMI_TRANSPARENT; + } else if ((appearance & lightsOutOpaque) == lightsOutOpaque) { + return MODE_LIGHTS_OUT; + } else if ((appearance & APPEARANCE_LOW_PROFILE_BARS) != 0) { + return MODE_LIGHTS_OUT_TRANSPARENT; + } else if ((appearance & APPEARANCE_OPAQUE_STATUS_BARS) != 0) { + return MODE_OPAQUE; + } else if ((appearance & APPEARANCE_SEMI_TRANSPARENT_STATUS_BARS) != 0) { + return MODE_SEMI_TRANSPARENT; + } else { + return MODE_TRANSPARENT; + } + } + + protected void showWirelessChargingAnimation(int batteryLevel) { + showChargingAnimation(batteryLevel, UNKNOWN_BATTERY_LEVEL, 0); + } + + protected void showChargingAnimation(int batteryLevel, int transmittingBatteryLevel, + long animationDelay) { + WirelessChargingAnimation.makeWirelessChargingAnimation(mContext, null, + transmittingBatteryLevel, batteryLevel, + new WirelessChargingAnimation.Callback() { + @Override + public void onAnimationStarting() { + mNotificationShadeWindowController.setRequestTopUi(true, TAG); + } + + @Override + public void onAnimationEnded() { + mNotificationShadeWindowController.setRequestTopUi(false, TAG); + } + }, false, sUiEventLogger).show(animationDelay); + } + + public void checkBarModes() { + if (mDemoModeController.isInDemoMode()) return; + if (mStatusBarTransitions != null) { + checkBarMode(mStatusBarMode, mStatusBarWindowState, mStatusBarTransitions); + } + mNavigationBarController.checkNavBarModes(mDisplayId); + mNoAnimationOnNextBarModeChange = false; + } + + // Called by NavigationBarFragment + public void setQsScrimEnabled(boolean scrimEnabled) { + mNotificationPanelViewController.setQsScrimEnabled(scrimEnabled); + } + + /** Temporarily hides Bubbles if the status bar is hidden. */ + void updateBubblesVisibility() { + mBubblesOptional.ifPresent(bubbles -> bubbles.onStatusBarVisibilityChanged( + mStatusBarMode != MODE_LIGHTS_OUT + && mStatusBarMode != MODE_LIGHTS_OUT_TRANSPARENT + && !mStatusBarWindowHidden)); + } + + void checkBarMode(@TransitionMode int mode, @WindowVisibleState int windowState, + BarTransitions transitions) { + final boolean anim = !mNoAnimationOnNextBarModeChange && mDeviceInteractive + && windowState != WINDOW_STATE_HIDDEN; + transitions.transitionTo(mode, anim); + } + + private void finishBarAnimations() { + if (mStatusBarTransitions != null) { + mStatusBarTransitions.finishAnimations(); + } + mNavigationBarController.finishBarAnimations(mDisplayId); + } + + private final Runnable mCheckBarModes = this::checkBarModes; + + public void setInteracting(int barWindow, boolean interacting) { + mInteractingWindows = interacting + ? (mInteractingWindows | barWindow) + : (mInteractingWindows & ~barWindow); + if (mInteractingWindows != 0) { + mAutoHideController.suspendAutoHide(); + } else { + mAutoHideController.resumeSuspendedAutoHide(); + } + checkBarModes(); + } + + private void dismissVolumeDialog() { + if (mVolumeComponent != null) { + mVolumeComponent.dismissNow(); + } + } + + public static String viewInfo(View v) { + return "[(" + v.getLeft() + "," + v.getTop() + ")(" + v.getRight() + "," + v.getBottom() + + ") " + v.getWidth() + "x" + v.getHeight() + "]"; + } + + @Override + public void dump(FileDescriptor fd, PrintWriter pwOriginal, String[] args) { + IndentingPrintWriter pw = DumpUtilsKt.asIndenting(pwOriginal); + synchronized (mQueueLock) { + pw.println("Current Status Bar state:"); + pw.println(" mExpandedVisible=" + mExpandedVisible); + pw.println(" mDisplayMetrics=" + mDisplayMetrics); + pw.println(" mStackScroller: " + viewInfo(mStackScroller)); + pw.println(" mStackScroller: " + viewInfo(mStackScroller) + + " scroll " + mStackScroller.getScrollX() + + "," + mStackScroller.getScrollY()); + } + + pw.print(" mInteractingWindows="); pw.println(mInteractingWindows); + pw.print(" mStatusBarWindowState="); + pw.println(windowStateToString(mStatusBarWindowState)); + pw.print(" mStatusBarMode="); + pw.println(BarTransitions.modeToString(mStatusBarMode)); + pw.print(" mDozing="); pw.println(mDozing); + pw.print(" mWallpaperSupported= "); pw.println(mWallpaperSupported); + + pw.println(" ShadeWindowView: "); + if (mNotificationShadeWindowViewController != null) { + mNotificationShadeWindowViewController.dump(fd, pw, args); + dumpBarTransitions(pw, "PhoneStatusBarTransitions", mStatusBarTransitions); + } + + pw.println(" mMediaManager: "); + if (mMediaManager != null) { + mMediaManager.dump(fd, pw, args); + } + + pw.println(" Panels: "); + if (mNotificationPanelViewController != null) { + pw.println(" mNotificationPanel=" + + mNotificationPanelViewController.getView() + " params=" + + mNotificationPanelViewController.getView().getLayoutParams().debug("")); + pw.print (" "); + mNotificationPanelViewController.dump(fd, pw, args); + } + pw.println(" mStackScroller: "); + if (mStackScroller != null) { + // Double indent until we rewrite the rest of this dump() + pw.increaseIndent(); + pw.increaseIndent(); + mStackScroller.dump(fd, pw, args); + pw.decreaseIndent(); + pw.decreaseIndent(); + } + pw.println(" Theme:"); + String nightMode = mUiModeManager == null ? "null" : mUiModeManager.getNightMode() + ""; + pw.println(" dark theme: " + nightMode + + " (auto: " + UiModeManager.MODE_NIGHT_AUTO + + ", yes: " + UiModeManager.MODE_NIGHT_YES + + ", no: " + UiModeManager.MODE_NIGHT_NO + ")"); + final boolean lightWpTheme = mContext.getThemeResId() + == R.style.Theme_SystemUI_LightWallpaper; + pw.println(" light wallpaper theme: " + lightWpTheme); + + if (mKeyguardIndicationController != null) { + mKeyguardIndicationController.dump(fd, pw, args); + } + + if (mScrimController != null) { + mScrimController.dump(fd, pw, args); + } + + if (mLightRevealScrim != null) { + pw.println( + "mLightRevealScrim.getRevealEffect(): " + mLightRevealScrim.getRevealEffect()); + pw.println( + "mLightRevealScrim.getRevealAmount(): " + mLightRevealScrim.getRevealAmount()); + } + + if (mStatusBarKeyguardViewManager != null) { + mStatusBarKeyguardViewManager.dump(pw); + } + + mNotificationsController.dump(fd, pw, args, DUMPTRUCK); + + if (DEBUG_GESTURES) { + pw.print(" status bar gestures: "); + mGestureRec.dump(fd, pw, args); + } + + if (mHeadsUpManager != null) { + mHeadsUpManager.dump(fd, pw, args); + } else { + pw.println(" mHeadsUpManager: null"); + } + + if (mStatusBarTouchableRegionManager != null) { + mStatusBarTouchableRegionManager.dump(fd, pw, args); + } else { + pw.println(" mStatusBarTouchableRegionManager: null"); + } + + if (mLightBarController != null) { + mLightBarController.dump(fd, pw, args); + } + + pw.println("SharedPreferences:"); + for (Map.Entry entry : Prefs.getAll(mContext).entrySet()) { + pw.print(" "); pw.print(entry.getKey()); pw.print("="); pw.println(entry.getValue()); + } + + pw.println("Camera gesture intents:"); + pw.println(" Insecure camera: " + CameraIntents.getInsecureCameraIntent(mContext)); + pw.println(" Secure camera: " + CameraIntents.getSecureCameraIntent(mContext)); + pw.println(" Override package: " + + CameraIntents.getOverrideCameraPackage(mContext)); + } + + public static void dumpBarTransitions( + PrintWriter pw, String var, @Nullable BarTransitions transitions) { + pw.print(" "); pw.print(var); pw.print(".BarTransitions.mMode="); + if (transitions != null) { + pw.println(BarTransitions.modeToString(transitions.getMode())); + } else { + pw.println("Unknown"); + } + } + + public void createAndAddWindows(@Nullable RegisterStatusBarResult result) { + makeStatusBarView(result); + mNotificationShadeWindowController.attach(); + mStatusBarWindowController.attach(); + } + + // called by makeStatusbar and also by PhoneStatusBarView + void updateDisplaySize() { + mDisplay.getMetrics(mDisplayMetrics); + mDisplay.getSize(mCurrentDisplaySize); + if (DEBUG_GESTURES) { + mGestureRec.tag("display", + String.format("%dx%d", mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels)); + } + } + + float getDisplayDensity() { + return mDisplayMetrics.density; + } + + public float getDisplayWidth() { + return mDisplayMetrics.widthPixels; + } + + public float getDisplayHeight() { + return mDisplayMetrics.heightPixels; + } + + int getRotation() { + return mDisplay.getRotation(); + } + + int getDisplayId() { + return mDisplayId; + } + + public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned, + boolean dismissShade, int flags) { + startActivityDismissingKeyguard(intent, onlyProvisioned, dismissShade, + false /* disallowEnterPictureInPictureWhileLaunching */, null /* callback */, + flags, null /* animationController */); + } + + public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned, + boolean dismissShade) { + startActivityDismissingKeyguard(intent, onlyProvisioned, dismissShade, 0); + } + + void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned, + final boolean dismissShade, final boolean disallowEnterPictureInPictureWhileLaunching, + final Callback callback, int flags, + @Nullable ActivityLaunchAnimator.Controller animationController) { + if (onlyProvisioned && !mDeviceProvisionedController.isDeviceProvisioned()) return; + + final boolean willLaunchResolverActivity = + mActivityIntentHelper.wouldLaunchResolverActivity(intent, + mLockscreenUserManager.getCurrentUserId()); + + boolean animate = + animationController != null && !willLaunchResolverActivity && shouldAnimateLaunch( + true /* isActivityIntent */); + ActivityLaunchAnimator.Controller animController = + animationController != null ? wrapAnimationController(animationController, + dismissShade) : null; + + // If we animate, we will dismiss the shade only once the animation is done. This is taken + // care of by the StatusBarLaunchAnimationController. + boolean dismissShadeDirectly = dismissShade && animController == null; + + Runnable runnable = () -> { + mAssistManagerLazy.get().hideAssist(); + intent.setFlags( + Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); + intent.addFlags(flags); + int[] result = new int[]{ActivityManager.START_CANCELED}; + + mActivityLaunchAnimator.startIntentWithAnimation(animController, + animate, intent.getPackage(), (adapter) -> { + ActivityOptions options = new ActivityOptions( + getActivityOptions(mDisplayId, adapter)); + options.setDisallowEnterPictureInPictureWhileLaunching( + disallowEnterPictureInPictureWhileLaunching); + if (CameraIntents.isInsecureCameraIntent(intent)) { + // Normally an activity will set it's requested rotation + // animation on its window. However when launching an activity + // causes the orientation to change this is too late. In these cases + // the default animation is used. This doesn't look good for + // the camera (as it rotates the camera contents out of sync + // with physical reality). So, we ask the WindowManager to + // force the crossfade animation if an orientation change + // happens to occur during the launch. + options.setRotationAnimationHint( + WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS); + } + if (Settings.Panel.ACTION_VOLUME.equals(intent.getAction())) { + // Settings Panel is implemented as activity(not a dialog), so + // underlying app is paused and may enter picture-in-picture mode + // as a result. + // So we need to disable picture-in-picture mode here + // if it is volume panel. + options.setDisallowEnterPictureInPictureWhileLaunching(true); + } + + try { + result[0] = ActivityTaskManager.getService().startActivityAsUser( + null, mContext.getBasePackageName(), + mContext.getAttributionTag(), + intent, + intent.resolveTypeIfNeeded(mContext.getContentResolver()), + null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, + options.toBundle(), UserHandle.CURRENT.getIdentifier()); + } catch (RemoteException e) { + Log.w(TAG, "Unable to start activity", e); + } + return result[0]; + }); + + if (callback != null) { + callback.onActivityStarted(result[0]); + } + }; + Runnable cancelRunnable = () -> { + if (callback != null) { + callback.onActivityStarted(ActivityManager.START_CANCELED); + } + }; + executeRunnableDismissingKeyguard(runnable, cancelRunnable, dismissShadeDirectly, + willLaunchResolverActivity, true /* deferred */, animate); + } + + @Nullable + private ActivityLaunchAnimator.Controller wrapAnimationController( + ActivityLaunchAnimator.Controller animationController, boolean dismissShade) { + View rootView = animationController.getLaunchContainer().getRootView(); + + Optional controllerFromStatusBar = + mStatusBarWindowController.wrapAnimationControllerIfInStatusBar( + rootView, animationController); + if (controllerFromStatusBar.isPresent()) { + return controllerFromStatusBar.get(); + } + + if (dismissShade) { + // If the view is not in the status bar, then we are animating a view in the shade. + // We have to make sure that we collapse it when the animation ends or is cancelled. + return new StatusBarLaunchAnimatorController(animationController, this, + true /* isLaunchForActivity */); + } + + return animationController; + } + + public void readyForKeyguardDone() { + mStatusBarKeyguardViewManager.readyForKeyguardDone(); + } + + public void executeRunnableDismissingKeyguard(final Runnable runnable, + final Runnable cancelAction, + final boolean dismissShade, + final boolean afterKeyguardGone, + final boolean deferred) { + executeRunnableDismissingKeyguard(runnable, cancelAction, dismissShade, afterKeyguardGone, + deferred, false /* willAnimateOnKeyguard */); + } + + public void executeRunnableDismissingKeyguard(final Runnable runnable, + final Runnable cancelAction, + final boolean dismissShade, + final boolean afterKeyguardGone, + final boolean deferred, + final boolean willAnimateOnKeyguard) { + OnDismissAction onDismissAction = new OnDismissAction() { + @Override + public boolean onDismiss() { + if (runnable != null) { + if (mStatusBarKeyguardViewManager.isShowing() + && mStatusBarKeyguardViewManager.isOccluded()) { + mStatusBarKeyguardViewManager.addAfterKeyguardGoneRunnable(runnable); + } else { + mMainExecutor.execute(runnable); + } + } + if (dismissShade) { + if (mExpandedVisible && !mBouncerShowing) { + mShadeController.animateCollapsePanels( + CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, + true /* force */, true /* delayed*/); + } else { + + // Do it after DismissAction has been processed to conserve the needed + // ordering. + mMainExecutor.execute(mShadeController::runPostCollapseRunnables); + } + } else if (CentralSurfaces.this.isInLaunchTransition() + && mNotificationPanelViewController.isLaunchTransitionFinished()) { + + // We are not dismissing the shade, but the launch transition is already + // finished, + // so nobody will call readyForKeyguardDone anymore. Post it such that + // keyguardDonePending gets called first. + mMainExecutor.execute(mStatusBarKeyguardViewManager::readyForKeyguardDone); + } + return deferred; + } + + @Override + public boolean willRunAnimationOnKeyguard() { + return willAnimateOnKeyguard; + } + }; + dismissKeyguardThenExecute(onDismissAction, cancelAction, afterKeyguardGone); + } + + private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + Trace.beginSection("CentralSurfaces#onReceive"); + if (DEBUG) Log.v(TAG, "onReceive: " + intent); + String action = intent.getAction(); + String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY); + if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { + KeyboardShortcuts.dismiss(); + mRemoteInputManager.closeRemoteInputs(); + if (mLockscreenUserManager.isCurrentProfile(getSendingUserId())) { + int flags = CommandQueue.FLAG_EXCLUDE_NONE; + if (reason != null) { + if (reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) { + flags |= CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL; + } + // Do not collapse notifications when starting dreaming if the notifications + // shade is used for the screen off animation. It might require expanded + // state for the scrims to be visible + if (reason.equals(SYSTEM_DIALOG_REASON_DREAM) + && mScreenOffAnimationController.shouldExpandNotifications()) { + flags |= CommandQueue.FLAG_EXCLUDE_NOTIFICATION_PANEL; + } + } + mShadeController.animateCollapsePanels(flags); + } + } else if (Intent.ACTION_SCREEN_OFF.equals(action)) { + if (mNotificationShadeWindowController != null) { + mNotificationShadeWindowController.setNotTouchable(false); + } + finishBarAnimations(); + resetUserExpandedStates(); + } else if (DevicePolicyManager.ACTION_SHOW_DEVICE_MONITORING_DIALOG.equals(action)) { + mQSPanelController.showDeviceMonitoringDialog(); + } + Trace.endSection(); + } + }; + + private final BroadcastReceiver mDemoReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + if (DEBUG) Log.v(TAG, "onReceive: " + intent); + String action = intent.getAction(); + if (ACTION_FAKE_ARTWORK.equals(action)) { + if (DEBUG_MEDIA_FAKE_ARTWORK) { + mPresenter.updateMediaMetaData(true, true); + } + } + } + }; + + public void resetUserExpandedStates() { + mNotificationsController.resetUserExpandedStates(); + } + + private void executeWhenUnlocked(OnDismissAction action, boolean requiresShadeOpen, + boolean afterKeyguardGone) { + if (mStatusBarKeyguardViewManager.isShowing() && requiresShadeOpen) { + mStatusBarStateController.setLeaveOpenOnKeyguardHide(true); + } + dismissKeyguardThenExecute(action, null /* cancelAction */, + afterKeyguardGone /* afterKeyguardGone */); + } + + protected void dismissKeyguardThenExecute(OnDismissAction action, boolean afterKeyguardGone) { + dismissKeyguardThenExecute(action, null /* cancelRunnable */, afterKeyguardGone); + } + + @Override + public void dismissKeyguardThenExecute(OnDismissAction action, Runnable cancelAction, + boolean afterKeyguardGone) { + if (mWakefulnessLifecycle.getWakefulness() == WAKEFULNESS_ASLEEP + && mKeyguardStateController.canDismissLockScreen() + && !mStatusBarStateController.leaveOpenOnKeyguardHide() + && mDozeServiceHost.isPulsing()) { + // Reuse the biometric wake-and-unlock transition if we dismiss keyguard from a pulse. + // TODO: Factor this transition out of BiometricUnlockController. + mBiometricUnlockController.startWakeAndUnlock( + BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING); + } + if (mStatusBarKeyguardViewManager.isShowing()) { + mStatusBarKeyguardViewManager.dismissWithAction(action, cancelAction, + afterKeyguardGone); + } else { + action.onDismiss(); + } + } + /** + * Notify the shade controller that the current user changed + * + * @param newUserId userId of the new user + */ + public void setLockscreenUser(int newUserId) { + if (mLockscreenWallpaper != null) { + mLockscreenWallpaper.setCurrentUser(newUserId); + } + mScrimController.setCurrentUser(newUserId); + if (mWallpaperSupported) { + mWallpaperChangedReceiver.onReceive(mContext, null); + } + } + + /** + * Reload some of our resources when the configuration changes. + * + * We don't reload everything when the configuration changes -- we probably + * should, but getting that smooth is tough. Someday we'll fix that. In the + * meantime, just update the things that we know change. + */ + void updateResources() { + // Update the quick setting tiles + if (mQSPanelController != null) { + mQSPanelController.updateResources(); + } + + if (mStatusBarWindowController != null) { + mStatusBarWindowController.refreshStatusBarHeight(); + } + + if (mNotificationPanelViewController != null) { + mNotificationPanelViewController.updateResources(); + } + if (mBrightnessMirrorController != null) { + mBrightnessMirrorController.updateResources(); + } + if (mStatusBarKeyguardViewManager != null) { + mStatusBarKeyguardViewManager.updateResources(); + } + + mPowerButtonReveal = new PowerButtonReveal(mContext.getResources().getDimensionPixelSize( + com.android.systemui.R.dimen.physical_power_button_center_screen_location_y)); + } + + // Visibility reporting + protected void handleVisibleToUserChanged(boolean visibleToUser) { + if (visibleToUser) { + handleVisibleToUserChangedImpl(visibleToUser); + mNotificationLogger.startNotificationLogging(); + } else { + mNotificationLogger.stopNotificationLogging(); + handleVisibleToUserChangedImpl(visibleToUser); + } + } + + // Visibility reporting + void handleVisibleToUserChangedImpl(boolean visibleToUser) { + if (visibleToUser) { + /* The LEDs are turned off when the notification panel is shown, even just a little bit. + * See also CentralSurfaces.setPanelExpanded for another place where we attempt to do + * this. + */ + boolean pinnedHeadsUp = mHeadsUpManager.hasPinnedHeadsUp(); + boolean clearNotificationEffects = + !mPresenter.isPresenterFullyCollapsed() && + (mState == StatusBarState.SHADE + || mState == StatusBarState.SHADE_LOCKED); + int notificationLoad = mNotificationsController.getActiveNotificationsCount(); + if (pinnedHeadsUp && mPresenter.isPresenterFullyCollapsed()) { + notificationLoad = 1; + } + final int finalNotificationLoad = notificationLoad; + mUiBgExecutor.execute(() -> { + try { + mBarService.onPanelRevealed(clearNotificationEffects, + finalNotificationLoad); + } catch (RemoteException ex) { + // Won't fail unless the world has ended. + } + }); + } else { + mUiBgExecutor.execute(() -> { + try { + mBarService.onPanelHidden(); + } catch (RemoteException ex) { + // Won't fail unless the world has ended. + } + }); + } + + } + + private void logStateToEventlog() { + boolean isShowing = mStatusBarKeyguardViewManager.isShowing(); + boolean isOccluded = mStatusBarKeyguardViewManager.isOccluded(); + boolean isBouncerShowing = mStatusBarKeyguardViewManager.isBouncerShowing(); + boolean isSecure = mKeyguardStateController.isMethodSecure(); + boolean unlocked = mKeyguardStateController.canDismissLockScreen(); + int stateFingerprint = getLoggingFingerprint(mState, + isShowing, + isOccluded, + isBouncerShowing, + isSecure, + unlocked); + if (stateFingerprint != mLastLoggedStateFingerprint) { + if (mStatusBarStateLog == null) { + mStatusBarStateLog = new LogMaker(MetricsEvent.VIEW_UNKNOWN); + } + mMetricsLogger.write(mStatusBarStateLog + .setCategory(isBouncerShowing ? MetricsEvent.BOUNCER : MetricsEvent.LOCKSCREEN) + .setType(isShowing ? MetricsEvent.TYPE_OPEN : MetricsEvent.TYPE_CLOSE) + .setSubtype(isSecure ? 1 : 0)); + EventLogTags.writeSysuiStatusBarState(mState, + isShowing ? 1 : 0, + isOccluded ? 1 : 0, + isBouncerShowing ? 1 : 0, + isSecure ? 1 : 0, + unlocked ? 1 : 0); + mLastLoggedStateFingerprint = stateFingerprint; + + StringBuilder uiEventValueBuilder = new StringBuilder(); + uiEventValueBuilder.append(isBouncerShowing ? "BOUNCER" : "LOCKSCREEN"); + uiEventValueBuilder.append(isShowing ? "_OPEN" : "_CLOSE"); + uiEventValueBuilder.append(isSecure ? "_SECURE" : "_INSECURE"); + sUiEventLogger.log(StatusBarUiEvent.valueOf(uiEventValueBuilder.toString())); + } + } + + /** + * Returns a fingerprint of fields logged to eventlog + */ + private static int getLoggingFingerprint(int statusBarState, boolean keyguardShowing, + boolean keyguardOccluded, boolean bouncerShowing, boolean secure, + boolean currentlyInsecure) { + // Reserve 8 bits for statusBarState. We'll never go higher than + // that, right? Riiiight. + return (statusBarState & 0xFF) + | ((keyguardShowing ? 1 : 0) << 8) + | ((keyguardOccluded ? 1 : 0) << 9) + | ((bouncerShowing ? 1 : 0) << 10) + | ((secure ? 1 : 0) << 11) + | ((currentlyInsecure ? 1 : 0) << 12); + } + + @Override + public void postQSRunnableDismissingKeyguard(final Runnable runnable) { + mMainExecutor.execute(() -> { + mStatusBarStateController.setLeaveOpenOnKeyguardHide(true); + executeRunnableDismissingKeyguard( + () -> mMainExecutor.execute(runnable), null, false, false, false); + }); + } + + @Override + public void postStartActivityDismissingKeyguard(PendingIntent intent) { + postStartActivityDismissingKeyguard(intent, null /* animationController */); + } + + @Override + public void postStartActivityDismissingKeyguard(final PendingIntent intent, + @Nullable ActivityLaunchAnimator.Controller animationController) { + mMainExecutor.execute(() -> startPendingIntentDismissingKeyguard(intent, + null /* intentSentUiThreadCallback */, animationController)); + } + + @Override + public void postStartActivityDismissingKeyguard(final Intent intent, int delay) { + postStartActivityDismissingKeyguard(intent, delay, null /* animationController */); + } + + @Override + public void postStartActivityDismissingKeyguard(Intent intent, int delay, + @Nullable ActivityLaunchAnimator.Controller animationController) { + mMainExecutor.executeDelayed( + () -> + startActivityDismissingKeyguard(intent, true /* onlyProvisioned */, + true /* dismissShade */, + false /* disallowEnterPictureInPictureWhileLaunching */, + null /* callback */, + 0 /* flags */, + animationController), + delay); + } + + public void showKeyguard() { + mStatusBarStateController.setKeyguardRequested(true); + mStatusBarStateController.setLeaveOpenOnKeyguardHide(false); + updateIsKeyguard(); + mAssistManagerLazy.get().onLockscreenShown(); + } + + public boolean hideKeyguard() { + mStatusBarStateController.setKeyguardRequested(false); + return updateIsKeyguard(); + } + + boolean updateIsKeyguard() { + return updateIsKeyguard(false /* forceStateChange */); + } + + boolean updateIsKeyguard(boolean forceStateChange) { + boolean wakeAndUnlocking = mBiometricUnlockController.getMode() + == BiometricUnlockController.MODE_WAKE_AND_UNLOCK; + + // For dozing, keyguard needs to be shown whenever the device is non-interactive. Otherwise + // there's no surface we can show to the user. Note that the device goes fully interactive + // late in the transition, so we also allow the device to start dozing once the screen has + // turned off fully. + boolean keyguardForDozing = mDozeServiceHost.getDozingRequested() + && (!mDeviceInteractive || isGoingToSleep() && (isScreenFullyOff() || mIsKeyguard)); + boolean isWakingAndOccluded = isOccluded() && isWaking(); + boolean shouldBeKeyguard = (mStatusBarStateController.isKeyguardRequested() + || keyguardForDozing) && !wakeAndUnlocking && !isWakingAndOccluded; + if (keyguardForDozing) { + updatePanelExpansionForKeyguard(); + } + if (shouldBeKeyguard) { + if (mScreenOffAnimationController.isKeyguardShowDelayed() + || (isGoingToSleep() + && mScreenLifecycle.getScreenState() == ScreenLifecycle.SCREEN_TURNING_OFF)) { + // Delay showing the keyguard until screen turned off. + } else { + showKeyguardImpl(); + } + } else { + // During folding a foldable device this might be called as a result of + // 'onScreenTurnedOff' call for the inner display. + // In this case: + // * When phone is locked on folding: it doesn't make sense to hide keyguard as it + // will be immediately locked again + // * When phone is unlocked: we still don't want to execute hiding of the keyguard + // as the animation could prepare 'fake AOD' interface (without actually + // transitioning to keyguard state) and this might reset the view states + if (!mScreenOffAnimationController.isKeyguardHideDelayed()) { + return hideKeyguardImpl(forceStateChange); + } + } + return false; + } + + public void showKeyguardImpl() { + Trace.beginSection("CentralSurfaces#showKeyguard"); + mIsKeyguard = true; + // In case we're locking while a smartspace transition is in progress, reset it. + mKeyguardUnlockAnimationController.resetSmartspaceTransition(); + if (mKeyguardStateController.isLaunchTransitionFadingAway()) { + mNotificationPanelViewController.cancelAnimation(); + onLaunchTransitionFadingEnded(); + } + mMessageRouter.cancelMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); + if (!mLockscreenShadeTransitionController.isWakingToShadeLocked()) { + mStatusBarStateController.setState(StatusBarState.KEYGUARD); + } + updatePanelExpansionForKeyguard(); + Trace.endSection(); + } + + private void updatePanelExpansionForKeyguard() { + if (mState == StatusBarState.KEYGUARD && mBiometricUnlockController.getMode() + != BiometricUnlockController.MODE_WAKE_AND_UNLOCK && !mBouncerShowing) { + mShadeController.instantExpandNotificationsPanel(); + } + } + + private void onLaunchTransitionFadingEnded() { + mNotificationPanelViewController.resetAlpha(); + mNotificationPanelViewController.onAffordanceLaunchEnded(); + releaseGestureWakeLock(); + runLaunchTransitionEndRunnable(); + mKeyguardStateController.setLaunchTransitionFadingAway(false); + mPresenter.updateMediaMetaData(true /* metaDataChanged */, true); + } + + public boolean isInLaunchTransition() { + return mNotificationPanelViewController.isLaunchTransitionRunning() + || mNotificationPanelViewController.isLaunchTransitionFinished(); + } + + /** + * Fades the content of the keyguard away after the launch transition is done. + * + * @param beforeFading the runnable to be run when the circle is fully expanded and the fading + * starts + * @param endRunnable the runnable to be run when the transition is done + */ + public void fadeKeyguardAfterLaunchTransition(final Runnable beforeFading, + Runnable endRunnable) { + mMessageRouter.cancelMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); + mLaunchTransitionEndRunnable = endRunnable; + Runnable hideRunnable = () -> { + mKeyguardStateController.setLaunchTransitionFadingAway(true); + if (beforeFading != null) { + beforeFading.run(); + } + updateScrimController(); + mPresenter.updateMediaMetaData(false, true); + mNotificationPanelViewController.resetAlpha(); + mNotificationPanelViewController.fadeOut( + FADE_KEYGUARD_START_DELAY, FADE_KEYGUARD_DURATION, + this::onLaunchTransitionFadingEnded); + mCommandQueue.appTransitionStarting(mDisplayId, SystemClock.uptimeMillis(), + LightBarTransitionsController.DEFAULT_TINT_ANIMATION_DURATION, true); + }; + if (mNotificationPanelViewController.isLaunchTransitionRunning()) { + mNotificationPanelViewController.setLaunchTransitionEndRunnable(hideRunnable); + } else { + hideRunnable.run(); + } + } + + /** + * Fades the content of the Keyguard while we are dozing and makes it invisible when finished + * fading. + */ + public void fadeKeyguardWhilePulsing() { + mNotificationPanelViewController.fadeOut(0, FADE_KEYGUARD_DURATION_PULSING, + ()-> { + hideKeyguard(); + mStatusBarKeyguardViewManager.onKeyguardFadedAway(); + }).start(); + } + + /** + * Plays the animation when an activity that was occluding Keyguard goes away. + */ + public void animateKeyguardUnoccluding() { + mNotificationPanelViewController.setExpandedFraction(0f); + mCommandQueueCallbacks.animateExpandNotificationsPanel(); + mScrimController.setUnocclusionAnimationRunning(true); + } + + /** + * Starts the timeout when we try to start the affordances on Keyguard. We usually rely that + * Keyguard goes away via fadeKeyguardAfterLaunchTransition, however, that might not happen + * because the launched app crashed or something else went wrong. + */ + public void startLaunchTransitionTimeout() { + mMessageRouter.sendMessageDelayed( + MSG_LAUNCH_TRANSITION_TIMEOUT, LAUNCH_TRANSITION_TIMEOUT_MS); + } + + private void onLaunchTransitionTimeout() { + Log.w(TAG, "Launch transition: Timeout!"); + mNotificationPanelViewController.onAffordanceLaunchEnded(); + releaseGestureWakeLock(); + mNotificationPanelViewController.resetViews(false /* animate */); + } + + private void runLaunchTransitionEndRunnable() { + if (mLaunchTransitionEndRunnable != null) { + Runnable r = mLaunchTransitionEndRunnable; + + // mLaunchTransitionEndRunnable might call showKeyguard, which would execute it again, + // which would lead to infinite recursion. Protect against it. + mLaunchTransitionEndRunnable = null; + r.run(); + } + } + + /** + * @return true if we would like to stay in the shade, false if it should go away entirely + */ + public boolean hideKeyguardImpl(boolean forceStateChange) { + mIsKeyguard = false; + Trace.beginSection("CentralSurfaces#hideKeyguard"); + boolean staying = mStatusBarStateController.leaveOpenOnKeyguardHide(); + int previousState = mStatusBarStateController.getState(); + if (!(mStatusBarStateController.setState(StatusBarState.SHADE, forceStateChange))) { + //TODO: StatusBarStateController should probably know about hiding the keyguard and + // notify listeners. + + // If the state didn't change, we may still need to update public mode + mLockscreenUserManager.updatePublicMode(); + } + if (mStatusBarStateController.leaveOpenOnKeyguardHide()) { + if (!mStatusBarStateController.isKeyguardRequested()) { + mStatusBarStateController.setLeaveOpenOnKeyguardHide(false); + } + long delay = mKeyguardStateController.calculateGoingToFullShadeDelay(); + mLockscreenShadeTransitionController.onHideKeyguard(delay, previousState); + + // Disable layout transitions in navbar for this transition because the load is just + // too heavy for the CPU and GPU on any device. + mNavigationBarController.disableAnimationsDuringHide(mDisplayId, delay); + } else if (!mNotificationPanelViewController.isCollapsing()) { + instantCollapseNotificationPanel(); + } + + // Keyguard state has changed, but QS is not listening anymore. Make sure to update the tile + // visibilities so next time we open the panel we know the correct height already. + if (mQSPanelController != null) { + mQSPanelController.refreshAllTiles(); + } + mMessageRouter.cancelMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); + releaseGestureWakeLock(); + mNotificationPanelViewController.onAffordanceLaunchEnded(); + mNotificationPanelViewController.cancelAnimation(); + mNotificationPanelViewController.resetAlpha(); + mNotificationPanelViewController.resetTranslation(); + mNotificationPanelViewController.resetViewGroupFade(); + updateDozingState(); + updateScrimController(); + Trace.endSection(); + return staying; + } + + private void releaseGestureWakeLock() { + if (mGestureWakeLock.isHeld()) { + mGestureWakeLock.release(); + } + } + + /** + * Notifies the status bar that Keyguard is going away very soon. + */ + public void keyguardGoingAway() { + // Treat Keyguard exit animation as an app transition to achieve nice transition for status + // bar. + mKeyguardStateController.notifyKeyguardGoingAway(true); + mCommandQueue.appTransitionPending(mDisplayId, true /* forced */); + updateScrimController(); + } + + /** + * Notifies the status bar the Keyguard is fading away with the specified timings. + * @param startTime the start time of the animations in uptime millis + * @param delay the precalculated animation delay in milliseconds + * @param fadeoutDuration the duration of the exit animation, in milliseconds + * @param isBypassFading is this a fading away animation while bypassing + */ + public void setKeyguardFadingAway(long startTime, long delay, long fadeoutDuration, + boolean isBypassFading) { + mCommandQueue.appTransitionStarting(mDisplayId, startTime + fadeoutDuration + - LightBarTransitionsController.DEFAULT_TINT_ANIMATION_DURATION, + LightBarTransitionsController.DEFAULT_TINT_ANIMATION_DURATION, true); + mCommandQueue.recomputeDisableFlags(mDisplayId, fadeoutDuration > 0 /* animate */); + mCommandQueue.appTransitionStarting(mDisplayId, + startTime - LightBarTransitionsController.DEFAULT_TINT_ANIMATION_DURATION, + LightBarTransitionsController.DEFAULT_TINT_ANIMATION_DURATION, true); + mKeyguardStateController.notifyKeyguardFadingAway(delay, fadeoutDuration, isBypassFading); + } + + /** + * Notifies that the Keyguard fading away animation is done. + */ + public void finishKeyguardFadingAway() { + mKeyguardStateController.notifyKeyguardDoneFading(); + mScrimController.setExpansionAffectsAlpha(true); + } + + /** + * Switches theme from light to dark and vice-versa. + */ + protected void updateTheme() { + // Set additional scrim only if the lock and system wallpaper are different to prevent + // applying the dimming effect twice. + mUiBgExecutor.execute(() -> { + float dimAmount = 0f; + if (mWallpaperManager.lockScreenWallpaperExists()) { + dimAmount = mWallpaperManager.getWallpaperDimAmount(); + } + final float scrimDimAmount = dimAmount; + mMainExecutor.execute(() -> { + mScrimController.setAdditionalScrimBehindAlphaKeyguard(scrimDimAmount); + mScrimController.applyCompositeAlphaOnScrimBehindKeyguard(); + }); + }); + + // Lock wallpaper defines the color of the majority of the views, hence we'll use it + // to set our default theme. + final boolean lockDarkText = mColorExtractor.getNeutralColors().supportsDarkText(); + final int themeResId = lockDarkText ? R.style.Theme_SystemUI_LightWallpaper + : R.style.Theme_SystemUI; + if (mContext.getThemeResId() != themeResId) { + mContext.setTheme(themeResId); + mConfigurationController.notifyThemeChanged(); + } + } + + private void updateDozingState() { + Trace.traceCounter(Trace.TRACE_TAG_APP, "dozing", mDozing ? 1 : 0); + Trace.beginSection("CentralSurfaces#updateDozingState"); + + boolean visibleNotOccluded = mStatusBarKeyguardViewManager.isShowing() + && !mStatusBarKeyguardViewManager.isOccluded(); + // If we're dozing and we'll be animating the screen off, the keyguard isn't currently + // visible but will be shortly for the animation, so we should proceed as if it's visible. + boolean visibleNotOccludedOrWillBe = + visibleNotOccluded || (mDozing && mDozeParameters.shouldDelayKeyguardShow()); + + boolean wakeAndUnlock = mBiometricUnlockController.getMode() + == BiometricUnlockController.MODE_WAKE_AND_UNLOCK; + boolean animate = (!mDozing && mDozeServiceHost.shouldAnimateWakeup() && !wakeAndUnlock) + || (mDozing && mDozeParameters.shouldControlScreenOff() + && visibleNotOccludedOrWillBe); + + mNotificationPanelViewController.setDozing(mDozing, animate, mWakeUpTouchLocation); + updateQsExpansionEnabled(); + Trace.endSection(); + } + + public void userActivity() { + if (mState == StatusBarState.KEYGUARD) { + mKeyguardViewMediatorCallback.userActivity(); + } + } + + public boolean interceptMediaKey(KeyEvent event) { + return mState == StatusBarState.KEYGUARD + && mStatusBarKeyguardViewManager.interceptMediaKey(event); + } + + /** + * While IME is active and a BACK event is detected, check with + * {@link StatusBarKeyguardViewManager#dispatchBackKeyEventPreIme()} to see if the event + * should be handled before routing to IME, in order to prevent the user having to hit back + * twice to exit bouncer. + */ + public boolean dispatchKeyEventPreIme(KeyEvent event) { + switch (event.getKeyCode()) { + case KeyEvent.KEYCODE_BACK: + if (mState == StatusBarState.KEYGUARD + && mStatusBarKeyguardViewManager.dispatchBackKeyEventPreIme()) { + return onBackPressed(); + } + } + return false; + } + + protected boolean shouldUnlockOnMenuPressed() { + return mDeviceInteractive && mState != StatusBarState.SHADE + && mStatusBarKeyguardViewManager.shouldDismissOnMenuPressed(); + } + + public boolean onMenuPressed() { + if (shouldUnlockOnMenuPressed()) { + mShadeController.animateCollapsePanels( + CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL /* flags */, true /* force */); + return true; + } + return false; + } + + public void endAffordanceLaunch() { + releaseGestureWakeLock(); + mNotificationPanelViewController.onAffordanceLaunchEnded(); + } + + public boolean onBackPressed() { + boolean isScrimmedBouncer = mScrimController.getState() == ScrimState.BOUNCER_SCRIMMED; + if (mStatusBarKeyguardViewManager.onBackPressed(isScrimmedBouncer /* hideImmediately */)) { + if (isScrimmedBouncer) { + mStatusBarStateController.setLeaveOpenOnKeyguardHide(false); + } else { + mNotificationPanelViewController.expandWithoutQs(); + } + return true; + } + if (mNotificationPanelViewController.isQsCustomizing()) { + mNotificationPanelViewController.closeQsCustomizer(); + return true; + } + if (mNotificationPanelViewController.isQsExpanded()) { + if (mNotificationPanelViewController.isQsDetailShowing()) { + mNotificationPanelViewController.closeQsDetail(); + } else { + mNotificationPanelViewController.animateCloseQs(false /* animateAway */); + } + return true; + } + if (mNotificationPanelViewController.closeUserSwitcherIfOpen()) { + return true; + } + if (mState != StatusBarState.KEYGUARD && mState != StatusBarState.SHADE_LOCKED) { + if (mNotificationPanelViewController.canPanelBeCollapsed()) { + mShadeController.animateCollapsePanels(); + } + return true; + } + return false; + } + + public boolean onSpacePressed() { + if (mDeviceInteractive && mState != StatusBarState.SHADE) { + mShadeController.animateCollapsePanels( + CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL /* flags */, true /* force */); + return true; + } + return false; + } + + private void showBouncerOrLockScreenIfKeyguard() { + // If the keyguard is animating away, we aren't really the keyguard anymore and should not + // show the bouncer/lockscreen. + if (!mKeyguardViewMediator.isHiding() + && !mKeyguardUnlockAnimationController.isPlayingCannedUnlockAnimation()) { + if (mState == StatusBarState.SHADE_LOCKED + && mKeyguardUpdateMonitor.isUdfpsEnrolled()) { + // shade is showing while locked on the keyguard, so go back to showing the + // lock screen where users can use the UDFPS affordance to enter the device + mStatusBarKeyguardViewManager.reset(true); + } else if ((mState == StatusBarState.KEYGUARD + && !mStatusBarKeyguardViewManager.bouncerIsOrWillBeShowing()) + || mState == StatusBarState.SHADE_LOCKED) { + mStatusBarKeyguardViewManager.showGenericBouncer(true /* scrimmed */); + } + } + } + + /** + * Show the bouncer if we're currently on the keyguard or shade locked and aren't hiding. + * @param performAction the action to perform when the bouncer is dismissed. + * @param cancelAction the action to perform when unlock is aborted. + */ + public void showBouncerWithDimissAndCancelIfKeyguard(OnDismissAction performAction, + Runnable cancelAction) { + if ((mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) + && !mKeyguardViewMediator.isHiding()) { + mStatusBarKeyguardViewManager.dismissWithAction(performAction, cancelAction, + false /* afterKeyguardGone */); + } else if (cancelAction != null) { + cancelAction.run(); + } + } + + void instantCollapseNotificationPanel() { + mNotificationPanelViewController.instantCollapse(); + mShadeController.runPostCollapseRunnables(); + } + + /** + * Collapse the panel directly if we are on the main thread, post the collapsing on the main + * thread if we are not. + */ + void collapsePanelOnMainThread() { + if (Looper.getMainLooper().isCurrentThread()) { + mShadeController.collapsePanel(); + } else { + mContext.getMainExecutor().execute(mShadeController::collapsePanel); + } + } + + /** Collapse the panel. The collapsing will be animated for the given {@code duration}. */ + void collapsePanelWithDuration(int duration) { + mNotificationPanelViewController.collapseWithDuration(duration); + } + + /** + * Updates the light reveal effect to reflect the reason we're waking or sleeping (for example, + * from the power button). + * @param wakingUp Whether we're updating because we're waking up (true) or going to sleep + * (false). + */ + private void updateRevealEffect(boolean wakingUp) { + if (mLightRevealScrim == null) { + return; + } + + final boolean wakingUpFromPowerButton = wakingUp + && !(mLightRevealScrim.getRevealEffect() instanceof CircleReveal) + && mWakefulnessLifecycle.getLastWakeReason() + == PowerManager.WAKE_REASON_POWER_BUTTON; + final boolean sleepingFromPowerButton = !wakingUp + && mWakefulnessLifecycle.getLastSleepReason() + == PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON; + + if (wakingUpFromPowerButton || sleepingFromPowerButton) { + mLightRevealScrim.setRevealEffect(mPowerButtonReveal); + mLightRevealScrim.setRevealAmount(1f - mStatusBarStateController.getDozeAmount()); + } else if (!wakingUp || !(mLightRevealScrim.getRevealEffect() instanceof CircleReveal)) { + // If we're going to sleep, but it's not from the power button, use the default reveal. + // If we're waking up, only use the default reveal if the biometric controller didn't + // already set it to the circular reveal because we're waking up from a fingerprint/face + // auth. + mLightRevealScrim.setRevealEffect(LiftReveal.INSTANCE); + mLightRevealScrim.setRevealAmount(1f - mStatusBarStateController.getDozeAmount()); + } + } + + public LightRevealScrim getLightRevealScrim() { + return mLightRevealScrim; + } + + private void updateKeyguardState() { + mKeyguardStateController.notifyKeyguardState(mStatusBarKeyguardViewManager.isShowing(), + mStatusBarKeyguardViewManager.isOccluded()); + } + + public void onTrackingStarted() { + mShadeController.runPostCollapseRunnables(); + } + + public void onClosingFinished() { + mShadeController.runPostCollapseRunnables(); + if (!mPresenter.isPresenterFullyCollapsed()) { + // if we set it not to be focusable when collapsing, we have to undo it when we aborted + // the closing + mNotificationShadeWindowController.setNotificationShadeFocusable(true); + } + } + + public void onUnlockHintStarted() { + mFalsingCollector.onUnlockHintStarted(); + mKeyguardIndicationController.showActionToUnlock(); + } + + public void onHintFinished() { + // Delay the reset a bit so the user can read the text. + mKeyguardIndicationController.hideTransientIndicationDelayed(HINT_RESET_DELAY_MS); + } + + public void onCameraHintStarted() { + mFalsingCollector.onCameraHintStarted(); + mKeyguardIndicationController.showTransientIndication(R.string.camera_hint); + } + + public void onVoiceAssistHintStarted() { + mFalsingCollector.onLeftAffordanceHintStarted(); + mKeyguardIndicationController.showTransientIndication(R.string.voice_hint); + } + + public void onPhoneHintStarted() { + mFalsingCollector.onLeftAffordanceHintStarted(); + mKeyguardIndicationController.showTransientIndication(R.string.phone_hint); + } + + public void onTrackingStopped(boolean expand) { + if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) { + if (!expand && !mKeyguardStateController.canDismissLockScreen()) { + mStatusBarKeyguardViewManager.showBouncer(false /* scrimmed */); + } + } + } + + // TODO: Figure out way to remove these. + public NavigationBarView getNavigationBarView() { + return mNavigationBarController.getNavigationBarView(mDisplayId); + } + + public void showPinningEnterExitToast(boolean entering) { + mNavigationBarController.showPinningEnterExitToast(mDisplayId, entering); + } + + public void showPinningEscapeToast() { + mNavigationBarController.showPinningEscapeToast(mDisplayId); + } + + /** + * TODO: Remove this method. Views should not be passed forward. Will cause theme issues. + * @return bottom area view + */ + public KeyguardBottomAreaView getKeyguardBottomAreaView() { + return mNotificationPanelViewController.getKeyguardBottomAreaView(); + } + + /** + * Propagation of the bouncer state, indicating that it's fully visible. + */ + public void setBouncerShowing(boolean bouncerShowing) { + mBouncerShowing = bouncerShowing; + mKeyguardBypassController.setBouncerShowing(bouncerShowing); + mPulseExpansionHandler.setBouncerShowing(bouncerShowing); + setBouncerShowingForStatusBarComponents(bouncerShowing); + mStatusBarHideIconsForBouncerManager.setBouncerShowingAndTriggerUpdate(bouncerShowing); + mCommandQueue.recomputeDisableFlags(mDisplayId, true /* animate */); + updateScrimController(); + if (!mBouncerShowing) { + updatePanelExpansionForKeyguard(); + } + } + + /** + * Propagate the bouncer state to status bar components. + * + * Separate from {@link #setBouncerShowing} because we sometimes re-create the status bar and + * should update only the status bar components. + */ + private void setBouncerShowingForStatusBarComponents(boolean bouncerShowing) { + int importance = bouncerShowing + ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS + : IMPORTANT_FOR_ACCESSIBILITY_AUTO; + if (mPhoneStatusBarViewController != null) { + mPhoneStatusBarViewController.setImportantForAccessibility(importance); + } + mNotificationPanelViewController.setImportantForAccessibility(importance); + mNotificationPanelViewController.setBouncerShowing(bouncerShowing); + } + + /** + * Collapses the notification shade if it is tracking or expanded. + */ + public void collapseShade() { + if (mNotificationPanelViewController.isTracking()) { + mNotificationShadeWindowViewController.cancelCurrentTouch(); + } + if (mPanelExpanded && mState == StatusBarState.SHADE) { + mShadeController.animateCollapsePanels(); + } + } + + @VisibleForTesting + final WakefulnessLifecycle.Observer mWakefulnessObserver = new WakefulnessLifecycle.Observer() { + @Override + public void onFinishedGoingToSleep() { + mNotificationPanelViewController.onAffordanceLaunchEnded(); + releaseGestureWakeLock(); + mLaunchCameraWhenFinishedWaking = false; + mDeviceInteractive = false; + mWakeUpComingFromTouch = false; + mWakeUpTouchLocation = null; + updateVisibleToUser(); + + updateNotificationPanelTouchState(); + mNotificationShadeWindowViewController.cancelCurrentTouch(); + if (mLaunchCameraOnFinishedGoingToSleep) { + mLaunchCameraOnFinishedGoingToSleep = false; + + // This gets executed before we will show Keyguard, so post it in order that the state + // is correct. + mMainExecutor.execute(() -> mCommandQueueCallbacks.onCameraLaunchGestureDetected( + mLastCameraLaunchSource)); + } + + if (mLaunchEmergencyActionOnFinishedGoingToSleep) { + mLaunchEmergencyActionOnFinishedGoingToSleep = false; + + // This gets executed before we will show Keyguard, so post it in order that the + // state is correct. + mMainExecutor.execute( + () -> mCommandQueueCallbacks.onEmergencyActionLaunchGestureDetected()); + } + updateIsKeyguard(); + } + + @Override + public void onStartedGoingToSleep() { + String tag = "CentralSurfaces#onStartedGoingToSleep"; + DejankUtils.startDetectingBlockingIpcs(tag); + updateRevealEffect(false /* wakingUp */); + updateNotificationPanelTouchState(); + maybeEscalateHeadsUp(); + dismissVolumeDialog(); + mWakeUpCoordinator.setFullyAwake(false); + mKeyguardBypassController.onStartedGoingToSleep(); + + // The unlocked screen off and fold to aod animations might use our LightRevealScrim - + // we need to be expanded for it to be visible. + if (mDozeParameters.shouldShowLightRevealScrim()) { + makeExpandedVisible(true); + } + + DejankUtils.stopDetectingBlockingIpcs(tag); + } + + @Override + public void onStartedWakingUp() { + String tag = "CentralSurfaces#onStartedWakingUp"; + DejankUtils.startDetectingBlockingIpcs(tag); + mNotificationShadeWindowController.batchApplyWindowLayoutParams(()-> { + mDeviceInteractive = true; + mWakeUpCoordinator.setWakingUp(true); + if (!mKeyguardBypassController.getBypassEnabled()) { + mHeadsUpManager.releaseAllImmediately(); + } + updateVisibleToUser(); + updateIsKeyguard(); + mDozeServiceHost.stopDozing(); + // This is intentionally below the stopDozing call above, since it avoids that we're + // unnecessarily animating the wakeUp transition. Animations should only be enabled + // once we fully woke up. + updateRevealEffect(true /* wakingUp */); + updateNotificationPanelTouchState(); + + // If we are waking up during the screen off animation, we should undo making the + // expanded visible (we did that so the LightRevealScrim would be visible). + if (mScreenOffAnimationController.shouldHideLightRevealScrimOnWakeUp()) { + makeExpandedInvisible(); + } + + }); + DejankUtils.stopDetectingBlockingIpcs(tag); + } + + @Override + public void onFinishedWakingUp() { + mWakeUpCoordinator.setFullyAwake(true); + mWakeUpCoordinator.setWakingUp(false); + if (mLaunchCameraWhenFinishedWaking) { + mNotificationPanelViewController.launchCamera( + false /* animate */, mLastCameraLaunchSource); + mLaunchCameraWhenFinishedWaking = false; + } + if (mLaunchEmergencyActionWhenFinishedWaking) { + mLaunchEmergencyActionWhenFinishedWaking = false; + Intent emergencyIntent = getEmergencyActionIntent(); + if (emergencyIntent != null) { + mContext.startActivityAsUser(emergencyIntent, UserHandle.CURRENT); + } + } + updateScrimController(); + } + }; + + /** + * We need to disable touch events because these might + * collapse the panel after we expanded it, and thus we would end up with a blank + * Keyguard. + */ + void updateNotificationPanelTouchState() { + boolean goingToSleepWithoutAnimation = isGoingToSleep() + && !mDozeParameters.shouldControlScreenOff(); + boolean disabled = (!mDeviceInteractive && !mDozeServiceHost.isPulsing()) + || goingToSleepWithoutAnimation; + mNotificationPanelViewController.setTouchAndAnimationDisabled(disabled); + mNotificationIconAreaController.setAnimationsEnabled(!disabled); + } + + final ScreenLifecycle.Observer mScreenObserver = new ScreenLifecycle.Observer() { + @Override + public void onScreenTurningOn(Runnable onDrawn) { + mFalsingCollector.onScreenTurningOn(); + mNotificationPanelViewController.onScreenTurningOn(); + } + + @Override + public void onScreenTurnedOn() { + mScrimController.onScreenTurnedOn(); + } + + @Override + public void onScreenTurnedOff() { + Trace.beginSection("CentralSurfaces#onScreenTurnedOff"); + mFalsingCollector.onScreenOff(); + mScrimController.onScreenTurnedOff(); + if (mCloseQsBeforeScreenOff) { + mNotificationPanelViewController.closeQs(); + mCloseQsBeforeScreenOff = false; + } + updateIsKeyguard(); + Trace.endSection(); + } + }; + + public int getWakefulnessState() { + return mWakefulnessLifecycle.getWakefulness(); + } + + /** + * @return true if the screen is currently fully off, i.e. has finished turning off and has + * since not started turning on. + */ + public boolean isScreenFullyOff() { + return mScreenLifecycle.getScreenState() == ScreenLifecycle.SCREEN_OFF; + } + + public void showScreenPinningRequest(int taskId, boolean allowCancel) { + mScreenPinningRequest.showPrompt(taskId, allowCancel); + } + + @Nullable Intent getEmergencyActionIntent() { + Intent emergencyIntent = new Intent(EmergencyGesture.ACTION_LAUNCH_EMERGENCY); + PackageManager pm = mContext.getPackageManager(); + List emergencyActivities = pm.queryIntentActivities(emergencyIntent, + PackageManager.MATCH_SYSTEM_ONLY); + ResolveInfo resolveInfo = getTopEmergencySosInfo(emergencyActivities); + if (resolveInfo == null) { + Log.wtf(TAG, "Couldn't find an app to process the emergency intent."); + return null; + } + emergencyIntent.setComponent(new ComponentName(resolveInfo.activityInfo.packageName, + resolveInfo.activityInfo.name)); + emergencyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + return emergencyIntent; + } + + /** + * Select and return the "best" ResolveInfo for Emergency SOS Activity. + */ + private @Nullable ResolveInfo getTopEmergencySosInfo(List emergencyActivities) { + // No matched activity. + if (emergencyActivities == null || emergencyActivities.isEmpty()) { + return null; + } + + // Of multiple matched Activities, give preference to the pre-set package name. + String preferredAppPackageName = + mContext.getString(R.string.config_preferredEmergencySosPackage); + + // If there is no preferred app, then return first match. + if (TextUtils.isEmpty(preferredAppPackageName)) { + return emergencyActivities.get(0); + } + + for (ResolveInfo emergencyInfo: emergencyActivities) { + // If activity is from the preferred app, use it. + if (TextUtils.equals(emergencyInfo.activityInfo.packageName, preferredAppPackageName)) { + return emergencyInfo; + } + } + // No matching activity: return first match + return emergencyActivities.get(0); + } + + boolean isCameraAllowedByAdmin() { + if (mDevicePolicyManager.getCameraDisabled(null, + mLockscreenUserManager.getCurrentUserId())) { + return false; + } else if (mStatusBarKeyguardViewManager == null + || (isKeyguardShowing() && isKeyguardSecure())) { + // Check if the admin has disabled the camera specifically for the keyguard + return (mDevicePolicyManager.getKeyguardDisabledFeatures(null, + mLockscreenUserManager.getCurrentUserId()) + & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA) == 0; + } + return true; + } + + boolean isGoingToSleep() { + return mWakefulnessLifecycle.getWakefulness() + == WakefulnessLifecycle.WAKEFULNESS_GOING_TO_SLEEP; + } + + boolean isWaking() { + return mWakefulnessLifecycle.getWakefulness() == WakefulnessLifecycle.WAKEFULNESS_WAKING; + } + + public void notifyBiometricAuthModeChanged() { + mDozeServiceHost.updateDozing(); + updateScrimController(); + } + + /** + * Set the amount of progress we are currently in if we're transitioning to the full shade. + * 0.0f means we're not transitioning yet, while 1 means we're all the way in the full + * shade. + */ + public void setTransitionToFullShadeProgress(float transitionToFullShadeProgress) { + mTransitionToFullShadeProgress = transitionToFullShadeProgress; + } + + @VisibleForTesting + public void updateScrimController() { + Trace.beginSection("CentralSurfaces#updateScrimController"); + + boolean unlocking = mKeyguardStateController.isShowing() && ( + mBiometricUnlockController.isWakeAndUnlock() + || mKeyguardStateController.isKeyguardFadingAway() + || mKeyguardStateController.isKeyguardGoingAway() + || mKeyguardViewMediator.requestedShowSurfaceBehindKeyguard() + || mKeyguardViewMediator.isAnimatingBetweenKeyguardAndSurfaceBehind()); + + mScrimController.setExpansionAffectsAlpha(!unlocking); + + boolean launchingAffordanceWithPreview = + mNotificationPanelViewController.isLaunchingAffordanceWithPreview(); + mScrimController.setLaunchingAffordanceWithPreview(launchingAffordanceWithPreview); + + if (mStatusBarKeyguardViewManager.isShowingAlternateAuth()) { + if (mState == StatusBarState.SHADE || mState == StatusBarState.SHADE_LOCKED + || mTransitionToFullShadeProgress > 0f) { + mScrimController.transitionTo(ScrimState.AUTH_SCRIMMED_SHADE); + } else { + mScrimController.transitionTo(ScrimState.AUTH_SCRIMMED); + } + } else if (mBouncerShowing && !unlocking) { + // Bouncer needs the front scrim when it's on top of an activity, + // tapping on a notification, editing QS or being dismissed by + // FLAG_DISMISS_KEYGUARD_ACTIVITY. + ScrimState state = mStatusBarKeyguardViewManager.bouncerNeedsScrimming() + ? ScrimState.BOUNCER_SCRIMMED : ScrimState.BOUNCER; + mScrimController.transitionTo(state); + } else if (launchingAffordanceWithPreview) { + // We want to avoid animating when launching with a preview. + mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback); + } else if (mBrightnessMirrorVisible) { + mScrimController.transitionTo(ScrimState.BRIGHTNESS_MIRROR); + } else if (mState == StatusBarState.SHADE_LOCKED) { + mScrimController.transitionTo(ScrimState.SHADE_LOCKED); + } else if (mDozeServiceHost.isPulsing()) { + mScrimController.transitionTo(ScrimState.PULSING, + mDozeScrimController.getScrimCallback()); + } else if (mDozeServiceHost.hasPendingScreenOffCallback()) { + mScrimController.transitionTo(ScrimState.OFF, new ScrimController.Callback() { + @Override + public void onFinished() { + mDozeServiceHost.executePendingScreenOffCallback(); + } + }); + } else if (mDozing && !unlocking) { + mScrimController.transitionTo(ScrimState.AOD); + } else if (mIsKeyguard && !unlocking) { + mScrimController.transitionTo(ScrimState.KEYGUARD); + } else { + mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback); + } + updateLightRevealScrimVisibility(); + + Trace.endSection(); + } + + public boolean isKeyguardShowing() { + if (mStatusBarKeyguardViewManager == null) { + Slog.i(TAG, "isKeyguardShowing() called before startKeyguard(), returning true"); + return true; + } + return mStatusBarKeyguardViewManager.isShowing(); + } + + public boolean shouldIgnoreTouch() { + return (mStatusBarStateController.isDozing() + && mDozeServiceHost.getIgnoreTouchWhilePulsing()) + || mScreenOffAnimationController.shouldIgnoreKeyguardTouches(); + } + + // Begin Extra BaseStatusBar methods. + + protected final CommandQueue mCommandQueue; + protected IStatusBarService mBarService; + + // all notifications + protected NotificationStackScrollLayout mStackScroller; + + // handling reordering + private final VisualStabilityManager mVisualStabilityManager; + + protected AccessibilityManager mAccessibilityManager; + + protected boolean mDeviceInteractive; + + protected boolean mVisible; + + // mScreenOnFromKeyguard && mVisible. + private boolean mVisibleToUser; + + protected DevicePolicyManager mDevicePolicyManager; + private final PowerManager mPowerManager; + protected StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; + + protected KeyguardManager mKeyguardManager; + private final DeviceProvisionedController mDeviceProvisionedController; + + private final NavigationBarController mNavigationBarController; + private final AccessibilityFloatingMenuController mAccessibilityFloatingMenuController; + + // UI-specific methods + + protected WindowManager mWindowManager; + protected IWindowManager mWindowManagerService; + private IDreamManager mDreamManager; + + protected Display mDisplay; + private int mDisplayId; + + protected NotificationShelfController mNotificationShelfController; + + private final Lazy mAssistManagerLazy; + + public boolean isDeviceInteractive() { + return mDeviceInteractive; + } + + private final BroadcastReceiver mBannerActionBroadcastReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (BANNER_ACTION_CANCEL.equals(action) || BANNER_ACTION_SETUP.equals(action)) { + NotificationManager noMan = (NotificationManager) + mContext.getSystemService(Context.NOTIFICATION_SERVICE); + noMan.cancel(com.android.internal.messages.nano.SystemMessageProto.SystemMessage. + NOTE_HIDDEN_NOTIFICATIONS); + + Settings.Secure.putInt(mContext.getContentResolver(), + Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 0); + if (BANNER_ACTION_SETUP.equals(action)) { + mShadeController.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, + true /* force */); + mContext.startActivity(new Intent(Settings.ACTION_APP_NOTIFICATION_REDACTION) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + + ); + } + } + } + }; + + public void setNotificationSnoozed(StatusBarNotification sbn, SnoozeOption snoozeOption) { + mNotificationsController.setNotificationSnoozed(sbn, snoozeOption); + } + + + public void awakenDreams() { + mUiBgExecutor.execute(() -> { + try { + mDreamManager.awaken(); + } catch (RemoteException e) { + e.printStackTrace(); + } + }); + } + + protected void toggleKeyboardShortcuts(int deviceId) { + KeyboardShortcuts.toggle(mContext, deviceId); + } + + protected void dismissKeyboardShortcuts() { + KeyboardShortcuts.dismiss(); + } + + /** + * Dismiss the keyguard then execute an action. + * + * @param action The action to execute after dismissing the keyguard. + * @param collapsePanel Whether we should collapse the panel after dismissing the keyguard. + * @param willAnimateOnKeyguard Whether {@param action} will run an animation on the keyguard if + * we are locked. + */ + private void executeActionDismissingKeyguard(Runnable action, boolean afterKeyguardGone, + boolean collapsePanel, boolean willAnimateOnKeyguard) { + if (!mDeviceProvisionedController.isDeviceProvisioned()) return; + + OnDismissAction onDismissAction = new OnDismissAction() { + @Override + public boolean onDismiss() { + new Thread(() -> { + try { + // The intent we are sending is for the application, which + // won't have permission to immediately start an activity after + // the user switches to home. We know it is safe to do at this + // point, so make sure new activity switches are now allowed. + ActivityManager.getService().resumeAppSwitches(); + } catch (RemoteException e) { + } + action.run(); + }).start(); + + return collapsePanel ? mShadeController.collapsePanel() : willAnimateOnKeyguard; + } + + @Override + public boolean willRunAnimationOnKeyguard() { + return willAnimateOnKeyguard; + } + }; + dismissKeyguardThenExecute(onDismissAction, afterKeyguardGone); + } + + @Override + public void startPendingIntentDismissingKeyguard(final PendingIntent intent) { + startPendingIntentDismissingKeyguard(intent, null); + } + + @Override + public void startPendingIntentDismissingKeyguard( + final PendingIntent intent, @Nullable final Runnable intentSentUiThreadCallback) { + startPendingIntentDismissingKeyguard(intent, intentSentUiThreadCallback, + (ActivityLaunchAnimator.Controller) null); + } + + @Override + public void startPendingIntentDismissingKeyguard(PendingIntent intent, + Runnable intentSentUiThreadCallback, View associatedView) { + ActivityLaunchAnimator.Controller animationController = null; + if (associatedView instanceof ExpandableNotificationRow) { + animationController = mNotificationAnimationProvider.getAnimatorController( + ((ExpandableNotificationRow) associatedView)); + } + + startPendingIntentDismissingKeyguard(intent, intentSentUiThreadCallback, + animationController); + } + + @Override + public void startPendingIntentDismissingKeyguard( + final PendingIntent intent, @Nullable final Runnable intentSentUiThreadCallback, + @Nullable ActivityLaunchAnimator.Controller animationController) { + final boolean willLaunchResolverActivity = intent.isActivity() + && mActivityIntentHelper.wouldLaunchResolverActivity(intent.getIntent(), + mLockscreenUserManager.getCurrentUserId()); + + boolean animate = !willLaunchResolverActivity + && animationController != null + && shouldAnimateLaunch(intent.isActivity()); + + // If we animate, don't collapse the shade and defer the keyguard dismiss (in case we run + // the animation on the keyguard). The animation will take care of (instantly) collapsing + // the shade and hiding the keyguard once it is done. + boolean collapse = !animate; + executeActionDismissingKeyguard(() -> { + try { + // We wrap animationCallback with a StatusBarLaunchAnimatorController so that the + // shade is collapsed after the animation (or when it is cancelled, aborted, etc). + ActivityLaunchAnimator.Controller controller = + animationController != null ? new StatusBarLaunchAnimatorController( + animationController, this, intent.isActivity()) : null; + + mActivityLaunchAnimator.startPendingIntentWithAnimation( + controller, animate, intent.getCreatorPackage(), + (animationAdapter) -> intent.sendAndReturnResult(null, 0, null, null, null, + null, getActivityOptions(mDisplayId, animationAdapter))); + } catch (PendingIntent.CanceledException e) { + // the stack trace isn't very helpful here. + // Just log the exception message. + Log.w(TAG, "Sending intent failed: " + e); + if (!collapse) { + // executeActionDismissingKeyguard did not collapse for us already. + collapsePanelOnMainThread(); + } + // TODO: Dismiss Keyguard. + } + if (intent.isActivity()) { + mAssistManagerLazy.get().hideAssist(); + } + if (intentSentUiThreadCallback != null) { + postOnUiThread(intentSentUiThreadCallback); + } + }, willLaunchResolverActivity, collapse, animate); + } + + private void postOnUiThread(Runnable runnable) { + mMainExecutor.execute(runnable); + } + + /** + * Returns an ActivityOptions bundle created using the given parameters. + * + * @param displayId The ID of the display to launch the activity in. Typically this would be the + * display the status bar is on. + * @param animationAdapter The animation adapter used to start this activity, or {@code null} + * for the default animation. + */ + public static Bundle getActivityOptions(int displayId, + @Nullable RemoteAnimationAdapter animationAdapter) { + ActivityOptions options = getDefaultActivityOptions(animationAdapter); + options.setLaunchDisplayId(displayId); + options.setCallerDisplayId(displayId); + return options.toBundle(); + } + + /** + * Returns an ActivityOptions bundle created using the given parameters. + * + * @param displayId The ID of the display to launch the activity in. Typically this would be the + * display the status bar is on. + * @param animationAdapter The animation adapter used to start this activity, or {@code null} + * for the default animation. + * @param isKeyguardShowing Whether keyguard is currently showing. + * @param eventTime The event time in milliseconds since boot, not including sleep. See + * {@link ActivityOptions#setSourceInfo}. + */ + public static Bundle getActivityOptions(int displayId, + @Nullable RemoteAnimationAdapter animationAdapter, boolean isKeyguardShowing, + long eventTime) { + ActivityOptions options = getDefaultActivityOptions(animationAdapter); + options.setSourceInfo(isKeyguardShowing ? ActivityOptions.SourceInfo.TYPE_LOCKSCREEN + : ActivityOptions.SourceInfo.TYPE_NOTIFICATION, eventTime); + options.setLaunchDisplayId(displayId); + options.setCallerDisplayId(displayId); + return options.toBundle(); + } + + public static ActivityOptions getDefaultActivityOptions( + @Nullable RemoteAnimationAdapter animationAdapter) { + ActivityOptions options; + if (animationAdapter != null) { + if (ENABLE_SHELL_TRANSITIONS) { + options = ActivityOptions.makeRemoteTransition( + RemoteTransitionAdapter.adaptRemoteAnimation(animationAdapter)); + } else { + options = ActivityOptions.makeRemoteAnimation(animationAdapter); + } + } else { + options = ActivityOptions.makeBasic(); + } + return options; + } + + void visibilityChanged(boolean visible) { + if (mVisible != visible) { + mVisible = visible; + if (!visible) { + mGutsManager.closeAndSaveGuts(true /* removeLeavebehind */, true /* force */, + true /* removeControls */, -1 /* x */, -1 /* y */, true /* resetMenu */); + } + } + updateVisibleToUser(); + } + + protected void updateVisibleToUser() { + boolean oldVisibleToUser = mVisibleToUser; + mVisibleToUser = mVisible && mDeviceInteractive; + + if (oldVisibleToUser != mVisibleToUser) { + handleVisibleToUserChanged(mVisibleToUser); + } + } + + /** + * Clear Buzz/Beep/Blink. + */ + public void clearNotificationEffects() { + try { + mBarService.clearNotificationEffects(); + } catch (RemoteException e) { + // Won't fail unless the world has ended. + } + } + + /** + * @return Whether the security bouncer from Keyguard is showing. + */ + public boolean isBouncerShowing() { + return mBouncerShowing; + } + + /** + * @return Whether the security bouncer from Keyguard is showing. + */ + public boolean isBouncerShowingScrimmed() { + return isBouncerShowing() && mStatusBarKeyguardViewManager.bouncerNeedsScrimming(); + } + + public boolean isBouncerShowingOverDream() { + return isBouncerShowing() && mDreamOverlayStateController.isOverlayActive(); + } + + /** + * When {@link KeyguardBouncer} starts to be dismissed, playing its animation. + */ + public void onBouncerPreHideAnimation() { + mNotificationPanelViewController.onBouncerPreHideAnimation(); + + } + + /** + * @return a PackageManger for userId or if userId is < 0 (USER_ALL etc) then + * return PackageManager for mContext + */ + public static PackageManager getPackageManagerForUser(Context context, int userId) { + Context contextForUser = context; + // UserHandle defines special userId as negative values, e.g. USER_ALL + if (userId >= 0) { + try { + // Create a context for the correct user so if a package isn't installed + // for user 0 we can still load information about the package. + contextForUser = + context.createPackageContextAsUser(context.getPackageName(), + Context.CONTEXT_RESTRICTED, + new UserHandle(userId)); + } catch (NameNotFoundException e) { + // Shouldn't fail to find the package name for system ui. + } + } + return contextForUser.getPackageManager(); + } + + public boolean isKeyguardSecure() { + if (mStatusBarKeyguardViewManager == null) { + // startKeyguard() hasn't been called yet, so we don't know. + // Make sure anything that needs to know isKeyguardSecure() checks and re-checks this + // value onVisibilityChanged(). + Slog.w(TAG, "isKeyguardSecure() called before startKeyguard(), returning false", + new Throwable()); + return false; + } + return mStatusBarKeyguardViewManager.isSecure(); + } + public NotificationPanelViewController getPanelController() { + return mNotificationPanelViewController; + } + // End Extra BaseStatusBarMethods. + + public NotificationGutsManager getGutsManager() { + return mGutsManager; + } + + boolean isTransientShown() { + return mTransientShown; + } + + private void updateLightRevealScrimVisibility() { + if (mLightRevealScrim == null) { + // status bar may not be inflated yet + return; + } + + mLightRevealScrim.setAlpha(mScrimController.getState().getMaxLightRevealScrimAlpha()); + } + + private final KeyguardUpdateMonitorCallback mUpdateCallback = + new KeyguardUpdateMonitorCallback() { + @Override + public void onDreamingStateChanged(boolean dreaming) { + if (dreaming) { + maybeEscalateHeadsUp(); + } + } + + // TODO: (b/145659174) remove when moving to NewNotifPipeline. Replaced by + // KeyguardCoordinator + @Override + public void onStrongAuthStateChanged(int userId) { + super.onStrongAuthStateChanged(userId); + mNotificationsController.requestNotificationUpdate("onStrongAuthStateChanged"); + } + }; + + + private final FalsingManager.FalsingBeliefListener mFalsingBeliefListener = + new FalsingManager.FalsingBeliefListener() { + @Override + public void onFalse() { + // Hides quick settings, bouncer, and quick-quick settings. + mStatusBarKeyguardViewManager.reset(true); + } + }; + + // Notifies StatusBarKeyguardViewManager every time the keyguard transition is over, + // this animation is tied to the scrim for historic reasons. + // TODO: notify when keyguard has faded away instead of the scrim. + private final ScrimController.Callback mUnlockScrimCallback = new ScrimController + .Callback() { + @Override + public void onFinished() { + if (mStatusBarKeyguardViewManager == null) { + Log.w(TAG, "Tried to notify keyguard visibility when " + + "mStatusBarKeyguardViewManager was null"); + return; + } + if (mKeyguardStateController.isKeyguardFadingAway()) { + mStatusBarKeyguardViewManager.onKeyguardFadedAway(); + } + } + + @Override + public void onCancelled() { + onFinished(); + } + }; + + private final DeviceProvisionedListener mUserSetupObserver = new DeviceProvisionedListener() { + @Override + public void onUserSetupChanged() { + final boolean userSetup = mDeviceProvisionedController.isCurrentUserSetup(); + Log.d(TAG, "mUserSetupObserver - DeviceProvisionedListener called for " + + "current user"); + if (MULTIUSER_DEBUG) { + Log.d(TAG, String.format("User setup changed: userSetup=%s mUserSetup=%s", + userSetup, mUserSetup)); + } + + if (userSetup != mUserSetup) { + mUserSetup = userSetup; + if (!mUserSetup) { + animateCollapseQuickSettings(); + } + if (mNotificationPanelViewController != null) { + mNotificationPanelViewController.setUserSetupComplete(mUserSetup); + } + updateQsExpansionEnabled(); + } + } + }; + + private final BroadcastReceiver mWallpaperChangedReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + if (!mWallpaperSupported) { + // Receiver should not have been registered at all... + Log.wtf(TAG, "WallpaperManager not supported"); + return; + } + WallpaperInfo info = mWallpaperManager.getWallpaperInfo(UserHandle.USER_CURRENT); + mWallpaperController.onWallpaperInfoUpdated(info); + + final boolean deviceSupportsAodWallpaper = mContext.getResources().getBoolean( + com.android.internal.R.bool.config_dozeSupportsAodWallpaper); + // If WallpaperInfo is null, it must be ImageWallpaper. + final boolean supportsAmbientMode = deviceSupportsAodWallpaper + && (info != null && info.supportsAmbientMode()); + + mNotificationShadeWindowController.setWallpaperSupportsAmbientMode(supportsAmbientMode); + mScrimController.setWallpaperSupportsAmbientMode(supportsAmbientMode); + mKeyguardViewMediator.setWallpaperSupportsAmbientMode(supportsAmbientMode); + } + }; + + private final ConfigurationListener mConfigurationListener = new ConfigurationListener() { + @Override + public void onConfigChanged(Configuration newConfig) { + updateResources(); + updateDisplaySize(); // populates mDisplayMetrics + + if (DEBUG) { + Log.v(TAG, "configuration changed: " + mContext.getResources().getConfiguration()); + } + + if (!mNotifPipelineFlags.isNewPipelineEnabled()) { + mViewHierarchyManager.updateRowStates(); + } + mScreenPinningRequest.onConfigurationChanged(); + } + + @Override + public void onDensityOrFontScaleChanged() { + // TODO: Remove this. + if (mBrightnessMirrorController != null) { + mBrightnessMirrorController.onDensityOrFontScaleChanged(); + } + // TODO: Bring these out of CentralSurfaces. + mUserInfoControllerImpl.onDensityOrFontScaleChanged(); + mUserSwitcherController.onDensityOrFontScaleChanged(); + mNotificationIconAreaController.onDensityOrFontScaleChanged(mContext); + mHeadsUpManager.onDensityOrFontScaleChanged(); + } + + @Override + public void onThemeChanged() { + if (mBrightnessMirrorController != null) { + mBrightnessMirrorController.onOverlayChanged(); + } + // We need the new R.id.keyguard_indication_area before recreating + // mKeyguardIndicationController + mNotificationPanelViewController.onThemeChanged(); + + if (mStatusBarKeyguardViewManager != null) { + mStatusBarKeyguardViewManager.onThemeChanged(); + } + if (mAmbientIndicationContainer instanceof AutoReinflateContainer) { + ((AutoReinflateContainer) mAmbientIndicationContainer).inflateLayout(); + } + mNotificationIconAreaController.onThemeChanged(); + } + + @Override + public void onUiModeChanged() { + if (mBrightnessMirrorController != null) { + mBrightnessMirrorController.onUiModeChanged(); + } + } + }; + + private StatusBarStateController.StateListener mStateListener = + new StatusBarStateController.StateListener() { + @Override + public void onStatePreChange(int oldState, int newState) { + // If we're visible and switched to SHADE_LOCKED (the user dragged + // down on the lockscreen), clear notification LED, vibration, + // ringing. + // Other transitions are covered in handleVisibleToUserChanged(). + if (mVisible && (newState == StatusBarState.SHADE_LOCKED + || mStatusBarStateController.goingToFullShade())) { + clearNotificationEffects(); + } + if (newState == StatusBarState.KEYGUARD) { + mRemoteInputManager.onPanelCollapsed(); + maybeEscalateHeadsUp(); + } + } + + @Override + public void onStateChanged(int newState) { + mState = newState; + updateReportRejectedTouchVisibility(); + mDozeServiceHost.updateDozing(); + updateTheme(); + mNavigationBarController.touchAutoDim(mDisplayId); + Trace.beginSection("CentralSurfaces#updateKeyguardState"); + if (mState == StatusBarState.KEYGUARD) { + mNotificationPanelViewController.cancelPendingPanelCollapse(); + } + updateDozingState(); + checkBarModes(); + updateScrimController(); + mPresenter.updateMediaMetaData(false, mState != StatusBarState.KEYGUARD); + updateKeyguardState(); + Trace.endSection(); + } + + @Override + public void onDozeAmountChanged(float linear, float eased) { + if (mFeatureFlags.isEnabled(Flags.LOCKSCREEN_ANIMATIONS) + && !(mLightRevealScrim.getRevealEffect() instanceof CircleReveal) + && !mBiometricUnlockController.isWakeAndUnlock()) { + mLightRevealScrim.setRevealAmount(1f - linear); + } + } + + @Override + public void onDozingChanged(boolean isDozing) { + Trace.beginSection("CentralSurfaces#updateDozing"); + mDozing = isDozing; + + // Collapse the notification panel if open + boolean dozingAnimated = mDozeServiceHost.getDozingRequested() + && mDozeParameters.shouldControlScreenOff(); + mNotificationPanelViewController.resetViews(dozingAnimated); + + updateQsExpansionEnabled(); + mKeyguardViewMediator.setDozing(mDozing); + + mNotificationsController.requestNotificationUpdate("onDozingChanged"); + updateDozingState(); + mDozeServiceHost.updateDozing(); + updateScrimController(); + updateReportRejectedTouchVisibility(); + Trace.endSection(); + } + + @Override + public void onFullscreenStateChanged(boolean isFullscreen) { + mIsFullscreen = isFullscreen; + maybeUpdateBarMode(); + } + }; + + private final BatteryController.BatteryStateChangeCallback mBatteryStateChangeCallback = + new BatteryController.BatteryStateChangeCallback() { + @Override + public void onPowerSaveChanged(boolean isPowerSave) { + mMainExecutor.execute(mCheckBarModes); + if (mDozeServiceHost != null) { + mDozeServiceHost.firePowerSaveChanged(isPowerSave); + } + } + }; + + private final ActivityLaunchAnimator.Callback mActivityLaunchAnimatorCallback = + new ActivityLaunchAnimator.Callback() { + @Override + public boolean isOnKeyguard() { + return mKeyguardStateController.isShowing(); + } + + @Override + public void hideKeyguardWithAnimation(IRemoteAnimationRunner runner) { + // We post to the main thread for 2 reasons: + // 1. KeyguardViewMediator is not thread-safe. + // 2. To ensure that ViewMediatorCallback#keyguardDonePending is called before + // ViewMediatorCallback#readyForKeyguardDone. The wrong order could occur + // when doing + // dismissKeyguardThenExecute { hideKeyguardWithAnimation(runner) }. + mMainExecutor.execute(() -> mKeyguardViewMediator.hideWithAnimation(runner)); + } + + @Override + public int getBackgroundColor(TaskInfo task) { + if (!mStartingSurfaceOptional.isPresent()) { + Log.w(TAG, "No starting surface, defaulting to SystemBGColor"); + return SplashscreenContentDrawer.getSystemBGColor(); + } + + return mStartingSurfaceOptional.get().getBackgroundColor(task); + } + }; + + private final ActivityLaunchAnimator.Listener mActivityLaunchAnimatorListener = + new ActivityLaunchAnimator.Listener() { + @Override + public void onLaunchAnimationStart() { + mKeyguardViewMediator.setBlursDisabledForAppLaunch(true); + } + + @Override + public void onLaunchAnimationEnd() { + mKeyguardViewMediator.setBlursDisabledForAppLaunch(false); + } + }; + + private final DemoMode mDemoModeCallback = new DemoMode() { + @Override + public void onDemoModeFinished() { + checkBarModes(); + } + + @Override + public void dispatchDemoCommand(String command, Bundle args) { } + }; +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java new file mode 100644 index 000000000000..536be1c1a866 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java @@ -0,0 +1,593 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.phone; + +import static android.view.InsetsState.ITYPE_STATUS_BAR; +import static android.view.InsetsState.containsType; + +import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_AWAKE; +import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_WAKING; + +import android.annotation.Nullable; +import android.app.StatusBarManager; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.res.Resources; +import android.os.Bundle; +import android.os.PowerManager; +import android.os.SystemClock; +import android.os.UserHandle; +import android.os.VibrationAttributes; +import android.os.VibrationEffect; +import android.os.Vibrator; +import android.util.Log; +import android.util.Slog; +import android.view.InsetsState.InternalInsetsType; +import android.view.InsetsVisibilities; +import android.view.KeyEvent; +import android.view.WindowInsetsController.Appearance; +import android.view.WindowInsetsController.Behavior; + +import com.android.internal.logging.MetricsLogger; +import com.android.internal.logging.nano.MetricsProto.MetricsEvent; +import com.android.internal.view.AppearanceRegion; +import com.android.keyguard.KeyguardUpdateMonitor; +import com.android.systemui.R; +import com.android.systemui.assist.AssistManager; +import com.android.systemui.camera.CameraIntents; +import com.android.systemui.dagger.qualifiers.DisplayId; +import com.android.systemui.dagger.qualifiers.Main; +import com.android.systemui.keyguard.WakefulnessLifecycle; +import com.android.systemui.qs.QSPanelController; +import com.android.systemui.statusbar.CommandQueue; +import com.android.systemui.statusbar.DisableFlagsLogger; +import com.android.systemui.statusbar.SysuiStatusBarStateController; +import com.android.systemui.statusbar.VibratorHelper; +import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent; +import com.android.systemui.statusbar.policy.DeviceProvisionedController; +import com.android.systemui.statusbar.policy.HeadsUpManager; +import com.android.systemui.statusbar.policy.KeyguardStateController; +import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler; + +import java.util.Optional; + +import javax.inject.Inject; + +/** */ +@CentralSurfacesComponent.CentralSurfacesScope +public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callbacks { + private final CentralSurfaces mCentralSurfaces; + private final Context mContext; + private final ShadeController mShadeController; + private final CommandQueue mCommandQueue; + private final NotificationPanelViewController mNotificationPanelViewController; + private final RemoteInputQuickSettingsDisabler mRemoteInputQuickSettingsDisabler; + private final MetricsLogger mMetricsLogger; + private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; + private final KeyguardStateController mKeyguardStateController; + private final HeadsUpManager mHeadsUpManager; + private final WakefulnessLifecycle mWakefulnessLifecycle; + private final DeviceProvisionedController mDeviceProvisionedController; + private final StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; + private final AssistManager mAssistManager; + private final DozeServiceHost mDozeServiceHost; + private final SysuiStatusBarStateController mStatusBarStateController; + private final NotificationShadeWindowView mNotificationShadeWindowView; + private final NotificationStackScrollLayoutController mNotificationStackScrollLayoutController; + private final StatusBarHideIconsForBouncerManager mStatusBarHideIconsForBouncerManager; + private final PowerManager mPowerManager; + private final VibratorHelper mVibratorHelper; + private final Optional mVibratorOptional; + private final LightBarController mLightBarController; + private final DisableFlagsLogger mDisableFlagsLogger; + private final int mDisplayId; + private final boolean mVibrateOnOpening; + private final VibrationEffect mCameraLaunchGestureVibrationEffect; + + + private static final VibrationAttributes HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES = + VibrationAttributes.createForUsage(VibrationAttributes.USAGE_HARDWARE_FEEDBACK); + + @Inject + CentralSurfacesCommandQueueCallbacks( + CentralSurfaces centralSurfaces, + Context context, + @Main Resources resources, + ShadeController shadeController, + CommandQueue commandQueue, + NotificationPanelViewController notificationPanelViewController, + RemoteInputQuickSettingsDisabler remoteInputQuickSettingsDisabler, + MetricsLogger metricsLogger, + KeyguardUpdateMonitor keyguardUpdateMonitor, + KeyguardStateController keyguardStateController, + HeadsUpManager headsUpManager, + WakefulnessLifecycle wakefulnessLifecycle, + DeviceProvisionedController deviceProvisionedController, + StatusBarKeyguardViewManager statusBarKeyguardViewManager, + AssistManager assistManager, + DozeServiceHost dozeServiceHost, + SysuiStatusBarStateController statusBarStateController, + NotificationShadeWindowView notificationShadeWindowView, + NotificationStackScrollLayoutController notificationStackScrollLayoutController, + StatusBarHideIconsForBouncerManager statusBarHideIconsForBouncerManager, + PowerManager powerManager, + VibratorHelper vibratorHelper, + Optional vibratorOptional, + LightBarController lightBarController, + DisableFlagsLogger disableFlagsLogger, + @DisplayId int displayId) { + + mCentralSurfaces = centralSurfaces; + mContext = context; + mShadeController = shadeController; + mCommandQueue = commandQueue; + mNotificationPanelViewController = notificationPanelViewController; + mRemoteInputQuickSettingsDisabler = remoteInputQuickSettingsDisabler; + mMetricsLogger = metricsLogger; + mKeyguardUpdateMonitor = keyguardUpdateMonitor; + mKeyguardStateController = keyguardStateController; + mHeadsUpManager = headsUpManager; + mWakefulnessLifecycle = wakefulnessLifecycle; + mDeviceProvisionedController = deviceProvisionedController; + mStatusBarKeyguardViewManager = statusBarKeyguardViewManager; + mAssistManager = assistManager; + mDozeServiceHost = dozeServiceHost; + mStatusBarStateController = statusBarStateController; + mNotificationShadeWindowView = notificationShadeWindowView; + mNotificationStackScrollLayoutController = notificationStackScrollLayoutController; + mStatusBarHideIconsForBouncerManager = statusBarHideIconsForBouncerManager; + mPowerManager = powerManager; + mVibratorHelper = vibratorHelper; + mVibratorOptional = vibratorOptional; + mLightBarController = lightBarController; + mDisableFlagsLogger = disableFlagsLogger; + mDisplayId = displayId; + + mVibrateOnOpening = resources.getBoolean(R.bool.config_vibrateOnIconAnimation); + mCameraLaunchGestureVibrationEffect = getCameraGestureVibrationEffect( + mVibratorOptional, resources); + } + + @Override + public void abortTransient(int displayId, @InternalInsetsType int[] types) { + if (displayId != mDisplayId) { + return; + } + if (!containsType(types, ITYPE_STATUS_BAR)) { + return; + } + mCentralSurfaces.clearTransient(); + } + + @Override + public void addQsTile(ComponentName tile) { + QSPanelController qsPanelController = mCentralSurfaces.getQSPanelController(); + if (qsPanelController != null && qsPanelController.getHost() != null) { + qsPanelController.getHost().addTile(tile); + } + } + + @Override + public void remQsTile(ComponentName tile) { + QSPanelController qsPanelController = mCentralSurfaces.getQSPanelController(); + if (qsPanelController != null && qsPanelController.getHost() != null) { + qsPanelController.getHost().removeTile(tile); + } + } + + @Override + public void clickTile(ComponentName tile) { + QSPanelController qsPanelController = mCentralSurfaces.getQSPanelController(); + if (qsPanelController != null) { + qsPanelController.clickTile(tile); + } + } + + @Override + public void animateCollapsePanels(int flags, boolean force) { + mShadeController.animateCollapsePanels(flags, force, false /* delayed */, + 1.0f /* speedUpFactor */); + } + + @Override + public void animateExpandNotificationsPanel() { + if (CentralSurfaces.SPEW) { + Log.d(CentralSurfaces.TAG, + "animateExpand: mExpandedVisible=" + mCentralSurfaces.isExpandedVisible()); + } + if (!mCommandQueue.panelsEnabled()) { + return; + } + + mNotificationPanelViewController.expandWithoutQs(); + } + + @Override + public void animateExpandSettingsPanel(@Nullable String subPanel) { + if (CentralSurfaces.SPEW) { + Log.d(CentralSurfaces.TAG, + "animateExpand: mExpandedVisible=" + mCentralSurfaces.isExpandedVisible()); + } + if (!mCommandQueue.panelsEnabled()) { + return; + } + + // Settings are not available in setup + if (!mDeviceProvisionedController.isCurrentUserSetup()) return; + + mNotificationPanelViewController.expandWithQs(); + } + + @Override + public void appTransitionCancelled(int displayId) { + } + + @Override + public void appTransitionFinished(int displayId) { + } + + @Override + public void dismissKeyboardShortcutsMenu() { + mCentralSurfaces.resendMessage(CentralSurfaces.MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU); + } + /** + * State is one or more of the DISABLE constants from StatusBarManager. + */ + @Override + public void disable(int displayId, int state1, int state2, boolean animate) { + if (displayId != mDisplayId) { + return; + } + + int state2BeforeAdjustment = state2; + state2 = mRemoteInputQuickSettingsDisabler.adjustDisableFlags(state2); + Log.d(CentralSurfaces.TAG, + mDisableFlagsLogger.getDisableFlagsString( + /* old= */ new DisableFlagsLogger.DisableState( + mCentralSurfaces.getDisabled1(), mCentralSurfaces.getDisabled2()), + /* new= */ new DisableFlagsLogger.DisableState( + state1, state2BeforeAdjustment), + /* newStateAfterLocalModification= */ new DisableFlagsLogger.DisableState( + state1, state2))); + + final int old1 = mCentralSurfaces.getDisabled1(); + final int diff1 = state1 ^ old1; + mCentralSurfaces.setDisabled1(state1); + + final int old2 = mCentralSurfaces.getDisabled2(); + final int diff2 = state2 ^ old2; + mCentralSurfaces.setDisabled2(state2); + + if ((diff1 & StatusBarManager.DISABLE_EXPAND) != 0) { + if ((state1 & StatusBarManager.DISABLE_EXPAND) != 0) { + mShadeController.animateCollapsePanels(); + } + } + + if ((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) { + if (mCentralSurfaces.areNotificationAlertsDisabled()) { + mHeadsUpManager.releaseAllImmediately(); + } + } + + if ((diff2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) != 0) { + mCentralSurfaces.updateQsExpansionEnabled(); + } + + if ((diff2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE) != 0) { + mCentralSurfaces.updateQsExpansionEnabled(); + if ((state2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE) != 0) { + mShadeController.animateCollapsePanels(); + } + } + } + + /** + * Called for system navigation gestures. First action opens the panel, second opens + * settings. Down action closes the entire panel. + */ + @Override + public void handleSystemKey(int key) { + if (CentralSurfaces.SPEW) { + Log.d(CentralSurfaces.TAG, "handleNavigationKey: " + key); + } + if (!mCommandQueue.panelsEnabled() || !mKeyguardUpdateMonitor.isDeviceInteractive() + || mKeyguardStateController.isShowing() && !mKeyguardStateController.isOccluded()) { + return; + } + + // Panels are not available in setup + if (!mDeviceProvisionedController.isCurrentUserSetup()) return; + + if (KeyEvent.KEYCODE_SYSTEM_NAVIGATION_UP == key) { + mMetricsLogger.action(MetricsEvent.ACTION_SYSTEM_NAVIGATION_KEY_UP); + mNotificationPanelViewController.collapse( + false /* delayed */, 1.0f /* speedUpFactor */); + } else if (KeyEvent.KEYCODE_SYSTEM_NAVIGATION_DOWN == key) { + mMetricsLogger.action(MetricsEvent.ACTION_SYSTEM_NAVIGATION_KEY_DOWN); + if (mNotificationPanelViewController.isFullyCollapsed()) { + if (mVibrateOnOpening) { + mVibratorHelper.vibrate(VibrationEffect.EFFECT_TICK); + } + mNotificationPanelViewController.expand(true /* animate */); + mNotificationStackScrollLayoutController.setWillExpand(true); + mHeadsUpManager.unpinAll(true /* userUnpinned */); + mMetricsLogger.count(NotificationPanelView.COUNTER_PANEL_OPEN, 1); + } else if (!mNotificationPanelViewController.isInSettings() + && !mNotificationPanelViewController.isExpanding()) { + mNotificationPanelViewController.flingSettings(0 /* velocity */, + NotificationPanelView.FLING_EXPAND); + mMetricsLogger.count(NotificationPanelView.COUNTER_PANEL_OPEN_QS, 1); + } + } + + } + + @Override + public void onCameraLaunchGestureDetected(int source) { + mCentralSurfaces.setLastCameraLaunchSource(source); + if (mCentralSurfaces.isGoingToSleep()) { + if (CentralSurfaces.DEBUG_CAMERA_LIFT) { + Slog.d(CentralSurfaces.TAG, "Finish going to sleep before launching camera"); + } + mCentralSurfaces.setLaunchCameraOnFinishedGoingToSleep(true); + return; + } + if (!mNotificationPanelViewController.canCameraGestureBeLaunched()) { + if (CentralSurfaces.DEBUG_CAMERA_LIFT) { + Slog.d(CentralSurfaces.TAG, "Can't launch camera right now"); + } + return; + } + if (!mCentralSurfaces.isDeviceInteractive()) { + mPowerManager.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_CAMERA_LAUNCH, + "com.android.systemui:CAMERA_GESTURE"); + } + vibrateForCameraGesture(); + + if (source == StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP) { + Log.v(CentralSurfaces.TAG, "Camera launch"); + mKeyguardUpdateMonitor.onCameraLaunched(); + } + + if (!mStatusBarKeyguardViewManager.isShowing()) { + final Intent cameraIntent = CameraIntents.getInsecureCameraIntent(mContext); + mCentralSurfaces.startActivityDismissingKeyguard(cameraIntent, + false /* onlyProvisioned */, true /* dismissShade */, + true /* disallowEnterPictureInPictureWhileLaunching */, null /* callback */, 0, + null /* animationController */); + } else { + if (!mCentralSurfaces.isDeviceInteractive()) { + // Avoid flickering of the scrim when we instant launch the camera and the bouncer + // comes on. + mCentralSurfaces.acquireGestureWakeLock( + CentralSurfaces.LAUNCH_TRANSITION_TIMEOUT_MS + 1000L); + } + if (isWakingUpOrAwake()) { + if (CentralSurfaces.DEBUG_CAMERA_LIFT) { + Slog.d(CentralSurfaces.TAG, "Launching camera"); + } + if (mStatusBarKeyguardViewManager.isBouncerShowing()) { + mStatusBarKeyguardViewManager.reset(true /* hide */); + } + mNotificationPanelViewController.launchCamera( + mCentralSurfaces.isDeviceInteractive() /* animate */, source); + mCentralSurfaces.updateScrimController(); + } else { + // We need to defer the camera launch until the screen comes on, since otherwise + // we will dismiss us too early since we are waiting on an activity to be drawn and + // incorrectly get notified because of the screen on event (which resumes and pauses + // some activities) + if (CentralSurfaces.DEBUG_CAMERA_LIFT) { + Slog.d(CentralSurfaces.TAG, "Deferring until screen turns on"); + } + mCentralSurfaces.setLaunchCameraOnFinishedWaking(true); + } + } + } + + @Override + public void onEmergencyActionLaunchGestureDetected() { + Intent emergencyIntent = mCentralSurfaces.getEmergencyActionIntent(); + + if (emergencyIntent == null) { + Log.wtf(CentralSurfaces.TAG, "Couldn't find an app to process the emergency intent."); + return; + } + + if (isGoingToSleep()) { + mCentralSurfaces.setLaunchEmergencyActionOnFinishedGoingToSleep(true); + return; + } + + if (!mCentralSurfaces.isDeviceInteractive()) { + mPowerManager.wakeUp(SystemClock.uptimeMillis(), + PowerManager.WAKE_REASON_GESTURE, + "com.android.systemui:EMERGENCY_GESTURE"); + } + // TODO(b/169087248) Possibly add haptics here for emergency action. Currently disabled for + // app-side haptic experimentation. + + if (!mStatusBarKeyguardViewManager.isShowing()) { + mCentralSurfaces.startActivityDismissingKeyguard(emergencyIntent, + false /* onlyProvisioned */, true /* dismissShade */, + true /* disallowEnterPictureInPictureWhileLaunching */, null /* callback */, 0, + null /* animationController */); + return; + } + + if (!mCentralSurfaces.isDeviceInteractive()) { + // Avoid flickering of the scrim when we instant launch the camera and the bouncer + // comes on. + mCentralSurfaces.acquireGestureWakeLock( + CentralSurfaces.LAUNCH_TRANSITION_TIMEOUT_MS + 1000L); + } + + if (isWakingUpOrAwake()) { + if (mStatusBarKeyguardViewManager.isBouncerShowing()) { + mStatusBarKeyguardViewManager.reset(true /* hide */); + } + mContext.startActivityAsUser(emergencyIntent, UserHandle.CURRENT); + return; + } + // We need to defer the emergency action launch until the screen comes on, since otherwise + // we will dismiss us too early since we are waiting on an activity to be drawn and + // incorrectly get notified because of the screen on event (which resumes and pauses + // some activities) + mCentralSurfaces.setLaunchEmergencyActionOnFinishedWaking(true); + } + + @Override + public void onRecentsAnimationStateChanged(boolean running) { + mCentralSurfaces.setInteracting(StatusBarManager.WINDOW_NAVIGATION_BAR, running); + } + + + @Override + public void onSystemBarAttributesChanged(int displayId, @Appearance int appearance, + AppearanceRegion[] appearanceRegions, boolean navbarColorManagedByIme, + @Behavior int behavior, InsetsVisibilities requestedVisibilities, String packageName) { + if (displayId != mDisplayId) { + return; + } + boolean barModeChanged = mCentralSurfaces.setAppearance(appearance); + + mLightBarController.onStatusBarAppearanceChanged(appearanceRegions, barModeChanged, + mCentralSurfaces.getBarMode(), navbarColorManagedByIme); + + mCentralSurfaces.updateBubblesVisibility(); + mStatusBarStateController.setSystemBarAttributes( + appearance, behavior, requestedVisibilities, packageName); + } + + @Override + public void showTransient(int displayId, @InternalInsetsType int[] types, + boolean isGestureOnSystemBar) { + if (displayId != mDisplayId) { + return; + } + if (!containsType(types, ITYPE_STATUS_BAR)) { + return; + } + mCentralSurfaces.showTransientUnchecked(); + } + + @Override + public void toggleKeyboardShortcutsMenu(int deviceId) { + mCentralSurfaces.resendMessage(new CentralSurfaces.KeyboardShortcutsMessage(deviceId)); + } + + @Override + public void setTopAppHidesStatusBar(boolean topAppHidesStatusBar) { + mStatusBarHideIconsForBouncerManager + .setTopAppHidesStatusBarAndTriggerUpdate(topAppHidesStatusBar); + } + + @Override + public void showAssistDisclosure() { + mAssistManager.showDisclosure(); + } + + @Override + public void showPinningEnterExitToast(boolean entering) { + mCentralSurfaces.showPinningEnterExitToast(entering); + } + + @Override + public void showPinningEscapeToast() { + mCentralSurfaces.showPinningEscapeToast(); + } + + @Override + public void showScreenPinningRequest(int taskId) { + if (mKeyguardStateController.isShowing()) { + // Don't allow apps to trigger this from keyguard. + return; + } + // Show screen pinning request, since this comes from an app, show 'no thanks', button. + mCentralSurfaces.showScreenPinningRequest(taskId, true); + } + + @Override + public void showWirelessChargingAnimation(int batteryLevel) { + mCentralSurfaces.showWirelessChargingAnimation(batteryLevel); + } + + @Override + public void startAssist(Bundle args) { + mAssistManager.startAssist(args); + } + + @Override + public void suppressAmbientDisplay(boolean suppressed) { + mDozeServiceHost.setAlwaysOnSuppressed(suppressed); + } + + @Override + public void togglePanel() { + if (mCentralSurfaces.isPanelExpanded()) { + mShadeController.animateCollapsePanels(); + } else { + animateExpandNotificationsPanel(); + } + } + + private boolean isGoingToSleep() { + return mWakefulnessLifecycle.getWakefulness() + == WakefulnessLifecycle.WAKEFULNESS_GOING_TO_SLEEP; + } + + private boolean isWakingUpOrAwake() { + return mWakefulnessLifecycle.getWakefulness() == WAKEFULNESS_AWAKE + || mWakefulnessLifecycle.getWakefulness() == WAKEFULNESS_WAKING; + } + + private void vibrateForCameraGesture() { + mVibratorOptional.ifPresent( + v -> v.vibrate(mCameraLaunchGestureVibrationEffect, + HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES)); + } + + private static VibrationEffect getCameraGestureVibrationEffect( + Optional vibratorOptional, Resources resources) { + if (vibratorOptional.isPresent() && vibratorOptional.get().areAllPrimitivesSupported( + VibrationEffect.Composition.PRIMITIVE_QUICK_RISE, + VibrationEffect.Composition.PRIMITIVE_CLICK)) { + return VibrationEffect.startComposition() + .addPrimitive(VibrationEffect.Composition.PRIMITIVE_QUICK_RISE) + .addPrimitive(VibrationEffect.Composition.PRIMITIVE_CLICK, 1, 50) + .compose(); + } + if (vibratorOptional.isPresent() && vibratorOptional.get().hasAmplitudeControl()) { + // Make sure to pass -1 for repeat so VibratorManagerService doesn't stop us when going + // to sleep. + return VibrationEffect.createWaveform( + CentralSurfaces.CAMERA_LAUNCH_GESTURE_VIBRATION_TIMINGS, + CentralSurfaces.CAMERA_LAUNCH_GESTURE_VIBRATION_AMPLITUDES, + /* repeat= */ -1); + } + + int[] pattern = resources.getIntArray(R.array.config_cameraLaunchGestureVibePattern); + long[] timings = new long[pattern.length]; + for (int i = 0; i < pattern.length; i++) { + timings[i] = pattern[i]; + } + return VibrationEffect.createWaveform(timings, /* repeat= */ -1); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java index 696c5a760bf6..55b310ff986d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java @@ -97,7 +97,7 @@ public final class DozeServiceHost implements DozeHost { private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; private NotificationPanelViewController mNotificationPanel; private View mAmbientIndicationContainer; - private StatusBar mStatusBar; + private CentralSurfaces mCentralSurfaces; private boolean mAlwaysOnSuppressed; @Inject @@ -146,12 +146,12 @@ public final class DozeServiceHost implements DozeHost { * Initialize instance with objects only available later during execution. */ public void initialize( - StatusBar statusBar, + CentralSurfaces centralSurfaces, StatusBarKeyguardViewManager statusBarKeyguardViewManager, NotificationShadeWindowViewController notificationShadeWindowViewController, NotificationPanelViewController notificationPanel, View ambientIndicationContainer) { - mStatusBar = statusBar; + mCentralSurfaces = centralSurfaces; mStatusBarKeyguardViewManager = statusBarKeyguardViewManager; mNotificationPanel = notificationPanel; mNotificationShadeWindowViewController = notificationShadeWindowViewController; @@ -205,7 +205,7 @@ public final class DozeServiceHost implements DozeHost { mDozingRequested = true; updateDozing(); mDozeLog.traceDozing(mStatusBarStateController.isDozing()); - mStatusBar.updateIsKeyguard(); + mCentralSurfaces.updateIsKeyguard(); } } @@ -247,13 +247,13 @@ public final class DozeServiceHost implements DozeHost { && mWakeLockScreenPerformsAuth; // Set the state to pulsing, so ScrimController will know what to do once we ask it to // execute the transition. The pulse callback will then be invoked when the scrims - // are black, indicating that StatusBar is ready to present the rest of the UI. + // are black, indicating that CentralSurfaces is ready to present the rest of the UI. mPulsing = true; mDozeScrimController.pulse(new PulseCallback() { @Override public void onPulseStarted() { callback.onPulseStarted(); - mStatusBar.updateNotificationPanelTouchState(); + mCentralSurfaces.updateNotificationPanelTouchState(); setPulsing(true); } @@ -261,7 +261,7 @@ public final class DozeServiceHost implements DozeHost { public void onPulseFinished() { mPulsing = false; callback.onPulseFinished(); - mStatusBar.updateNotificationPanelTouchState(); + mCentralSurfaces.updateNotificationPanelTouchState(); mScrimController.setWakeLockScreenSensorActive(false); setPulsing(false); } @@ -274,14 +274,14 @@ public final class DozeServiceHost implements DozeHost { if (mKeyguardUpdateMonitor != null && passiveAuthInterrupt) { mKeyguardUpdateMonitor.onAuthInterruptDetected(pulsing /* active */); } - mStatusBar.updateScrimController(); + mCentralSurfaces.updateScrimController(); mPulseExpansionHandler.setPulsing(pulsing); mNotificationWakeUpCoordinator.setPulsing(pulsing); } }, reason); // DozeScrimController is in pulse state, now let's ask ScrimController to start // pulsing and draw the black frame, if necessary. - mStatusBar.updateScrimController(); + mCentralSurfaces.updateScrimController(); } @Override @@ -403,14 +403,14 @@ public final class DozeServiceHost implements DozeHost { Log.w(TAG, "Overlapping onDisplayOffCallback. Ignoring previous one."); } mPendingScreenOffCallback = onDisplayOffCallback; - mStatusBar.updateScrimController(); + mCentralSurfaces.updateScrimController(); } @Override public void cancelGentleSleep() { mPendingScreenOffCallback = null; if (mScrimController.getState() == ScrimState.OFF) { - mStatusBar.updateScrimController(); + mCentralSurfaces.updateScrimController(); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index 84103c0bb377..541aeab22a80 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -118,7 +118,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL KeyguardStateController.Callback, AccessibilityController.AccessibilityStateChangedCallback { - final static String TAG = "StatusBar/KeyguardBottomAreaView"; + final static String TAG = "CentralSurfaces/KeyguardBottomAreaView"; public static final String CAMERA_LAUNCH_SOURCE_AFFORDANCE = "lockscreen_affordance"; public static final String CAMERA_LAUNCH_SOURCE_WIGGLE = "wiggle_gesture"; @@ -169,7 +169,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL private FlashlightController mFlashlightController; private PreviewInflater mPreviewInflater; private AccessibilityController mAccessibilityController; - private StatusBar mStatusBar; + private CentralSurfaces mCentralSurfaces; private KeyguardAffordanceHelper mAffordanceHelper; private FalsingManager mFalsingManager; private boolean mUserSetupComplete; @@ -274,7 +274,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL }; public void initFrom(KeyguardBottomAreaView oldBottomArea) { - setStatusBar(oldBottomArea.mStatusBar); + setCentralSurfaces(oldBottomArea.mCentralSurfaces); // if it exists, continue to use the original ambient indication container // instead of the newly inflated one @@ -473,8 +473,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL mRightAffordanceView.setContentDescription(state.contentDescription); } - public void setStatusBar(StatusBar statusBar) { - mStatusBar = statusBar; + public void setCentralSurfaces(CentralSurfaces centralSurfaces) { + mCentralSurfaces = centralSurfaces; updateCameraVisibility(); // in case onFinishInflate() was called too early } @@ -732,7 +732,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL } else { boolean dismissShade = !TextUtils.isEmpty(mRightButtonStr) && Dependency.get(TunerService.class).getValue(LOCKSCREEN_RIGHT_UNLOCK, 1) != 0; - mStatusBar.executeRunnableDismissingKeyguard(runnable, null /* cancelAction */, + mCentralSurfaces.executeRunnableDismissingKeyguard(runnable, null /* cancelAction */, dismissShade, false /* afterKeyguardGone */, true /* deferred */); } } @@ -1019,7 +1019,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL @Override public IconState getIcon() { - boolean isCameraDisabled = (mStatusBar != null) && !mStatusBar.isCameraAllowedByAdmin(); + boolean isCameraDisabled = (mCentralSurfaces != null) + && !mCentralSurfaces.isCameraAllowedByAdmin(); mIconState.isVisible = !isCameraDisabled && mShowCameraAffordance && mUserSetupComplete diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardEnvironmentImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardEnvironmentImpl.java index 9bdefcd98422..2c4fc6c6f734 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardEnvironmentImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardEnvironmentImpl.java @@ -14,8 +14,8 @@ package com.android.systemui.statusbar.phone; -import static com.android.systemui.statusbar.phone.StatusBar.DEBUG; -import static com.android.systemui.statusbar.phone.StatusBar.MULTIUSER_DEBUG; +import static com.android.systemui.statusbar.phone.CentralSurfaces.DEBUG; +import static com.android.systemui.statusbar.phone.CentralSurfaces.MULTIUSER_DEBUG; import android.service.notification.StatusBarNotification; import android.util.Log; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index 25f727f25791..61760fb8c78c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -189,7 +189,7 @@ import com.android.systemui.statusbar.notification.stack.NotificationStackScroll import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; import com.android.systemui.statusbar.notification.stack.StackStateAnimator; import com.android.systemui.statusbar.phone.LockscreenGestureLogger.LockscreenUiEvent; -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent; import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment; import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager; import com.android.systemui.statusbar.phone.panelstate.PanelState; @@ -222,7 +222,7 @@ import java.util.function.Consumer; import javax.inject.Inject; import javax.inject.Provider; -@StatusBarComponent.StatusBarScope +@CentralSurfacesComponent.CentralSurfacesScope public class NotificationPanelViewController extends PanelViewController implements NotifPanelEventSource { @@ -1132,10 +1132,10 @@ public class NotificationPanelViewController extends PanelViewController return mKeyguardStatusViewController.hasCustomClock(); } - private void setStatusBar(StatusBar bar) { + private void setCentralSurfaces(CentralSurfaces centralSurfaces) { // TODO: this can be injected. - mStatusBar = bar; - mKeyguardBottomArea.setStatusBar(mStatusBar); + mCentralSurfaces = centralSurfaces; + mKeyguardBottomArea.setCentralSurfaces(mCentralSurfaces); } public void updateResources() { @@ -1325,7 +1325,7 @@ public class NotificationPanelViewController extends PanelViewController mAffordanceHelper = new KeyguardAffordanceHelper( mKeyguardAffordanceHelperCallback, mView.getContext(), mFalsingManager); mKeyguardBottomArea.setAffordanceHelper(mAffordanceHelper); - mKeyguardBottomArea.setStatusBar(mStatusBar); + mKeyguardBottomArea.setCentralSurfaces(mCentralSurfaces); mKeyguardBottomArea.setUserSetupComplete(mUserSetupComplete); mKeyguardBottomArea.setFalsingManager(mFalsingManager); mKeyguardBottomArea.initWallet(mQuickAccessWalletController); @@ -1588,7 +1588,7 @@ public class NotificationPanelViewController extends PanelViewController float lockIconPadding = 0; if (mLockIconViewController.getTop() != 0) { - lockIconPadding = mStatusBar.getDisplayHeight() - mLockIconViewController.getTop() + lockIconPadding = mCentralSurfaces.getDisplayHeight() - mLockIconViewController.getTop() + mResources.getDimensionPixelSize(R.dimen.min_lock_icon_padding); } @@ -1742,7 +1742,7 @@ public class NotificationPanelViewController extends PanelViewController mAffordanceHelper.reset(false); mLastCameraLaunchSource = KeyguardBottomAreaView.CAMERA_LAUNCH_SOURCE_AFFORDANCE; } - mStatusBar.getGutsManager().closeAndSaveGuts(true /* leavebehind */, true /* force */, + mCentralSurfaces.getGutsManager().closeAndSaveGuts(true /* leavebehind */, true /* force */, true /* controls */, -1 /* x */, -1 /* y */, true /* resetMenu */); if (animate && !isFullyCollapsed()) { animateCloseQs(true /* animateAway */); @@ -1841,7 +1841,7 @@ public class NotificationPanelViewController extends PanelViewController @Override public void fling(float vel, boolean expand) { - GestureRecorder gr = mStatusBar.getGestureRecorder(); + GestureRecorder gr = mCentralSurfaces.getGestureRecorder(); if (gr != null) { gr.tag("fling " + ((vel > 0) ? "open" : "closed"), "notifications,v=" + vel); } @@ -2030,8 +2030,8 @@ public class NotificationPanelViewController extends PanelViewController mBarState == KEYGUARD ? MetricsEvent.ACTION_LS_QS : MetricsEvent.ACTION_SHADE_QS_PULL; mLockscreenGestureLogger.write(gesture, - (int) ((y - mInitialTouchY) / mStatusBar.getDisplayDensity()), - (int) (vel / mStatusBar.getDisplayDensity())); + (int) ((y - mInitialTouchY) / mCentralSurfaces.getDisplayDensity()), + (int) (vel / mCentralSurfaces.getDisplayDensity())); } private boolean flingExpandsQs(float vel) { @@ -2309,7 +2309,7 @@ public class NotificationPanelViewController extends PanelViewController } private int getFalsingThreshold() { - float factor = mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f; + float factor = mCentralSurfaces.isWakeUpComingFromTouch() ? 1.5f : 1.0f; return (int) (mQsFalsingThreshold * factor); } @@ -2336,7 +2336,7 @@ public class NotificationPanelViewController extends PanelViewController // When expanding QS, let's authenticate the user if possible, // this will speed up notification actions. if (height == 0) { - mStatusBar.requestFaceAuth(false); + mCentralSurfaces.requestFaceAuth(false); } } @@ -2347,7 +2347,7 @@ public class NotificationPanelViewController extends PanelViewController updateQsState(); requestPanelHeightUpdate(); mFalsingCollector.setQsExpanded(expanded); - mStatusBar.setQsExpanded(expanded); + mCentralSurfaces.setQsExpanded(expanded); mNotificationsQSContainerController.setQsExpanded(expanded); mPulseExpansionHandler.setQsExpanded(expanded); mKeyguardBypassController.setQSExpanded(expanded); @@ -2431,7 +2431,7 @@ public class NotificationPanelViewController extends PanelViewController if (!mFalsingManager.isUnlockingDisabled() && mQsFullyExpanded && mFalsingCollector.shouldEnforceBouncer()) { - mStatusBar.executeRunnableDismissingKeyguard(null, null /* cancelAction */, + mCentralSurfaces.executeRunnableDismissingKeyguard(null, null /* cancelAction */, false /* dismissShade */, true /* afterKeyguardGone */, false /* deferred */); } if (DEBUG) { @@ -3119,7 +3119,7 @@ public class NotificationPanelViewController extends PanelViewController if (mPanelExpanded != isExpanded) { mHeadsUpManager.setIsPanelExpanded(isExpanded); mStatusBarTouchableRegionManager.setPanelExpanded(isExpanded); - mStatusBar.setPanelExpanded(isExpanded); + mCentralSurfaces.setPanelExpanded(isExpanded); mPanelExpanded = isExpanded; if (!isExpanded && mQs != null && mQs.isCustomizing()) { @@ -3244,7 +3244,7 @@ public class NotificationPanelViewController extends PanelViewController mKeyguardBottomArea.setImportantForAccessibility( alpha == 0f ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS : View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); - View ambientIndicationContainer = mStatusBar.getAmbientIndicationContainer(); + View ambientIndicationContainer = mCentralSurfaces.getAmbientIndicationContainer(); if (ambientIndicationContainer != null) { ambientIndicationContainer.setAlpha(alpha); } @@ -3583,7 +3583,7 @@ public class NotificationPanelViewController extends PanelViewController @Override protected void onClosingFinished() { - mStatusBar.onClosingFinished(); + mCentralSurfaces.onClosingFinished(); setClosingWithAlphaFadeout(false); mMediaHierarchyManager.closeGuts(); } @@ -3645,7 +3645,7 @@ public class NotificationPanelViewController extends PanelViewController } public void clearNotificationEffects() { - mStatusBar.clearNotificationEffects(); + mCentralSurfaces.clearNotificationEffects(); } @Override @@ -3707,7 +3707,7 @@ public class NotificationPanelViewController extends PanelViewController * Whether the camera application can be launched for the camera launch gesture. */ public boolean canCameraGestureBeLaunched() { - if (!mStatusBar.isCameraAllowedByAdmin()) { + if (!mCentralSurfaces.isCameraAllowedByAdmin()) { return false; } @@ -4086,10 +4086,10 @@ public class NotificationPanelViewController extends PanelViewController * @param hideExpandedRunnable a runnable to run when we need to hide the expanded panel. */ public void initDependencies( - StatusBar statusBar, + CentralSurfaces centralSurfaces, Runnable hideExpandedRunnable, NotificationShelfController notificationShelfController) { - setStatusBar(statusBar); + setCentralSurfaces(centralSurfaces); mHideExpandedRunnable = hideExpandedRunnable; mNotificationStackScrollLayoutController.setShelfController(notificationShelfController); mNotificationShelfController = notificationShelfController; @@ -4162,7 +4162,7 @@ public class NotificationPanelViewController extends PanelViewController initDownStates(event); // Do not let touches go to shade or QS if the bouncer is visible, // but still let user swipe down to expand the panel, dismissing the bouncer. - if (mStatusBar.isBouncerShowing()) { + if (mCentralSurfaces.isBouncerShowing()) { return true; } if (mCommandQueue.panelsEnabled() @@ -4205,8 +4205,8 @@ public class NotificationPanelViewController extends PanelViewController // Do not allow panel expansion if bouncer is scrimmed or showing over a dream, // otherwise user would be able to pull down QS or expand the shade. - if (mStatusBar.isBouncerShowingScrimmed() - || mStatusBar.isBouncerShowingOverDream()) { + if (mCentralSurfaces.isBouncerShowingScrimmed() + || mCentralSurfaces.isBouncerShowingOverDream()) { return false; } @@ -4270,15 +4270,15 @@ public class NotificationPanelViewController extends PanelViewController new PhoneStatusBarView.TouchEventHandler() { @Override public void onInterceptTouchEvent(MotionEvent event) { - mStatusBar.onTouchEvent(event); + mCentralSurfaces.onTouchEvent(event); } @Override public boolean handleTouchEvent(MotionEvent event) { - mStatusBar.onTouchEvent(event); + mCentralSurfaces.onTouchEvent(event); // TODO(b/202981994): Move the touch debugging in this method to a central - // location. (Right now, it's split between StatusBar and here.) + // location. (Right now, it's split between CentralSurfaces and here.) // If panels aren't enabled, ignore the gesture and don't pass it down to the // panel view. @@ -4495,7 +4495,7 @@ public class NotificationPanelViewController extends PanelViewController : !rightPage; mIsLaunchTransitionRunning = true; mLaunchAnimationEndRunnable = null; - float displayDensity = mStatusBar.getDisplayDensity(); + float displayDensity = mCentralSurfaces.getDisplayDensity(); int lengthDp = Math.abs((int) (translation / displayDensity)); int velocityDp = Math.abs((int) (vel / displayDensity)); if (start) { @@ -4503,7 +4503,7 @@ public class NotificationPanelViewController extends PanelViewController mLockscreenGestureLogger.log(LockscreenUiEvent.LOCKSCREEN_DIALER); mFalsingCollector.onLeftAffordanceOn(); if (mFalsingCollector.shouldEnforceBouncer()) { - mStatusBar.executeRunnableDismissingKeyguard( + mCentralSurfaces.executeRunnableDismissingKeyguard( () -> mKeyguardBottomArea.launchLeftAffordance(), null, true /* dismissShade */, false /* afterKeyguardGone */, true /* deferred */); @@ -4519,7 +4519,7 @@ public class NotificationPanelViewController extends PanelViewController } mFalsingCollector.onCameraOn(); if (mFalsingCollector.shouldEnforceBouncer()) { - mStatusBar.executeRunnableDismissingKeyguard( + mCentralSurfaces.executeRunnableDismissingKeyguard( () -> mKeyguardBottomArea.launchCamera(mLastCameraLaunchSource), null, true /* dismissShade */, false /* afterKeyguardGone */, true /* deferred */); @@ -4527,7 +4527,7 @@ public class NotificationPanelViewController extends PanelViewController mKeyguardBottomArea.launchCamera(mLastCameraLaunchSource); } } - mStatusBar.startLaunchTransitionTimeout(); + mCentralSurfaces.startLaunchTransitionTimeout(); mBlockTouches = true; } @@ -4539,7 +4539,7 @@ public class NotificationPanelViewController extends PanelViewController mLaunchAnimationEndRunnable.run(); mLaunchAnimationEndRunnable = null; } - mStatusBar.readyForKeyguardDone(); + mCentralSurfaces.readyForKeyguardDone(); } @Override @@ -4576,18 +4576,18 @@ public class NotificationPanelViewController extends PanelViewController mHintAnimationRunning = true; mAffordanceHelper.startHintAnimation(rightIcon, () -> { mHintAnimationRunning = false; - mStatusBar.onHintFinished(); + mCentralSurfaces.onHintFinished(); }); rightIcon = mView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL ? !rightIcon : rightIcon; if (rightIcon) { - mStatusBar.onCameraHintStarted(); + mCentralSurfaces.onCameraHintStarted(); } else { if (mKeyguardBottomArea.isLeftVoiceAssist()) { - mStatusBar.onVoiceAssistHintStarted(); + mCentralSurfaces.onVoiceAssistHintStarted(); } else { - mStatusBar.onPhoneHintStarted(); + mCentralSurfaces.onPhoneHintStarted(); } } } @@ -4618,7 +4618,7 @@ public class NotificationPanelViewController extends PanelViewController @Override public float getAffordanceFalsingFactor() { - return mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f; + return mCentralSurfaces.isWakeUpComingFromTouch() ? 1.5f : 1.0f; } @Override @@ -5134,7 +5134,7 @@ public class NotificationPanelViewController extends PanelViewController mView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); } if (state == STATE_OPENING) { - mStatusBar.makeExpandedVisible(false); + mCentralSurfaces.makeExpandedVisible(false); } if (state == STATE_CLOSED) { // Close the status bar in the next frame so we can show the end of the diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java index 5caf4f604fcd..0ff010aedfff 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java @@ -840,7 +840,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW Set mComponentsForcingTopUi = new HashSet<>(); /** - * The {@link StatusBar} state from the status bar. + * The status bar state from {@link CentralSurfaces}. */ int mStatusBarState; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowView.java index fb0e306b2e8b..1e3a02b0606b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowView.java @@ -58,7 +58,7 @@ import com.android.systemui.R; */ public class NotificationShadeWindowView extends FrameLayout { public static final String TAG = "NotificationShadeWindowView"; - public static final boolean DEBUG = StatusBar.DEBUG; + public static final boolean DEBUG = CentralSurfaces.DEBUG; private int mRightInset = 0; private int mLeftInset = 0; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java index 8a191f1614c3..101c86f6dac1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java @@ -44,7 +44,7 @@ import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent; import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager; import com.android.systemui.statusbar.window.StatusBarWindowStateController; import com.android.systemui.tuner.TunerService; @@ -58,7 +58,7 @@ import javax.inject.Inject; /** * Controller for {@link NotificationShadeWindowView}. */ -@StatusBarComponent.StatusBarScope +@CentralSurfacesComponent.CentralSurfacesScope public class NotificationShadeWindowViewController { private static final String TAG = "NotifShadeWindowVC"; private final FalsingCollector mFalsingCollector; @@ -79,7 +79,7 @@ public class NotificationShadeWindowViewController { private boolean mExpandAnimationRunning; private NotificationStackScrollLayout mStackScrollLayout; private PhoneStatusBarViewController mStatusBarViewController; - private final StatusBar mService; + private final CentralSurfaces mService; private final NotificationShadeWindowController mNotificationShadeWindowController; private DragDownHelper mDragDownHelper; private boolean mDoubleTapEnabled; @@ -108,7 +108,7 @@ public class NotificationShadeWindowViewController { StatusBarWindowStateController statusBarWindowStateController, LockIconViewController lockIconViewController, Optional lowLightClockController, - StatusBar statusBar, + CentralSurfaces centralSurfaces, NotificationShadeWindowController controller) { mLockscreenShadeTransitionController = transitionController; mFalsingCollector = falsingCollector; @@ -124,7 +124,7 @@ public class NotificationShadeWindowViewController { mStatusBarWindowStateController = statusBarWindowStateController; mLockIconViewController = lockIconViewController; mLowLightClockController = lowLightClockController; - mService = statusBar; + mService = centralSurfaces; mNotificationShadeWindowController = controller; // This view is not part of the newly inflated expanded status bar. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java index 249f9886253c..45dc943de2f8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java @@ -27,7 +27,7 @@ public abstract class PanelView extends FrameLayout { public static final String TAG = PanelView.class.getSimpleName(); private PanelViewController.TouchHandler mTouchHandler; - protected StatusBar mStatusBar; + protected CentralSurfaces mCentralSurfaces; protected HeadsUpManagerPhone mHeadsUpManager; protected KeyguardBottomAreaView mKeyguardBottomArea; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java index 85e804233ed9..7c1775ed2a5e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java @@ -113,7 +113,7 @@ public abstract class PanelViewController { Log.v(TAG, (mViewName != null ? (mViewName + ": ") : "") + String.format(fmt, args)); } - protected StatusBar mStatusBar; + protected CentralSurfaces mCentralSurfaces; protected HeadsUpManagerPhone mHeadsUpManager; protected final StatusBarTouchableRegionManager mStatusBarTouchableRegionManager; @@ -349,9 +349,9 @@ public abstract class PanelViewController { //TODO: keyguard opens QS a different way; log that too? // Log the position of the swipe that opened the panel - float width = mStatusBar.getDisplayWidth(); - float height = mStatusBar.getDisplayHeight(); - int rot = mStatusBar.getRotation(); + float width = mCentralSurfaces.getDisplayWidth(); + float height = mCentralSurfaces.getDisplayHeight(); + int rot = mCentralSurfaces.getRotation(); mLockscreenGestureLogger.writeAtFractionalPosition(MetricsEvent.ACTION_PANEL_VIEW_EXPAND, (int) (event.getX() / width * 100), (int) (event.getY() / height * 100), rot); @@ -433,10 +433,11 @@ public abstract class PanelViewController { } mDozeLog.traceFling(expand, mTouchAboveFalsingThreshold, - mStatusBar.isFalsingThresholdNeeded(), mStatusBar.isWakeUpComingFromTouch()); + mCentralSurfaces.isFalsingThresholdNeeded(), + mCentralSurfaces.isWakeUpComingFromTouch()); // Log collapse gesture if on lock screen. if (!expand && onKeyguard) { - float displayDensity = mStatusBar.getDisplayDensity(); + float displayDensity = mCentralSurfaces.getDisplayDensity(); int heightDp = (int) Math.abs((y - mInitialTouchY) / displayDensity); int velocityDp = (int) Math.abs(vel / displayDensity); mLockscreenGestureLogger.write(MetricsEvent.ACTION_LS_UNLOCK, heightDp, velocityDp); @@ -453,7 +454,7 @@ public abstract class PanelViewController { if (mUpdateFlingOnLayout) { mUpdateFlingVelocity = vel; } - } else if (!mStatusBar.isBouncerShowing() + } else if (!mCentralSurfaces.isBouncerShowing() && !mStatusBarKeyguardViewManager.isShowingAlternateAuthOrAnimating() && !mKeyguardStateController.isKeyguardGoingAway()) { boolean expands = onEmptySpaceClick(mInitialTouchX); @@ -469,7 +470,7 @@ public abstract class PanelViewController { } private int getFalsingThreshold() { - float factor = mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f; + float factor = mCentralSurfaces.isWakeUpComingFromTouch() ? 1.5f : 1.0f; return (int) (mUnlockFalsingThreshold * factor); } @@ -479,14 +480,14 @@ public abstract class PanelViewController { protected void onTrackingStopped(boolean expand) { mTracking = false; - mStatusBar.onTrackingStopped(expand); + mCentralSurfaces.onTrackingStopped(expand); updatePanelExpansionAndVisibility(); } protected void onTrackingStarted() { endClosing(); mTracking = true; - mStatusBar.onTrackingStarted(); + mCentralSurfaces.onTrackingStarted(); notifyExpandingStarted(); updatePanelExpansionAndVisibility(); } @@ -556,7 +557,7 @@ public abstract class PanelViewController { */ private boolean isFalseTouch(float x, float y, @Classifier.InteractionType int interactionType) { - if (!mStatusBar.isFalsingThresholdNeeded()) { + if (!mCentralSurfaces.isFalsingThresholdNeeded()) { return false; } if (mFalsingManager.isClassifierEnabled()) { @@ -921,7 +922,7 @@ public abstract class PanelViewController { mView.getViewTreeObserver().removeOnGlobalLayoutListener(this); return; } - if (mStatusBar.getNotificationShadeWindowView().isVisibleToUser()) { + if (mCentralSurfaces.getNotificationShadeWindowView().isVisibleToUser()) { mView.getViewTreeObserver().removeOnGlobalLayoutListener(this); if (mAnimateAfterExpanding) { notifyExpandingStarted(); @@ -976,11 +977,11 @@ public abstract class PanelViewController { } protected void onUnlockHintFinished() { - mStatusBar.onHintFinished(); + mCentralSurfaces.onHintFinished(); } protected void onUnlockHintStarted() { - mStatusBar.onUnlockHintStarted(); + mCentralSurfaces.onUnlockHintStarted(); } public boolean isUnlockHintRunning() { @@ -1018,7 +1019,7 @@ public abstract class PanelViewController { View[] viewsToAnimate = { mKeyguardBottomArea.getIndicationArea(), - mStatusBar.getAmbientIndicationContainer()}; + mCentralSurfaces.getAmbientIndicationContainer()}; for (View v : viewsToAnimate) { if (v == null) { continue; @@ -1210,7 +1211,7 @@ public abstract class PanelViewController { switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: - mStatusBar.userActivity(); + mCentralSurfaces.userActivity(); mAnimatingOnDown = mHeightAnimator != null && !mIsSpringBackAnimation; mMinExpandHeight = 0.0f; mDownTime = SystemClock.uptimeMillis(); @@ -1340,7 +1341,7 @@ public abstract class PanelViewController { onTrackingStarted(); } if (isFullyCollapsed() && !mHeadsUpManager.hasPinnedHeadsUp() - && !mStatusBar.isBouncerShowing()) { + && !mCentralSurfaces.isBouncerShowing()) { startOpening(event); } break; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenOffAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenOffAnimationController.kt index ea61a8b94e7e..c8174669cc65 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenOffAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenOffAnimationController.kt @@ -37,8 +37,8 @@ class ScreenOffAnimationController @Inject constructor( private val animations: List = listOfNotNull(foldToAodAnimation, unlockedScreenOffAnimation) - fun initialize(statusBar: StatusBar, lightRevealScrim: LightRevealScrim) { - animations.forEach { it.initialize(statusBar, lightRevealScrim) } + fun initialize(centralSurfaces: CentralSurfaces, lightRevealScrim: LightRevealScrim) { + animations.forEach { it.initialize(centralSurfaces, lightRevealScrim) } wakefulnessLifecycle.addObserver(this) } @@ -131,7 +131,7 @@ class ScreenOffAnimationController @Inject constructor( animations.any { it.isKeyguardHideDelayed() } /** - * Return true to make the StatusBar expanded so we can animate [LightRevealScrim] + * Return true to make the status bar expanded so we can animate [LightRevealScrim] */ fun shouldShowLightRevealScrim(): Boolean = animations.any { it.shouldPlayAnimation() } @@ -197,7 +197,7 @@ class ScreenOffAnimationController @Inject constructor( } interface ScreenOffAnimation { - fun initialize(statusBar: StatusBar, lightRevealScrim: LightRevealScrim) {} + fun initialize(centralSurfaces: CentralSurfaces, lightRevealScrim: LightRevealScrim) {} /** * Called when started going to sleep, should return true if the animation will be played diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java index 8d64041ab76b..a3c795f36d5d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java @@ -413,7 +413,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump } if (mKeyguardUpdateMonitor.needsSlowUnlockTransition() && mState == ScrimState.UNLOCKED) { - mAnimationDelay = StatusBar.FADE_KEYGUARD_START_DELAY; + mAnimationDelay = CentralSurfaces.FADE_KEYGUARD_START_DELAY; scheduleUpdate(); } else if (((oldState == ScrimState.AOD || oldState == ScrimState.PULSING) // leaving doze && (!mDozeParameters.getAlwaysOn() || mState == ScrimState.UNLOCKED)) @@ -1255,7 +1255,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump public void setScrimBehindChangeRunnable(Runnable changeRunnable) { // TODO: remove this. This is necessary because of an order-of-operations limitation. - // The fix is to move more of these class into @StatusBarScope + // The fix is to move more of these class into @CentralSurfacesScope if (mScrimBehind == null) { mScrimBehindChangeRunnable = changeRunnable; } else { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java index bfd625bbd288..902887027667 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java @@ -238,7 +238,7 @@ public enum ScrimState { mAnimationDuration = mKeyguardFadingAway ? mKeyguardFadingAwayDuration - : StatusBar.FADE_KEYGUARD_DURATION; + : CentralSurfaces.FADE_KEYGUARD_DURATION; boolean fromAod = previousState == AOD || previousState == PULSING; mAnimateChange = !mLaunchingAffordanceWithPreview && !fromAod; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadeController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadeController.java index 24bb7f25f2eb..83ee125f84c2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadeController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadeController.java @@ -18,9 +18,9 @@ import com.android.systemui.statusbar.StatusBarState; /** * {@link ShadeController} is an abstraction of the work that used to be hard-coded in - * {@link StatusBar}. The shade itself represents the concept of the status bar window state, and - * can be in multiple states: dozing, locked, showing the bouncer, occluded, etc. All/some of these - * are coordinated with {@link StatusBarKeyguardViewManager} via + * {@link CentralSurfaces}. The shade itself represents the concept of the status bar window state, + * and can be in multiple states: dozing, locked, showing the bouncer, occluded, etc. All/some of + * these are coordinated with {@link StatusBarKeyguardViewManager} via * {@link com.android.systemui.keyguard.KeyguardViewMediator} and others. */ public interface ShadeController { @@ -38,7 +38,7 @@ public interface ShadeController { /** * Collapse the shade animated, showing the bouncer when on {@link StatusBarState#KEYGUARD} or - * dismissing {@link StatusBar} when on {@link StatusBarState#SHADE}. + * dismissing {@link CentralSurfaces} when on {@link StatusBarState#SHADE}. */ void animateCollapsePanels(int flags, boolean force); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadeControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadeControllerImpl.java index 53ef97dc317c..cee8b335f380 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadeControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadeControllerImpl.java @@ -47,7 +47,7 @@ public class ShadeControllerImpl implements ShadeController { protected final NotificationShadeWindowController mNotificationShadeWindowController; private final StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; private final int mDisplayId; - protected final Lazy> mStatusBarOptionalLazy; + protected final Lazy> mCentralSurfacesOptionalLazy; private final Lazy mAssistManagerLazy; private final ArrayList mPostCollapseRunnables = new ArrayList<>(); @@ -59,7 +59,7 @@ public class ShadeControllerImpl implements ShadeController { NotificationShadeWindowController notificationShadeWindowController, StatusBarKeyguardViewManager statusBarKeyguardViewManager, WindowManager windowManager, - Lazy> statusBarOptionalLazy, + Lazy> centralSurfacesOptionalLazy, Lazy assistManagerLazy ) { mCommandQueue = commandQueue; @@ -67,15 +67,15 @@ public class ShadeControllerImpl implements ShadeController { mNotificationShadeWindowController = notificationShadeWindowController; mStatusBarKeyguardViewManager = statusBarKeyguardViewManager; mDisplayId = windowManager.getDefaultDisplay().getDisplayId(); - // TODO: Remove circular reference to StatusBar when possible. - mStatusBarOptionalLazy = statusBarOptionalLazy; + // TODO: Remove circular reference to CentralSurfaces when possible. + mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy; mAssistManagerLazy = assistManagerLazy; } @Override public void instantExpandNotificationsPanel() { // Make our window larger and the panel expanded. - getStatusBar().makeExpandedVisible(true /* force */); + getCentralSurfaces().makeExpandedVisible(true /* force */); getNotificationPanelViewController().expand(false /* animate */); mCommandQueue.recomputeDisableFlags(mDisplayId, false /* animate */); } @@ -110,7 +110,7 @@ public class ShadeControllerImpl implements ShadeController { } if (SPEW) { Log.d(TAG, "animateCollapse():" - + " mExpandedVisible=" + getStatusBar().isExpandedVisible() + + " mExpandedVisible=" + getCentralSurfaces().isExpandedVisible() + " flags=" + flags); } @@ -124,7 +124,7 @@ public class ShadeControllerImpl implements ShadeController { // release focus immediately to kick off focus change transition mNotificationShadeWindowController.setNotificationShadeFocusable(false); - getStatusBar().getNotificationShadeWindowViewController().cancelExpandHelper(); + getCentralSurfaces().getNotificationShadeWindowViewController().cancelExpandHelper(); getNotificationPanelViewController() .collapsePanel(true /* animate */, delayed, speedUpFactor); } @@ -136,7 +136,7 @@ public class ShadeControllerImpl implements ShadeController { if (!getNotificationPanelViewController().isFullyCollapsed()) { mCommandQueue.animateCollapsePanels( CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */); - getStatusBar().visibilityChanged(false); + getCentralSurfaces().visibilityChanged(false); mAssistManagerLazy.get().hideAssist(); } return false; @@ -155,7 +155,7 @@ public class ShadeControllerImpl implements ShadeController { new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { - if (getStatusBar().getNotificationShadeWindowView().isVisibleToUser()) { + if (getCentralSurfaces().getNotificationShadeWindowView().isVisibleToUser()) { getNotificationPanelViewController().removeOnGlobalLayoutListener(this); getNotificationPanelViewController().getView().post(executable); } @@ -185,7 +185,7 @@ public class ShadeControllerImpl implements ShadeController { // close the shade if it was open animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */, true /* delayed */); - getStatusBar().visibilityChanged(false); + getCentralSurfaces().visibilityChanged(false); return true; } else { @@ -201,26 +201,26 @@ public class ShadeControllerImpl implements ShadeController { runPostCollapseRunnables(); } } else if (!getPresenter().isPresenterFullyCollapsed()) { - getStatusBar().instantCollapseNotificationPanel(); - getStatusBar().visibilityChanged(false); + getCentralSurfaces().instantCollapseNotificationPanel(); + getCentralSurfaces().visibilityChanged(false); } else { runPostCollapseRunnables(); } } - private StatusBar getStatusBar() { - return mStatusBarOptionalLazy.get().get(); + private CentralSurfaces getCentralSurfaces() { + return mCentralSurfacesOptionalLazy.get().get(); } private NotificationPresenter getPresenter() { - return getStatusBar().getPresenter(); + return getCentralSurfaces().getPresenter(); } protected NotificationShadeWindowView getNotificationShadeWindowView() { - return getStatusBar().getNotificationShadeWindowView(); + return getCentralSurfaces().getNotificationShadeWindowView(); } private NotificationPanelViewController getNotificationPanelViewController() { - return getStatusBar().getPanelController(); + return getCentralSurfaces().getPanelController(); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SplitShadeHeaderController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SplitShadeHeaderController.kt index a1be5acdac13..7555356af163 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SplitShadeHeaderController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SplitShadeHeaderController.kt @@ -30,7 +30,7 @@ import com.android.systemui.flags.Flags import com.android.systemui.qs.ChipVisibilityListener import com.android.systemui.qs.HeaderPrivacyIconsController import com.android.systemui.qs.carrier.QSCarrierGroupController -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent.StatusBarScope +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent.CentralSurfacesScope import com.android.systemui.statusbar.phone.dagger.StatusBarViewModule.SPLIT_SHADE_BATTERY_CONTROLLER import com.android.systemui.statusbar.phone.dagger.StatusBarViewModule.SPLIT_SHADE_HEADER import java.io.FileDescriptor @@ -38,7 +38,7 @@ import java.io.PrintWriter import javax.inject.Inject import javax.inject.Named -@StatusBarScope +@CentralSurfacesScope class SplitShadeHeaderController @Inject constructor( @Named(SPLIT_SHADE_HEADER) private val statusBar: View, private val statusBarIconController: StatusBarIconController, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java deleted file mode 100644 index b767e17fe861..000000000000 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ /dev/null @@ -1,4439 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.statusbar.phone; - -import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN; -import static android.app.StatusBarManager.WINDOW_STATE_SHOWING; -import static android.app.StatusBarManager.WindowVisibleState; -import static android.app.StatusBarManager.windowStateToString; -import static android.view.InsetsState.ITYPE_STATUS_BAR; -import static android.view.InsetsState.containsType; -import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS; -import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_STATUS_BARS; -import static android.view.WindowInsetsController.APPEARANCE_SEMI_TRANSPARENT_STATUS_BARS; - -import static androidx.core.view.ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO; -import static androidx.core.view.ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS; -import static androidx.lifecycle.Lifecycle.State.RESUMED; - -import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME; -import static com.android.systemui.charging.WirelessChargingLayout.UNKNOWN_BATTERY_LEVEL; -import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_ASLEEP; -import static com.android.systemui.statusbar.NotificationLockscreenUserManager.PERMISSION_SELF; -import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT; -import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT_TRANSPARENT; -import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE; -import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT; -import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT; -import static com.android.systemui.statusbar.phone.BarTransitions.TransitionMode; -import static com.android.wm.shell.transition.Transitions.ENABLE_SHELL_TRANSITIONS; - -import android.annotation.Nullable; -import android.app.ActivityManager; -import android.app.ActivityOptions; -import android.app.ActivityTaskManager; -import android.app.IWallpaperManager; -import android.app.KeyguardManager; -import android.app.Notification; -import android.app.NotificationManager; -import android.app.PendingIntent; -import android.app.StatusBarManager; -import android.app.TaskInfo; -import android.app.TaskStackBuilder; -import android.app.UiModeManager; -import android.app.WallpaperInfo; -import android.app.WallpaperManager; -import android.app.admin.DevicePolicyManager; -import android.content.BroadcastReceiver; -import android.content.ComponentCallbacks2; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.pm.IPackageManager; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.content.pm.ResolveInfo; -import android.content.res.Configuration; -import android.graphics.Point; -import android.graphics.PointF; -import android.hardware.devicestate.DeviceStateManager; -import android.metrics.LogMaker; -import android.net.Uri; -import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; -import android.os.PowerManager; -import android.os.RemoteException; -import android.os.ServiceManager; -import android.os.SystemClock; -import android.os.SystemProperties; -import android.os.Trace; -import android.os.UserHandle; -import android.provider.Settings; -import android.service.dreams.DreamService; -import android.service.dreams.IDreamManager; -import android.service.notification.StatusBarNotification; -import android.text.TextUtils; -import android.util.ArraySet; -import android.util.DisplayMetrics; -import android.util.EventLog; -import android.util.IndentingPrintWriter; -import android.util.Log; -import android.util.MathUtils; -import android.util.Slog; -import android.view.Display; -import android.view.IRemoteAnimationRunner; -import android.view.IWindowManager; -import android.view.KeyEvent; -import android.view.MotionEvent; -import android.view.RemoteAnimationAdapter; -import android.view.ThreadedRenderer; -import android.view.View; -import android.view.ViewGroup; -import android.view.WindowInsetsController.Appearance; -import android.view.WindowManager; -import android.view.WindowManagerGlobal; -import android.view.accessibility.AccessibilityManager; -import android.widget.DateTimeView; - -import androidx.annotation.NonNull; -import androidx.lifecycle.Lifecycle; -import androidx.lifecycle.LifecycleOwner; -import androidx.lifecycle.LifecycleRegistry; - -import com.android.internal.annotations.VisibleForTesting; -import com.android.internal.colorextraction.ColorExtractor; -import com.android.internal.jank.InteractionJankMonitor; -import com.android.internal.logging.MetricsLogger; -import com.android.internal.logging.UiEvent; -import com.android.internal.logging.UiEventLogger; -import com.android.internal.logging.UiEventLoggerImpl; -import com.android.internal.logging.nano.MetricsProto.MetricsEvent; -import com.android.internal.statusbar.IStatusBarService; -import com.android.internal.statusbar.RegisterStatusBarResult; -import com.android.keyguard.KeyguardUpdateMonitor; -import com.android.keyguard.KeyguardUpdateMonitorCallback; -import com.android.keyguard.ViewMediatorCallback; -import com.android.systemui.ActivityIntentHelper; -import com.android.systemui.AutoReinflateContainer; -import com.android.systemui.CoreStartable; -import com.android.systemui.DejankUtils; -import com.android.systemui.EventLogTags; -import com.android.systemui.InitController; -import com.android.systemui.Prefs; -import com.android.systemui.R; -import com.android.systemui.accessibility.floatingmenu.AccessibilityFloatingMenuController; -import com.android.systemui.animation.ActivityLaunchAnimator; -import com.android.systemui.animation.DelegateLaunchAnimatorController; -import com.android.systemui.animation.RemoteTransitionAdapter; -import com.android.systemui.assist.AssistManager; -import com.android.systemui.biometrics.AuthRippleController; -import com.android.systemui.broadcast.BroadcastDispatcher; -import com.android.systemui.camera.CameraIntents; -import com.android.systemui.charging.WirelessChargingAnimation; -import com.android.systemui.classifier.FalsingCollector; -import com.android.systemui.colorextraction.SysuiColorExtractor; -import com.android.systemui.dagger.qualifiers.Main; -import com.android.systemui.dagger.qualifiers.UiBackground; -import com.android.systemui.demomode.DemoMode; -import com.android.systemui.demomode.DemoModeController; -import com.android.systemui.dreams.DreamOverlayStateController; -import com.android.systemui.emergency.EmergencyGesture; -import com.android.systemui.flags.FeatureFlags; -import com.android.systemui.flags.Flags; -import com.android.systemui.fragments.ExtensionFragmentListener; -import com.android.systemui.fragments.FragmentHostManager; -import com.android.systemui.fragments.FragmentService; -import com.android.systemui.keyguard.KeyguardService; -import com.android.systemui.keyguard.KeyguardUnlockAnimationController; -import com.android.systemui.keyguard.KeyguardViewMediator; -import com.android.systemui.keyguard.ScreenLifecycle; -import com.android.systemui.keyguard.WakefulnessLifecycle; -import com.android.systemui.navigationbar.NavigationBarController; -import com.android.systemui.navigationbar.NavigationBarView; -import com.android.systemui.plugins.ActivityStarter; -import com.android.systemui.plugins.DarkIconDispatcher; -import com.android.systemui.plugins.FalsingManager; -import com.android.systemui.plugins.OverlayPlugin; -import com.android.systemui.plugins.PluginDependencyProvider; -import com.android.systemui.plugins.PluginListener; -import com.android.systemui.plugins.qs.QS; -import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper.SnoozeOption; -import com.android.systemui.plugins.statusbar.StatusBarStateController; -import com.android.systemui.qs.QSFragment; -import com.android.systemui.qs.QSPanelController; -import com.android.systemui.recents.ScreenPinningRequest; -import com.android.systemui.scrim.ScrimView; -import com.android.systemui.settings.brightness.BrightnessSliderController; -import com.android.systemui.shared.plugins.PluginManager; -import com.android.systemui.statusbar.AutoHideUiElement; -import com.android.systemui.statusbar.BackDropView; -import com.android.systemui.statusbar.CircleReveal; -import com.android.systemui.statusbar.CommandQueue; -import com.android.systemui.statusbar.GestureRecorder; -import com.android.systemui.statusbar.KeyboardShortcuts; -import com.android.systemui.statusbar.KeyguardIndicationController; -import com.android.systemui.statusbar.LiftReveal; -import com.android.systemui.statusbar.LightRevealScrim; -import com.android.systemui.statusbar.LockscreenShadeTransitionController; -import com.android.systemui.statusbar.NotificationLockscreenUserManager; -import com.android.systemui.statusbar.NotificationMediaManager; -import com.android.systemui.statusbar.NotificationPresenter; -import com.android.systemui.statusbar.NotificationRemoteInputManager; -import com.android.systemui.statusbar.NotificationShadeDepthController; -import com.android.systemui.statusbar.NotificationShadeWindowController; -import com.android.systemui.statusbar.NotificationShelfController; -import com.android.systemui.statusbar.NotificationViewHierarchyManager; -import com.android.systemui.statusbar.PowerButtonReveal; -import com.android.systemui.statusbar.PulseExpansionHandler; -import com.android.systemui.statusbar.StatusBarState; -import com.android.systemui.statusbar.SysuiStatusBarStateController; -import com.android.systemui.statusbar.charging.WiredChargingRippleController; -import com.android.systemui.statusbar.connectivity.NetworkController; -import com.android.systemui.statusbar.core.StatusBarInitializer; -import com.android.systemui.statusbar.notification.DynamicPrivacyController; -import com.android.systemui.statusbar.notification.NotifPipelineFlags; -import com.android.systemui.statusbar.notification.NotificationActivityStarter; -import com.android.systemui.statusbar.notification.NotificationEntryManager; -import com.android.systemui.statusbar.notification.NotificationLaunchAnimatorControllerProvider; -import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; -import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager; -import com.android.systemui.statusbar.notification.collection.render.NotifShadeEventSource; -import com.android.systemui.statusbar.notification.init.NotificationsController; -import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider; -import com.android.systemui.statusbar.notification.logging.NotificationLogger; -import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; -import com.android.systemui.statusbar.notification.row.NotificationGutsManager; -import com.android.systemui.statusbar.notification.stack.NotificationListContainer; -import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; -import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; -import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneModule; -import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallController; -import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager; -import com.android.systemui.statusbar.policy.BatteryController; -import com.android.systemui.statusbar.policy.BrightnessMirrorController; -import com.android.systemui.statusbar.policy.ConfigurationController; -import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; -import com.android.systemui.statusbar.policy.DeviceProvisionedController; -import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener; -import com.android.systemui.statusbar.policy.ExtensionController; -import com.android.systemui.statusbar.policy.KeyguardStateController; -import com.android.systemui.statusbar.policy.UserInfoControllerImpl; -import com.android.systemui.statusbar.policy.UserSwitcherController; -import com.android.systemui.statusbar.window.StatusBarWindowController; -import com.android.systemui.statusbar.window.StatusBarWindowStateController; -import com.android.systemui.util.DumpUtilsKt; -import com.android.systemui.util.WallpaperController; -import com.android.systemui.util.concurrency.DelayableExecutor; -import com.android.systemui.util.concurrency.MessageRouter; -import com.android.systemui.volume.VolumeComponent; -import com.android.systemui.wmshell.BubblesManager; -import com.android.wm.shell.bubbles.Bubbles; -import com.android.wm.shell.startingsurface.SplashscreenContentDrawer; -import com.android.wm.shell.startingsurface.StartingSurface; - -import java.io.FileDescriptor; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.Executor; - -import javax.inject.Named; - -import dagger.Lazy; - -/** */ -public class StatusBar extends CoreStartable implements - ActivityStarter, - LifecycleOwner { - public static final boolean MULTIUSER_DEBUG = false; - - protected static final int MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU = 1027; - - // Should match the values in PhoneWindowManager - public static final String SYSTEM_DIALOG_REASON_KEY = "reason"; - public static final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; - public static final String SYSTEM_DIALOG_REASON_DREAM = "dream"; - static public final String SYSTEM_DIALOG_REASON_SCREENSHOT = "screenshot"; - - private static final String BANNER_ACTION_CANCEL = - "com.android.systemui.statusbar.banner_action_cancel"; - private static final String BANNER_ACTION_SETUP = - "com.android.systemui.statusbar.banner_action_setup"; - public static final String TAG = "StatusBar"; - public static final boolean DEBUG = false; - public static final boolean SPEW = false; - public static final boolean DUMPTRUCK = true; // extra dumpsys info - public static final boolean DEBUG_GESTURES = false; - public static final boolean DEBUG_MEDIA_FAKE_ARTWORK = false; - public static final boolean DEBUG_CAMERA_LIFT = false; - - public static final boolean DEBUG_WINDOW_STATE = false; - - // additional instrumentation for testing purposes; intended to be left on during development - public static final boolean CHATTY = DEBUG; - - public static final boolean SHOW_LOCKSCREEN_MEDIA_ARTWORK = true; - - public static final String ACTION_FAKE_ARTWORK = "fake_artwork"; - - private static final int MSG_OPEN_SETTINGS_PANEL = 1002; - private static final int MSG_LAUNCH_TRANSITION_TIMEOUT = 1003; - // 1020-1040 reserved for BaseStatusBar - - // Time after we abort the launch transition. - static final long LAUNCH_TRANSITION_TIMEOUT_MS = 5000; - - protected static final boolean CLOSE_PANEL_WHEN_EMPTIED = true; - - /** - * The delay to reset the hint text when the hint animation is finished running. - */ - private static final int HINT_RESET_DELAY_MS = 1200; - - public static final int FADE_KEYGUARD_START_DELAY = 100; - public static final int FADE_KEYGUARD_DURATION = 300; - public static final int FADE_KEYGUARD_DURATION_PULSING = 96; - - public static final long[] CAMERA_LAUNCH_GESTURE_VIBRATION_TIMINGS = - new long[]{20, 20, 20, 20, 100, 20}; - public static final int[] CAMERA_LAUNCH_GESTURE_VIBRATION_AMPLITUDES = - new int[]{39, 82, 139, 213, 0, 127}; - - /** - * If true, the system is in the half-boot-to-decryption-screen state. - * Prudently disable QS and notifications. - */ - public static final boolean ONLY_CORE_APPS; - - /** If true, the lockscreen will show a distinct wallpaper */ - public static final boolean ENABLE_LOCKSCREEN_WALLPAPER = true; - - private static final UiEventLogger sUiEventLogger = new UiEventLoggerImpl(); - - static { - boolean onlyCoreApps; - try { - IPackageManager packageManager = - IPackageManager.Stub.asInterface(ServiceManager.getService("package")); - onlyCoreApps = packageManager != null && packageManager.isOnlyCoreApps(); - } catch (RemoteException e) { - onlyCoreApps = false; - } - ONLY_CORE_APPS = onlyCoreApps; - } - - private final LockscreenShadeTransitionController mLockscreenShadeTransitionController; - private final DreamOverlayStateController mDreamOverlayStateController; - private StatusBarCommandQueueCallbacks mCommandQueueCallbacks; - private float mTransitionToFullShadeProgress = 0f; - private NotificationListContainer mNotifListContainer; - - void onStatusBarWindowStateChanged(@WindowVisibleState int state) { - updateBubblesVisibility(); - mStatusBarWindowState = state; - } - - void acquireGestureWakeLock(long time) { - mGestureWakeLock.acquire(time); - } - - boolean setAppearance(int appearance) { - if (mAppearance != appearance) { - mAppearance = appearance; - return updateBarMode(barMode(isTransientShown(), appearance)); - } - - return false; - } - - int getBarMode() { - return mStatusBarMode; - } - - void resendMessage(int msg) { - mMessageRouter.cancelMessages(msg); - mMessageRouter.sendMessage(msg); - } - - void resendMessage(Object msg) { - mMessageRouter.cancelMessages(msg.getClass()); - mMessageRouter.sendMessage(msg); - } - - int getDisabled1() { - return mDisabled1; - } - - void setDisabled1(int disabled) { - mDisabled1 = disabled; - } - - int getDisabled2() { - return mDisabled2; - } - - void setDisabled2(int disabled) { - mDisabled2 = disabled; - } - - void setLastCameraLaunchSource(int source) { - mLastCameraLaunchSource = source; - } - - void setLaunchCameraOnFinishedGoingToSleep(boolean launch) { - mLaunchCameraOnFinishedGoingToSleep = launch; - } - - void setLaunchCameraOnFinishedWaking(boolean launch) { - mLaunchCameraWhenFinishedWaking = launch; - } - - void setLaunchEmergencyActionOnFinishedGoingToSleep(boolean launch) { - mLaunchEmergencyActionOnFinishedGoingToSleep = launch; - } - - void setLaunchEmergencyActionOnFinishedWaking(boolean launch) { - mLaunchEmergencyActionWhenFinishedWaking = launch; - } - - void setTopHidesStatusBar(boolean hides) { - mTopHidesStatusBar = hides; - } - - QSPanelController getQSPanelController() { - return mQSPanelController; - } - - /** */ - public void animateExpandNotificationsPanel() { - mCommandQueueCallbacks.animateExpandNotificationsPanel(); - } - - /** */ - public void animateExpandSettingsPanel(@Nullable String subpanel) { - mCommandQueueCallbacks.animateExpandSettingsPanel(subpanel); - } - - /** */ - public void animateCollapsePanels(int flags, boolean force) { - mCommandQueueCallbacks.animateCollapsePanels(flags, force); - } - - /** */ - public void togglePanel() { - mCommandQueueCallbacks.togglePanel(); - } - /** - * The {@link StatusBarState} of the status bar. - */ - protected int mState; // TODO: remove this. Just use StatusBarStateController - protected boolean mBouncerShowing; - - private final PhoneStatusBarPolicy mIconPolicy; - - private final VolumeComponent mVolumeComponent; - private BrightnessMirrorController mBrightnessMirrorController; - private boolean mBrightnessMirrorVisible; - private BiometricUnlockController mBiometricUnlockController; - private final LightBarController mLightBarController; - private final Lazy mLockscreenWallpaperLazy; - private final LockscreenGestureLogger mLockscreenGestureLogger; - @Nullable - protected LockscreenWallpaper mLockscreenWallpaper; - private final AutoHideController mAutoHideController; - - private final Point mCurrentDisplaySize = new Point(); - - protected NotificationShadeWindowView mNotificationShadeWindowView; - protected PhoneStatusBarView mStatusBarView; - private PhoneStatusBarViewController mPhoneStatusBarViewController; - private PhoneStatusBarTransitions mStatusBarTransitions; - private AuthRippleController mAuthRippleController; - @WindowVisibleState private int mStatusBarWindowState = WINDOW_STATE_SHOWING; - protected final NotificationShadeWindowController mNotificationShadeWindowController; - private final StatusBarWindowController mStatusBarWindowController; - private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; - @VisibleForTesting - DozeServiceHost mDozeServiceHost; - private boolean mWakeUpComingFromTouch; - private PointF mWakeUpTouchLocation; - private LightRevealScrim mLightRevealScrim; - private PowerButtonReveal mPowerButtonReveal; - - private final Object mQueueLock = new Object(); - - private final PulseExpansionHandler mPulseExpansionHandler; - private final NotificationWakeUpCoordinator mWakeUpCoordinator; - private final KeyguardBypassController mKeyguardBypassController; - private final KeyguardStateController mKeyguardStateController; - private final HeadsUpManagerPhone mHeadsUpManager; - private final StatusBarTouchableRegionManager mStatusBarTouchableRegionManager; - private final DynamicPrivacyController mDynamicPrivacyController; - private final FalsingCollector mFalsingCollector; - private final FalsingManager mFalsingManager; - private final BroadcastDispatcher mBroadcastDispatcher; - private final ConfigurationController mConfigurationController; - protected NotificationShadeWindowViewController mNotificationShadeWindowViewController; - private final DozeParameters mDozeParameters; - private final Lazy mBiometricUnlockControllerLazy; - private final StatusBarComponent.Factory mStatusBarComponentFactory; - private final PluginManager mPluginManager; - private final ShadeController mShadeController; - private final InitController mInitController; - - private final PluginDependencyProvider mPluginDependencyProvider; - private final KeyguardDismissUtil mKeyguardDismissUtil; - private final ExtensionController mExtensionController; - private final UserInfoControllerImpl mUserInfoControllerImpl; - private final DemoModeController mDemoModeController; - private final NotificationsController mNotificationsController; - private final OngoingCallController mOngoingCallController; - private final StatusBarSignalPolicy mStatusBarSignalPolicy; - private final StatusBarHideIconsForBouncerManager mStatusBarHideIconsForBouncerManager; - - // expanded notifications - // the sliding/resizing panel within the notification window - protected NotificationPanelViewController mNotificationPanelViewController; - - // settings - private QSPanelController mQSPanelController; - - KeyguardIndicationController mKeyguardIndicationController; - - private View mReportRejectedTouch; - - private boolean mExpandedVisible; - - private final int[] mAbsPos = new int[2]; - - private final NotifShadeEventSource mNotifShadeEventSource; - protected final NotificationEntryManager mEntryManager; - private final NotificationGutsManager mGutsManager; - private final NotificationLogger mNotificationLogger; - private final NotificationViewHierarchyManager mViewHierarchyManager; - private final PanelExpansionStateManager mPanelExpansionStateManager; - private final KeyguardViewMediator mKeyguardViewMediator; - protected final NotificationInterruptStateProvider mNotificationInterruptStateProvider; - private final BrightnessSliderController.Factory mBrightnessSliderFactory; - private final FeatureFlags mFeatureFlags; - private final FragmentService mFragmentService; - private final ScreenOffAnimationController mScreenOffAnimationController; - private final WallpaperController mWallpaperController; - private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController; - private final MessageRouter mMessageRouter; - private final WallpaperManager mWallpaperManager; - - private StatusBarComponent mStatusBarComponent; - - // Flags for disabling the status bar - // Two variables becaseu the first one evidently ran out of room for new flags. - private int mDisabled1 = 0; - private int mDisabled2 = 0; - - /** @see android.view.WindowInsetsController#setSystemBarsAppearance(int, int) */ - private @Appearance int mAppearance; - - private boolean mTransientShown; - - private final DisplayMetrics mDisplayMetrics; - - // XXX: gesture research - private final GestureRecorder mGestureRec = DEBUG_GESTURES - ? new GestureRecorder("/sdcard/statusbar_gestures.dat") - : null; - - private final ScreenPinningRequest mScreenPinningRequest; - - private final MetricsLogger mMetricsLogger; - - // ensure quick settings is disabled until the current user makes it through the setup wizard - @VisibleForTesting - protected boolean mUserSetup = false; - - @VisibleForTesting - public enum StatusBarUiEvent implements UiEventLogger.UiEventEnum { - @UiEvent(doc = "Secured lockscreen is opened.") - LOCKSCREEN_OPEN_SECURE(405), - - @UiEvent(doc = "Lockscreen without security is opened.") - LOCKSCREEN_OPEN_INSECURE(406), - - @UiEvent(doc = "Secured lockscreen is closed.") - LOCKSCREEN_CLOSE_SECURE(407), - - @UiEvent(doc = "Lockscreen without security is closed.") - LOCKSCREEN_CLOSE_INSECURE(408), - - @UiEvent(doc = "Secured bouncer is opened.") - BOUNCER_OPEN_SECURE(409), - - @UiEvent(doc = "Bouncer without security is opened.") - BOUNCER_OPEN_INSECURE(410), - - @UiEvent(doc = "Secured bouncer is closed.") - BOUNCER_CLOSE_SECURE(411), - - @UiEvent(doc = "Bouncer without security is closed.") - BOUNCER_CLOSE_INSECURE(412); - - private final int mId; - - StatusBarUiEvent(int id) { - mId = id; - } - - @Override - public int getId() { - return mId; - } - } - - private Handler mMainHandler; - private final DelayableExecutor mMainExecutor; - - private int mInteractingWindows; - private @TransitionMode int mStatusBarMode; - - private final ViewMediatorCallback mKeyguardViewMediatorCallback; - private final ScrimController mScrimController; - protected DozeScrimController mDozeScrimController; - private final Executor mUiBgExecutor; - - protected boolean mDozing; - private boolean mIsFullscreen; - - boolean mCloseQsBeforeScreenOff; - - private final NotificationMediaManager mMediaManager; - private final NotificationLockscreenUserManager mLockscreenUserManager; - private final NotificationRemoteInputManager mRemoteInputManager; - private boolean mWallpaperSupported; - - private Runnable mLaunchTransitionEndRunnable; - private boolean mLaunchCameraWhenFinishedWaking; - private boolean mLaunchCameraOnFinishedGoingToSleep; - private boolean mLaunchEmergencyActionWhenFinishedWaking; - private boolean mLaunchEmergencyActionOnFinishedGoingToSleep; - private int mLastCameraLaunchSource; - protected PowerManager.WakeLock mGestureWakeLock; - - private final int[] mTmpInt2 = new int[2]; - - // Fingerprint (as computed by getLoggingFingerprint() of the last logged state. - private int mLastLoggedStateFingerprint; - private boolean mTopHidesStatusBar; - private boolean mStatusBarWindowHidden; - private boolean mIsOccluded; - private boolean mIsLaunchingActivityOverLockscreen; - - private final UserSwitcherController mUserSwitcherController; - private final NetworkController mNetworkController; - private final LifecycleRegistry mLifecycle = new LifecycleRegistry(this); - protected final BatteryController mBatteryController; - protected boolean mPanelExpanded; - private UiModeManager mUiModeManager; - protected boolean mIsKeyguard; - private LogMaker mStatusBarStateLog; - protected final NotificationIconAreaController mNotificationIconAreaController; - @Nullable private View mAmbientIndicationContainer; - private final SysuiColorExtractor mColorExtractor; - private final ScreenLifecycle mScreenLifecycle; - private final WakefulnessLifecycle mWakefulnessLifecycle; - - private boolean mNoAnimationOnNextBarModeChange; - private final SysuiStatusBarStateController mStatusBarStateController; - - private final ActivityLaunchAnimator mActivityLaunchAnimator; - private NotificationLaunchAnimatorControllerProvider mNotificationAnimationProvider; - protected NotificationPresenter mPresenter; - private NotificationActivityStarter mNotificationActivityStarter; - private final Lazy mNotificationShadeDepthControllerLazy; - private final Optional mBubblesManagerOptional; - private final Optional mBubblesOptional; - private final Bubbles.BubbleExpandListener mBubbleExpandListener; - private final Optional mStartingSurfaceOptional; - private final NotifPipelineFlags mNotifPipelineFlags; - - private final ActivityIntentHelper mActivityIntentHelper; - private NotificationStackScrollLayoutController mStackScrollerController; - - private final ColorExtractor.OnColorsChangedListener mOnColorsChangedListener = - (extractor, which) -> updateTheme(); - - private final InteractionJankMonitor mJankMonitor; - - - /** - * Public constructor for StatusBar. - * - * StatusBar is considered optional, and therefore can not be marked as @Inject directly. - * Instead, an @Provide method is included. See {@link StatusBarPhoneModule}. - */ - @SuppressWarnings("OptionalUsedAsFieldOrParameterType") - public StatusBar( - Context context, - NotificationsController notificationsController, - FragmentService fragmentService, - LightBarController lightBarController, - AutoHideController autoHideController, - StatusBarWindowController statusBarWindowController, - StatusBarWindowStateController statusBarWindowStateController, - KeyguardUpdateMonitor keyguardUpdateMonitor, - StatusBarSignalPolicy statusBarSignalPolicy, - PulseExpansionHandler pulseExpansionHandler, - NotificationWakeUpCoordinator notificationWakeUpCoordinator, - KeyguardBypassController keyguardBypassController, - KeyguardStateController keyguardStateController, - HeadsUpManagerPhone headsUpManagerPhone, - DynamicPrivacyController dynamicPrivacyController, - FalsingManager falsingManager, - FalsingCollector falsingCollector, - BroadcastDispatcher broadcastDispatcher, - NotifShadeEventSource notifShadeEventSource, - NotificationEntryManager notificationEntryManager, - NotificationGutsManager notificationGutsManager, - NotificationLogger notificationLogger, - NotificationInterruptStateProvider notificationInterruptStateProvider, - NotificationViewHierarchyManager notificationViewHierarchyManager, - PanelExpansionStateManager panelExpansionStateManager, - KeyguardViewMediator keyguardViewMediator, - DisplayMetrics displayMetrics, - MetricsLogger metricsLogger, - @UiBackground Executor uiBgExecutor, - NotificationMediaManager notificationMediaManager, - NotificationLockscreenUserManager lockScreenUserManager, - NotificationRemoteInputManager remoteInputManager, - UserSwitcherController userSwitcherController, - NetworkController networkController, - BatteryController batteryController, - SysuiColorExtractor colorExtractor, - ScreenLifecycle screenLifecycle, - WakefulnessLifecycle wakefulnessLifecycle, - SysuiStatusBarStateController statusBarStateController, - Optional bubblesManagerOptional, - Optional bubblesOptional, - VisualStabilityManager visualStabilityManager, - DeviceProvisionedController deviceProvisionedController, - NavigationBarController navigationBarController, - AccessibilityFloatingMenuController accessibilityFloatingMenuController, - Lazy assistManagerLazy, - ConfigurationController configurationController, - NotificationShadeWindowController notificationShadeWindowController, - DozeParameters dozeParameters, - ScrimController scrimController, - Lazy lockscreenWallpaperLazy, - LockscreenGestureLogger lockscreenGestureLogger, - Lazy biometricUnlockControllerLazy, - DozeServiceHost dozeServiceHost, - PowerManager powerManager, - ScreenPinningRequest screenPinningRequest, - DozeScrimController dozeScrimController, - VolumeComponent volumeComponent, - CommandQueue commandQueue, - StatusBarComponent.Factory statusBarComponentFactory, - PluginManager pluginManager, - ShadeController shadeController, - StatusBarKeyguardViewManager statusBarKeyguardViewManager, - ViewMediatorCallback viewMediatorCallback, - InitController initController, - @Named(TIME_TICK_HANDLER_NAME) Handler timeTickHandler, - PluginDependencyProvider pluginDependencyProvider, - KeyguardDismissUtil keyguardDismissUtil, - ExtensionController extensionController, - UserInfoControllerImpl userInfoControllerImpl, - PhoneStatusBarPolicy phoneStatusBarPolicy, - KeyguardIndicationController keyguardIndicationController, - DemoModeController demoModeController, - Lazy notificationShadeDepthControllerLazy, - StatusBarTouchableRegionManager statusBarTouchableRegionManager, - NotificationIconAreaController notificationIconAreaController, - BrightnessSliderController.Factory brightnessSliderFactory, - ScreenOffAnimationController screenOffAnimationController, - WallpaperController wallpaperController, - OngoingCallController ongoingCallController, - StatusBarHideIconsForBouncerManager statusBarHideIconsForBouncerManager, - LockscreenShadeTransitionController lockscreenShadeTransitionController, - FeatureFlags featureFlags, - KeyguardUnlockAnimationController keyguardUnlockAnimationController, - @Main Handler mainHandler, - @Main DelayableExecutor delayableExecutor, - @Main MessageRouter messageRouter, - WallpaperManager wallpaperManager, - Optional startingSurfaceOptional, - ActivityLaunchAnimator activityLaunchAnimator, - NotifPipelineFlags notifPipelineFlags, - InteractionJankMonitor jankMonitor, - DeviceStateManager deviceStateManager, - DreamOverlayStateController dreamOverlayStateController, - WiredChargingRippleController wiredChargingRippleController) { - super(context); - mNotificationsController = notificationsController; - mFragmentService = fragmentService; - mLightBarController = lightBarController; - mAutoHideController = autoHideController; - mStatusBarWindowController = statusBarWindowController; - mKeyguardUpdateMonitor = keyguardUpdateMonitor; - mPulseExpansionHandler = pulseExpansionHandler; - mWakeUpCoordinator = notificationWakeUpCoordinator; - mKeyguardBypassController = keyguardBypassController; - mKeyguardStateController = keyguardStateController; - mHeadsUpManager = headsUpManagerPhone; - mKeyguardIndicationController = keyguardIndicationController; - mStatusBarTouchableRegionManager = statusBarTouchableRegionManager; - mDynamicPrivacyController = dynamicPrivacyController; - mFalsingCollector = falsingCollector; - mFalsingManager = falsingManager; - mBroadcastDispatcher = broadcastDispatcher; - mNotifShadeEventSource = notifShadeEventSource; - mEntryManager = notificationEntryManager; - mGutsManager = notificationGutsManager; - mNotificationLogger = notificationLogger; - mNotificationInterruptStateProvider = notificationInterruptStateProvider; - mViewHierarchyManager = notificationViewHierarchyManager; - mPanelExpansionStateManager = panelExpansionStateManager; - mKeyguardViewMediator = keyguardViewMediator; - mDisplayMetrics = displayMetrics; - mMetricsLogger = metricsLogger; - mUiBgExecutor = uiBgExecutor; - mMediaManager = notificationMediaManager; - mLockscreenUserManager = lockScreenUserManager; - mRemoteInputManager = remoteInputManager; - mUserSwitcherController = userSwitcherController; - mNetworkController = networkController; - mBatteryController = batteryController; - mColorExtractor = colorExtractor; - mScreenLifecycle = screenLifecycle; - mWakefulnessLifecycle = wakefulnessLifecycle; - mStatusBarStateController = statusBarStateController; - mBubblesManagerOptional = bubblesManagerOptional; - mBubblesOptional = bubblesOptional; - mVisualStabilityManager = visualStabilityManager; - mDeviceProvisionedController = deviceProvisionedController; - mNavigationBarController = navigationBarController; - mAccessibilityFloatingMenuController = accessibilityFloatingMenuController; - mAssistManagerLazy = assistManagerLazy; - mConfigurationController = configurationController; - mNotificationShadeWindowController = notificationShadeWindowController; - mDozeServiceHost = dozeServiceHost; - mPowerManager = powerManager; - mDozeParameters = dozeParameters; - mScrimController = scrimController; - mLockscreenWallpaperLazy = lockscreenWallpaperLazy; - mLockscreenGestureLogger = lockscreenGestureLogger; - mScreenPinningRequest = screenPinningRequest; - mDozeScrimController = dozeScrimController; - mBiometricUnlockControllerLazy = biometricUnlockControllerLazy; - mNotificationShadeDepthControllerLazy = notificationShadeDepthControllerLazy; - mVolumeComponent = volumeComponent; - mCommandQueue = commandQueue; - mStatusBarComponentFactory = statusBarComponentFactory; - mPluginManager = pluginManager; - mShadeController = shadeController; - mStatusBarKeyguardViewManager = statusBarKeyguardViewManager; - mKeyguardViewMediatorCallback = viewMediatorCallback; - mInitController = initController; - mPluginDependencyProvider = pluginDependencyProvider; - mKeyguardDismissUtil = keyguardDismissUtil; - mExtensionController = extensionController; - mUserInfoControllerImpl = userInfoControllerImpl; - mIconPolicy = phoneStatusBarPolicy; - mDemoModeController = demoModeController; - mNotificationIconAreaController = notificationIconAreaController; - mBrightnessSliderFactory = brightnessSliderFactory; - mWallpaperController = wallpaperController; - mOngoingCallController = ongoingCallController; - mStatusBarSignalPolicy = statusBarSignalPolicy; - mStatusBarHideIconsForBouncerManager = statusBarHideIconsForBouncerManager; - mFeatureFlags = featureFlags; - mKeyguardUnlockAnimationController = keyguardUnlockAnimationController; - mMainHandler = mainHandler; - mMainExecutor = delayableExecutor; - mMessageRouter = messageRouter; - mWallpaperManager = wallpaperManager; - mJankMonitor = jankMonitor; - mDreamOverlayStateController = dreamOverlayStateController; - - mLockscreenShadeTransitionController = lockscreenShadeTransitionController; - mStartingSurfaceOptional = startingSurfaceOptional; - mNotifPipelineFlags = notifPipelineFlags; - lockscreenShadeTransitionController.setStatusbar(this); - statusBarWindowStateController.addListener(this::onStatusBarWindowStateChanged); - - mScreenOffAnimationController = screenOffAnimationController; - - mPanelExpansionStateManager.addExpansionListener(this::onPanelExpansionChanged); - - mBubbleExpandListener = - (isExpanding, key) -> mContext.getMainExecutor().execute(() -> { - mNotificationsController.requestNotificationUpdate("onBubbleExpandChanged"); - updateScrimController(); - }); - - mActivityIntentHelper = new ActivityIntentHelper(mContext); - mActivityLaunchAnimator = activityLaunchAnimator; - - // The status bar background may need updating when the ongoing call status changes. - mOngoingCallController.addCallback((animate) -> maybeUpdateBarMode()); - - // TODO(b/190746471): Find a better home for this. - DateTimeView.setReceiverHandler(timeTickHandler); - - mMessageRouter.subscribeTo(KeyboardShortcutsMessage.class, - data -> toggleKeyboardShortcuts(data.mDeviceId)); - mMessageRouter.subscribeTo(MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU, - id -> dismissKeyboardShortcuts()); - mMessageRouter.subscribeTo(AnimateExpandSettingsPanelMessage.class, - data -> mCommandQueueCallbacks.animateExpandSettingsPanel(data.mSubpanel)); - mMessageRouter.subscribeTo(MSG_LAUNCH_TRANSITION_TIMEOUT, - id -> onLaunchTransitionTimeout()); - - deviceStateManager.registerCallback(mMainExecutor, - new FoldStateListener(mContext, this::onFoldedStateChanged)); - wiredChargingRippleController.registerCallbacks(); - } - - @Override - public void start() { - mScreenLifecycle.addObserver(mScreenObserver); - mWakefulnessLifecycle.addObserver(mWakefulnessObserver); - mUiModeManager = mContext.getSystemService(UiModeManager.class); - if (mBubblesOptional.isPresent()) { - mBubblesOptional.get().setExpandListener(mBubbleExpandListener); - } - - mStatusBarSignalPolicy.init(); - mKeyguardIndicationController.init(); - - mColorExtractor.addOnColorsChangedListener(mOnColorsChangedListener); - mStatusBarStateController.addCallback(mStateListener, - SysuiStatusBarStateController.RANK_STATUS_BAR); - - mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); - mDreamManager = IDreamManager.Stub.asInterface( - ServiceManager.checkService(DreamService.DREAM_SERVICE)); - - mDisplay = mContext.getDisplay(); - mDisplayId = mDisplay.getDisplayId(); - updateDisplaySize(); - mStatusBarHideIconsForBouncerManager.setDisplayId(mDisplayId); - - // start old BaseStatusBar.start(). - mWindowManagerService = WindowManagerGlobal.getWindowManagerService(); - mDevicePolicyManager = (DevicePolicyManager) mContext.getSystemService( - Context.DEVICE_POLICY_SERVICE); - - mAccessibilityManager = (AccessibilityManager) - mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); - - mKeyguardUpdateMonitor.setKeyguardBypassController(mKeyguardBypassController); - mBarService = IStatusBarService.Stub.asInterface( - ServiceManager.getService(Context.STATUS_BAR_SERVICE)); - - mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); - mWallpaperSupported = mWallpaperManager.isWallpaperSupported(); - - RegisterStatusBarResult result = null; - try { - result = mBarService.registerStatusBar(mCommandQueue); - } catch (RemoteException ex) { - ex.rethrowFromSystemServer(); - } - - createAndAddWindows(result); - - if (mWallpaperSupported) { - // Make sure we always have the most current wallpaper info. - IntentFilter wallpaperChangedFilter = new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED); - mBroadcastDispatcher.registerReceiver(mWallpaperChangedReceiver, wallpaperChangedFilter, - null /* handler */, UserHandle.ALL); - mWallpaperChangedReceiver.onReceive(mContext, null); - } else if (DEBUG) { - Log.v(TAG, "start(): no wallpaper service "); - } - - // Set up the initial notification state. This needs to happen before CommandQueue.disable() - setUpPresenter(); - - if (containsType(result.mTransientBarTypes, ITYPE_STATUS_BAR)) { - showTransientUnchecked(); - } - mCommandQueueCallbacks.onSystemBarAttributesChanged(mDisplayId, result.mAppearance, - result.mAppearanceRegions, result.mNavbarColorManagedByIme, result.mBehavior, - result.mRequestedVisibilities, result.mPackageName); - - // StatusBarManagerService has a back up of IME token and it's restored here. - mCommandQueueCallbacks.setImeWindowStatus(mDisplayId, result.mImeToken, - result.mImeWindowVis, result.mImeBackDisposition, result.mShowImeSwitcher); - - // Set up the initial icon state - int numIcons = result.mIcons.size(); - for (int i = 0; i < numIcons; i++) { - mCommandQueue.setIcon(result.mIcons.keyAt(i), result.mIcons.valueAt(i)); - } - - - if (DEBUG) { - Log.d(TAG, String.format( - "init: icons=%d disabled=0x%08x lights=0x%08x imeButton=0x%08x", - numIcons, - result.mDisabledFlags1, - result.mAppearance, - result.mImeWindowVis)); - } - - IntentFilter internalFilter = new IntentFilter(); - internalFilter.addAction(BANNER_ACTION_CANCEL); - internalFilter.addAction(BANNER_ACTION_SETUP); - mContext.registerReceiver(mBannerActionBroadcastReceiver, internalFilter, PERMISSION_SELF, - null, Context.RECEIVER_EXPORTED_UNAUDITED); - - if (mWallpaperSupported) { - IWallpaperManager wallpaperManager = IWallpaperManager.Stub.asInterface( - ServiceManager.getService(Context.WALLPAPER_SERVICE)); - try { - wallpaperManager.setInAmbientMode(false /* ambientMode */, 0L /* duration */); - } catch (RemoteException e) { - // Just pass, nothing critical. - } - } - - // end old BaseStatusBar.start(). - - // Lastly, call to the icon policy to install/update all the icons. - mIconPolicy.init(); - - mKeyguardStateController.addCallback(new KeyguardStateController.Callback() { - @Override - public void onUnlockedChanged() { - updateKeyguardState(); - logStateToEventlog(); - } - }); - startKeyguard(); - - mKeyguardUpdateMonitor.registerCallback(mUpdateCallback); - mDozeServiceHost.initialize( - this, - mStatusBarKeyguardViewManager, - mNotificationShadeWindowViewController, - mNotificationPanelViewController, - mAmbientIndicationContainer); - updateLightRevealScrimVisibility(); - - mConfigurationController.addCallback(mConfigurationListener); - - mBatteryController.observe(mLifecycle, mBatteryStateChangeCallback); - mLifecycle.setCurrentState(RESUMED); - - mAccessibilityFloatingMenuController.init(); - - // set the initial view visibility - int disabledFlags1 = result.mDisabledFlags1; - int disabledFlags2 = result.mDisabledFlags2; - mInitController.addPostInitTask( - () -> setUpDisableFlags(disabledFlags1, disabledFlags2)); - - mFalsingManager.addFalsingBeliefListener(mFalsingBeliefListener); - - mPluginManager.addPluginListener( - new PluginListener() { - private final ArraySet mOverlays = new ArraySet<>(); - - @Override - public void onPluginConnected(OverlayPlugin plugin, Context pluginContext) { - mMainExecutor.execute( - () -> plugin.setup(getNotificationShadeWindowView(), - getNavigationBarView(), - new Callback(plugin), mDozeParameters)); - } - - @Override - public void onPluginDisconnected(OverlayPlugin plugin) { - mMainExecutor.execute(() -> { - mOverlays.remove(plugin); - mNotificationShadeWindowController - .setForcePluginOpen(mOverlays.size() != 0, this); - }); - } - - class Callback implements OverlayPlugin.Callback { - private final OverlayPlugin mPlugin; - - Callback(OverlayPlugin plugin) { - mPlugin = plugin; - } - - @Override - public void onHoldStatusBarOpenChange() { - if (mPlugin.holdStatusBarOpen()) { - mOverlays.add(mPlugin); - } else { - mOverlays.remove(mPlugin); - } - mMainExecutor.execute(() -> { - mNotificationShadeWindowController - .setStateListener(b -> mOverlays.forEach( - o -> o.setCollapseDesired(b))); - mNotificationShadeWindowController - .setForcePluginOpen(mOverlays.size() != 0, this); - }); - } - } - }, OverlayPlugin.class, true /* Allow multiple plugins */); - - mStartingSurfaceOptional.ifPresent(startingSurface -> startingSurface.setSysuiProxy( - (requestTopUi, componentTag) -> mMainExecutor.execute(() -> - mNotificationShadeWindowController.setRequestTopUi( - requestTopUi, componentTag)))); - } - - private void onFoldedStateChanged(boolean isFolded, boolean willGoToSleep) { - Trace.beginSection("StatusBar#onFoldedStateChanged"); - onFoldedStateChangedInternal(isFolded, willGoToSleep); - Trace.endSection(); - } - - private void onFoldedStateChangedInternal(boolean isFolded, boolean willGoToSleep) { - // Folded state changes are followed by a screen off event. - // By default turning off the screen also closes the shade. - // We want to make sure that the shade status is kept after - // folding/unfolding. - boolean isShadeOpen = mShadeController.isShadeOpen(); - boolean leaveOpen = isShadeOpen && !willGoToSleep; - if (DEBUG) { - Log.d(TAG, String.format( - "#onFoldedStateChanged(): " - + "isFolded=%s, " - + "willGoToSleep=%s, " - + "isShadeOpen=%s, " - + "leaveOpen=%s", - isFolded, willGoToSleep, isShadeOpen, leaveOpen)); - } - if (leaveOpen) { - mStatusBarStateController.setLeaveOpenOnKeyguardHide(true); - if (mIsKeyguard) { - // When device state changes on keyguard we don't want to keep the state of - // the shade and instead we open clean state of keyguard with shade closed. - // Normally some parts of QS state (like expanded/collapsed) are persisted and - // that causes incorrect UI rendering, especially when changing state with QS - // expanded. To prevent that we can close QS which resets QS and some parts of - // the shade to its default state. Read more in b/201537421 - mCloseQsBeforeScreenOff = true; - } - } - } - - // ================================================================================ - // Constructing the view - // ================================================================================ - protected void makeStatusBarView(@Nullable RegisterStatusBarResult result) { - updateDisplaySize(); // populates mDisplayMetrics - updateResources(); - updateTheme(); - - inflateStatusBarWindow(); - mNotificationShadeWindowView.setOnTouchListener(getStatusBarWindowTouchListener()); - mWallpaperController.setRootView(mNotificationShadeWindowView); - - // TODO: Deal with the ugliness that comes from having some of the statusbar broken out - // into fragments, but the rest here, it leaves some awkward lifecycle and whatnot. - mNotificationLogger.setUpWithContainer(mNotifListContainer); - mNotificationIconAreaController.setupShelf(mNotificationShelfController); - mPanelExpansionStateManager.addExpansionListener(mWakeUpCoordinator); - mUserSwitcherController.init(mNotificationShadeWindowView); - - // Allow plugins to reference DarkIconDispatcher and StatusBarStateController - mPluginDependencyProvider.allowPluginDependency(DarkIconDispatcher.class); - mPluginDependencyProvider.allowPluginDependency(StatusBarStateController.class); - - // Set up CollapsedStatusBarFragment and PhoneStatusBarView - StatusBarInitializer initializer = mStatusBarComponent.getStatusBarInitializer(); - initializer.setStatusBarViewUpdatedListener( - (statusBarView, statusBarViewController, statusBarTransitions) -> { - mStatusBarView = statusBarView; - mPhoneStatusBarViewController = statusBarViewController; - mStatusBarTransitions = statusBarTransitions; - mNotificationShadeWindowViewController - .setStatusBarViewController(mPhoneStatusBarViewController); - // Ensure we re-propagate panel expansion values to the panel controller and - // any listeners it may have, such as PanelBar. This will also ensure we - // re-display the notification panel if necessary (for example, if - // a heads-up notification was being displayed and should continue being - // displayed). - mNotificationPanelViewController.updatePanelExpansionAndVisibility(); - setBouncerShowingForStatusBarComponents(mBouncerShowing); - checkBarModes(); - }); - initializer.initializeStatusBar(mStatusBarComponent); - - mStatusBarTouchableRegionManager.setup(this, mNotificationShadeWindowView); - mHeadsUpManager.addListener(mNotificationPanelViewController.getOnHeadsUpChangedListener()); - if (!mNotifPipelineFlags.isNewPipelineEnabled()) { - mHeadsUpManager.addListener(mVisualStabilityManager); - } - mNotificationPanelViewController.setHeadsUpManager(mHeadsUpManager); - - createNavigationBar(result); - - if (ENABLE_LOCKSCREEN_WALLPAPER && mWallpaperSupported) { - mLockscreenWallpaper = mLockscreenWallpaperLazy.get(); - } - - mNotificationPanelViewController.setKeyguardIndicationController( - mKeyguardIndicationController); - - mAmbientIndicationContainer = mNotificationShadeWindowView.findViewById( - R.id.ambient_indication_container); - - mAutoHideController.setStatusBar(new AutoHideUiElement() { - @Override - public void synchronizeState() { - checkBarModes(); - } - - @Override - public boolean shouldHideOnTouch() { - return !mRemoteInputManager.isRemoteInputActive(); - } - - @Override - public boolean isVisible() { - return isTransientShown(); - } - - @Override - public void hide() { - clearTransient(); - } - }); - - ScrimView scrimBehind = mNotificationShadeWindowView.findViewById(R.id.scrim_behind); - ScrimView notificationsScrim = mNotificationShadeWindowView - .findViewById(R.id.scrim_notifications); - ScrimView scrimInFront = mNotificationShadeWindowView.findViewById(R.id.scrim_in_front); - - mScrimController.setScrimVisibleListener(scrimsVisible -> { - mNotificationShadeWindowController.setScrimsVisibility(scrimsVisible); - }); - mScrimController.attachViews(scrimBehind, notificationsScrim, scrimInFront); - - mLightRevealScrim = mNotificationShadeWindowView.findViewById(R.id.light_reveal_scrim); - mLightRevealScrim.setScrimOpaqueChangedListener((opaque) -> { - Runnable updateOpaqueness = () -> { - mNotificationShadeWindowController.setLightRevealScrimOpaque( - mLightRevealScrim.isScrimOpaque()); - mScreenOffAnimationController - .onScrimOpaqueChanged(mLightRevealScrim.isScrimOpaque()); - }; - if (opaque) { - // Delay making the view opaque for a frame, because it needs some time to render - // otherwise this can lead to a flicker where the scrim doesn't cover the screen - mLightRevealScrim.post(updateOpaqueness); - } else { - updateOpaqueness.run(); - } - }); - - mScreenOffAnimationController.initialize(this, mLightRevealScrim); - updateLightRevealScrimVisibility(); - - mNotificationPanelViewController.initDependencies( - this, - this::makeExpandedInvisible, - mNotificationShelfController); - - BackDropView backdrop = mNotificationShadeWindowView.findViewById(R.id.backdrop); - mMediaManager.setup(backdrop, backdrop.findViewById(R.id.backdrop_front), - backdrop.findViewById(R.id.backdrop_back), mScrimController, mLockscreenWallpaper); - float maxWallpaperZoom = mContext.getResources().getFloat( - com.android.internal.R.dimen.config_wallpaperMaxScale); - mNotificationShadeDepthControllerLazy.get().addListener(depth -> { - float scale = MathUtils.lerp(maxWallpaperZoom, 1f, depth); - backdrop.setPivotX(backdrop.getWidth() / 2f); - backdrop.setPivotY(backdrop.getHeight() / 2f); - backdrop.setScaleX(scale); - backdrop.setScaleY(scale); - }); - - mNotificationPanelViewController.setUserSetupComplete(mUserSetup); - - // Set up the quick settings tile panel - final View container = mNotificationShadeWindowView.findViewById(R.id.qs_frame); - if (container != null) { - FragmentHostManager fragmentHostManager = FragmentHostManager.get(container); - ExtensionFragmentListener.attachExtensonToFragment(container, QS.TAG, R.id.qs_frame, - mExtensionController - .newExtension(QS.class) - .withPlugin(QS.class) - .withDefault(this::createDefaultQSFragment) - .build()); - mBrightnessMirrorController = new BrightnessMirrorController( - mNotificationShadeWindowView, - mNotificationPanelViewController, - mNotificationShadeDepthControllerLazy.get(), - mBrightnessSliderFactory, - (visible) -> { - mBrightnessMirrorVisible = visible; - updateScrimController(); - }); - fragmentHostManager.addTagListener(QS.TAG, (tag, f) -> { - QS qs = (QS) f; - if (qs instanceof QSFragment) { - mQSPanelController = ((QSFragment) qs).getQSPanelController(); - ((QSFragment) qs).setBrightnessMirrorController(mBrightnessMirrorController); - } - }); - } - - mReportRejectedTouch = mNotificationShadeWindowView - .findViewById(R.id.report_rejected_touch); - if (mReportRejectedTouch != null) { - updateReportRejectedTouchVisibility(); - mReportRejectedTouch.setOnClickListener(v -> { - Uri session = mFalsingManager.reportRejectedTouch(); - if (session == null) { return; } - - StringWriter message = new StringWriter(); - message.write("Build info: "); - message.write(SystemProperties.get("ro.build.description")); - message.write("\nSerial number: "); - message.write(SystemProperties.get("ro.serialno")); - message.write("\n"); - - startActivityDismissingKeyguard(Intent.createChooser(new Intent(Intent.ACTION_SEND) - .setType("*/*") - .putExtra(Intent.EXTRA_SUBJECT, "Rejected touch report") - .putExtra(Intent.EXTRA_STREAM, session) - .putExtra(Intent.EXTRA_TEXT, message.toString()), - "Share rejected touch report") - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), - true /* onlyProvisioned */, true /* dismissShade */); - }); - } - - if (!mPowerManager.isInteractive()) { - mBroadcastReceiver.onReceive(mContext, new Intent(Intent.ACTION_SCREEN_OFF)); - } - mGestureWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, - "sysui:GestureWakeLock"); - - // receive broadcasts - registerBroadcastReceiver(); - - IntentFilter demoFilter = new IntentFilter(); - if (DEBUG_MEDIA_FAKE_ARTWORK) { - demoFilter.addAction(ACTION_FAKE_ARTWORK); - } - mContext.registerReceiverAsUser(mDemoReceiver, UserHandle.ALL, demoFilter, - android.Manifest.permission.DUMP, null, - Context.RECEIVER_EXPORTED_UNAUDITED); - - // listen for USER_SETUP_COMPLETE setting (per-user) - mDeviceProvisionedController.addCallback(mUserSetupObserver); - mUserSetupObserver.onUserSetupChanged(); - - // disable profiling bars, since they overlap and clutter the output on app windows - ThreadedRenderer.overrideProperty("disableProfileBars", "true"); - - // Private API call to make the shadows look better for Recents - ThreadedRenderer.overrideProperty("ambientRatio", String.valueOf(1.5f)); - } - - - /** - * When swiping up to dismiss the lock screen, the panel expansion fraction goes from 1f to 0f. - * This results in the clock/notifications/other content disappearing off the top of the screen. - * - * We also use the expansion fraction to animate in the app/launcher surface from the bottom of - * the screen, 'pushing' off the notifications and other content. To do this, we dispatch the - * expansion fraction to the KeyguardViewMediator if we're in the process of dismissing the - * keyguard. - */ - private void dispatchPanelExpansionForKeyguardDismiss(float fraction, boolean trackingTouch) { - // Things that mean we're not dismissing the keyguard, and should ignore this expansion: - // - Keyguard isn't even visible. - // - Keyguard is visible, but can't be dismissed (swiping up will show PIN/password prompt). - // - The SIM is locked, you can't swipe to unlock. If the SIM is locked but there is no - // device lock set, canDismissLockScreen returns true even though you should not be able - // to dismiss the lock screen until entering the SIM PIN. - // - QS is expanded and we're swiping - swiping up now will hide QS, not dismiss the - // keyguard. - if (!isKeyguardShowing() - || !mKeyguardStateController.canDismissLockScreen() - || mKeyguardViewMediator.isAnySimPinSecure() - || (mNotificationPanelViewController.isQsExpanded() && trackingTouch)) { - return; - } - - // Otherwise, we should let the keyguard know about this if we're tracking touch, or if we - // are already animating the keyguard dismiss (since we will need to either finish or cancel - // the animation). - if (trackingTouch - || mKeyguardViewMediator.isAnimatingBetweenKeyguardAndSurfaceBehindOrWillBe() - || mKeyguardUnlockAnimationController.isUnlockingWithSmartSpaceTransition()) { - mKeyguardStateController.notifyKeyguardDismissAmountChanged( - 1f - fraction, trackingTouch); - } - } - - private void onPanelExpansionChanged(float fraction, boolean expanded, boolean tracking) { - dispatchPanelExpansionForKeyguardDismiss(fraction, tracking); - - if (fraction == 0 || fraction == 1) { - if (getNavigationBarView() != null) { - getNavigationBarView().onStatusBarPanelStateChanged(); - } - if (getNotificationPanelViewController() != null) { - getNotificationPanelViewController().updateSystemUiStateFlags(); - } - } - } - - @NonNull - @Override - public Lifecycle getLifecycle() { - return mLifecycle; - } - - @VisibleForTesting - protected void registerBroadcastReceiver() { - IntentFilter filter = new IntentFilter(); - filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); - filter.addAction(Intent.ACTION_SCREEN_OFF); - filter.addAction(DevicePolicyManager.ACTION_SHOW_DEVICE_MONITORING_DIALOG); - mBroadcastDispatcher.registerReceiver(mBroadcastReceiver, filter, null, UserHandle.ALL); - } - - protected QS createDefaultQSFragment() { - return FragmentHostManager.get(mNotificationShadeWindowView).create(QSFragment.class); - } - - private void setUpPresenter() { - // Set up the initial notification state. - mActivityLaunchAnimator.setCallback(mActivityLaunchAnimatorCallback); - mActivityLaunchAnimator.addListener(mActivityLaunchAnimatorListener); - mNotificationAnimationProvider = new NotificationLaunchAnimatorControllerProvider( - mNotificationShadeWindowViewController, - mNotifListContainer, - mHeadsUpManager, - mJankMonitor); - mNotificationShelfController.setOnActivatedListener(mPresenter); - mRemoteInputManager.addControllerCallback(mNotificationShadeWindowController); - mStackScrollerController.setNotificationActivityStarter(mNotificationActivityStarter); - mGutsManager.setNotificationActivityStarter(mNotificationActivityStarter); - mNotificationsController.initialize( - mPresenter, - mNotifListContainer, - mStackScrollerController.getNotifStackController(), - mNotificationActivityStarter, - mStatusBarComponent.getBindRowCallback()); - } - - /** - * Post-init task of {@link #start()} - * @param state1 disable1 flags - * @param state2 disable2 flags - */ - protected void setUpDisableFlags(int state1, int state2) { - mCommandQueue.disable(mDisplayId, state1, state2, false /* animate */); - } - - /** - * Ask the display to wake up if currently dozing, else do nothing - * - * @param time when to wake up - * @param where the view requesting the wakeup - * @param why the reason for the wake up - */ - public void wakeUpIfDozing(long time, View where, String why) { - if (mDozing && mScreenOffAnimationController.allowWakeUpIfDozing()) { - mPowerManager.wakeUp( - time, PowerManager.WAKE_REASON_GESTURE, "com.android.systemui:" + why); - mWakeUpComingFromTouch = true; - where.getLocationInWindow(mTmpInt2); - - // NOTE, the incoming view can sometimes be the entire container... unsure if - // this location is valuable enough - mWakeUpTouchLocation = new PointF(mTmpInt2[0] + where.getWidth() / 2, - mTmpInt2[1] + where.getHeight() / 2); - mFalsingCollector.onScreenOnFromTouch(); - } - } - - // TODO(b/117478341): This was left such that CarStatusBar can override this method. - // Try to remove this. - protected void createNavigationBar(@Nullable RegisterStatusBarResult result) { - mNavigationBarController.createNavigationBars(true /* includeDefaultDisplay */, result); - } - - /** - * Returns the {@link android.view.View.OnTouchListener} that will be invoked when the - * background window of the status bar is clicked. - */ - protected View.OnTouchListener getStatusBarWindowTouchListener() { - return (v, event) -> { - mAutoHideController.checkUserAutoHide(event); - mRemoteInputManager.checkRemoteInputOutside(event); - if (event.getAction() == MotionEvent.ACTION_DOWN) { - if (mExpandedVisible) { - mShadeController.animateCollapsePanels(); - } - } - return mNotificationShadeWindowView.onTouchEvent(event); - }; - } - - private void inflateStatusBarWindow() { - if (mStatusBarComponent != null) { - // Tear down - for (StatusBarComponent.Startable startable : mStatusBarComponent.getStartables()) { - startable.stop(); - } - } - mStatusBarComponent = mStatusBarComponentFactory.create(); - mFragmentService.addFragmentInstantiationProvider(mStatusBarComponent); - - mNotificationShadeWindowView = mStatusBarComponent.getNotificationShadeWindowView(); - mNotificationShadeWindowViewController = mStatusBarComponent - .getNotificationShadeWindowViewController(); - mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView); - mNotificationShadeWindowViewController.setupExpandedStatusBar(); - mNotificationPanelViewController = mStatusBarComponent.getNotificationPanelViewController(); - mStatusBarComponent.getLockIconViewController().init(); - mStackScrollerController = mStatusBarComponent.getNotificationStackScrollLayoutController(); - mStackScroller = mStackScrollerController.getView(); - mNotifListContainer = mStatusBarComponent.getNotificationListContainer(); - mPresenter = mStatusBarComponent.getNotificationPresenter(); - mNotificationActivityStarter = mStatusBarComponent.getNotificationActivityStarter(); - mNotificationShelfController = mStatusBarComponent.getNotificationShelfController(); - mAuthRippleController = mStatusBarComponent.getAuthRippleController(); - - mAuthRippleController.init(); - - mHeadsUpManager.addListener(mStatusBarComponent.getStatusBarHeadsUpChangeListener()); - - // Listen for demo mode changes - mDemoModeController.addCallback(mDemoModeCallback); - - if (mCommandQueueCallbacks != null) { - mCommandQueue.removeCallback(mCommandQueueCallbacks); - } - mCommandQueueCallbacks = mStatusBarComponent.getStatusBarCommandQueueCallbacks(); - // Connect in to the status bar manager service - mCommandQueue.addCallback(mCommandQueueCallbacks); - - // Perform all other initialization for StatusBarScope - for (StatusBarComponent.Startable startable : mStatusBarComponent.getStartables()) { - startable.start(); - } - } - - protected void startKeyguard() { - Trace.beginSection("StatusBar#startKeyguard"); - mBiometricUnlockController = mBiometricUnlockControllerLazy.get(); - mBiometricUnlockController.setBiometricModeListener( - new BiometricUnlockController.BiometricModeListener() { - @Override - public void onResetMode() { - setWakeAndUnlocking(false); - } - - @Override - public void onModeChanged(int mode) { - switch (mode) { - case BiometricUnlockController.MODE_WAKE_AND_UNLOCK_FROM_DREAM: - case BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING: - case BiometricUnlockController.MODE_WAKE_AND_UNLOCK: - setWakeAndUnlocking(true); - } - } - - @Override - public void notifyBiometricAuthModeChanged() { - StatusBar.this.notifyBiometricAuthModeChanged(); - } - - private void setWakeAndUnlocking(boolean wakeAndUnlocking) { - if (getNavigationBarView() != null) { - getNavigationBarView().setWakeAndUnlocking(wakeAndUnlocking); - } - } - }); - mStatusBarKeyguardViewManager.registerStatusBar( - /* statusBar= */ this, - mNotificationPanelViewController, - mPanelExpansionStateManager, - mBiometricUnlockController, - mStackScroller, - mKeyguardBypassController); - mKeyguardIndicationController - .setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); - mBiometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager); - mRemoteInputManager.addControllerCallback(mStatusBarKeyguardViewManager); - mDynamicPrivacyController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); - - mLightBarController.setBiometricUnlockController(mBiometricUnlockController); - mMediaManager.setBiometricUnlockController(mBiometricUnlockController); - mKeyguardDismissUtil.setDismissHandler(this::executeWhenUnlocked); - Trace.endSection(); - } - - public NotificationShadeWindowView getNotificationShadeWindowView() { - return mNotificationShadeWindowView; - } - - public NotificationShadeWindowViewController getNotificationShadeWindowViewController() { - return mNotificationShadeWindowViewController; - } - - public NotificationPanelViewController getNotificationPanelViewController() { - return mNotificationPanelViewController; - } - - public ViewGroup getBouncerContainer() { - return mNotificationShadeWindowViewController.getBouncerContainer(); - } - - public int getStatusBarHeight() { - return mStatusBarWindowController.getStatusBarHeight(); - } - - /** - * Disable QS if device not provisioned. - * If the user switcher is simple then disable QS during setup because - * the user intends to use the lock screen user switcher, QS in not needed. - */ - void updateQsExpansionEnabled() { - final boolean expandEnabled = mDeviceProvisionedController.isDeviceProvisioned() - && (mUserSetup || mUserSwitcherController == null - || !mUserSwitcherController.isSimpleUserSwitcher()) - && !isShadeDisabled() - && ((mDisabled2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) == 0) - && !mDozing - && !ONLY_CORE_APPS; - mNotificationPanelViewController.setQsExpansionEnabledPolicy(expandEnabled); - Log.d(TAG, "updateQsExpansionEnabled - QS Expand enabled: " + expandEnabled); - } - - public boolean isShadeDisabled() { - return (mDisabled2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE) != 0; - } - - /** - * Request a notification update - * @param reason why we're requesting a notification update - */ - public void requestNotificationUpdate(String reason) { - mNotificationsController.requestNotificationUpdate(reason); - } - - /** - * Asks {@link KeyguardUpdateMonitor} to run face auth. - */ - public void requestFaceAuth(boolean userInitiatedRequest) { - if (!mKeyguardStateController.canDismissLockScreen()) { - mKeyguardUpdateMonitor.requestFaceAuth(userInitiatedRequest); - } - } - - private void updateReportRejectedTouchVisibility() { - if (mReportRejectedTouch == null) { - return; - } - mReportRejectedTouch.setVisibility(mState == StatusBarState.KEYGUARD && !mDozing - && mFalsingCollector.isReportingEnabled() ? View.VISIBLE : View.INVISIBLE); - } - - boolean areNotificationAlertsDisabled() { - return (mDisabled1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0; - } - - @Override - public void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade, - int flags) { - startActivityDismissingKeyguard(intent, onlyProvisioned, dismissShade, flags); - } - - @Override - public void startActivity(Intent intent, boolean dismissShade) { - startActivityDismissingKeyguard(intent, false /* onlyProvisioned */, dismissShade); - } - - @Override - public void startActivity(Intent intent, boolean dismissShade, - @Nullable ActivityLaunchAnimator.Controller animationController, - boolean showOverLockscreenWhenLocked) { - // Make sure that we dismiss the keyguard if it is directly dismissable or when we don't - // want to show the activity above it. - if (mKeyguardStateController.isUnlocked() || !showOverLockscreenWhenLocked) { - startActivityDismissingKeyguard(intent, false, dismissShade, - false /* disallowEnterPictureInPictureWhileLaunching */, null /* callback */, - 0 /* flags */, animationController); - return; - } - - boolean animate = - animationController != null && shouldAnimateLaunch(true /* isActivityIntent */, - showOverLockscreenWhenLocked); - - ActivityLaunchAnimator.Controller controller = null; - if (animate) { - // Wrap the animation controller to dismiss the shade and set - // mIsLaunchingActivityOverLockscreen during the animation. - ActivityLaunchAnimator.Controller delegate = wrapAnimationController( - animationController, dismissShade); - controller = new DelegateLaunchAnimatorController(delegate) { - @Override - public void onIntentStarted(boolean willAnimate) { - getDelegate().onIntentStarted(willAnimate); - - if (willAnimate) { - StatusBar.this.mIsLaunchingActivityOverLockscreen = true; - } - } - - @Override - public void onLaunchAnimationEnd(boolean isExpandingFullyAbove) { - // Set mIsLaunchingActivityOverLockscreen to false before actually finishing the - // animation so that we can assume that mIsLaunchingActivityOverLockscreen - // being true means that we will collapse the shade (or at least run the - // post collapse runnables) later on. - StatusBar.this.mIsLaunchingActivityOverLockscreen = false; - getDelegate().onLaunchAnimationEnd(isExpandingFullyAbove); - } - - @Override - public void onLaunchAnimationCancelled() { - // Set mIsLaunchingActivityOverLockscreen to false before actually finishing the - // animation so that we can assume that mIsLaunchingActivityOverLockscreen - // being true means that we will collapse the shade (or at least run the - // post collapse runnables) later on. - StatusBar.this.mIsLaunchingActivityOverLockscreen = false; - getDelegate().onLaunchAnimationCancelled(); - } - }; - } else if (dismissShade) { - // The animation will take care of dismissing the shade at the end of the animation. If - // we don't animate, collapse it directly. - collapseShade(); - } - - mActivityLaunchAnimator.startIntentWithAnimation(controller, animate, - intent.getPackage(), showOverLockscreenWhenLocked, (adapter) -> TaskStackBuilder - .create(mContext) - .addNextIntent(intent) - .startActivities(getActivityOptions(getDisplayId(), adapter), - UserHandle.CURRENT)); - } - - /** - * Whether we are currently animating an activity launch above the lockscreen (occluding - * activity). - */ - public boolean isLaunchingActivityOverLockscreen() { - return mIsLaunchingActivityOverLockscreen; - } - - @Override - public void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade) { - startActivityDismissingKeyguard(intent, onlyProvisioned, dismissShade); - } - - @Override - public void startActivity(Intent intent, boolean dismissShade, Callback callback) { - startActivityDismissingKeyguard(intent, false, dismissShade, - false /* disallowEnterPictureInPictureWhileLaunching */, callback, 0, - null /* animationController */); - } - - public void setQsExpanded(boolean expanded) { - mNotificationShadeWindowController.setQsExpanded(expanded); - mNotificationPanelViewController.setStatusAccessibilityImportance(expanded - ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS - : View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); - mNotificationPanelViewController.updateSystemUiStateFlags(); - if (getNavigationBarView() != null) { - getNavigationBarView().onStatusBarPanelStateChanged(); - } - } - - public boolean isWakeUpComingFromTouch() { - return mWakeUpComingFromTouch; - } - - public boolean isFalsingThresholdNeeded() { - return true; - } - - /** - * To be called when there's a state change in StatusBarKeyguardViewManager. - */ - public void onKeyguardViewManagerStatesUpdated() { - logStateToEventlog(); - } - - public void setPanelExpanded(boolean isExpanded) { - if (mPanelExpanded != isExpanded) { - mNotificationLogger.onPanelExpandedChanged(isExpanded); - } - mPanelExpanded = isExpanded; - mStatusBarHideIconsForBouncerManager.setPanelExpandedAndTriggerUpdate(isExpanded); - mNotificationShadeWindowController.setPanelExpanded(isExpanded); - mStatusBarStateController.setPanelExpanded(isExpanded); - if (isExpanded && mStatusBarStateController.getState() != StatusBarState.KEYGUARD) { - if (DEBUG) { - Log.v(TAG, "clearing notification effects from Height"); - } - clearNotificationEffects(); - } - - if (!isExpanded) { - mRemoteInputManager.onPanelCollapsed(); - } - } - - public ViewGroup getNotificationScrollLayout() { - return mStackScroller; - } - - public boolean isPulsing() { - return mDozeServiceHost.isPulsing(); - } - - @Nullable - public View getAmbientIndicationContainer() { - return mAmbientIndicationContainer; - } - - /** - * When the keyguard is showing and covered by a "showWhenLocked" activity it - * is occluded. This is controlled by {@link com.android.server.policy.PhoneWindowManager} - * - * @return whether the keyguard is currently occluded - */ - public boolean isOccluded() { - return mIsOccluded; - } - - public void setOccluded(boolean occluded) { - mIsOccluded = occluded; - mStatusBarHideIconsForBouncerManager.setIsOccludedAndTriggerUpdate(occluded); - mScrimController.setKeyguardOccluded(occluded); - } - - /** A launch animation was cancelled. */ - //TODO: These can / should probably be moved to NotificationPresenter or ShadeController - public void onLaunchAnimationCancelled(boolean isLaunchForActivity) { - if (mPresenter.isPresenterFullyCollapsed() && !mPresenter.isCollapsing() - && isLaunchForActivity) { - onClosingFinished(); - } else { - mShadeController.collapsePanel(true /* animate */); - } - } - - /** A launch animation ended. */ - public void onLaunchAnimationEnd(boolean launchIsFullScreen) { - if (!mPresenter.isCollapsing()) { - onClosingFinished(); - } - if (launchIsFullScreen) { - instantCollapseNotificationPanel(); - } - } - - /** - * Whether we should animate an activity launch. - * - * Note: This method must be called *before* dismissing the keyguard. - */ - public boolean shouldAnimateLaunch(boolean isActivityIntent, boolean showOverLockscreen) { - // TODO(b/184121838): Support launch animations when occluded. - if (isOccluded()) { - return false; - } - - // Always animate if we are not showing the keyguard or if we animate over the lockscreen - // (without unlocking it). - if (showOverLockscreen || !mKeyguardStateController.isShowing()) { - return true; - } - - // If we are locked and have to dismiss the keyguard, only animate if remote unlock - // animations are enabled. We also don't animate non-activity launches as they can break the - // animation. - // TODO(b/184121838): Support non activity launches on the lockscreen. - return isActivityIntent && KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation; - } - - /** Whether we should animate an activity launch. */ - public boolean shouldAnimateLaunch(boolean isActivityIntent) { - return shouldAnimateLaunch(isActivityIntent, false /* showOverLockscreen */); - } - - public boolean isDeviceInVrMode() { - return mPresenter.isDeviceInVrMode(); - } - - public NotificationPresenter getPresenter() { - return mPresenter; - } - - @VisibleForTesting - void setBarStateForTest(int state) { - mState = state; - } - - static class KeyboardShortcutsMessage { - final int mDeviceId; - - KeyboardShortcutsMessage(int deviceId) { - mDeviceId = deviceId; - } - } - - static class AnimateExpandSettingsPanelMessage { - final String mSubpanel; - - AnimateExpandSettingsPanelMessage(String subpanel) { - mSubpanel = subpanel; - } - } - - private void maybeEscalateHeadsUp() { - mHeadsUpManager.getAllEntries().forEach(entry -> { - final StatusBarNotification sbn = entry.getSbn(); - final Notification notification = sbn.getNotification(); - if (notification.fullScreenIntent != null) { - if (DEBUG) { - Log.d(TAG, "converting a heads up to fullScreen"); - } - try { - EventLog.writeEvent(EventLogTags.SYSUI_HEADS_UP_ESCALATION, - sbn.getKey()); - wakeUpForFullScreenIntent(); - notification.fullScreenIntent.send(); - entry.notifyFullScreenIntentLaunched(); - } catch (PendingIntent.CanceledException e) { - } - } - }); - mHeadsUpManager.releaseAllImmediately(); - } - - void wakeUpForFullScreenIntent() { - if (isGoingToSleep() || mDozing) { - mPowerManager.wakeUp( - SystemClock.uptimeMillis(), - PowerManager.WAKE_REASON_APPLICATION, - "com.android.systemui:full_screen_intent"); - mWakeUpComingFromTouch = false; - mWakeUpTouchLocation = null; - } - } - - void makeExpandedVisible(boolean force) { - if (SPEW) Log.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible); - if (!force && (mExpandedVisible || !mCommandQueue.panelsEnabled())) { - return; - } - - mExpandedVisible = true; - - // Expand the window to encompass the full screen in anticipation of the drag. - // This is only possible to do atomically because the status bar is at the top of the screen! - mNotificationShadeWindowController.setPanelVisible(true); - - visibilityChanged(true); - mCommandQueue.recomputeDisableFlags(mDisplayId, !force /* animate */); - setInteracting(StatusBarManager.WINDOW_STATUS_BAR, true); - } - - public void postAnimateCollapsePanels() { - mMainExecutor.execute(mShadeController::animateCollapsePanels); - } - - public void postAnimateForceCollapsePanels() { - mMainExecutor.execute( - () -> mShadeController.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, - true /* force */)); - } - - public void postAnimateOpenPanels() { - mMessageRouter.sendMessage(MSG_OPEN_SETTINGS_PANEL); - } - - public boolean isExpandedVisible() { - return mExpandedVisible; - } - - public boolean isPanelExpanded() { - return mPanelExpanded; - } - - /** - * Called when another window is about to transfer it's input focus. - */ - public void onInputFocusTransfer(boolean start, boolean cancel, float velocity) { - if (!mCommandQueue.panelsEnabled()) { - return; - } - - if (start) { - mNotificationPanelViewController.startWaitingForOpenPanelGesture(); - } else { - mNotificationPanelViewController.stopWaitingForOpenPanelGesture(cancel, velocity); - } - } - - public void animateCollapseQuickSettings() { - if (mState == StatusBarState.SHADE) { - mNotificationPanelViewController.collapsePanel( - true, false /* delayed */, 1.0f /* speedUpFactor */); - } - } - - void makeExpandedInvisible() { - if (SPEW) Log.d(TAG, "makeExpandedInvisible: mExpandedVisible=" + mExpandedVisible - + " mExpandedVisible=" + mExpandedVisible); - - if (!mExpandedVisible || mNotificationShadeWindowView == null) { - return; - } - - // Ensure the panel is fully collapsed (just in case; bug 6765842, 7260868) - mNotificationPanelViewController.collapsePanel(/*animate=*/ false, false /* delayed*/, - 1.0f /* speedUpFactor */); - - mNotificationPanelViewController.closeQs(); - - mExpandedVisible = false; - visibilityChanged(false); - - // Update the visibility of notification shade and status bar window. - mNotificationShadeWindowController.setPanelVisible(false); - mStatusBarWindowController.setForceStatusBarVisible(false); - - // Close any guts that might be visible - mGutsManager.closeAndSaveGuts(true /* removeLeavebehind */, true /* force */, - true /* removeControls */, -1 /* x */, -1 /* y */, true /* resetMenu */); - - mShadeController.runPostCollapseRunnables(); - setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false); - if (!mNotificationActivityStarter.isCollapsingToShowActivityOverLockscreen()) { - showBouncerOrLockScreenIfKeyguard(); - } else if (DEBUG) { - Log.d(TAG, "Not showing bouncer due to activity showing over lockscreen"); - } - mCommandQueue.recomputeDisableFlags( - mDisplayId, - mNotificationPanelViewController.hideStatusBarIconsWhenExpanded() /* animate */); - - // Trimming will happen later if Keyguard is showing - doing it here might cause a jank in - // the bouncer appear animation. - if (!mStatusBarKeyguardViewManager.isShowing()) { - WindowManagerGlobal.getInstance().trimMemory(ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN); - } - } - - /** Called when a touch event occurred on {@link PhoneStatusBarView}. */ - public void onTouchEvent(MotionEvent event) { - // TODO(b/202981994): Move this touch debugging to a central location. (Right now, it's - // split between NotificationPanelViewController and here.) - if (DEBUG_GESTURES) { - if (event.getActionMasked() != MotionEvent.ACTION_MOVE) { - EventLog.writeEvent(EventLogTags.SYSUI_STATUSBAR_TOUCH, - event.getActionMasked(), (int) event.getX(), (int) event.getY(), - mDisabled1, mDisabled2); - } - - } - - if (SPEW) { - Log.d(TAG, "Touch: rawY=" + event.getRawY() + " event=" + event + " mDisabled1=" - + mDisabled1 + " mDisabled2=" + mDisabled2); - } else if (CHATTY) { - if (event.getAction() != MotionEvent.ACTION_MOVE) { - Log.d(TAG, String.format( - "panel: %s at (%f, %f) mDisabled1=0x%08x mDisabled2=0x%08x", - MotionEvent.actionToString(event.getAction()), - event.getRawX(), event.getRawY(), mDisabled1, mDisabled2)); - } - } - - if (DEBUG_GESTURES) { - mGestureRec.add(event); - } - - if (mStatusBarWindowState == WINDOW_STATE_SHOWING) { - final boolean upOrCancel = - event.getAction() == MotionEvent.ACTION_UP || - event.getAction() == MotionEvent.ACTION_CANCEL; - setInteracting(StatusBarManager.WINDOW_STATUS_BAR, !upOrCancel || mExpandedVisible); - } - } - - public GestureRecorder getGestureRecorder() { - return mGestureRec; - } - - public BiometricUnlockController getBiometricUnlockController() { - return mBiometricUnlockController; - } - - void showTransientUnchecked() { - if (!mTransientShown) { - mTransientShown = true; - mNoAnimationOnNextBarModeChange = true; - maybeUpdateBarMode(); - } - } - - - void clearTransient() { - if (mTransientShown) { - mTransientShown = false; - maybeUpdateBarMode(); - } - } - - private void maybeUpdateBarMode() { - final int barMode = barMode(mTransientShown, mAppearance); - if (updateBarMode(barMode)) { - mLightBarController.onStatusBarModeChanged(barMode); - updateBubblesVisibility(); - } - } - - private boolean updateBarMode(int barMode) { - if (mStatusBarMode != barMode) { - mStatusBarMode = barMode; - checkBarModes(); - mAutoHideController.touchAutoHide(); - return true; - } - return false; - } - - private @TransitionMode int barMode(boolean isTransient, int appearance) { - final int lightsOutOpaque = APPEARANCE_LOW_PROFILE_BARS | APPEARANCE_OPAQUE_STATUS_BARS; - if (mOngoingCallController.hasOngoingCall() && mIsFullscreen) { - return MODE_SEMI_TRANSPARENT; - } else if (isTransient) { - return MODE_SEMI_TRANSPARENT; - } else if ((appearance & lightsOutOpaque) == lightsOutOpaque) { - return MODE_LIGHTS_OUT; - } else if ((appearance & APPEARANCE_LOW_PROFILE_BARS) != 0) { - return MODE_LIGHTS_OUT_TRANSPARENT; - } else if ((appearance & APPEARANCE_OPAQUE_STATUS_BARS) != 0) { - return MODE_OPAQUE; - } else if ((appearance & APPEARANCE_SEMI_TRANSPARENT_STATUS_BARS) != 0) { - return MODE_SEMI_TRANSPARENT; - } else { - return MODE_TRANSPARENT; - } - } - - protected void showWirelessChargingAnimation(int batteryLevel) { - showChargingAnimation(batteryLevel, UNKNOWN_BATTERY_LEVEL, 0); - } - - protected void showChargingAnimation(int batteryLevel, int transmittingBatteryLevel, - long animationDelay) { - WirelessChargingAnimation.makeWirelessChargingAnimation(mContext, null, - transmittingBatteryLevel, batteryLevel, - new WirelessChargingAnimation.Callback() { - @Override - public void onAnimationStarting() { - mNotificationShadeWindowController.setRequestTopUi(true, TAG); - } - - @Override - public void onAnimationEnded() { - mNotificationShadeWindowController.setRequestTopUi(false, TAG); - } - }, false, sUiEventLogger).show(animationDelay); - } - - public void checkBarModes() { - if (mDemoModeController.isInDemoMode()) return; - if (mStatusBarTransitions != null) { - checkBarMode(mStatusBarMode, mStatusBarWindowState, mStatusBarTransitions); - } - mNavigationBarController.checkNavBarModes(mDisplayId); - mNoAnimationOnNextBarModeChange = false; - } - - // Called by NavigationBarFragment - public void setQsScrimEnabled(boolean scrimEnabled) { - mNotificationPanelViewController.setQsScrimEnabled(scrimEnabled); - } - - /** Temporarily hides Bubbles if the status bar is hidden. */ - void updateBubblesVisibility() { - mBubblesOptional.ifPresent(bubbles -> bubbles.onStatusBarVisibilityChanged( - mStatusBarMode != MODE_LIGHTS_OUT - && mStatusBarMode != MODE_LIGHTS_OUT_TRANSPARENT - && !mStatusBarWindowHidden)); - } - - void checkBarMode(@TransitionMode int mode, @WindowVisibleState int windowState, - BarTransitions transitions) { - final boolean anim = !mNoAnimationOnNextBarModeChange && mDeviceInteractive - && windowState != WINDOW_STATE_HIDDEN; - transitions.transitionTo(mode, anim); - } - - private void finishBarAnimations() { - if (mStatusBarTransitions != null) { - mStatusBarTransitions.finishAnimations(); - } - mNavigationBarController.finishBarAnimations(mDisplayId); - } - - private final Runnable mCheckBarModes = this::checkBarModes; - - public void setInteracting(int barWindow, boolean interacting) { - mInteractingWindows = interacting - ? (mInteractingWindows | barWindow) - : (mInteractingWindows & ~barWindow); - if (mInteractingWindows != 0) { - mAutoHideController.suspendAutoHide(); - } else { - mAutoHideController.resumeSuspendedAutoHide(); - } - checkBarModes(); - } - - private void dismissVolumeDialog() { - if (mVolumeComponent != null) { - mVolumeComponent.dismissNow(); - } - } - - public static String viewInfo(View v) { - return "[(" + v.getLeft() + "," + v.getTop() + ")(" + v.getRight() + "," + v.getBottom() - + ") " + v.getWidth() + "x" + v.getHeight() + "]"; - } - - @Override - public void dump(FileDescriptor fd, PrintWriter pwOriginal, String[] args) { - IndentingPrintWriter pw = DumpUtilsKt.asIndenting(pwOriginal); - synchronized (mQueueLock) { - pw.println("Current Status Bar state:"); - pw.println(" mExpandedVisible=" + mExpandedVisible); - pw.println(" mDisplayMetrics=" + mDisplayMetrics); - pw.println(" mStackScroller: " + viewInfo(mStackScroller)); - pw.println(" mStackScroller: " + viewInfo(mStackScroller) - + " scroll " + mStackScroller.getScrollX() - + "," + mStackScroller.getScrollY()); - } - - pw.print(" mInteractingWindows="); pw.println(mInteractingWindows); - pw.print(" mStatusBarWindowState="); - pw.println(windowStateToString(mStatusBarWindowState)); - pw.print(" mStatusBarMode="); - pw.println(BarTransitions.modeToString(mStatusBarMode)); - pw.print(" mDozing="); pw.println(mDozing); - pw.print(" mWallpaperSupported= "); pw.println(mWallpaperSupported); - - pw.println(" ShadeWindowView: "); - if (mNotificationShadeWindowViewController != null) { - mNotificationShadeWindowViewController.dump(fd, pw, args); - dumpBarTransitions(pw, "PhoneStatusBarTransitions", mStatusBarTransitions); - } - - pw.println(" mMediaManager: "); - if (mMediaManager != null) { - mMediaManager.dump(fd, pw, args); - } - - pw.println(" Panels: "); - if (mNotificationPanelViewController != null) { - pw.println(" mNotificationPanel=" - + mNotificationPanelViewController.getView() + " params=" - + mNotificationPanelViewController.getView().getLayoutParams().debug("")); - pw.print (" "); - mNotificationPanelViewController.dump(fd, pw, args); - } - pw.println(" mStackScroller: "); - if (mStackScroller != null) { - // Double indent until we rewrite the rest of this dump() - pw.increaseIndent(); - pw.increaseIndent(); - mStackScroller.dump(fd, pw, args); - pw.decreaseIndent(); - pw.decreaseIndent(); - } - pw.println(" Theme:"); - String nightMode = mUiModeManager == null ? "null" : mUiModeManager.getNightMode() + ""; - pw.println(" dark theme: " + nightMode + - " (auto: " + UiModeManager.MODE_NIGHT_AUTO + - ", yes: " + UiModeManager.MODE_NIGHT_YES + - ", no: " + UiModeManager.MODE_NIGHT_NO + ")"); - final boolean lightWpTheme = mContext.getThemeResId() - == R.style.Theme_SystemUI_LightWallpaper; - pw.println(" light wallpaper theme: " + lightWpTheme); - - if (mKeyguardIndicationController != null) { - mKeyguardIndicationController.dump(fd, pw, args); - } - - if (mScrimController != null) { - mScrimController.dump(fd, pw, args); - } - - if (mLightRevealScrim != null) { - pw.println( - "mLightRevealScrim.getRevealEffect(): " + mLightRevealScrim.getRevealEffect()); - pw.println( - "mLightRevealScrim.getRevealAmount(): " + mLightRevealScrim.getRevealAmount()); - } - - if (mStatusBarKeyguardViewManager != null) { - mStatusBarKeyguardViewManager.dump(pw); - } - - mNotificationsController.dump(fd, pw, args, DUMPTRUCK); - - if (DEBUG_GESTURES) { - pw.print(" status bar gestures: "); - mGestureRec.dump(fd, pw, args); - } - - if (mHeadsUpManager != null) { - mHeadsUpManager.dump(fd, pw, args); - } else { - pw.println(" mHeadsUpManager: null"); - } - - if (mStatusBarTouchableRegionManager != null) { - mStatusBarTouchableRegionManager.dump(fd, pw, args); - } else { - pw.println(" mStatusBarTouchableRegionManager: null"); - } - - if (mLightBarController != null) { - mLightBarController.dump(fd, pw, args); - } - - pw.println("SharedPreferences:"); - for (Map.Entry entry : Prefs.getAll(mContext).entrySet()) { - pw.print(" "); pw.print(entry.getKey()); pw.print("="); pw.println(entry.getValue()); - } - - pw.println("Camera gesture intents:"); - pw.println(" Insecure camera: " + CameraIntents.getInsecureCameraIntent(mContext)); - pw.println(" Secure camera: " + CameraIntents.getSecureCameraIntent(mContext)); - pw.println(" Override package: " - + CameraIntents.getOverrideCameraPackage(mContext)); - } - - public static void dumpBarTransitions( - PrintWriter pw, String var, @Nullable BarTransitions transitions) { - pw.print(" "); pw.print(var); pw.print(".BarTransitions.mMode="); - if (transitions != null) { - pw.println(BarTransitions.modeToString(transitions.getMode())); - } else { - pw.println("Unknown"); - } - } - - public void createAndAddWindows(@Nullable RegisterStatusBarResult result) { - makeStatusBarView(result); - mNotificationShadeWindowController.attach(); - mStatusBarWindowController.attach(); - } - - // called by makeStatusbar and also by PhoneStatusBarView - void updateDisplaySize() { - mDisplay.getMetrics(mDisplayMetrics); - mDisplay.getSize(mCurrentDisplaySize); - if (DEBUG_GESTURES) { - mGestureRec.tag("display", - String.format("%dx%d", mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels)); - } - } - - float getDisplayDensity() { - return mDisplayMetrics.density; - } - - public float getDisplayWidth() { - return mDisplayMetrics.widthPixels; - } - - public float getDisplayHeight() { - return mDisplayMetrics.heightPixels; - } - - int getRotation() { - return mDisplay.getRotation(); - } - - int getDisplayId() { - return mDisplayId; - } - - public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned, - boolean dismissShade, int flags) { - startActivityDismissingKeyguard(intent, onlyProvisioned, dismissShade, - false /* disallowEnterPictureInPictureWhileLaunching */, null /* callback */, - flags, null /* animationController */); - } - - public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned, - boolean dismissShade) { - startActivityDismissingKeyguard(intent, onlyProvisioned, dismissShade, 0); - } - - void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned, - final boolean dismissShade, final boolean disallowEnterPictureInPictureWhileLaunching, - final Callback callback, int flags, - @Nullable ActivityLaunchAnimator.Controller animationController) { - if (onlyProvisioned && !mDeviceProvisionedController.isDeviceProvisioned()) return; - - final boolean willLaunchResolverActivity = - mActivityIntentHelper.wouldLaunchResolverActivity(intent, - mLockscreenUserManager.getCurrentUserId()); - - boolean animate = - animationController != null && !willLaunchResolverActivity && shouldAnimateLaunch( - true /* isActivityIntent */); - ActivityLaunchAnimator.Controller animController = - animationController != null ? wrapAnimationController(animationController, - dismissShade) : null; - - // If we animate, we will dismiss the shade only once the animation is done. This is taken - // care of by the StatusBarLaunchAnimationController. - boolean dismissShadeDirectly = dismissShade && animController == null; - - Runnable runnable = () -> { - mAssistManagerLazy.get().hideAssist(); - intent.setFlags( - Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); - intent.addFlags(flags); - int[] result = new int[]{ActivityManager.START_CANCELED}; - - mActivityLaunchAnimator.startIntentWithAnimation(animController, - animate, intent.getPackage(), (adapter) -> { - ActivityOptions options = new ActivityOptions( - getActivityOptions(mDisplayId, adapter)); - options.setDisallowEnterPictureInPictureWhileLaunching( - disallowEnterPictureInPictureWhileLaunching); - if (CameraIntents.isInsecureCameraIntent(intent)) { - // Normally an activity will set it's requested rotation - // animation on its window. However when launching an activity - // causes the orientation to change this is too late. In these cases - // the default animation is used. This doesn't look good for - // the camera (as it rotates the camera contents out of sync - // with physical reality). So, we ask the WindowManager to - // force the crossfade animation if an orientation change - // happens to occur during the launch. - options.setRotationAnimationHint( - WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS); - } - if (Settings.Panel.ACTION_VOLUME.equals(intent.getAction())) { - // Settings Panel is implemented as activity(not a dialog), so - // underlying app is paused and may enter picture-in-picture mode - // as a result. - // So we need to disable picture-in-picture mode here - // if it is volume panel. - options.setDisallowEnterPictureInPictureWhileLaunching(true); - } - - try { - result[0] = ActivityTaskManager.getService().startActivityAsUser( - null, mContext.getBasePackageName(), - mContext.getAttributionTag(), - intent, - intent.resolveTypeIfNeeded(mContext.getContentResolver()), - null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, - options.toBundle(), UserHandle.CURRENT.getIdentifier()); - } catch (RemoteException e) { - Log.w(TAG, "Unable to start activity", e); - } - return result[0]; - }); - - if (callback != null) { - callback.onActivityStarted(result[0]); - } - }; - Runnable cancelRunnable = () -> { - if (callback != null) { - callback.onActivityStarted(ActivityManager.START_CANCELED); - } - }; - executeRunnableDismissingKeyguard(runnable, cancelRunnable, dismissShadeDirectly, - willLaunchResolverActivity, true /* deferred */, animate); - } - - @Nullable - private ActivityLaunchAnimator.Controller wrapAnimationController( - ActivityLaunchAnimator.Controller animationController, boolean dismissShade) { - View rootView = animationController.getLaunchContainer().getRootView(); - - Optional controllerFromStatusBar = - mStatusBarWindowController.wrapAnimationControllerIfInStatusBar( - rootView, animationController); - if (controllerFromStatusBar.isPresent()) { - return controllerFromStatusBar.get(); - } - - if (dismissShade) { - // If the view is not in the status bar, then we are animating a view in the shade. - // We have to make sure that we collapse it when the animation ends or is cancelled. - return new StatusBarLaunchAnimatorController(animationController, this, - true /* isLaunchForActivity */); - } - - return animationController; - } - - public void readyForKeyguardDone() { - mStatusBarKeyguardViewManager.readyForKeyguardDone(); - } - - public void executeRunnableDismissingKeyguard(final Runnable runnable, - final Runnable cancelAction, - final boolean dismissShade, - final boolean afterKeyguardGone, - final boolean deferred) { - executeRunnableDismissingKeyguard(runnable, cancelAction, dismissShade, afterKeyguardGone, - deferred, false /* willAnimateOnKeyguard */); - } - - public void executeRunnableDismissingKeyguard(final Runnable runnable, - final Runnable cancelAction, - final boolean dismissShade, - final boolean afterKeyguardGone, - final boolean deferred, - final boolean willAnimateOnKeyguard) { - OnDismissAction onDismissAction = new OnDismissAction() { - @Override - public boolean onDismiss() { - if (runnable != null) { - if (mStatusBarKeyguardViewManager.isShowing() - && mStatusBarKeyguardViewManager.isOccluded()) { - mStatusBarKeyguardViewManager.addAfterKeyguardGoneRunnable(runnable); - } else { - mMainExecutor.execute(runnable); - } - } - if (dismissShade) { - if (mExpandedVisible && !mBouncerShowing) { - mShadeController.animateCollapsePanels( - CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, - true /* force */, true /* delayed*/); - } else { - - // Do it after DismissAction has been processed to conserve the needed - // ordering. - mMainExecutor.execute(mShadeController::runPostCollapseRunnables); - } - } else if (StatusBar.this.isInLaunchTransition() - && mNotificationPanelViewController.isLaunchTransitionFinished()) { - - // We are not dismissing the shade, but the launch transition is already - // finished, - // so nobody will call readyForKeyguardDone anymore. Post it such that - // keyguardDonePending gets called first. - mMainExecutor.execute(mStatusBarKeyguardViewManager::readyForKeyguardDone); - } - return deferred; - } - - @Override - public boolean willRunAnimationOnKeyguard() { - return willAnimateOnKeyguard; - } - }; - dismissKeyguardThenExecute(onDismissAction, cancelAction, afterKeyguardGone); - } - - private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - Trace.beginSection("StatusBar#onReceive"); - if (DEBUG) Log.v(TAG, "onReceive: " + intent); - String action = intent.getAction(); - String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY); - if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { - KeyboardShortcuts.dismiss(); - mRemoteInputManager.closeRemoteInputs(); - if (mLockscreenUserManager.isCurrentProfile(getSendingUserId())) { - int flags = CommandQueue.FLAG_EXCLUDE_NONE; - if (reason != null) { - if (reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) { - flags |= CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL; - } - // Do not collapse notifications when starting dreaming if the notifications - // shade is used for the screen off animation. It might require expanded - // state for the scrims to be visible - if (reason.equals(SYSTEM_DIALOG_REASON_DREAM) - && mScreenOffAnimationController.shouldExpandNotifications()) { - flags |= CommandQueue.FLAG_EXCLUDE_NOTIFICATION_PANEL; - } - } - mShadeController.animateCollapsePanels(flags); - } - } else if (Intent.ACTION_SCREEN_OFF.equals(action)) { - if (mNotificationShadeWindowController != null) { - mNotificationShadeWindowController.setNotTouchable(false); - } - finishBarAnimations(); - resetUserExpandedStates(); - } else if (DevicePolicyManager.ACTION_SHOW_DEVICE_MONITORING_DIALOG.equals(action)) { - mQSPanelController.showDeviceMonitoringDialog(); - } - Trace.endSection(); - } - }; - - private final BroadcastReceiver mDemoReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (DEBUG) Log.v(TAG, "onReceive: " + intent); - String action = intent.getAction(); - if (ACTION_FAKE_ARTWORK.equals(action)) { - if (DEBUG_MEDIA_FAKE_ARTWORK) { - mPresenter.updateMediaMetaData(true, true); - } - } - } - }; - - public void resetUserExpandedStates() { - mNotificationsController.resetUserExpandedStates(); - } - - private void executeWhenUnlocked(OnDismissAction action, boolean requiresShadeOpen, - boolean afterKeyguardGone) { - if (mStatusBarKeyguardViewManager.isShowing() && requiresShadeOpen) { - mStatusBarStateController.setLeaveOpenOnKeyguardHide(true); - } - dismissKeyguardThenExecute(action, null /* cancelAction */, - afterKeyguardGone /* afterKeyguardGone */); - } - - protected void dismissKeyguardThenExecute(OnDismissAction action, boolean afterKeyguardGone) { - dismissKeyguardThenExecute(action, null /* cancelRunnable */, afterKeyguardGone); - } - - @Override - public void dismissKeyguardThenExecute(OnDismissAction action, Runnable cancelAction, - boolean afterKeyguardGone) { - if (mWakefulnessLifecycle.getWakefulness() == WAKEFULNESS_ASLEEP - && mKeyguardStateController.canDismissLockScreen() - && !mStatusBarStateController.leaveOpenOnKeyguardHide() - && mDozeServiceHost.isPulsing()) { - // Reuse the biometric wake-and-unlock transition if we dismiss keyguard from a pulse. - // TODO: Factor this transition out of BiometricUnlockController. - mBiometricUnlockController.startWakeAndUnlock( - BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING); - } - if (mStatusBarKeyguardViewManager.isShowing()) { - mStatusBarKeyguardViewManager.dismissWithAction(action, cancelAction, - afterKeyguardGone); - } else { - action.onDismiss(); - } - } - /** - * Notify the shade controller that the current user changed - * - * @param newUserId userId of the new user - */ - public void setLockscreenUser(int newUserId) { - if (mLockscreenWallpaper != null) { - mLockscreenWallpaper.setCurrentUser(newUserId); - } - mScrimController.setCurrentUser(newUserId); - if (mWallpaperSupported) { - mWallpaperChangedReceiver.onReceive(mContext, null); - } - } - - /** - * Reload some of our resources when the configuration changes. - * - * We don't reload everything when the configuration changes -- we probably - * should, but getting that smooth is tough. Someday we'll fix that. In the - * meantime, just update the things that we know change. - */ - void updateResources() { - // Update the quick setting tiles - if (mQSPanelController != null) { - mQSPanelController.updateResources(); - } - - if (mStatusBarWindowController != null) { - mStatusBarWindowController.refreshStatusBarHeight(); - } - - if (mNotificationPanelViewController != null) { - mNotificationPanelViewController.updateResources(); - } - if (mBrightnessMirrorController != null) { - mBrightnessMirrorController.updateResources(); - } - if (mStatusBarKeyguardViewManager != null) { - mStatusBarKeyguardViewManager.updateResources(); - } - - mPowerButtonReveal = new PowerButtonReveal(mContext.getResources().getDimensionPixelSize( - com.android.systemui.R.dimen.physical_power_button_center_screen_location_y)); - } - - // Visibility reporting - protected void handleVisibleToUserChanged(boolean visibleToUser) { - if (visibleToUser) { - handleVisibleToUserChangedImpl(visibleToUser); - mNotificationLogger.startNotificationLogging(); - } else { - mNotificationLogger.stopNotificationLogging(); - handleVisibleToUserChangedImpl(visibleToUser); - } - } - - // Visibility reporting - void handleVisibleToUserChangedImpl(boolean visibleToUser) { - if (visibleToUser) { - /* The LEDs are turned off when the notification panel is shown, even just a little bit. - * See also StatusBar.setPanelExpanded for another place where we attempt to do this. */ - boolean pinnedHeadsUp = mHeadsUpManager.hasPinnedHeadsUp(); - boolean clearNotificationEffects = - !mPresenter.isPresenterFullyCollapsed() && - (mState == StatusBarState.SHADE - || mState == StatusBarState.SHADE_LOCKED); - int notificationLoad = mNotificationsController.getActiveNotificationsCount(); - if (pinnedHeadsUp && mPresenter.isPresenterFullyCollapsed()) { - notificationLoad = 1; - } - final int finalNotificationLoad = notificationLoad; - mUiBgExecutor.execute(() -> { - try { - mBarService.onPanelRevealed(clearNotificationEffects, - finalNotificationLoad); - } catch (RemoteException ex) { - // Won't fail unless the world has ended. - } - }); - } else { - mUiBgExecutor.execute(() -> { - try { - mBarService.onPanelHidden(); - } catch (RemoteException ex) { - // Won't fail unless the world has ended. - } - }); - } - - } - - private void logStateToEventlog() { - boolean isShowing = mStatusBarKeyguardViewManager.isShowing(); - boolean isOccluded = mStatusBarKeyguardViewManager.isOccluded(); - boolean isBouncerShowing = mStatusBarKeyguardViewManager.isBouncerShowing(); - boolean isSecure = mKeyguardStateController.isMethodSecure(); - boolean unlocked = mKeyguardStateController.canDismissLockScreen(); - int stateFingerprint = getLoggingFingerprint(mState, - isShowing, - isOccluded, - isBouncerShowing, - isSecure, - unlocked); - if (stateFingerprint != mLastLoggedStateFingerprint) { - if (mStatusBarStateLog == null) { - mStatusBarStateLog = new LogMaker(MetricsEvent.VIEW_UNKNOWN); - } - mMetricsLogger.write(mStatusBarStateLog - .setCategory(isBouncerShowing ? MetricsEvent.BOUNCER : MetricsEvent.LOCKSCREEN) - .setType(isShowing ? MetricsEvent.TYPE_OPEN : MetricsEvent.TYPE_CLOSE) - .setSubtype(isSecure ? 1 : 0)); - EventLogTags.writeSysuiStatusBarState(mState, - isShowing ? 1 : 0, - isOccluded ? 1 : 0, - isBouncerShowing ? 1 : 0, - isSecure ? 1 : 0, - unlocked ? 1 : 0); - mLastLoggedStateFingerprint = stateFingerprint; - - StringBuilder uiEventValueBuilder = new StringBuilder(); - uiEventValueBuilder.append(isBouncerShowing ? "BOUNCER" : "LOCKSCREEN"); - uiEventValueBuilder.append(isShowing ? "_OPEN" : "_CLOSE"); - uiEventValueBuilder.append(isSecure ? "_SECURE" : "_INSECURE"); - sUiEventLogger.log(StatusBarUiEvent.valueOf(uiEventValueBuilder.toString())); - } - } - - /** - * Returns a fingerprint of fields logged to eventlog - */ - private static int getLoggingFingerprint(int statusBarState, boolean keyguardShowing, - boolean keyguardOccluded, boolean bouncerShowing, boolean secure, - boolean currentlyInsecure) { - // Reserve 8 bits for statusBarState. We'll never go higher than - // that, right? Riiiight. - return (statusBarState & 0xFF) - | ((keyguardShowing ? 1 : 0) << 8) - | ((keyguardOccluded ? 1 : 0) << 9) - | ((bouncerShowing ? 1 : 0) << 10) - | ((secure ? 1 : 0) << 11) - | ((currentlyInsecure ? 1 : 0) << 12); - } - - @Override - public void postQSRunnableDismissingKeyguard(final Runnable runnable) { - mMainExecutor.execute(() -> { - mStatusBarStateController.setLeaveOpenOnKeyguardHide(true); - executeRunnableDismissingKeyguard( - () -> mMainExecutor.execute(runnable), null, false, false, false); - }); - } - - @Override - public void postStartActivityDismissingKeyguard(PendingIntent intent) { - postStartActivityDismissingKeyguard(intent, null /* animationController */); - } - - @Override - public void postStartActivityDismissingKeyguard(final PendingIntent intent, - @Nullable ActivityLaunchAnimator.Controller animationController) { - mMainExecutor.execute(() -> startPendingIntentDismissingKeyguard(intent, - null /* intentSentUiThreadCallback */, animationController)); - } - - @Override - public void postStartActivityDismissingKeyguard(final Intent intent, int delay) { - postStartActivityDismissingKeyguard(intent, delay, null /* animationController */); - } - - @Override - public void postStartActivityDismissingKeyguard(Intent intent, int delay, - @Nullable ActivityLaunchAnimator.Controller animationController) { - mMainExecutor.executeDelayed( - () -> - startActivityDismissingKeyguard(intent, true /* onlyProvisioned */, - true /* dismissShade */, - false /* disallowEnterPictureInPictureWhileLaunching */, - null /* callback */, - 0 /* flags */, - animationController), - delay); - } - - public void showKeyguard() { - mStatusBarStateController.setKeyguardRequested(true); - mStatusBarStateController.setLeaveOpenOnKeyguardHide(false); - updateIsKeyguard(); - mAssistManagerLazy.get().onLockscreenShown(); - } - - public boolean hideKeyguard() { - mStatusBarStateController.setKeyguardRequested(false); - return updateIsKeyguard(); - } - - boolean updateIsKeyguard() { - return updateIsKeyguard(false /* forceStateChange */); - } - - boolean updateIsKeyguard(boolean forceStateChange) { - boolean wakeAndUnlocking = mBiometricUnlockController.getMode() - == BiometricUnlockController.MODE_WAKE_AND_UNLOCK; - - // For dozing, keyguard needs to be shown whenever the device is non-interactive. Otherwise - // there's no surface we can show to the user. Note that the device goes fully interactive - // late in the transition, so we also allow the device to start dozing once the screen has - // turned off fully. - boolean keyguardForDozing = mDozeServiceHost.getDozingRequested() - && (!mDeviceInteractive || isGoingToSleep() && (isScreenFullyOff() || mIsKeyguard)); - boolean isWakingAndOccluded = isOccluded() && isWaking(); - boolean shouldBeKeyguard = (mStatusBarStateController.isKeyguardRequested() - || keyguardForDozing) && !wakeAndUnlocking && !isWakingAndOccluded; - if (keyguardForDozing) { - updatePanelExpansionForKeyguard(); - } - if (shouldBeKeyguard) { - if (mScreenOffAnimationController.isKeyguardShowDelayed() - || (isGoingToSleep() - && mScreenLifecycle.getScreenState() == ScreenLifecycle.SCREEN_TURNING_OFF)) { - // Delay showing the keyguard until screen turned off. - } else { - showKeyguardImpl(); - } - } else { - // During folding a foldable device this might be called as a result of - // 'onScreenTurnedOff' call for the inner display. - // In this case: - // * When phone is locked on folding: it doesn't make sense to hide keyguard as it - // will be immediately locked again - // * When phone is unlocked: we still don't want to execute hiding of the keyguard - // as the animation could prepare 'fake AOD' interface (without actually - // transitioning to keyguard state) and this might reset the view states - if (!mScreenOffAnimationController.isKeyguardHideDelayed()) { - return hideKeyguardImpl(forceStateChange); - } - } - return false; - } - - public void showKeyguardImpl() { - Trace.beginSection("StatusBar#showKeyguard"); - mIsKeyguard = true; - // In case we're locking while a smartspace transition is in progress, reset it. - mKeyguardUnlockAnimationController.resetSmartspaceTransition(); - if (mKeyguardStateController.isLaunchTransitionFadingAway()) { - mNotificationPanelViewController.cancelAnimation(); - onLaunchTransitionFadingEnded(); - } - mMessageRouter.cancelMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); - if (!mLockscreenShadeTransitionController.isWakingToShadeLocked()) { - mStatusBarStateController.setState(StatusBarState.KEYGUARD); - } - updatePanelExpansionForKeyguard(); - Trace.endSection(); - } - - private void updatePanelExpansionForKeyguard() { - if (mState == StatusBarState.KEYGUARD && mBiometricUnlockController.getMode() - != BiometricUnlockController.MODE_WAKE_AND_UNLOCK && !mBouncerShowing) { - mShadeController.instantExpandNotificationsPanel(); - } - } - - private void onLaunchTransitionFadingEnded() { - mNotificationPanelViewController.resetAlpha(); - mNotificationPanelViewController.onAffordanceLaunchEnded(); - releaseGestureWakeLock(); - runLaunchTransitionEndRunnable(); - mKeyguardStateController.setLaunchTransitionFadingAway(false); - mPresenter.updateMediaMetaData(true /* metaDataChanged */, true); - } - - public boolean isInLaunchTransition() { - return mNotificationPanelViewController.isLaunchTransitionRunning() - || mNotificationPanelViewController.isLaunchTransitionFinished(); - } - - /** - * Fades the content of the keyguard away after the launch transition is done. - * - * @param beforeFading the runnable to be run when the circle is fully expanded and the fading - * starts - * @param endRunnable the runnable to be run when the transition is done - */ - public void fadeKeyguardAfterLaunchTransition(final Runnable beforeFading, - Runnable endRunnable) { - mMessageRouter.cancelMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); - mLaunchTransitionEndRunnable = endRunnable; - Runnable hideRunnable = () -> { - mKeyguardStateController.setLaunchTransitionFadingAway(true); - if (beforeFading != null) { - beforeFading.run(); - } - updateScrimController(); - mPresenter.updateMediaMetaData(false, true); - mNotificationPanelViewController.resetAlpha(); - mNotificationPanelViewController.fadeOut( - FADE_KEYGUARD_START_DELAY, FADE_KEYGUARD_DURATION, - this::onLaunchTransitionFadingEnded); - mCommandQueue.appTransitionStarting(mDisplayId, SystemClock.uptimeMillis(), - LightBarTransitionsController.DEFAULT_TINT_ANIMATION_DURATION, true); - }; - if (mNotificationPanelViewController.isLaunchTransitionRunning()) { - mNotificationPanelViewController.setLaunchTransitionEndRunnable(hideRunnable); - } else { - hideRunnable.run(); - } - } - - /** - * Fades the content of the Keyguard while we are dozing and makes it invisible when finished - * fading. - */ - public void fadeKeyguardWhilePulsing() { - mNotificationPanelViewController.fadeOut(0, FADE_KEYGUARD_DURATION_PULSING, - ()-> { - hideKeyguard(); - mStatusBarKeyguardViewManager.onKeyguardFadedAway(); - }).start(); - } - - /** - * Plays the animation when an activity that was occluding Keyguard goes away. - */ - public void animateKeyguardUnoccluding() { - mNotificationPanelViewController.setExpandedFraction(0f); - mCommandQueueCallbacks.animateExpandNotificationsPanel(); - mScrimController.setUnocclusionAnimationRunning(true); - } - - /** - * Starts the timeout when we try to start the affordances on Keyguard. We usually rely that - * Keyguard goes away via fadeKeyguardAfterLaunchTransition, however, that might not happen - * because the launched app crashed or something else went wrong. - */ - public void startLaunchTransitionTimeout() { - mMessageRouter.sendMessageDelayed( - MSG_LAUNCH_TRANSITION_TIMEOUT, LAUNCH_TRANSITION_TIMEOUT_MS); - } - - private void onLaunchTransitionTimeout() { - Log.w(TAG, "Launch transition: Timeout!"); - mNotificationPanelViewController.onAffordanceLaunchEnded(); - releaseGestureWakeLock(); - mNotificationPanelViewController.resetViews(false /* animate */); - } - - private void runLaunchTransitionEndRunnable() { - if (mLaunchTransitionEndRunnable != null) { - Runnable r = mLaunchTransitionEndRunnable; - - // mLaunchTransitionEndRunnable might call showKeyguard, which would execute it again, - // which would lead to infinite recursion. Protect against it. - mLaunchTransitionEndRunnable = null; - r.run(); - } - } - - /** - * @return true if we would like to stay in the shade, false if it should go away entirely - */ - public boolean hideKeyguardImpl(boolean forceStateChange) { - mIsKeyguard = false; - Trace.beginSection("StatusBar#hideKeyguard"); - boolean staying = mStatusBarStateController.leaveOpenOnKeyguardHide(); - int previousState = mStatusBarStateController.getState(); - if (!(mStatusBarStateController.setState(StatusBarState.SHADE, forceStateChange))) { - //TODO: StatusBarStateController should probably know about hiding the keyguard and - // notify listeners. - - // If the state didn't change, we may still need to update public mode - mLockscreenUserManager.updatePublicMode(); - } - if (mStatusBarStateController.leaveOpenOnKeyguardHide()) { - if (!mStatusBarStateController.isKeyguardRequested()) { - mStatusBarStateController.setLeaveOpenOnKeyguardHide(false); - } - long delay = mKeyguardStateController.calculateGoingToFullShadeDelay(); - mLockscreenShadeTransitionController.onHideKeyguard(delay, previousState); - - // Disable layout transitions in navbar for this transition because the load is just - // too heavy for the CPU and GPU on any device. - mNavigationBarController.disableAnimationsDuringHide(mDisplayId, delay); - } else if (!mNotificationPanelViewController.isCollapsing()) { - instantCollapseNotificationPanel(); - } - - // Keyguard state has changed, but QS is not listening anymore. Make sure to update the tile - // visibilities so next time we open the panel we know the correct height already. - if (mQSPanelController != null) { - mQSPanelController.refreshAllTiles(); - } - mMessageRouter.cancelMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); - releaseGestureWakeLock(); - mNotificationPanelViewController.onAffordanceLaunchEnded(); - mNotificationPanelViewController.cancelAnimation(); - mNotificationPanelViewController.resetAlpha(); - mNotificationPanelViewController.resetTranslation(); - mNotificationPanelViewController.resetViewGroupFade(); - updateDozingState(); - updateScrimController(); - Trace.endSection(); - return staying; - } - - private void releaseGestureWakeLock() { - if (mGestureWakeLock.isHeld()) { - mGestureWakeLock.release(); - } - } - - /** - * Notifies the status bar that Keyguard is going away very soon. - */ - public void keyguardGoingAway() { - // Treat Keyguard exit animation as an app transition to achieve nice transition for status - // bar. - mKeyguardStateController.notifyKeyguardGoingAway(true); - mCommandQueue.appTransitionPending(mDisplayId, true /* forced */); - updateScrimController(); - } - - /** - * Notifies the status bar the Keyguard is fading away with the specified timings. - * @param startTime the start time of the animations in uptime millis - * @param delay the precalculated animation delay in milliseconds - * @param fadeoutDuration the duration of the exit animation, in milliseconds - * @param isBypassFading is this a fading away animation while bypassing - */ - public void setKeyguardFadingAway(long startTime, long delay, long fadeoutDuration, - boolean isBypassFading) { - mCommandQueue.appTransitionStarting(mDisplayId, startTime + fadeoutDuration - - LightBarTransitionsController.DEFAULT_TINT_ANIMATION_DURATION, - LightBarTransitionsController.DEFAULT_TINT_ANIMATION_DURATION, true); - mCommandQueue.recomputeDisableFlags(mDisplayId, fadeoutDuration > 0 /* animate */); - mCommandQueue.appTransitionStarting(mDisplayId, - startTime - LightBarTransitionsController.DEFAULT_TINT_ANIMATION_DURATION, - LightBarTransitionsController.DEFAULT_TINT_ANIMATION_DURATION, true); - mKeyguardStateController.notifyKeyguardFadingAway(delay, fadeoutDuration, isBypassFading); - } - - /** - * Notifies that the Keyguard fading away animation is done. - */ - public void finishKeyguardFadingAway() { - mKeyguardStateController.notifyKeyguardDoneFading(); - mScrimController.setExpansionAffectsAlpha(true); - } - - /** - * Switches theme from light to dark and vice-versa. - */ - protected void updateTheme() { - // Set additional scrim only if the lock and system wallpaper are different to prevent - // applying the dimming effect twice. - mUiBgExecutor.execute(() -> { - float dimAmount = 0f; - if (mWallpaperManager.lockScreenWallpaperExists()) { - dimAmount = mWallpaperManager.getWallpaperDimAmount(); - } - final float scrimDimAmount = dimAmount; - mMainExecutor.execute(() -> { - mScrimController.setAdditionalScrimBehindAlphaKeyguard(scrimDimAmount); - mScrimController.applyCompositeAlphaOnScrimBehindKeyguard(); - }); - }); - - // Lock wallpaper defines the color of the majority of the views, hence we'll use it - // to set our default theme. - final boolean lockDarkText = mColorExtractor.getNeutralColors().supportsDarkText(); - final int themeResId = lockDarkText ? R.style.Theme_SystemUI_LightWallpaper - : R.style.Theme_SystemUI; - if (mContext.getThemeResId() != themeResId) { - mContext.setTheme(themeResId); - mConfigurationController.notifyThemeChanged(); - } - } - - private void updateDozingState() { - Trace.traceCounter(Trace.TRACE_TAG_APP, "dozing", mDozing ? 1 : 0); - Trace.beginSection("StatusBar#updateDozingState"); - - boolean visibleNotOccluded = mStatusBarKeyguardViewManager.isShowing() - && !mStatusBarKeyguardViewManager.isOccluded(); - // If we're dozing and we'll be animating the screen off, the keyguard isn't currently - // visible but will be shortly for the animation, so we should proceed as if it's visible. - boolean visibleNotOccludedOrWillBe = - visibleNotOccluded || (mDozing && mDozeParameters.shouldDelayKeyguardShow()); - - boolean wakeAndUnlock = mBiometricUnlockController.getMode() - == BiometricUnlockController.MODE_WAKE_AND_UNLOCK; - boolean animate = (!mDozing && mDozeServiceHost.shouldAnimateWakeup() && !wakeAndUnlock) - || (mDozing && mDozeParameters.shouldControlScreenOff() - && visibleNotOccludedOrWillBe); - - mNotificationPanelViewController.setDozing(mDozing, animate, mWakeUpTouchLocation); - updateQsExpansionEnabled(); - Trace.endSection(); - } - - public void userActivity() { - if (mState == StatusBarState.KEYGUARD) { - mKeyguardViewMediatorCallback.userActivity(); - } - } - - public boolean interceptMediaKey(KeyEvent event) { - return mState == StatusBarState.KEYGUARD - && mStatusBarKeyguardViewManager.interceptMediaKey(event); - } - - /** - * While IME is active and a BACK event is detected, check with - * {@link StatusBarKeyguardViewManager#dispatchBackKeyEventPreIme()} to see if the event - * should be handled before routing to IME, in order to prevent the user having to hit back - * twice to exit bouncer. - */ - public boolean dispatchKeyEventPreIme(KeyEvent event) { - switch (event.getKeyCode()) { - case KeyEvent.KEYCODE_BACK: - if (mState == StatusBarState.KEYGUARD - && mStatusBarKeyguardViewManager.dispatchBackKeyEventPreIme()) { - return onBackPressed(); - } - } - return false; - } - - protected boolean shouldUnlockOnMenuPressed() { - return mDeviceInteractive && mState != StatusBarState.SHADE - && mStatusBarKeyguardViewManager.shouldDismissOnMenuPressed(); - } - - public boolean onMenuPressed() { - if (shouldUnlockOnMenuPressed()) { - mShadeController.animateCollapsePanels( - CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL /* flags */, true /* force */); - return true; - } - return false; - } - - public void endAffordanceLaunch() { - releaseGestureWakeLock(); - mNotificationPanelViewController.onAffordanceLaunchEnded(); - } - - public boolean onBackPressed() { - boolean isScrimmedBouncer = mScrimController.getState() == ScrimState.BOUNCER_SCRIMMED; - if (mStatusBarKeyguardViewManager.onBackPressed(isScrimmedBouncer /* hideImmediately */)) { - if (isScrimmedBouncer) { - mStatusBarStateController.setLeaveOpenOnKeyguardHide(false); - } else { - mNotificationPanelViewController.expandWithoutQs(); - } - return true; - } - if (mNotificationPanelViewController.isQsCustomizing()) { - mNotificationPanelViewController.closeQsCustomizer(); - return true; - } - if (mNotificationPanelViewController.isQsExpanded()) { - if (mNotificationPanelViewController.isQsDetailShowing()) { - mNotificationPanelViewController.closeQsDetail(); - } else { - mNotificationPanelViewController.animateCloseQs(false /* animateAway */); - } - return true; - } - if (mNotificationPanelViewController.closeUserSwitcherIfOpen()) { - return true; - } - if (mState != StatusBarState.KEYGUARD && mState != StatusBarState.SHADE_LOCKED) { - if (mNotificationPanelViewController.canPanelBeCollapsed()) { - mShadeController.animateCollapsePanels(); - } - return true; - } - return false; - } - - public boolean onSpacePressed() { - if (mDeviceInteractive && mState != StatusBarState.SHADE) { - mShadeController.animateCollapsePanels( - CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL /* flags */, true /* force */); - return true; - } - return false; - } - - private void showBouncerOrLockScreenIfKeyguard() { - // If the keyguard is animating away, we aren't really the keyguard anymore and should not - // show the bouncer/lockscreen. - if (!mKeyguardViewMediator.isHiding() - && !mKeyguardUnlockAnimationController.isPlayingCannedUnlockAnimation()) { - if (mState == StatusBarState.SHADE_LOCKED - && mKeyguardUpdateMonitor.isUdfpsEnrolled()) { - // shade is showing while locked on the keyguard, so go back to showing the - // lock screen where users can use the UDFPS affordance to enter the device - mStatusBarKeyguardViewManager.reset(true); - } else if ((mState == StatusBarState.KEYGUARD - && !mStatusBarKeyguardViewManager.bouncerIsOrWillBeShowing()) - || mState == StatusBarState.SHADE_LOCKED) { - mStatusBarKeyguardViewManager.showGenericBouncer(true /* scrimmed */); - } - } - } - - /** - * Show the bouncer if we're currently on the keyguard or shade locked and aren't hiding. - * @param performAction the action to perform when the bouncer is dismissed. - * @param cancelAction the action to perform when unlock is aborted. - */ - public void showBouncerWithDimissAndCancelIfKeyguard(OnDismissAction performAction, - Runnable cancelAction) { - if ((mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) - && !mKeyguardViewMediator.isHiding()) { - mStatusBarKeyguardViewManager.dismissWithAction(performAction, cancelAction, - false /* afterKeyguardGone */); - } else if (cancelAction != null) { - cancelAction.run(); - } - } - - void instantCollapseNotificationPanel() { - mNotificationPanelViewController.instantCollapse(); - mShadeController.runPostCollapseRunnables(); - } - - /** - * Collapse the panel directly if we are on the main thread, post the collapsing on the main - * thread if we are not. - */ - void collapsePanelOnMainThread() { - if (Looper.getMainLooper().isCurrentThread()) { - mShadeController.collapsePanel(); - } else { - mContext.getMainExecutor().execute(mShadeController::collapsePanel); - } - } - - /** Collapse the panel. The collapsing will be animated for the given {@code duration}. */ - void collapsePanelWithDuration(int duration) { - mNotificationPanelViewController.collapseWithDuration(duration); - } - - /** - * Updates the light reveal effect to reflect the reason we're waking or sleeping (for example, - * from the power button). - * @param wakingUp Whether we're updating because we're waking up (true) or going to sleep - * (false). - */ - private void updateRevealEffect(boolean wakingUp) { - if (mLightRevealScrim == null) { - return; - } - - final boolean wakingUpFromPowerButton = wakingUp - && !(mLightRevealScrim.getRevealEffect() instanceof CircleReveal) - && mWakefulnessLifecycle.getLastWakeReason() - == PowerManager.WAKE_REASON_POWER_BUTTON; - final boolean sleepingFromPowerButton = !wakingUp - && mWakefulnessLifecycle.getLastSleepReason() - == PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON; - - if (wakingUpFromPowerButton || sleepingFromPowerButton) { - mLightRevealScrim.setRevealEffect(mPowerButtonReveal); - mLightRevealScrim.setRevealAmount(1f - mStatusBarStateController.getDozeAmount()); - } else if (!wakingUp || !(mLightRevealScrim.getRevealEffect() instanceof CircleReveal)) { - // If we're going to sleep, but it's not from the power button, use the default reveal. - // If we're waking up, only use the default reveal if the biometric controller didn't - // already set it to the circular reveal because we're waking up from a fingerprint/face - // auth. - mLightRevealScrim.setRevealEffect(LiftReveal.INSTANCE); - mLightRevealScrim.setRevealAmount(1f - mStatusBarStateController.getDozeAmount()); - } - } - - public LightRevealScrim getLightRevealScrim() { - return mLightRevealScrim; - } - - private void updateKeyguardState() { - mKeyguardStateController.notifyKeyguardState(mStatusBarKeyguardViewManager.isShowing(), - mStatusBarKeyguardViewManager.isOccluded()); - } - - public void onTrackingStarted() { - mShadeController.runPostCollapseRunnables(); - } - - public void onClosingFinished() { - mShadeController.runPostCollapseRunnables(); - if (!mPresenter.isPresenterFullyCollapsed()) { - // if we set it not to be focusable when collapsing, we have to undo it when we aborted - // the closing - mNotificationShadeWindowController.setNotificationShadeFocusable(true); - } - } - - public void onUnlockHintStarted() { - mFalsingCollector.onUnlockHintStarted(); - mKeyguardIndicationController.showActionToUnlock(); - } - - public void onHintFinished() { - // Delay the reset a bit so the user can read the text. - mKeyguardIndicationController.hideTransientIndicationDelayed(HINT_RESET_DELAY_MS); - } - - public void onCameraHintStarted() { - mFalsingCollector.onCameraHintStarted(); - mKeyguardIndicationController.showTransientIndication(R.string.camera_hint); - } - - public void onVoiceAssistHintStarted() { - mFalsingCollector.onLeftAffordanceHintStarted(); - mKeyguardIndicationController.showTransientIndication(R.string.voice_hint); - } - - public void onPhoneHintStarted() { - mFalsingCollector.onLeftAffordanceHintStarted(); - mKeyguardIndicationController.showTransientIndication(R.string.phone_hint); - } - - public void onTrackingStopped(boolean expand) { - if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) { - if (!expand && !mKeyguardStateController.canDismissLockScreen()) { - mStatusBarKeyguardViewManager.showBouncer(false /* scrimmed */); - } - } - } - - // TODO: Figure out way to remove these. - public NavigationBarView getNavigationBarView() { - return mNavigationBarController.getNavigationBarView(mDisplayId); - } - - public void showPinningEnterExitToast(boolean entering) { - mNavigationBarController.showPinningEnterExitToast(mDisplayId, entering); - } - - public void showPinningEscapeToast() { - mNavigationBarController.showPinningEscapeToast(mDisplayId); - } - - /** - * TODO: Remove this method. Views should not be passed forward. Will cause theme issues. - * @return bottom area view - */ - public KeyguardBottomAreaView getKeyguardBottomAreaView() { - return mNotificationPanelViewController.getKeyguardBottomAreaView(); - } - - /** - * Propagation of the bouncer state, indicating that it's fully visible. - */ - public void setBouncerShowing(boolean bouncerShowing) { - mBouncerShowing = bouncerShowing; - mKeyguardBypassController.setBouncerShowing(bouncerShowing); - mPulseExpansionHandler.setBouncerShowing(bouncerShowing); - setBouncerShowingForStatusBarComponents(bouncerShowing); - mStatusBarHideIconsForBouncerManager.setBouncerShowingAndTriggerUpdate(bouncerShowing); - mCommandQueue.recomputeDisableFlags(mDisplayId, true /* animate */); - updateScrimController(); - if (!mBouncerShowing) { - updatePanelExpansionForKeyguard(); - } - } - - /** - * Propagate the bouncer state to status bar components. - * - * Separate from {@link #setBouncerShowing} because we sometimes re-create the status bar and - * should update only the status bar components. - */ - private void setBouncerShowingForStatusBarComponents(boolean bouncerShowing) { - int importance = bouncerShowing - ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS - : IMPORTANT_FOR_ACCESSIBILITY_AUTO; - if (mPhoneStatusBarViewController != null) { - mPhoneStatusBarViewController.setImportantForAccessibility(importance); - } - mNotificationPanelViewController.setImportantForAccessibility(importance); - mNotificationPanelViewController.setBouncerShowing(bouncerShowing); - } - - /** - * Collapses the notification shade if it is tracking or expanded. - */ - public void collapseShade() { - if (mNotificationPanelViewController.isTracking()) { - mNotificationShadeWindowViewController.cancelCurrentTouch(); - } - if (mPanelExpanded && mState == StatusBarState.SHADE) { - mShadeController.animateCollapsePanels(); - } - } - - @VisibleForTesting - final WakefulnessLifecycle.Observer mWakefulnessObserver = new WakefulnessLifecycle.Observer() { - @Override - public void onFinishedGoingToSleep() { - mNotificationPanelViewController.onAffordanceLaunchEnded(); - releaseGestureWakeLock(); - mLaunchCameraWhenFinishedWaking = false; - mDeviceInteractive = false; - mWakeUpComingFromTouch = false; - mWakeUpTouchLocation = null; - updateVisibleToUser(); - - updateNotificationPanelTouchState(); - mNotificationShadeWindowViewController.cancelCurrentTouch(); - if (mLaunchCameraOnFinishedGoingToSleep) { - mLaunchCameraOnFinishedGoingToSleep = false; - - // This gets executed before we will show Keyguard, so post it in order that the state - // is correct. - mMainExecutor.execute(() -> mCommandQueueCallbacks.onCameraLaunchGestureDetected( - mLastCameraLaunchSource)); - } - - if (mLaunchEmergencyActionOnFinishedGoingToSleep) { - mLaunchEmergencyActionOnFinishedGoingToSleep = false; - - // This gets executed before we will show Keyguard, so post it in order that the - // state is correct. - mMainExecutor.execute( - () -> mCommandQueueCallbacks.onEmergencyActionLaunchGestureDetected()); - } - updateIsKeyguard(); - } - - @Override - public void onStartedGoingToSleep() { - String tag = "StatusBar#onStartedGoingToSleep"; - DejankUtils.startDetectingBlockingIpcs(tag); - updateRevealEffect(false /* wakingUp */); - updateNotificationPanelTouchState(); - maybeEscalateHeadsUp(); - dismissVolumeDialog(); - mWakeUpCoordinator.setFullyAwake(false); - mKeyguardBypassController.onStartedGoingToSleep(); - - // The unlocked screen off and fold to aod animations might use our LightRevealScrim - - // we need to be expanded for it to be visible. - if (mDozeParameters.shouldShowLightRevealScrim()) { - makeExpandedVisible(true); - } - - DejankUtils.stopDetectingBlockingIpcs(tag); - } - - @Override - public void onStartedWakingUp() { - String tag = "StatusBar#onStartedWakingUp"; - DejankUtils.startDetectingBlockingIpcs(tag); - mNotificationShadeWindowController.batchApplyWindowLayoutParams(()-> { - mDeviceInteractive = true; - mWakeUpCoordinator.setWakingUp(true); - if (!mKeyguardBypassController.getBypassEnabled()) { - mHeadsUpManager.releaseAllImmediately(); - } - updateVisibleToUser(); - updateIsKeyguard(); - mDozeServiceHost.stopDozing(); - // This is intentionally below the stopDozing call above, since it avoids that we're - // unnecessarily animating the wakeUp transition. Animations should only be enabled - // once we fully woke up. - updateRevealEffect(true /* wakingUp */); - updateNotificationPanelTouchState(); - - // If we are waking up during the screen off animation, we should undo making the - // expanded visible (we did that so the LightRevealScrim would be visible). - if (mScreenOffAnimationController.shouldHideLightRevealScrimOnWakeUp()) { - makeExpandedInvisible(); - } - - }); - DejankUtils.stopDetectingBlockingIpcs(tag); - } - - @Override - public void onFinishedWakingUp() { - mWakeUpCoordinator.setFullyAwake(true); - mWakeUpCoordinator.setWakingUp(false); - if (mLaunchCameraWhenFinishedWaking) { - mNotificationPanelViewController.launchCamera( - false /* animate */, mLastCameraLaunchSource); - mLaunchCameraWhenFinishedWaking = false; - } - if (mLaunchEmergencyActionWhenFinishedWaking) { - mLaunchEmergencyActionWhenFinishedWaking = false; - Intent emergencyIntent = getEmergencyActionIntent(); - if (emergencyIntent != null) { - mContext.startActivityAsUser(emergencyIntent, UserHandle.CURRENT); - } - } - updateScrimController(); - } - }; - - /** - * We need to disable touch events because these might - * collapse the panel after we expanded it, and thus we would end up with a blank - * Keyguard. - */ - void updateNotificationPanelTouchState() { - boolean goingToSleepWithoutAnimation = isGoingToSleep() - && !mDozeParameters.shouldControlScreenOff(); - boolean disabled = (!mDeviceInteractive && !mDozeServiceHost.isPulsing()) - || goingToSleepWithoutAnimation; - mNotificationPanelViewController.setTouchAndAnimationDisabled(disabled); - mNotificationIconAreaController.setAnimationsEnabled(!disabled); - } - - final ScreenLifecycle.Observer mScreenObserver = new ScreenLifecycle.Observer() { - @Override - public void onScreenTurningOn(Runnable onDrawn) { - mFalsingCollector.onScreenTurningOn(); - mNotificationPanelViewController.onScreenTurningOn(); - } - - @Override - public void onScreenTurnedOn() { - mScrimController.onScreenTurnedOn(); - } - - @Override - public void onScreenTurnedOff() { - Trace.beginSection("StatusBar#onScreenTurnedOff"); - mFalsingCollector.onScreenOff(); - mScrimController.onScreenTurnedOff(); - if (mCloseQsBeforeScreenOff) { - mNotificationPanelViewController.closeQs(); - mCloseQsBeforeScreenOff = false; - } - updateIsKeyguard(); - Trace.endSection(); - } - }; - - public int getWakefulnessState() { - return mWakefulnessLifecycle.getWakefulness(); - } - - /** - * @return true if the screen is currently fully off, i.e. has finished turning off and has - * since not started turning on. - */ - public boolean isScreenFullyOff() { - return mScreenLifecycle.getScreenState() == ScreenLifecycle.SCREEN_OFF; - } - - public void showScreenPinningRequest(int taskId, boolean allowCancel) { - mScreenPinningRequest.showPrompt(taskId, allowCancel); - } - - @Nullable Intent getEmergencyActionIntent() { - Intent emergencyIntent = new Intent(EmergencyGesture.ACTION_LAUNCH_EMERGENCY); - PackageManager pm = mContext.getPackageManager(); - List emergencyActivities = pm.queryIntentActivities(emergencyIntent, - PackageManager.MATCH_SYSTEM_ONLY); - ResolveInfo resolveInfo = getTopEmergencySosInfo(emergencyActivities); - if (resolveInfo == null) { - Log.wtf(TAG, "Couldn't find an app to process the emergency intent."); - return null; - } - emergencyIntent.setComponent(new ComponentName(resolveInfo.activityInfo.packageName, - resolveInfo.activityInfo.name)); - emergencyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - return emergencyIntent; - } - - /** - * Select and return the "best" ResolveInfo for Emergency SOS Activity. - */ - private @Nullable ResolveInfo getTopEmergencySosInfo(List emergencyActivities) { - // No matched activity. - if (emergencyActivities == null || emergencyActivities.isEmpty()) { - return null; - } - - // Of multiple matched Activities, give preference to the pre-set package name. - String preferredAppPackageName = - mContext.getString(R.string.config_preferredEmergencySosPackage); - - // If there is no preferred app, then return first match. - if (TextUtils.isEmpty(preferredAppPackageName)) { - return emergencyActivities.get(0); - } - - for (ResolveInfo emergencyInfo: emergencyActivities) { - // If activity is from the preferred app, use it. - if (TextUtils.equals(emergencyInfo.activityInfo.packageName, preferredAppPackageName)) { - return emergencyInfo; - } - } - // No matching activity: return first match - return emergencyActivities.get(0); - } - - boolean isCameraAllowedByAdmin() { - if (mDevicePolicyManager.getCameraDisabled(null, - mLockscreenUserManager.getCurrentUserId())) { - return false; - } else if (mStatusBarKeyguardViewManager == null - || (isKeyguardShowing() && isKeyguardSecure())) { - // Check if the admin has disabled the camera specifically for the keyguard - return (mDevicePolicyManager.getKeyguardDisabledFeatures(null, - mLockscreenUserManager.getCurrentUserId()) - & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA) == 0; - } - return true; - } - - boolean isGoingToSleep() { - return mWakefulnessLifecycle.getWakefulness() - == WakefulnessLifecycle.WAKEFULNESS_GOING_TO_SLEEP; - } - - boolean isWaking() { - return mWakefulnessLifecycle.getWakefulness() == WakefulnessLifecycle.WAKEFULNESS_WAKING; - } - - public void notifyBiometricAuthModeChanged() { - mDozeServiceHost.updateDozing(); - updateScrimController(); - } - - /** - * Set the amount of progress we are currently in if we're transitioning to the full shade. - * 0.0f means we're not transitioning yet, while 1 means we're all the way in the full - * shade. - */ - public void setTransitionToFullShadeProgress(float transitionToFullShadeProgress) { - mTransitionToFullShadeProgress = transitionToFullShadeProgress; - } - - @VisibleForTesting - public void updateScrimController() { - Trace.beginSection("StatusBar#updateScrimController"); - - boolean unlocking = mKeyguardStateController.isShowing() && ( - mBiometricUnlockController.isWakeAndUnlock() - || mKeyguardStateController.isKeyguardFadingAway() - || mKeyguardStateController.isKeyguardGoingAway() - || mKeyguardViewMediator.requestedShowSurfaceBehindKeyguard() - || mKeyguardViewMediator.isAnimatingBetweenKeyguardAndSurfaceBehind()); - - mScrimController.setExpansionAffectsAlpha(!unlocking); - - boolean launchingAffordanceWithPreview = - mNotificationPanelViewController.isLaunchingAffordanceWithPreview(); - mScrimController.setLaunchingAffordanceWithPreview(launchingAffordanceWithPreview); - - if (mStatusBarKeyguardViewManager.isShowingAlternateAuth()) { - if (mState == StatusBarState.SHADE || mState == StatusBarState.SHADE_LOCKED - || mTransitionToFullShadeProgress > 0f) { - mScrimController.transitionTo(ScrimState.AUTH_SCRIMMED_SHADE); - } else { - mScrimController.transitionTo(ScrimState.AUTH_SCRIMMED); - } - } else if (mBouncerShowing && !unlocking) { - // Bouncer needs the front scrim when it's on top of an activity, - // tapping on a notification, editing QS or being dismissed by - // FLAG_DISMISS_KEYGUARD_ACTIVITY. - ScrimState state = mStatusBarKeyguardViewManager.bouncerNeedsScrimming() - ? ScrimState.BOUNCER_SCRIMMED : ScrimState.BOUNCER; - mScrimController.transitionTo(state); - } else if (launchingAffordanceWithPreview) { - // We want to avoid animating when launching with a preview. - mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback); - } else if (mBrightnessMirrorVisible) { - mScrimController.transitionTo(ScrimState.BRIGHTNESS_MIRROR); - } else if (mState == StatusBarState.SHADE_LOCKED) { - mScrimController.transitionTo(ScrimState.SHADE_LOCKED); - } else if (mDozeServiceHost.isPulsing()) { - mScrimController.transitionTo(ScrimState.PULSING, - mDozeScrimController.getScrimCallback()); - } else if (mDozeServiceHost.hasPendingScreenOffCallback()) { - mScrimController.transitionTo(ScrimState.OFF, new ScrimController.Callback() { - @Override - public void onFinished() { - mDozeServiceHost.executePendingScreenOffCallback(); - } - }); - } else if (mDozing && !unlocking) { - mScrimController.transitionTo(ScrimState.AOD); - } else if (mIsKeyguard && !unlocking) { - mScrimController.transitionTo(ScrimState.KEYGUARD); - } else { - mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback); - } - updateLightRevealScrimVisibility(); - - Trace.endSection(); - } - - public boolean isKeyguardShowing() { - if (mStatusBarKeyguardViewManager == null) { - Slog.i(TAG, "isKeyguardShowing() called before startKeyguard(), returning true"); - return true; - } - return mStatusBarKeyguardViewManager.isShowing(); - } - - public boolean shouldIgnoreTouch() { - return (mStatusBarStateController.isDozing() - && mDozeServiceHost.getIgnoreTouchWhilePulsing()) - || mScreenOffAnimationController.shouldIgnoreKeyguardTouches(); - } - - // Begin Extra BaseStatusBar methods. - - protected final CommandQueue mCommandQueue; - protected IStatusBarService mBarService; - - // all notifications - protected NotificationStackScrollLayout mStackScroller; - - // handling reordering - private final VisualStabilityManager mVisualStabilityManager; - - protected AccessibilityManager mAccessibilityManager; - - protected boolean mDeviceInteractive; - - protected boolean mVisible; - - // mScreenOnFromKeyguard && mVisible. - private boolean mVisibleToUser; - - protected DevicePolicyManager mDevicePolicyManager; - private final PowerManager mPowerManager; - protected StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; - - protected KeyguardManager mKeyguardManager; - private final DeviceProvisionedController mDeviceProvisionedController; - - private final NavigationBarController mNavigationBarController; - private final AccessibilityFloatingMenuController mAccessibilityFloatingMenuController; - - // UI-specific methods - - protected WindowManager mWindowManager; - protected IWindowManager mWindowManagerService; - private IDreamManager mDreamManager; - - protected Display mDisplay; - private int mDisplayId; - - protected NotificationShelfController mNotificationShelfController; - - private final Lazy mAssistManagerLazy; - - public boolean isDeviceInteractive() { - return mDeviceInteractive; - } - - private final BroadcastReceiver mBannerActionBroadcastReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (BANNER_ACTION_CANCEL.equals(action) || BANNER_ACTION_SETUP.equals(action)) { - NotificationManager noMan = (NotificationManager) - mContext.getSystemService(Context.NOTIFICATION_SERVICE); - noMan.cancel(com.android.internal.messages.nano.SystemMessageProto.SystemMessage. - NOTE_HIDDEN_NOTIFICATIONS); - - Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 0); - if (BANNER_ACTION_SETUP.equals(action)) { - mShadeController.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, - true /* force */); - mContext.startActivity(new Intent(Settings.ACTION_APP_NOTIFICATION_REDACTION) - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - - ); - } - } - } - }; - - public void setNotificationSnoozed(StatusBarNotification sbn, SnoozeOption snoozeOption) { - mNotificationsController.setNotificationSnoozed(sbn, snoozeOption); - } - - - public void awakenDreams() { - mUiBgExecutor.execute(() -> { - try { - mDreamManager.awaken(); - } catch (RemoteException e) { - e.printStackTrace(); - } - }); - } - - protected void toggleKeyboardShortcuts(int deviceId) { - KeyboardShortcuts.toggle(mContext, deviceId); - } - - protected void dismissKeyboardShortcuts() { - KeyboardShortcuts.dismiss(); - } - - /** - * Dismiss the keyguard then execute an action. - * - * @param action The action to execute after dismissing the keyguard. - * @param collapsePanel Whether we should collapse the panel after dismissing the keyguard. - * @param willAnimateOnKeyguard Whether {@param action} will run an animation on the keyguard if - * we are locked. - */ - private void executeActionDismissingKeyguard(Runnable action, boolean afterKeyguardGone, - boolean collapsePanel, boolean willAnimateOnKeyguard) { - if (!mDeviceProvisionedController.isDeviceProvisioned()) return; - - OnDismissAction onDismissAction = new OnDismissAction() { - @Override - public boolean onDismiss() { - new Thread(() -> { - try { - // The intent we are sending is for the application, which - // won't have permission to immediately start an activity after - // the user switches to home. We know it is safe to do at this - // point, so make sure new activity switches are now allowed. - ActivityManager.getService().resumeAppSwitches(); - } catch (RemoteException e) { - } - action.run(); - }).start(); - - return collapsePanel ? mShadeController.collapsePanel() : willAnimateOnKeyguard; - } - - @Override - public boolean willRunAnimationOnKeyguard() { - return willAnimateOnKeyguard; - } - }; - dismissKeyguardThenExecute(onDismissAction, afterKeyguardGone); - } - - @Override - public void startPendingIntentDismissingKeyguard(final PendingIntent intent) { - startPendingIntentDismissingKeyguard(intent, null); - } - - @Override - public void startPendingIntentDismissingKeyguard( - final PendingIntent intent, @Nullable final Runnable intentSentUiThreadCallback) { - startPendingIntentDismissingKeyguard(intent, intentSentUiThreadCallback, - (ActivityLaunchAnimator.Controller) null); - } - - @Override - public void startPendingIntentDismissingKeyguard(PendingIntent intent, - Runnable intentSentUiThreadCallback, View associatedView) { - ActivityLaunchAnimator.Controller animationController = null; - if (associatedView instanceof ExpandableNotificationRow) { - animationController = mNotificationAnimationProvider.getAnimatorController( - ((ExpandableNotificationRow) associatedView)); - } - - startPendingIntentDismissingKeyguard(intent, intentSentUiThreadCallback, - animationController); - } - - @Override - public void startPendingIntentDismissingKeyguard( - final PendingIntent intent, @Nullable final Runnable intentSentUiThreadCallback, - @Nullable ActivityLaunchAnimator.Controller animationController) { - final boolean willLaunchResolverActivity = intent.isActivity() - && mActivityIntentHelper.wouldLaunchResolverActivity(intent.getIntent(), - mLockscreenUserManager.getCurrentUserId()); - - boolean animate = !willLaunchResolverActivity - && animationController != null - && shouldAnimateLaunch(intent.isActivity()); - - // If we animate, don't collapse the shade and defer the keyguard dismiss (in case we run - // the animation on the keyguard). The animation will take care of (instantly) collapsing - // the shade and hiding the keyguard once it is done. - boolean collapse = !animate; - executeActionDismissingKeyguard(() -> { - try { - // We wrap animationCallback with a StatusBarLaunchAnimatorController so that the - // shade is collapsed after the animation (or when it is cancelled, aborted, etc). - ActivityLaunchAnimator.Controller controller = - animationController != null ? new StatusBarLaunchAnimatorController( - animationController, this, intent.isActivity()) : null; - - mActivityLaunchAnimator.startPendingIntentWithAnimation( - controller, animate, intent.getCreatorPackage(), - (animationAdapter) -> intent.sendAndReturnResult(null, 0, null, null, null, - null, getActivityOptions(mDisplayId, animationAdapter))); - } catch (PendingIntent.CanceledException e) { - // the stack trace isn't very helpful here. - // Just log the exception message. - Log.w(TAG, "Sending intent failed: " + e); - if (!collapse) { - // executeActionDismissingKeyguard did not collapse for us already. - collapsePanelOnMainThread(); - } - // TODO: Dismiss Keyguard. - } - if (intent.isActivity()) { - mAssistManagerLazy.get().hideAssist(); - } - if (intentSentUiThreadCallback != null) { - postOnUiThread(intentSentUiThreadCallback); - } - }, willLaunchResolverActivity, collapse, animate); - } - - private void postOnUiThread(Runnable runnable) { - mMainExecutor.execute(runnable); - } - - /** - * Returns an ActivityOptions bundle created using the given parameters. - * - * @param displayId The ID of the display to launch the activity in. Typically this would be the - * display the status bar is on. - * @param animationAdapter The animation adapter used to start this activity, or {@code null} - * for the default animation. - */ - public static Bundle getActivityOptions(int displayId, - @Nullable RemoteAnimationAdapter animationAdapter) { - ActivityOptions options = getDefaultActivityOptions(animationAdapter); - options.setLaunchDisplayId(displayId); - options.setCallerDisplayId(displayId); - return options.toBundle(); - } - - /** - * Returns an ActivityOptions bundle created using the given parameters. - * - * @param displayId The ID of the display to launch the activity in. Typically this would be the - * display the status bar is on. - * @param animationAdapter The animation adapter used to start this activity, or {@code null} - * for the default animation. - * @param isKeyguardShowing Whether keyguard is currently showing. - * @param eventTime The event time in milliseconds since boot, not including sleep. See - * {@link ActivityOptions#setSourceInfo}. - */ - public static Bundle getActivityOptions(int displayId, - @Nullable RemoteAnimationAdapter animationAdapter, boolean isKeyguardShowing, - long eventTime) { - ActivityOptions options = getDefaultActivityOptions(animationAdapter); - options.setSourceInfo(isKeyguardShowing ? ActivityOptions.SourceInfo.TYPE_LOCKSCREEN - : ActivityOptions.SourceInfo.TYPE_NOTIFICATION, eventTime); - options.setLaunchDisplayId(displayId); - options.setCallerDisplayId(displayId); - return options.toBundle(); - } - - public static ActivityOptions getDefaultActivityOptions( - @Nullable RemoteAnimationAdapter animationAdapter) { - ActivityOptions options; - if (animationAdapter != null) { - if (ENABLE_SHELL_TRANSITIONS) { - options = ActivityOptions.makeRemoteTransition( - RemoteTransitionAdapter.adaptRemoteAnimation(animationAdapter)); - } else { - options = ActivityOptions.makeRemoteAnimation(animationAdapter); - } - } else { - options = ActivityOptions.makeBasic(); - } - return options; - } - - void visibilityChanged(boolean visible) { - if (mVisible != visible) { - mVisible = visible; - if (!visible) { - mGutsManager.closeAndSaveGuts(true /* removeLeavebehind */, true /* force */, - true /* removeControls */, -1 /* x */, -1 /* y */, true /* resetMenu */); - } - } - updateVisibleToUser(); - } - - protected void updateVisibleToUser() { - boolean oldVisibleToUser = mVisibleToUser; - mVisibleToUser = mVisible && mDeviceInteractive; - - if (oldVisibleToUser != mVisibleToUser) { - handleVisibleToUserChanged(mVisibleToUser); - } - } - - /** - * Clear Buzz/Beep/Blink. - */ - public void clearNotificationEffects() { - try { - mBarService.clearNotificationEffects(); - } catch (RemoteException e) { - // Won't fail unless the world has ended. - } - } - - /** - * @return Whether the security bouncer from Keyguard is showing. - */ - public boolean isBouncerShowing() { - return mBouncerShowing; - } - - /** - * @return Whether the security bouncer from Keyguard is showing. - */ - public boolean isBouncerShowingScrimmed() { - return isBouncerShowing() && mStatusBarKeyguardViewManager.bouncerNeedsScrimming(); - } - - public boolean isBouncerShowingOverDream() { - return isBouncerShowing() && mDreamOverlayStateController.isOverlayActive(); - } - - /** - * When {@link KeyguardBouncer} starts to be dismissed, playing its animation. - */ - public void onBouncerPreHideAnimation() { - mNotificationPanelViewController.onBouncerPreHideAnimation(); - - } - - /** - * @return a PackageManger for userId or if userId is < 0 (USER_ALL etc) then - * return PackageManager for mContext - */ - public static PackageManager getPackageManagerForUser(Context context, int userId) { - Context contextForUser = context; - // UserHandle defines special userId as negative values, e.g. USER_ALL - if (userId >= 0) { - try { - // Create a context for the correct user so if a package isn't installed - // for user 0 we can still load information about the package. - contextForUser = - context.createPackageContextAsUser(context.getPackageName(), - Context.CONTEXT_RESTRICTED, - new UserHandle(userId)); - } catch (NameNotFoundException e) { - // Shouldn't fail to find the package name for system ui. - } - } - return contextForUser.getPackageManager(); - } - - public boolean isKeyguardSecure() { - if (mStatusBarKeyguardViewManager == null) { - // startKeyguard() hasn't been called yet, so we don't know. - // Make sure anything that needs to know isKeyguardSecure() checks and re-checks this - // value onVisibilityChanged(). - Slog.w(TAG, "isKeyguardSecure() called before startKeyguard(), returning false", - new Throwable()); - return false; - } - return mStatusBarKeyguardViewManager.isSecure(); - } - public NotificationPanelViewController getPanelController() { - return mNotificationPanelViewController; - } - // End Extra BaseStatusBarMethods. - - public NotificationGutsManager getGutsManager() { - return mGutsManager; - } - - boolean isTransientShown() { - return mTransientShown; - } - - private void updateLightRevealScrimVisibility() { - if (mLightRevealScrim == null) { - // status bar may not be inflated yet - return; - } - - mLightRevealScrim.setAlpha(mScrimController.getState().getMaxLightRevealScrimAlpha()); - } - - private final KeyguardUpdateMonitorCallback mUpdateCallback = - new KeyguardUpdateMonitorCallback() { - @Override - public void onDreamingStateChanged(boolean dreaming) { - if (dreaming) { - maybeEscalateHeadsUp(); - } - } - - // TODO: (b/145659174) remove when moving to NewNotifPipeline. Replaced by - // KeyguardCoordinator - @Override - public void onStrongAuthStateChanged(int userId) { - super.onStrongAuthStateChanged(userId); - mNotificationsController.requestNotificationUpdate("onStrongAuthStateChanged"); - } - }; - - - private final FalsingManager.FalsingBeliefListener mFalsingBeliefListener = - new FalsingManager.FalsingBeliefListener() { - @Override - public void onFalse() { - // Hides quick settings, bouncer, and quick-quick settings. - mStatusBarKeyguardViewManager.reset(true); - } - }; - - // Notifies StatusBarKeyguardViewManager every time the keyguard transition is over, - // this animation is tied to the scrim for historic reasons. - // TODO: notify when keyguard has faded away instead of the scrim. - private final ScrimController.Callback mUnlockScrimCallback = new ScrimController - .Callback() { - @Override - public void onFinished() { - if (mStatusBarKeyguardViewManager == null) { - Log.w(TAG, "Tried to notify keyguard visibility when " - + "mStatusBarKeyguardViewManager was null"); - return; - } - if (mKeyguardStateController.isKeyguardFadingAway()) { - mStatusBarKeyguardViewManager.onKeyguardFadedAway(); - } - } - - @Override - public void onCancelled() { - onFinished(); - } - }; - - private final DeviceProvisionedListener mUserSetupObserver = new DeviceProvisionedListener() { - @Override - public void onUserSetupChanged() { - final boolean userSetup = mDeviceProvisionedController.isCurrentUserSetup(); - Log.d(TAG, "mUserSetupObserver - DeviceProvisionedListener called for " - + "current user"); - if (MULTIUSER_DEBUG) { - Log.d(TAG, String.format("User setup changed: userSetup=%s mUserSetup=%s", - userSetup, mUserSetup)); - } - - if (userSetup != mUserSetup) { - mUserSetup = userSetup; - if (!mUserSetup) { - animateCollapseQuickSettings(); - } - if (mNotificationPanelViewController != null) { - mNotificationPanelViewController.setUserSetupComplete(mUserSetup); - } - updateQsExpansionEnabled(); - } - } - }; - - private final BroadcastReceiver mWallpaperChangedReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (!mWallpaperSupported) { - // Receiver should not have been registered at all... - Log.wtf(TAG, "WallpaperManager not supported"); - return; - } - WallpaperInfo info = mWallpaperManager.getWallpaperInfo(UserHandle.USER_CURRENT); - mWallpaperController.onWallpaperInfoUpdated(info); - - final boolean deviceSupportsAodWallpaper = mContext.getResources().getBoolean( - com.android.internal.R.bool.config_dozeSupportsAodWallpaper); - // If WallpaperInfo is null, it must be ImageWallpaper. - final boolean supportsAmbientMode = deviceSupportsAodWallpaper - && (info != null && info.supportsAmbientMode()); - - mNotificationShadeWindowController.setWallpaperSupportsAmbientMode(supportsAmbientMode); - mScrimController.setWallpaperSupportsAmbientMode(supportsAmbientMode); - mKeyguardViewMediator.setWallpaperSupportsAmbientMode(supportsAmbientMode); - } - }; - - private final ConfigurationListener mConfigurationListener = new ConfigurationListener() { - @Override - public void onConfigChanged(Configuration newConfig) { - updateResources(); - updateDisplaySize(); // populates mDisplayMetrics - - if (DEBUG) { - Log.v(TAG, "configuration changed: " + mContext.getResources().getConfiguration()); - } - - if (!mNotifPipelineFlags.isNewPipelineEnabled()) { - mViewHierarchyManager.updateRowStates(); - } - mScreenPinningRequest.onConfigurationChanged(); - } - - @Override - public void onDensityOrFontScaleChanged() { - // TODO: Remove this. - if (mBrightnessMirrorController != null) { - mBrightnessMirrorController.onDensityOrFontScaleChanged(); - } - // TODO: Bring these out of StatusBar. - mUserInfoControllerImpl.onDensityOrFontScaleChanged(); - mUserSwitcherController.onDensityOrFontScaleChanged(); - mNotificationIconAreaController.onDensityOrFontScaleChanged(mContext); - mHeadsUpManager.onDensityOrFontScaleChanged(); - } - - @Override - public void onThemeChanged() { - if (mBrightnessMirrorController != null) { - mBrightnessMirrorController.onOverlayChanged(); - } - // We need the new R.id.keyguard_indication_area before recreating - // mKeyguardIndicationController - mNotificationPanelViewController.onThemeChanged(); - - if (mStatusBarKeyguardViewManager != null) { - mStatusBarKeyguardViewManager.onThemeChanged(); - } - if (mAmbientIndicationContainer instanceof AutoReinflateContainer) { - ((AutoReinflateContainer) mAmbientIndicationContainer).inflateLayout(); - } - mNotificationIconAreaController.onThemeChanged(); - } - - @Override - public void onUiModeChanged() { - if (mBrightnessMirrorController != null) { - mBrightnessMirrorController.onUiModeChanged(); - } - } - }; - - private StatusBarStateController.StateListener mStateListener = - new StatusBarStateController.StateListener() { - @Override - public void onStatePreChange(int oldState, int newState) { - // If we're visible and switched to SHADE_LOCKED (the user dragged - // down on the lockscreen), clear notification LED, vibration, - // ringing. - // Other transitions are covered in handleVisibleToUserChanged(). - if (mVisible && (newState == StatusBarState.SHADE_LOCKED - || mStatusBarStateController.goingToFullShade())) { - clearNotificationEffects(); - } - if (newState == StatusBarState.KEYGUARD) { - mRemoteInputManager.onPanelCollapsed(); - maybeEscalateHeadsUp(); - } - } - - @Override - public void onStateChanged(int newState) { - mState = newState; - updateReportRejectedTouchVisibility(); - mDozeServiceHost.updateDozing(); - updateTheme(); - mNavigationBarController.touchAutoDim(mDisplayId); - Trace.beginSection("StatusBar#updateKeyguardState"); - if (mState == StatusBarState.KEYGUARD) { - mNotificationPanelViewController.cancelPendingPanelCollapse(); - } - updateDozingState(); - checkBarModes(); - updateScrimController(); - mPresenter.updateMediaMetaData(false, mState != StatusBarState.KEYGUARD); - updateKeyguardState(); - Trace.endSection(); - } - - @Override - public void onDozeAmountChanged(float linear, float eased) { - if (mFeatureFlags.isEnabled(Flags.LOCKSCREEN_ANIMATIONS) - && !(mLightRevealScrim.getRevealEffect() instanceof CircleReveal) - && !mBiometricUnlockController.isWakeAndUnlock()) { - mLightRevealScrim.setRevealAmount(1f - linear); - } - } - - @Override - public void onDozingChanged(boolean isDozing) { - Trace.beginSection("StatusBar#updateDozing"); - mDozing = isDozing; - - // Collapse the notification panel if open - boolean dozingAnimated = mDozeServiceHost.getDozingRequested() - && mDozeParameters.shouldControlScreenOff(); - mNotificationPanelViewController.resetViews(dozingAnimated); - - updateQsExpansionEnabled(); - mKeyguardViewMediator.setDozing(mDozing); - - mNotificationsController.requestNotificationUpdate("onDozingChanged"); - updateDozingState(); - mDozeServiceHost.updateDozing(); - updateScrimController(); - updateReportRejectedTouchVisibility(); - Trace.endSection(); - } - - @Override - public void onFullscreenStateChanged(boolean isFullscreen) { - mIsFullscreen = isFullscreen; - maybeUpdateBarMode(); - } - }; - - private final BatteryController.BatteryStateChangeCallback mBatteryStateChangeCallback = - new BatteryController.BatteryStateChangeCallback() { - @Override - public void onPowerSaveChanged(boolean isPowerSave) { - mMainExecutor.execute(mCheckBarModes); - if (mDozeServiceHost != null) { - mDozeServiceHost.firePowerSaveChanged(isPowerSave); - } - } - }; - - private final ActivityLaunchAnimator.Callback mActivityLaunchAnimatorCallback = - new ActivityLaunchAnimator.Callback() { - @Override - public boolean isOnKeyguard() { - return mKeyguardStateController.isShowing(); - } - - @Override - public void hideKeyguardWithAnimation(IRemoteAnimationRunner runner) { - // We post to the main thread for 2 reasons: - // 1. KeyguardViewMediator is not thread-safe. - // 2. To ensure that ViewMediatorCallback#keyguardDonePending is called before - // ViewMediatorCallback#readyForKeyguardDone. The wrong order could occur - // when doing - // dismissKeyguardThenExecute { hideKeyguardWithAnimation(runner) }. - mMainExecutor.execute(() -> mKeyguardViewMediator.hideWithAnimation(runner)); - } - - @Override - public int getBackgroundColor(TaskInfo task) { - if (!mStartingSurfaceOptional.isPresent()) { - Log.w(TAG, "No starting surface, defaulting to SystemBGColor"); - return SplashscreenContentDrawer.getSystemBGColor(); - } - - return mStartingSurfaceOptional.get().getBackgroundColor(task); - } - }; - - private final ActivityLaunchAnimator.Listener mActivityLaunchAnimatorListener = - new ActivityLaunchAnimator.Listener() { - @Override - public void onLaunchAnimationStart() { - mKeyguardViewMediator.setBlursDisabledForAppLaunch(true); - } - - @Override - public void onLaunchAnimationEnd() { - mKeyguardViewMediator.setBlursDisabledForAppLaunch(false); - } - }; - - private final DemoMode mDemoModeCallback = new DemoMode() { - @Override - public void onDemoModeFinished() { - checkBarModes(); - } - - @Override - public void dispatchDemoCommand(String command, Bundle args) { } - }; -} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarCommandQueueCallbacks.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarCommandQueueCallbacks.java deleted file mode 100644 index 883445e17162..000000000000 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarCommandQueueCallbacks.java +++ /dev/null @@ -1,591 +0,0 @@ -/* - * Copyright (C) 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.statusbar.phone; - -import static android.view.InsetsState.ITYPE_STATUS_BAR; -import static android.view.InsetsState.containsType; - -import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_AWAKE; -import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_WAKING; - -import android.annotation.Nullable; -import android.app.StatusBarManager; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.res.Resources; -import android.os.Bundle; -import android.os.PowerManager; -import android.os.SystemClock; -import android.os.UserHandle; -import android.os.VibrationAttributes; -import android.os.VibrationEffect; -import android.os.Vibrator; -import android.util.Log; -import android.util.Slog; -import android.view.InsetsState.InternalInsetsType; -import android.view.InsetsVisibilities; -import android.view.KeyEvent; -import android.view.WindowInsetsController.Appearance; -import android.view.WindowInsetsController.Behavior; - -import com.android.internal.logging.MetricsLogger; -import com.android.internal.logging.nano.MetricsProto.MetricsEvent; -import com.android.internal.view.AppearanceRegion; -import com.android.keyguard.KeyguardUpdateMonitor; -import com.android.systemui.R; -import com.android.systemui.assist.AssistManager; -import com.android.systemui.camera.CameraIntents; -import com.android.systemui.dagger.qualifiers.DisplayId; -import com.android.systemui.dagger.qualifiers.Main; -import com.android.systemui.keyguard.WakefulnessLifecycle; -import com.android.systemui.qs.QSPanelController; -import com.android.systemui.statusbar.CommandQueue; -import com.android.systemui.statusbar.DisableFlagsLogger; -import com.android.systemui.statusbar.SysuiStatusBarStateController; -import com.android.systemui.statusbar.VibratorHelper; -import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; -import com.android.systemui.statusbar.policy.DeviceProvisionedController; -import com.android.systemui.statusbar.policy.HeadsUpManager; -import com.android.systemui.statusbar.policy.KeyguardStateController; -import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler; - -import java.util.Optional; - -import javax.inject.Inject; - -/** */ -@StatusBarComponent.StatusBarScope -public class StatusBarCommandQueueCallbacks implements CommandQueue.Callbacks { - private final StatusBar mStatusBar; - private final Context mContext; - private final ShadeController mShadeController; - private final CommandQueue mCommandQueue; - private final NotificationPanelViewController mNotificationPanelViewController; - private final RemoteInputQuickSettingsDisabler mRemoteInputQuickSettingsDisabler; - private final MetricsLogger mMetricsLogger; - private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; - private final KeyguardStateController mKeyguardStateController; - private final HeadsUpManager mHeadsUpManager; - private final WakefulnessLifecycle mWakefulnessLifecycle; - private final DeviceProvisionedController mDeviceProvisionedController; - private final StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; - private final AssistManager mAssistManager; - private final DozeServiceHost mDozeServiceHost; - private final SysuiStatusBarStateController mStatusBarStateController; - private final NotificationShadeWindowView mNotificationShadeWindowView; - private final NotificationStackScrollLayoutController mNotificationStackScrollLayoutController; - private final StatusBarHideIconsForBouncerManager mStatusBarHideIconsForBouncerManager; - private final PowerManager mPowerManager; - private final VibratorHelper mVibratorHelper; - private final Optional mVibratorOptional; - private final LightBarController mLightBarController; - private final DisableFlagsLogger mDisableFlagsLogger; - private final int mDisplayId; - private final boolean mVibrateOnOpening; - private final VibrationEffect mCameraLaunchGestureVibrationEffect; - - - private static final VibrationAttributes HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES = - VibrationAttributes.createForUsage(VibrationAttributes.USAGE_HARDWARE_FEEDBACK); - - @Inject - StatusBarCommandQueueCallbacks( - StatusBar statusBar, - Context context, - @Main Resources resources, - ShadeController shadeController, - CommandQueue commandQueue, - NotificationPanelViewController notificationPanelViewController, - RemoteInputQuickSettingsDisabler remoteInputQuickSettingsDisabler, - MetricsLogger metricsLogger, - KeyguardUpdateMonitor keyguardUpdateMonitor, - KeyguardStateController keyguardStateController, - HeadsUpManager headsUpManager, - WakefulnessLifecycle wakefulnessLifecycle, - DeviceProvisionedController deviceProvisionedController, - StatusBarKeyguardViewManager statusBarKeyguardViewManager, - AssistManager assistManager, - DozeServiceHost dozeServiceHost, - SysuiStatusBarStateController statusBarStateController, - NotificationShadeWindowView notificationShadeWindowView, - NotificationStackScrollLayoutController notificationStackScrollLayoutController, - StatusBarHideIconsForBouncerManager statusBarHideIconsForBouncerManager, - PowerManager powerManager, - VibratorHelper vibratorHelper, - Optional vibratorOptional, - LightBarController lightBarController, - DisableFlagsLogger disableFlagsLogger, - @DisplayId int displayId) { - - mStatusBar = statusBar; - mContext = context; - mShadeController = shadeController; - mCommandQueue = commandQueue; - mNotificationPanelViewController = notificationPanelViewController; - mRemoteInputQuickSettingsDisabler = remoteInputQuickSettingsDisabler; - mMetricsLogger = metricsLogger; - mKeyguardUpdateMonitor = keyguardUpdateMonitor; - mKeyguardStateController = keyguardStateController; - mHeadsUpManager = headsUpManager; - mWakefulnessLifecycle = wakefulnessLifecycle; - mDeviceProvisionedController = deviceProvisionedController; - mStatusBarKeyguardViewManager = statusBarKeyguardViewManager; - mAssistManager = assistManager; - mDozeServiceHost = dozeServiceHost; - mStatusBarStateController = statusBarStateController; - mNotificationShadeWindowView = notificationShadeWindowView; - mNotificationStackScrollLayoutController = notificationStackScrollLayoutController; - mStatusBarHideIconsForBouncerManager = statusBarHideIconsForBouncerManager; - mPowerManager = powerManager; - mVibratorHelper = vibratorHelper; - mVibratorOptional = vibratorOptional; - mLightBarController = lightBarController; - mDisableFlagsLogger = disableFlagsLogger; - mDisplayId = displayId; - - mVibrateOnOpening = resources.getBoolean(R.bool.config_vibrateOnIconAnimation); - mCameraLaunchGestureVibrationEffect = getCameraGestureVibrationEffect( - mVibratorOptional, resources); - } - - @Override - public void abortTransient(int displayId, @InternalInsetsType int[] types) { - if (displayId != mDisplayId) { - return; - } - if (!containsType(types, ITYPE_STATUS_BAR)) { - return; - } - mStatusBar.clearTransient(); - } - - @Override - public void addQsTile(ComponentName tile) { - QSPanelController qsPanelController = mStatusBar.getQSPanelController(); - if (qsPanelController != null && qsPanelController.getHost() != null) { - qsPanelController.getHost().addTile(tile); - } - } - - @Override - public void remQsTile(ComponentName tile) { - QSPanelController qsPanelController = mStatusBar.getQSPanelController(); - if (qsPanelController != null && qsPanelController.getHost() != null) { - qsPanelController.getHost().removeTile(tile); - } - } - - @Override - public void clickTile(ComponentName tile) { - QSPanelController qsPanelController = mStatusBar.getQSPanelController(); - if (qsPanelController != null) { - qsPanelController.clickTile(tile); - } - } - - @Override - public void animateCollapsePanels(int flags, boolean force) { - mShadeController.animateCollapsePanels(flags, force, false /* delayed */, - 1.0f /* speedUpFactor */); - } - - @Override - public void animateExpandNotificationsPanel() { - if (StatusBar.SPEW) { - Log.d(StatusBar.TAG, - "animateExpand: mExpandedVisible=" + mStatusBar.isExpandedVisible()); - } - if (!mCommandQueue.panelsEnabled()) { - return; - } - - mNotificationPanelViewController.expandWithoutQs(); - } - - @Override - public void animateExpandSettingsPanel(@Nullable String subPanel) { - if (StatusBar.SPEW) { - Log.d(StatusBar.TAG, - "animateExpand: mExpandedVisible=" + mStatusBar.isExpandedVisible()); - } - if (!mCommandQueue.panelsEnabled()) { - return; - } - - // Settings are not available in setup - if (!mDeviceProvisionedController.isCurrentUserSetup()) return; - - mNotificationPanelViewController.expandWithQs(); - } - - @Override - public void appTransitionCancelled(int displayId) { - } - - @Override - public void appTransitionFinished(int displayId) { - } - - @Override - public void dismissKeyboardShortcutsMenu() { - mStatusBar.resendMessage(StatusBar.MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU); - } - /** - * State is one or more of the DISABLE constants from StatusBarManager. - */ - @Override - public void disable(int displayId, int state1, int state2, boolean animate) { - if (displayId != mDisplayId) { - return; - } - - int state2BeforeAdjustment = state2; - state2 = mRemoteInputQuickSettingsDisabler.adjustDisableFlags(state2); - Log.d(StatusBar.TAG, - mDisableFlagsLogger.getDisableFlagsString( - /* old= */ new DisableFlagsLogger.DisableState( - mStatusBar.getDisabled1(), mStatusBar.getDisabled2()), - /* new= */ new DisableFlagsLogger.DisableState( - state1, state2BeforeAdjustment), - /* newStateAfterLocalModification= */ new DisableFlagsLogger.DisableState( - state1, state2))); - - final int old1 = mStatusBar.getDisabled1(); - final int diff1 = state1 ^ old1; - mStatusBar.setDisabled1(state1); - - final int old2 = mStatusBar.getDisabled2(); - final int diff2 = state2 ^ old2; - mStatusBar.setDisabled2(state2); - - if ((diff1 & StatusBarManager.DISABLE_EXPAND) != 0) { - if ((state1 & StatusBarManager.DISABLE_EXPAND) != 0) { - mShadeController.animateCollapsePanels(); - } - } - - if ((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) { - if (mStatusBar.areNotificationAlertsDisabled()) { - mHeadsUpManager.releaseAllImmediately(); - } - } - - if ((diff2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) != 0) { - mStatusBar.updateQsExpansionEnabled(); - } - - if ((diff2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE) != 0) { - mStatusBar.updateQsExpansionEnabled(); - if ((state2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE) != 0) { - mShadeController.animateCollapsePanels(); - } - } - } - - /** - * Called for system navigation gestures. First action opens the panel, second opens - * settings. Down action closes the entire panel. - */ - @Override - public void handleSystemKey(int key) { - if (StatusBar.SPEW) { - Log.d(StatusBar.TAG, "handleNavigationKey: " + key); - } - if (!mCommandQueue.panelsEnabled() || !mKeyguardUpdateMonitor.isDeviceInteractive() - || mKeyguardStateController.isShowing() && !mKeyguardStateController.isOccluded()) { - return; - } - - // Panels are not available in setup - if (!mDeviceProvisionedController.isCurrentUserSetup()) return; - - if (KeyEvent.KEYCODE_SYSTEM_NAVIGATION_UP == key) { - mMetricsLogger.action(MetricsEvent.ACTION_SYSTEM_NAVIGATION_KEY_UP); - mNotificationPanelViewController.collapse( - false /* delayed */, 1.0f /* speedUpFactor */); - } else if (KeyEvent.KEYCODE_SYSTEM_NAVIGATION_DOWN == key) { - mMetricsLogger.action(MetricsEvent.ACTION_SYSTEM_NAVIGATION_KEY_DOWN); - if (mNotificationPanelViewController.isFullyCollapsed()) { - if (mVibrateOnOpening) { - mVibratorHelper.vibrate(VibrationEffect.EFFECT_TICK); - } - mNotificationPanelViewController.expand(true /* animate */); - mNotificationStackScrollLayoutController.setWillExpand(true); - mHeadsUpManager.unpinAll(true /* userUnpinned */); - mMetricsLogger.count(NotificationPanelView.COUNTER_PANEL_OPEN, 1); - } else if (!mNotificationPanelViewController.isInSettings() - && !mNotificationPanelViewController.isExpanding()) { - mNotificationPanelViewController.flingSettings(0 /* velocity */, - NotificationPanelView.FLING_EXPAND); - mMetricsLogger.count(NotificationPanelView.COUNTER_PANEL_OPEN_QS, 1); - } - } - - } - - @Override - public void onCameraLaunchGestureDetected(int source) { - mStatusBar.setLastCameraLaunchSource(source); - if (mStatusBar.isGoingToSleep()) { - if (StatusBar.DEBUG_CAMERA_LIFT) { - Slog.d(StatusBar.TAG, "Finish going to sleep before launching camera"); - } - mStatusBar.setLaunchCameraOnFinishedGoingToSleep(true); - return; - } - if (!mNotificationPanelViewController.canCameraGestureBeLaunched()) { - if (StatusBar.DEBUG_CAMERA_LIFT) { - Slog.d(StatusBar.TAG, "Can't launch camera right now"); - } - return; - } - if (!mStatusBar.isDeviceInteractive()) { - mPowerManager.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_CAMERA_LAUNCH, - "com.android.systemui:CAMERA_GESTURE"); - } - vibrateForCameraGesture(); - - if (source == StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP) { - Log.v(StatusBar.TAG, "Camera launch"); - mKeyguardUpdateMonitor.onCameraLaunched(); - } - - if (!mStatusBarKeyguardViewManager.isShowing()) { - final Intent cameraIntent = CameraIntents.getInsecureCameraIntent(mContext); - mStatusBar.startActivityDismissingKeyguard(cameraIntent, - false /* onlyProvisioned */, true /* dismissShade */, - true /* disallowEnterPictureInPictureWhileLaunching */, null /* callback */, 0, - null /* animationController */); - } else { - if (!mStatusBar.isDeviceInteractive()) { - // Avoid flickering of the scrim when we instant launch the camera and the bouncer - // comes on. - mStatusBar.acquireGestureWakeLock(StatusBar.LAUNCH_TRANSITION_TIMEOUT_MS + 1000L); - } - if (isWakingUpOrAwake()) { - if (StatusBar.DEBUG_CAMERA_LIFT) { - Slog.d(StatusBar.TAG, "Launching camera"); - } - if (mStatusBarKeyguardViewManager.isBouncerShowing()) { - mStatusBarKeyguardViewManager.reset(true /* hide */); - } - mNotificationPanelViewController.launchCamera( - mStatusBar.isDeviceInteractive() /* animate */, source); - mStatusBar.updateScrimController(); - } else { - // We need to defer the camera launch until the screen comes on, since otherwise - // we will dismiss us too early since we are waiting on an activity to be drawn and - // incorrectly get notified because of the screen on event (which resumes and pauses - // some activities) - if (StatusBar.DEBUG_CAMERA_LIFT) { - Slog.d(StatusBar.TAG, "Deferring until screen turns on"); - } - mStatusBar.setLaunchCameraOnFinishedWaking(true); - } - } - } - - @Override - public void onEmergencyActionLaunchGestureDetected() { - Intent emergencyIntent = mStatusBar.getEmergencyActionIntent(); - - if (emergencyIntent == null) { - Log.wtf(StatusBar.TAG, "Couldn't find an app to process the emergency intent."); - return; - } - - if (isGoingToSleep()) { - mStatusBar.setLaunchEmergencyActionOnFinishedGoingToSleep(true); - return; - } - - if (!mStatusBar.isDeviceInteractive()) { - mPowerManager.wakeUp(SystemClock.uptimeMillis(), - PowerManager.WAKE_REASON_GESTURE, - "com.android.systemui:EMERGENCY_GESTURE"); - } - // TODO(b/169087248) Possibly add haptics here for emergency action. Currently disabled for - // app-side haptic experimentation. - - if (!mStatusBarKeyguardViewManager.isShowing()) { - mStatusBar.startActivityDismissingKeyguard(emergencyIntent, - false /* onlyProvisioned */, true /* dismissShade */, - true /* disallowEnterPictureInPictureWhileLaunching */, null /* callback */, 0, - null /* animationController */); - return; - } - - if (!mStatusBar.isDeviceInteractive()) { - // Avoid flickering of the scrim when we instant launch the camera and the bouncer - // comes on. - mStatusBar.acquireGestureWakeLock(StatusBar.LAUNCH_TRANSITION_TIMEOUT_MS + 1000L); - } - - if (isWakingUpOrAwake()) { - if (mStatusBarKeyguardViewManager.isBouncerShowing()) { - mStatusBarKeyguardViewManager.reset(true /* hide */); - } - mContext.startActivityAsUser(emergencyIntent, UserHandle.CURRENT); - return; - } - // We need to defer the emergency action launch until the screen comes on, since otherwise - // we will dismiss us too early since we are waiting on an activity to be drawn and - // incorrectly get notified because of the screen on event (which resumes and pauses - // some activities) - mStatusBar.setLaunchEmergencyActionOnFinishedWaking(true); - } - - @Override - public void onRecentsAnimationStateChanged(boolean running) { - mStatusBar.setInteracting(StatusBarManager.WINDOW_NAVIGATION_BAR, running); - } - - - @Override - public void onSystemBarAttributesChanged(int displayId, @Appearance int appearance, - AppearanceRegion[] appearanceRegions, boolean navbarColorManagedByIme, - @Behavior int behavior, InsetsVisibilities requestedVisibilities, String packageName) { - if (displayId != mDisplayId) { - return; - } - boolean barModeChanged = mStatusBar.setAppearance(appearance); - - mLightBarController.onStatusBarAppearanceChanged(appearanceRegions, barModeChanged, - mStatusBar.getBarMode(), navbarColorManagedByIme); - - mStatusBar.updateBubblesVisibility(); - mStatusBarStateController.setSystemBarAttributes( - appearance, behavior, requestedVisibilities, packageName); - } - - @Override - public void showTransient(int displayId, @InternalInsetsType int[] types, - boolean isGestureOnSystemBar) { - if (displayId != mDisplayId) { - return; - } - if (!containsType(types, ITYPE_STATUS_BAR)) { - return; - } - mStatusBar.showTransientUnchecked(); - } - - @Override - public void toggleKeyboardShortcutsMenu(int deviceId) { - mStatusBar.resendMessage(new StatusBar.KeyboardShortcutsMessage(deviceId)); - } - - @Override - public void setTopAppHidesStatusBar(boolean topAppHidesStatusBar) { - mStatusBarHideIconsForBouncerManager - .setTopAppHidesStatusBarAndTriggerUpdate(topAppHidesStatusBar); - } - - @Override - public void showAssistDisclosure() { - mAssistManager.showDisclosure(); - } - - @Override - public void showPinningEnterExitToast(boolean entering) { - mStatusBar.showPinningEnterExitToast(entering); - } - - @Override - public void showPinningEscapeToast() { - mStatusBar.showPinningEscapeToast(); - } - - @Override - public void showScreenPinningRequest(int taskId) { - if (mKeyguardStateController.isShowing()) { - // Don't allow apps to trigger this from keyguard. - return; - } - // Show screen pinning request, since this comes from an app, show 'no thanks', button. - mStatusBar.showScreenPinningRequest(taskId, true); - } - - @Override - public void showWirelessChargingAnimation(int batteryLevel) { - mStatusBar.showWirelessChargingAnimation(batteryLevel); - } - - @Override - public void startAssist(Bundle args) { - mAssistManager.startAssist(args); - } - - @Override - public void suppressAmbientDisplay(boolean suppressed) { - mDozeServiceHost.setAlwaysOnSuppressed(suppressed); - } - - @Override - public void togglePanel() { - if (mStatusBar.isPanelExpanded()) { - mShadeController.animateCollapsePanels(); - } else { - animateExpandNotificationsPanel(); - } - } - - private boolean isGoingToSleep() { - return mWakefulnessLifecycle.getWakefulness() - == WakefulnessLifecycle.WAKEFULNESS_GOING_TO_SLEEP; - } - - private boolean isWakingUpOrAwake() { - return mWakefulnessLifecycle.getWakefulness() == WAKEFULNESS_AWAKE - || mWakefulnessLifecycle.getWakefulness() == WAKEFULNESS_WAKING; - } - - private void vibrateForCameraGesture() { - mVibratorOptional.ifPresent( - v -> v.vibrate(mCameraLaunchGestureVibrationEffect, - HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES)); - } - - private static VibrationEffect getCameraGestureVibrationEffect( - Optional vibratorOptional, Resources resources) { - if (vibratorOptional.isPresent() && vibratorOptional.get().areAllPrimitivesSupported( - VibrationEffect.Composition.PRIMITIVE_QUICK_RISE, - VibrationEffect.Composition.PRIMITIVE_CLICK)) { - return VibrationEffect.startComposition() - .addPrimitive(VibrationEffect.Composition.PRIMITIVE_QUICK_RISE) - .addPrimitive(VibrationEffect.Composition.PRIMITIVE_CLICK, 1, 50) - .compose(); - } - if (vibratorOptional.isPresent() && vibratorOptional.get().hasAmplitudeControl()) { - // Make sure to pass -1 for repeat so VibratorManagerService doesn't stop us when going - // to sleep. - return VibrationEffect.createWaveform( - StatusBar.CAMERA_LAUNCH_GESTURE_VIBRATION_TIMINGS, - StatusBar.CAMERA_LAUNCH_GESTURE_VIBRATION_AMPLITUDES, - /* repeat= */ -1); - } - - int[] pattern = resources.getIntArray(R.array.config_cameraLaunchGestureVibePattern); - long[] timings = new long[pattern.length]; - for (int i = 0; i < pattern.length; i++) { - timings[i] = pattern[i]; - } - return VibrationEffect.createWaveform(timings, /* repeat= */ -1); - } -} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeadsUpChangeListener.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeadsUpChangeListener.java index 6eeae7f29839..50f21691b044 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeadsUpChangeListener.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeadsUpChangeListener.java @@ -22,14 +22,16 @@ import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.init.NotificationsController; -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent; import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener; import com.android.systemui.statusbar.window.StatusBarWindowController; import javax.inject.Inject; -/** Ties the {@link StatusBar} to {@link com.android.systemui.statusbar.policy.HeadsUpManager}. */ -@StatusBarComponent.StatusBarScope +/** + * Ties the {@link CentralSurfaces} to {@link com.android.systemui.statusbar.policy.HeadsUpManager}. + */ +@CentralSurfacesComponent.CentralSurfacesScope public class StatusBarHeadsUpChangeListener implements OnHeadsUpChangedListener { private final NotificationShadeWindowController mNotificationShadeWindowController; private final StatusBarWindowController mStatusBarWindowController; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java index c5d3937173e7..94b4979b1fd6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java @@ -245,7 +245,7 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu /** * Accept a list of CallIndicatorIconStates, and show the call strength icons. - * @param slot StatusBar slot for the call strength icons + * @param slot statusbar slot for the call strength icons * @param states All of the no Calling & SMS icon states */ @Override @@ -272,7 +272,7 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu /** * Accept a list of CallIndicatorIconStates, and show the no calling icons. - * @param slot StatusBar slot for the no calling icons + * @param slot statusbar slot for the no calling icons * @param states All of the no Calling & SMS icon states */ @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index a96ba56be58d..c160c22203a5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -124,8 +124,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb @Override public void onFullyShown() { updateStates(); - mStatusBar.wakeUpIfDozing(SystemClock.uptimeMillis(), - mStatusBar.getBouncerContainer(), "BOUNCER_VISIBLE"); + mCentralSurfaces.wakeUpIfDozing(SystemClock.uptimeMillis(), + mCentralSurfaces.getBouncerContainer(), "BOUNCER_VISIBLE"); } @Override @@ -175,7 +175,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb protected LockPatternUtils mLockPatternUtils; protected ViewMediatorCallback mViewMediatorCallback; - protected StatusBar mStatusBar; + protected CentralSurfaces mCentralSurfaces; private NotificationPanelViewController mNotificationPanelViewController; private BiometricUnlockController mBiometricUnlockController; @@ -277,16 +277,16 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } @Override - public void registerStatusBar(StatusBar statusBar, + public void registerCentralSurfaces(CentralSurfaces centralSurfaces, NotificationPanelViewController notificationPanelViewController, PanelExpansionStateManager panelExpansionStateManager, BiometricUnlockController biometricUnlockController, View notificationContainer, KeyguardBypassController bypassController) { - mStatusBar = statusBar; + mCentralSurfaces = centralSurfaces; mBiometricUnlockController = biometricUnlockController; - ViewGroup container = mStatusBar.getBouncerContainer(); + ViewGroup container = mCentralSurfaces.getBouncerContainer(); mBouncer = mKeyguardBouncerFactory.create(container, mExpansionCallback); mNotificationPanelViewController = notificationPanelViewController; if (panelExpansionStateManager != null) { @@ -354,13 +354,13 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } else if (mStatusBarStateController.getState() == StatusBarState.SHADE_LOCKED && mKeyguardUpdateManager.isUdfpsEnrolled()) { // Don't expand to the bouncer. Instead transition back to the lock screen (see - // StatusBar#showBouncerOrLockScreenIfKeyguard) where the user can use the UDFPS + // CentralSurfaces#showBouncerOrLockScreenIfKeyguard) where the user can use the UDFPS // affordance to enter the device (or swipe up to the input bouncer) return; } else if (bouncerNeedsScrimming()) { mBouncer.setExpansion(KeyguardBouncer.EXPANSION_VISIBLE); } else if (mShowing) { - if (!isWakeAndUnlocking() && !mStatusBar.isInLaunchTransition()) { + if (!isWakeAndUnlocking() && !mCentralSurfaces.isInLaunchTransition()) { mBouncer.setExpansion(fraction); } if (fraction != KeyguardBouncer.EXPANSION_HIDDEN && tracking @@ -371,7 +371,9 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } else if (mPulsing && fraction == KeyguardBouncer.EXPANSION_VISIBLE) { // Panel expanded while pulsing but didn't translate the bouncer (because we are // unlocked.) Let's simply wake-up to dismiss the lock screen. - mStatusBar.wakeUpIfDozing(SystemClock.uptimeMillis(), mStatusBar.getBouncerContainer(), + mCentralSurfaces.wakeUpIfDozing( + SystemClock.uptimeMillis(), + mCentralSurfaces.getBouncerContainer(), "BOUNCER_VISIBLE"); } } @@ -408,10 +410,10 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb protected void showBouncerOrKeyguard(boolean hideBouncerWhenShowing) { if (mBouncer.needsFullscreenBouncer() && !mDozing) { // The keyguard might be showing (already). So we need to hide it. - mStatusBar.hideKeyguard(); + mCentralSurfaces.hideKeyguard(); mBouncer.show(true /* resetSecuritySelection */); } else { - mStatusBar.showKeyguard(); + mCentralSurfaces.showKeyguard(); if (hideBouncerWhenShowing) { hideBouncer(false /* destroyView */); mBouncer.prepare(); @@ -540,7 +542,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mNotificationPanelViewController.resetViews(/* animate= */ true); // Hide bouncer and quick-quick settings. if (mOccluded && !mDozing) { - mStatusBar.hideKeyguard(); + mCentralSurfaces.hideKeyguard(); if (hideBouncerWhenShowing || mBouncer.needsFullscreenBouncer()) { hideBouncer(false /* destroyView */); } @@ -570,15 +572,15 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mBypassController.setAltBouncerShowing(isShowingAlternateAuth()); if (updateScrim) { - mStatusBar.updateScrimController(); + mCentralSurfaces.updateScrimController(); } } @Override public void onStartedWakingUp() { - mStatusBar.getNotificationShadeWindowView().getWindowInsetsController() + mCentralSurfaces.getNotificationShadeWindowView().getWindowInsetsController() .setAnimationsDisabled(false); - NavigationBarView navBarView = mStatusBar.getNavigationBarView(); + NavigationBarView navBarView = mCentralSurfaces.getNavigationBarView(); if (navBarView != null) { navBarView.forEachView(view -> view.animate() @@ -590,9 +592,9 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb @Override public void onStartedGoingToSleep() { - mStatusBar.getNotificationShadeWindowView().getWindowInsetsController() + mCentralSurfaces.getNotificationShadeWindowView().getWindowInsetsController() .setAnimationsDisabled(true); - NavigationBarView navBarView = mStatusBar.getNavigationBarView(); + NavigationBarView navBarView = mCentralSurfaces.getNavigationBarView(); if (navBarView != null) { navBarView.forEachView(view -> view.animate() @@ -628,7 +630,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } /** - * If {@link StatusBar} is pulsing. + * If {@link CentralSurfaces} is pulsing. */ public void setPulsing(boolean pulsing) { if (mPulsing != pulsing) { @@ -649,13 +651,13 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb @Override public void setOccluded(boolean occluded, boolean animate) { - mStatusBar.setOccluded(occluded); + mCentralSurfaces.setOccluded(occluded); if (occluded && !mOccluded && mShowing) { SysUiStatsLog.write(SysUiStatsLog.KEYGUARD_STATE_CHANGED, SysUiStatsLog.KEYGUARD_STATE_CHANGED__STATE__OCCLUDED); - if (mStatusBar.isInLaunchTransition()) { + if (mCentralSurfaces.isInLaunchTransition()) { setOccludedAndUpdateStates(true); - mStatusBar.fadeKeyguardAfterLaunchTransition(null /* beforeFading */, + mCentralSurfaces.fadeKeyguardAfterLaunchTransition(null /* beforeFading */, new Runnable() { @Override public void run() { @@ -666,7 +668,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb return; } - if (mStatusBar.isLaunchingActivityOverLockscreen()) { + if (mCentralSurfaces.isLaunchingActivityOverLockscreen()) { setOccludedAndUpdateStates(true); // When isLaunchingActivityOverLockscreen() is true, we know for sure that the post @@ -695,7 +697,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb reset(isOccluding /* hideBouncerWhenShowing*/); } if (animate && !occluded && mShowing && !mBouncer.isShowing()) { - mStatusBar.animateKeyguardUnoccluding(); + mCentralSurfaces.animateKeyguardUnoccluding(); } } @@ -712,7 +714,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb public void startPreHideAnimation(Runnable finishRunnable) { if (mBouncer.isShowing()) { mBouncer.startPreHideAnimation(finishRunnable); - mStatusBar.onBouncerPreHideAnimation(); + mCentralSurfaces.onBouncerPreHideAnimation(); // We update the state (which will show the keyguard) only if an animation will run on // the keyguard. If there is no animation, we wait before updating the state so that we @@ -745,11 +747,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb long uptimeMillis = SystemClock.uptimeMillis(); long delay = Math.max(0, startTime + HIDE_TIMING_CORRECTION_MS - uptimeMillis); - if (mStatusBar.isInLaunchTransition() + if (mCentralSurfaces.isInLaunchTransition() || mKeyguardStateController.isFlingingToDismissKeyguard()) { final boolean wasFlingingToDismissKeyguard = mKeyguardStateController.isFlingingToDismissKeyguard(); - mStatusBar.fadeKeyguardAfterLaunchTransition(new Runnable() { + mCentralSurfaces.fadeKeyguardAfterLaunchTransition(new Runnable() { @Override public void run() { mNotificationShadeWindowController.setKeyguardShowing(false); @@ -760,11 +762,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb }, new Runnable() { @Override public void run() { - mStatusBar.hideKeyguard(); + mCentralSurfaces.hideKeyguard(); mNotificationShadeWindowController.setKeyguardFadingAway(false); if (wasFlingingToDismissKeyguard) { - mStatusBar.finishKeyguardFadingAway(); + mCentralSurfaces.finishKeyguardFadingAway(); } mViewMediatorCallback.keyguardGone(); @@ -783,7 +785,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb delay = 0; fadeoutDuration = 240; } - mStatusBar.setKeyguardFadingAway(startTime, delay, fadeoutDuration, needsFading); + mCentralSurfaces.setKeyguardFadingAway(startTime, delay, fadeoutDuration, needsFading); mBiometricUnlockController.startKeyguardFadingAway(); hideBouncer(true /* destroyView */); if (wakeUnlockPulsing) { @@ -793,11 +795,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mNotificationContainer, fadeoutDuration, () -> { - mStatusBar.hideKeyguard(); + mCentralSurfaces.hideKeyguard(); onKeyguardFadedAway(); }); } else { - mStatusBar.fadeKeyguardWhilePulsing(); + mCentralSurfaces.fadeKeyguardWhilePulsing(); } wakeAndUnlockDejank(); } else { @@ -810,20 +812,20 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mNotificationContainer, fadeoutDuration, () -> { - mStatusBar.hideKeyguard(); + mCentralSurfaces.hideKeyguard(); }); } else { - mStatusBar.hideKeyguard(); + mCentralSurfaces.hideKeyguard(); } // hide() will happen asynchronously and might arrive after the scrims // were already hidden, this means that the transition callback won't // be triggered anymore and StatusBarWindowController will be forever in // the fadingAway state. - mStatusBar.updateScrimController(); + mCentralSurfaces.updateScrimController(); wakeAndUnlockDejank(); } else { - mStatusBar.hideKeyguard(); - mStatusBar.finishKeyguardFadingAway(); + mCentralSurfaces.hideKeyguard(); + mCentralSurfaces.finishKeyguardFadingAway(); mBiometricUnlockController.finishKeyguardFadingAway(); } } @@ -866,7 +868,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mNotificationContainer.postDelayed(() -> mNotificationShadeWindowController .setKeyguardFadingAway(false), 100); ViewGroupFadeHelper.reset(mNotificationPanelViewController.getView()); - mStatusBar.finishKeyguardFadingAway(); + mCentralSurfaces.finishKeyguardFadingAway(); mBiometricUnlockController.finishKeyguardFadingAway(); WindowManagerGlobal.getInstance().trimMemory( ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN); @@ -897,7 +899,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb @Override public void dismissAndCollapse() { - mStatusBar.executeRunnableDismissingKeyguard(null, null, true, false, true); + mCentralSurfaces.executeRunnableDismissingKeyguard(null, null, true, false, true); } /** @@ -922,7 +924,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb */ public boolean onBackPressed(boolean hideImmediately) { if (mBouncer.isShowing()) { - mStatusBar.endAffordanceLaunch(); + mCentralSurfaces.endAffordanceLaunch(); // The second condition is for SIM card locked bouncer if (mBouncer.isScrimmed() && !mBouncer.needsFullscreenBouncer()) { hideBouncer(false); @@ -978,11 +980,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb private Runnable mMakeNavigationBarVisibleRunnable = new Runnable() { @Override public void run() { - NavigationBarView view = mStatusBar.getNavigationBarView(); + NavigationBarView view = mCentralSurfaces.getNavigationBarView(); if (view != null) { view.setVisibility(View.VISIBLE); } - mStatusBar.getNotificationShadeWindowView().getWindowInsetsController() + mCentralSurfaces.getNotificationShadeWindowView().getWindowInsetsController() .show(navigationBars()); } }; @@ -1013,7 +1015,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) { mNotificationShadeWindowController.setBouncerShowing(bouncerShowing); - mStatusBar.setBouncerShowing(bouncerShowing); + mCentralSurfaces.setBouncerShowing(bouncerShowing); } if (occluded != mLastOccluded || mFirstUpdate) { @@ -1040,11 +1042,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mLastBiometricMode = mBiometricUnlockController.getMode(); mLastGesturalNav = mGesturalNav; mLastIsDocked = mIsDocked; - mStatusBar.onKeyguardViewManagerStatesUpdated(); + mCentralSurfaces.onKeyguardViewManagerStatesUpdated(); } private View getCurrentNavBarView() { - final NavigationBarView navBarView = mStatusBar.getNavigationBarView(); + final NavigationBarView navBarView = mCentralSurfaces.getNavigationBarView(); return navBarView != null ? navBarView.getCurrentView() : null; } @@ -1052,7 +1054,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb * Updates the visibility of the nav bar window (which will cause insets changes). */ protected void updateNavigationBarVisibility(boolean navBarVisible) { - if (mStatusBar.getNavigationBarView() != null) { + if (mCentralSurfaces.getNavigationBarView() != null) { if (navBarVisible) { long delay = getNavBarShowDelay(); if (delay == 0) { @@ -1063,7 +1065,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } } else { mNotificationContainer.removeCallbacks(mMakeNavigationBarVisibleRunnable); - mStatusBar.getNotificationShadeWindowView().getWindowInsetsController() + mCentralSurfaces.getNotificationShadeWindowView().getWindowInsetsController() .hide(navigationBars()); } } @@ -1120,7 +1122,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb @Override public boolean shouldDisableWindowAnimationsForUnlock() { - return mStatusBar.isInLaunchTransition(); + return mCentralSurfaces.isInLaunchTransition(); } @Override @@ -1139,7 +1141,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb @Override public void keyguardGoingAway() { - mStatusBar.keyguardGoingAway(); + mCentralSurfaces.keyguardGoingAway(); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarLaunchAnimatorController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarLaunchAnimatorController.kt index 09fca100749c..56b6dfc42ee3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarLaunchAnimatorController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarLaunchAnimatorController.kt @@ -10,34 +10,34 @@ import com.android.systemui.animation.LaunchAnimator */ class StatusBarLaunchAnimatorController( private val delegate: ActivityLaunchAnimator.Controller, - private val statusBar: StatusBar, + private val centralSurfaces: CentralSurfaces, private val isLaunchForActivity: Boolean = true ) : ActivityLaunchAnimator.Controller by delegate { // Always sync the opening window with the shade, given that we draw a hole punch in the shade // of the same size and position as the opening app to make it visible. override val openingWindowSyncView: View? - get() = statusBar.notificationShadeWindowView + get() = centralSurfaces.notificationShadeWindowView override fun onIntentStarted(willAnimate: Boolean) { delegate.onIntentStarted(willAnimate) if (!willAnimate) { - statusBar.collapsePanelOnMainThread() + centralSurfaces.collapsePanelOnMainThread() } } override fun onLaunchAnimationStart(isExpandingFullyAbove: Boolean) { delegate.onLaunchAnimationStart(isExpandingFullyAbove) - statusBar.notificationPanelViewController.setIsLaunchAnimationRunning(true) + centralSurfaces.notificationPanelViewController.setIsLaunchAnimationRunning(true) if (!isExpandingFullyAbove) { - statusBar.collapsePanelWithDuration( + centralSurfaces.collapsePanelWithDuration( ActivityLaunchAnimator.TIMINGS.totalDuration.toInt()) } } override fun onLaunchAnimationEnd(isExpandingFullyAbove: Boolean) { delegate.onLaunchAnimationEnd(isExpandingFullyAbove) - statusBar.notificationPanelViewController.setIsLaunchAnimationRunning(false) - statusBar.onLaunchAnimationEnd(isExpandingFullyAbove) + centralSurfaces.notificationPanelViewController.setIsLaunchAnimationRunning(false) + centralSurfaces.onLaunchAnimationEnd(isExpandingFullyAbove) } override fun onLaunchAnimationProgress( @@ -46,11 +46,11 @@ class StatusBarLaunchAnimatorController( linearProgress: Float ) { delegate.onLaunchAnimationProgress(state, progress, linearProgress) - statusBar.notificationPanelViewController.applyLaunchAnimationProgress(linearProgress) + centralSurfaces.notificationPanelViewController.applyLaunchAnimationProgress(linearProgress) } override fun onLaunchAnimationCancelled() { delegate.onLaunchAnimationCancelled() - statusBar.onLaunchAnimationCancelled(isLaunchForActivity) + centralSurfaces.onLaunchAnimationCancelled(isLaunchForActivity) } } \ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java index 74a1565df3fe..edbddbb3c3e7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java @@ -18,7 +18,7 @@ package com.android.systemui.statusbar.phone; import static android.service.notification.NotificationListenerService.REASON_CLICK; -import static com.android.systemui.statusbar.phone.StatusBar.getActivityOptions; +import static com.android.systemui.statusbar.phone.CentralSurfaces.getActivityOptions; import android.app.ActivityManager; import android.app.KeyguardManager; @@ -72,7 +72,7 @@ import com.android.systemui.statusbar.notification.interruption.NotificationInte import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRowDragController; import com.android.systemui.statusbar.notification.row.OnUserInteractionCallback; -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent; import com.android.systemui.statusbar.policy.HeadsUpUtil; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.wmshell.BubblesManager; @@ -87,7 +87,7 @@ import dagger.Lazy; /** * Status bar implementation of {@link NotificationActivityStarter}. */ -@StatusBarComponent.StatusBarScope +@CentralSurfacesComponent.CentralSurfacesScope class StatusBarNotificationActivityStarter implements NotificationActivityStarter { private final Context mContext; @@ -122,7 +122,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte private final MetricsLogger mMetricsLogger; private final StatusBarNotificationActivityStarterLogger mLogger; - private final StatusBar mStatusBar; + private final CentralSurfaces mCentralSurfaces; private final NotificationPresenter mPresenter; private final NotificationPanelViewController mNotificationPanel; private final ActivityLaunchAnimator mActivityLaunchAnimator; @@ -162,7 +162,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte MetricsLogger metricsLogger, StatusBarNotificationActivityStarterLogger logger, OnUserInteractionCallback onUserInteractionCallback, - StatusBar statusBar, + CentralSurfaces centralSurfaces, NotificationPresenter presenter, NotificationPanelViewController panel, ActivityLaunchAnimator activityLaunchAnimator, @@ -199,7 +199,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte mOnUserInteractionCallback = onUserInteractionCallback; // TODO: use KeyguardStateController#isOccluded to remove this dependency - mStatusBar = statusBar; + mCentralSurfaces = centralSurfaces; mPresenter = presenter; mNotificationPanel = panel; mActivityLaunchAnimator = activityLaunchAnimator; @@ -259,7 +259,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte && mActivityIntentHelper.wouldLaunchResolverActivity(intent.getIntent(), mLockscreenUserManager.getCurrentUserId()); final boolean animate = !willLaunchResolverActivity - && mStatusBar.shouldAnimateLaunch(isActivityIntent); + && mCentralSurfaces.shouldAnimateLaunch(isActivityIntent); boolean showOverLockscreen = mKeyguardStateController.isShowing() && intent != null && mActivityIntentHelper.wouldShowOverLockscreen(intent.getIntent(), mLockscreenUserManager.getCurrentUserId()); @@ -300,7 +300,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte mShadeController.addPostCollapseAction(runnable); mShadeController.collapsePanel(true /* animate */); } else if (mKeyguardStateController.isShowing() - && mStatusBar.isOccluded()) { + && mCentralSurfaces.isOccluded()) { mStatusBarKeyguardViewManager.addAfterKeyguardGoneRunnable(runnable); mShadeController.collapsePanel(); } else { @@ -475,7 +475,8 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte try { ActivityLaunchAnimator.Controller animationController = new StatusBarLaunchAnimatorController( - mNotificationAnimationProvider.getAnimatorController(row), mStatusBar, + mNotificationAnimationProvider.getAnimatorController(row), + mCentralSurfaces, isActivityIntent); mActivityLaunchAnimator.startPendingIntentWithAnimation(animationController, @@ -483,11 +484,11 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte long eventTime = row.getAndResetLastActionUpTime(); Bundle options = eventTime > 0 ? getActivityOptions( - mStatusBar.getDisplayId(), + mCentralSurfaces.getDisplayId(), adapter, mKeyguardStateController.isShowing(), eventTime) - : getActivityOptions(mStatusBar.getDisplayId(), adapter); + : getActivityOptions(mCentralSurfaces.getDisplayId(), adapter); return intent.sendAndReturnResult(mContext, 0, fillInIntent, null, null, null, options); }); @@ -502,7 +503,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte @Override public void startNotificationGutsIntent(final Intent intent, final int appUid, ExpandableNotificationRow row) { - boolean animate = mStatusBar.shouldAnimateLaunch(true /* isActivityIntent */); + boolean animate = mCentralSurfaces.shouldAnimateLaunch(true /* isActivityIntent */); ActivityStarter.OnDismissAction onDismissAction = new ActivityStarter.OnDismissAction() { @Override public boolean onDismiss() { @@ -510,14 +511,14 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte ActivityLaunchAnimator.Controller animationController = new StatusBarLaunchAnimatorController( mNotificationAnimationProvider.getAnimatorController(row), - mStatusBar, true /* isActivityIntent */); + mCentralSurfaces, true /* isActivityIntent */); mActivityLaunchAnimator.startIntentWithAnimation( animationController, animate, intent.getPackage(), (adapter) -> TaskStackBuilder.create(mContext) .addNextIntentWithParentStack(intent) .startActivities(getActivityOptions( - mStatusBar.getDisplayId(), + mCentralSurfaces.getDisplayId(), adapter), new UserHandle(UserHandle.getUserId(appUid)))); }); @@ -535,7 +536,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte @Override public void startHistoryIntent(View view, boolean showHistory) { - boolean animate = mStatusBar.shouldAnimateLaunch(true /* isActivityIntent */); + boolean animate = mCentralSurfaces.shouldAnimateLaunch(true /* isActivityIntent */); ActivityStarter.OnDismissAction onDismissAction = new ActivityStarter.OnDismissAction() { @Override public boolean onDismiss() { @@ -555,13 +556,14 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte ); ActivityLaunchAnimator.Controller animationController = viewController == null ? null - : new StatusBarLaunchAnimatorController(viewController, mStatusBar, + : new StatusBarLaunchAnimatorController(viewController, + mCentralSurfaces, true /* isActivityIntent */); mActivityLaunchAnimator.startIntentWithAnimation(animationController, animate, intent.getPackage(), (adapter) -> tsb.startActivities( - getActivityOptions(mStatusBar.getDisplayId(), adapter), + getActivityOptions(mCentralSurfaces.getDisplayId(), adapter), UserHandle.CURRENT)); }); return true; @@ -615,7 +617,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte try { EventLog.writeEvent(EventLogTags.SYSUI_FULLSCREEN_NOTIFICATION, entry.getKey()); - mStatusBar.wakeUpForFullScreenIntent(); + mCentralSurfaces.wakeUpForFullScreenIntent(); fullscreenIntent.send(); entry.notifyFullScreenIntentLaunched(); mMetricsLogger.count("note_fullscreen", 1); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java index de66bb09ccf8..aa061d74f6c6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java @@ -14,9 +14,9 @@ package com.android.systemui.statusbar.phone; -import static com.android.systemui.statusbar.phone.StatusBar.CLOSE_PANEL_WHEN_EMPTIED; -import static com.android.systemui.statusbar.phone.StatusBar.DEBUG; -import static com.android.systemui.statusbar.phone.StatusBar.MULTIUSER_DEBUG; +import static com.android.systemui.statusbar.phone.CentralSurfaces.CLOSE_PANEL_WHEN_EMPTIED; +import static com.android.systemui.statusbar.phone.CentralSurfaces.DEBUG; +import static com.android.systemui.statusbar.phone.CentralSurfaces.MULTIUSER_DEBUG; import android.app.KeyguardManager; import android.content.Context; @@ -71,7 +71,7 @@ import com.android.systemui.statusbar.notification.row.NotificationInfo.CheckSav import com.android.systemui.statusbar.notification.stack.NotificationListContainer; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; import com.android.systemui.statusbar.phone.LockscreenGestureLogger.LockscreenUiEvent; -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.KeyguardStateController; @@ -79,7 +79,7 @@ import java.util.List; import javax.inject.Inject; -@StatusBarComponent.StatusBarScope +@CentralSurfacesComponent.CentralSurfacesScope class StatusBarNotificationPresenter implements NotificationPresenter, ConfigurationController.ConfigurationListener, NotificationRowBinderImpl.BindRowCallback, @@ -104,7 +104,7 @@ class StatusBarNotificationPresenter implements NotificationPresenter, private final DozeScrimController mDozeScrimController; private final ScrimController mScrimController; private final KeyguardIndicationController mKeyguardIndicationController; - private final StatusBar mStatusBar; + private final CentralSurfaces mCentralSurfaces; private final ShadeController mShadeController; private final LockscreenShadeTransitionController mShadeTransitionController; private final CommandQueue mCommandQueue; @@ -135,7 +135,7 @@ class StatusBarNotificationPresenter implements NotificationPresenter, DynamicPrivacyController dynamicPrivacyController, KeyguardStateController keyguardStateController, KeyguardIndicationController keyguardIndicationController, - StatusBar statusBar, + CentralSurfaces centralSurfaces, ShadeController shadeController, LockscreenShadeTransitionController shadeTransitionController, CommandQueue commandQueue, @@ -162,7 +162,7 @@ class StatusBarNotificationPresenter implements NotificationPresenter, mDynamicPrivacyController = dynamicPrivacyController; mKeyguardIndicationController = keyguardIndicationController; // TODO: use KeyguardStateController#isOccluded to remove this dependency - mStatusBar = statusBar; + mCentralSurfaces = centralSurfaces; mShadeController = shadeController; mShadeTransitionController = shadeTransitionController; mCommandQueue = commandQueue; @@ -352,7 +352,7 @@ class StatusBarNotificationPresenter implements NotificationPresenter, updateNotificationViews("user switched"); } mMediaManager.clearCurrentMediaNotification(); - mStatusBar.setLockscreenUser(newUserId); + mCentralSurfaces.setLockscreenUser(newUserId); updateMediaMetaData(true, false); } @@ -406,7 +406,8 @@ class StatusBarNotificationPresenter implements NotificationPresenter, public void onExpandClicked(NotificationEntry clickedEntry, View clickedView, boolean nowExpanded) { mHeadsUpManager.setExpanded(clickedEntry, nowExpanded); - mStatusBar.wakeUpIfDozing(SystemClock.uptimeMillis(), clickedView, "NOTIFICATION_CLICK"); + mCentralSurfaces.wakeUpIfDozing( + SystemClock.uptimeMillis(), clickedView, "NOTIFICATION_CLICK"); if (nowExpanded) { if (mStatusBarStateController.getState() == StatusBarState.KEYGUARD) { mShadeTransitionController.goToLockedShade(clickedEntry.getRow()); @@ -474,7 +475,7 @@ class StatusBarNotificationPresenter implements NotificationPresenter, @Override public boolean suppressAwakeHeadsUp(NotificationEntry entry) { final StatusBarNotification sbn = entry.getSbn(); - if (mStatusBar.isOccluded()) { + if (mCentralSurfaces.isOccluded()) { boolean devicePublic = mLockscreenUserManager .isLockscreenPublicMode(mLockscreenUserManager.getCurrentUserId()); boolean userPublic = devicePublic @@ -497,7 +498,7 @@ class StatusBarNotificationPresenter implements NotificationPresenter, // we don't allow head-up on the lockscreen (unless there's a // "showWhenLocked" activity currently showing) if // the potential HUN has a fullscreen intent - if (mKeyguardStateController.isShowing() && !mStatusBar.isOccluded()) { + if (mKeyguardStateController.isShowing() && !mCentralSurfaces.isOccluded()) { if (DEBUG) { Log.d(TAG, "No heads up: entry has fullscreen intent on lockscreen " + sbn.getKey()); @@ -522,7 +523,7 @@ class StatusBarNotificationPresenter implements NotificationPresenter, @Override public boolean suppressInterruptions(NotificationEntry entry) { - return mStatusBar.areNotificationAlertsDisabled(); + return mCentralSurfaces.areNotificationAlertsDisabled(); } }; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarSignalPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarSignalPolicy.java index b0206f073011..ee242a4b1b75 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarSignalPolicy.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarSignalPolicy.java @@ -44,7 +44,7 @@ import java.util.Objects; import javax.inject.Inject; -/** Controls the signal policies for icons shown in the StatusBar. **/ +/** Controls the signal policies for icons shown in the statusbar. **/ @SysUISingleton public class StatusBarSignalPolicy implements SignalCallback, SecurityController.SecurityControllerCallback, Tunable { @@ -449,7 +449,7 @@ public class StatusBarSignalPolicy implements SignalCallback, } /** - * Stores the StatusBar state for no Calling & SMS. + * Stores the statusbar state for no Calling & SMS. */ public static class CallIndicatorIconState { public boolean isNoCalling; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java index b742394b18a5..95667cc0b972 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java @@ -59,7 +59,7 @@ public final class StatusBarTouchableRegionManager implements Dumpable { private boolean mIsStatusBarExpanded = false; private boolean mShouldAdjustInsets = false; - private StatusBar mStatusBar; + private CentralSurfaces mCentralSurfaces; private View mNotificationShadeWindowView; private View mNotificationPanelView; private boolean mForceCollapsedUntilLayout = false; @@ -119,9 +119,9 @@ public final class StatusBarTouchableRegionManager implements Dumpable { } protected void setup( - @NonNull StatusBar statusBar, + @NonNull CentralSurfaces centralSurfaces, @NonNull View notificationShadeWindowView) { - mStatusBar = statusBar; + mCentralSurfaces = centralSurfaces; mNotificationShadeWindowView = notificationShadeWindowView; mNotificationPanelView = mNotificationShadeWindowView.findViewById(R.id.notification_panel); } @@ -246,7 +246,7 @@ public final class StatusBarTouchableRegionManager implements Dumpable { new OnComputeInternalInsetsListener() { @Override public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo info) { - if (mIsStatusBarExpanded || mStatusBar.isBouncerShowing()) { + if (mIsStatusBarExpanded || mCentralSurfaces.isBouncerShowing()) { // The touchable region is always the full area when expanded return; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/TapAgainViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/TapAgainViewController.java index 26ba31c6f526..582afb1a23ea 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/TapAgainViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/TapAgainViewController.java @@ -20,7 +20,7 @@ import static com.android.systemui.classifier.FalsingModule.DOUBLE_TAP_TIMEOUT_M import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.dagger.qualifiers.Main; -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; import com.android.systemui.util.ViewController; @@ -32,7 +32,7 @@ import javax.inject.Named; /** * Controller for {@link TapAgainView}. */ -@StatusBarComponent.StatusBarScope +@CentralSurfacesComponent.CentralSurfacesScope public class TapAgainViewController extends ViewController { private final DelayableExecutor mDelayableExecutor; private final ConfigurationController mConfigurationController; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt index 09ff46bed074..c11d450e47b2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt @@ -60,7 +60,7 @@ class UnlockedScreenOffAnimationController @Inject constructor( private val handler: Handler = Handler() ) : WakefulnessLifecycle.Observer, ScreenOffAnimation { - private lateinit var statusBar: StatusBar + private lateinit var mCentralSurfaces: CentralSurfaces private lateinit var lightRevealScrim: LightRevealScrim private var animatorDurationScale = 1f @@ -100,7 +100,8 @@ class UnlockedScreenOffAnimationController @Inject constructor( } override fun onAnimationStart(animation: Animator?) { - interactionJankMonitor.begin(statusBar.notificationShadeWindowView, CUJ_SCREEN_OFF) + interactionJankMonitor.begin( + mCentralSurfaces.notificationShadeWindowView, CUJ_SCREEN_OFF) } }) } @@ -112,11 +113,11 @@ class UnlockedScreenOffAnimationController @Inject constructor( } override fun initialize( - statusBar: StatusBar, + centralSurfaces: CentralSurfaces, lightRevealScrim: LightRevealScrim ) { this.lightRevealScrim = lightRevealScrim - this.statusBar = statusBar + this.mCentralSurfaces = centralSurfaces updateAnimatorDurationScale() globalSettings.registerContentObserver( @@ -171,9 +172,9 @@ class UnlockedScreenOffAnimationController @Inject constructor( // Lock the keyguard if it was waiting for the screen off animation to end. keyguardViewMediatorLazy.get().maybeHandlePendingLock() - // Tell the StatusBar to become keyguard for real - we waited on that since - // it is slow and would have caused the animation to jank. - statusBar.updateIsKeyguard() + // Tell the CentralSurfaces to become keyguard for real - we waited on that + // since it is slow and would have caused the animation to jank. + mCentralSurfaces.updateIsKeyguard() // Run the callback given to us by the KeyguardVisibilityHelper. after.run() @@ -191,7 +192,8 @@ class UnlockedScreenOffAnimationController @Inject constructor( override fun onAnimationStart(animation: Animator?) { interactionJankMonitor.begin( - statusBar.notificationShadeWindowView, CUJ_SCREEN_OFF_SHOW_AOD) + mCentralSurfaces.notificationShadeWindowView, + CUJ_SCREEN_OFF_SHOW_AOD) } }) .start() @@ -208,12 +210,12 @@ class UnlockedScreenOffAnimationController @Inject constructor( override fun onFinishedWakingUp() { // Set this to false in onFinishedWakingUp rather than onStartedWakingUp so that other - // observers (such as StatusBar) can ask us whether we were playing the screen off animation - // and reset accordingly. + // observers (such as CentralSurfaces) can ask us whether we were playing the screen off + // animation and reset accordingly. aodUiAnimationPlaying = false - // If we can't control the screen off animation, we shouldn't mess with the StatusBar's - // keyguard state unnecessarily. + // If we can't control the screen off animation, we shouldn't mess with the + // CentralSurfaces's keyguard state unnecessarily. if (dozeParameters.get().canControlUnlockedScreenOff()) { // Make sure the status bar is in the correct keyguard state, forcing it if necessary. // This is required if the screen off animation is cancelled, since it might be @@ -222,7 +224,7 @@ class UnlockedScreenOffAnimationController @Inject constructor( // even if we're going from SHADE to SHADE or KEYGUARD to KEYGUARD, since we might have // changed parts of the UI (such as showing AOD in the shade) without actually changing // the StatusBarState. This ensures that the UI definitely reflects the desired state. - statusBar.updateIsKeyguard(true /* forceStateChange */) + mCentralSurfaces.updateIsKeyguard(true /* forceStateChange */) } } @@ -244,7 +246,7 @@ class UnlockedScreenOffAnimationController @Inject constructor( // Show AOD. That'll cause the KeyguardVisibilityHelper to call // #animateInKeyguard. - statusBar.notificationPanelViewController.showAodUi() + mCentralSurfaces.notificationPanelViewController.showAodUi() } }, (ANIMATE_IN_KEYGUARD_DELAY * animatorDurationScale).toLong()) @@ -280,8 +282,8 @@ class UnlockedScreenOffAnimationController @Inject constructor( // We currently draw both the light reveal scrim, and the AOD UI, in the shade. If it's // already expanded and showing notifications/QS, the animation looks really messy. For now, // disable it if the notification panel is not fully collapsed. - if ((!this::statusBar.isInitialized || - !statusBar.notificationPanelViewController.isFullyCollapsed) && + if ((!this::mCentralSurfaces.isInitialized || + !mCentralSurfaces.notificationPanelViewController.isFullyCollapsed) && // Status bar might be expanded because we have started // playing the animation already !isAnimationPlaying() diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/CentralSurfacesComponent.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/CentralSurfacesComponent.java new file mode 100644 index 000000000000..59c9d0baea3f --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/CentralSurfacesComponent.java @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.phone.dagger; + +import static com.android.systemui.statusbar.phone.dagger.StatusBarViewModule.STATUS_BAR_FRAGMENT; + +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import com.android.keyguard.LockIconViewController; +import com.android.systemui.biometrics.AuthRippleController; +import com.android.systemui.statusbar.NotificationPresenter; +import com.android.systemui.statusbar.NotificationShelfController; +import com.android.systemui.statusbar.core.StatusBarInitializer; +import com.android.systemui.statusbar.notification.NotificationActivityStarter; +import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinderImpl; +import com.android.systemui.statusbar.notification.collection.render.StatusBarNotifPanelEventSourceModule; +import com.android.systemui.statusbar.notification.stack.NotificationListContainer; +import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; +import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutListContainerModule; +import com.android.systemui.statusbar.phone.CentralSurfacesCommandQueueCallbacks; +import com.android.systemui.statusbar.phone.NotificationPanelViewController; +import com.android.systemui.statusbar.phone.NotificationShadeWindowView; +import com.android.systemui.statusbar.phone.NotificationShadeWindowViewController; +import com.android.systemui.statusbar.phone.SplitShadeHeaderController; +import com.android.systemui.statusbar.phone.StatusBarHeadsUpChangeListener; +import com.android.systemui.statusbar.phone.StatusBarNotificationActivityStarterModule; +import com.android.systemui.statusbar.phone.StatusBarNotificationPresenterModule; +import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.util.Set; + +import javax.inject.Named; +import javax.inject.Scope; + +import dagger.Subcomponent; + +/** + * Dagger subcomponent for classes (semi-)related to the status bar. The component is created once + * inside {@link com.android.systemui.statusbar.phone.CentralSurfaces} and never re-created. + * + * TODO(b/197137564): This should likely be re-factored a bit. It includes classes that aren't + * directly related to status bar functionality, like multiple notification classes. And, the fact + * that it has many getter methods indicates that we need to access many of these classes from + * outside the component. Should more items be moved *into* this component to avoid so many getters? + */ +@Subcomponent(modules = { + NotificationStackScrollLayoutListContainerModule.class, + StatusBarNotifPanelEventSourceModule.class, + StatusBarViewModule.class, + StatusBarNotificationActivityStarterModule.class, + StatusBarNotificationPresenterModule.class, +}) +@CentralSurfacesComponent.CentralSurfacesScope +public interface CentralSurfacesComponent { + /** + * Builder for {@link CentralSurfacesComponent}. + */ + @Subcomponent.Factory + interface Factory { + CentralSurfacesComponent create(); + } + + /** + * Scope annotation for singleton items within the CentralSurfacesComponent. + */ + @Documented + @Retention(RUNTIME) + @Scope + @interface CentralSurfacesScope {} + + /** + * Performs initialization logic after {@link CentralSurfacesComponent} has been constructed. + */ + interface Startable { + void start(); + void stop(); + } + + /** + * Creates a {@link NotificationShadeWindowView}. + */ + NotificationShadeWindowView getNotificationShadeWindowView(); + + /** */ + NotificationShelfController getNotificationShelfController(); + + /** */ + NotificationStackScrollLayoutController getNotificationStackScrollLayoutController(); + + /** + * Creates a NotificationShadeWindowViewController. + */ + NotificationShadeWindowViewController getNotificationShadeWindowViewController(); + + /** + * Creates a NotificationPanelViewController. + */ + NotificationPanelViewController getNotificationPanelViewController(); + + /** + * Creates a LockIconViewController. Must be init after creation. + */ + LockIconViewController getLockIconViewController(); + + /** + * Creates an AuthRippleViewController. Must be init after creation. + */ + AuthRippleController getAuthRippleController(); + + /** + * Creates a StatusBarHeadsUpChangeListener. + */ + StatusBarHeadsUpChangeListener getStatusBarHeadsUpChangeListener(); + + /** + * Creates a CentralSurfacesCommandQueueCallbacks. + */ + CentralSurfacesCommandQueueCallbacks getCentralSurfacesCommandQueueCallbacks(); + + /** + * Creates a SplitShadeHeaderController. + */ + SplitShadeHeaderController getSplitShadeHeaderController(); + + /** + * Creates a new {@link CollapsedStatusBarFragment} each time it's called. See + * {@link StatusBarViewModule#createCollapsedStatusBarFragment}. + */ + @Named(STATUS_BAR_FRAGMENT) + CollapsedStatusBarFragment createCollapsedStatusBarFragment(); + + /** + * Creates a StatusBarInitializer + */ + StatusBarInitializer getStatusBarInitializer(); + + /** + * Set of startables to be run after a CentralSurfacesComponent has been constructed. + */ + Set getStartables(); + + NotificationActivityStarter getNotificationActivityStarter(); + + NotificationPresenter getNotificationPresenter(); + + NotificationRowBinderImpl.BindRowCallback getBindRowCallback(); + + NotificationListContainer getNotificationListContainer(); +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java deleted file mode 100644 index 75461883fa5e..000000000000 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (C) 2019 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.statusbar.phone.dagger; - -import static com.android.systemui.statusbar.phone.dagger.StatusBarViewModule.STATUS_BAR_FRAGMENT; - -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import com.android.keyguard.LockIconViewController; -import com.android.systemui.biometrics.AuthRippleController; -import com.android.systemui.statusbar.NotificationPresenter; -import com.android.systemui.statusbar.NotificationShelfController; -import com.android.systemui.statusbar.core.StatusBarInitializer; -import com.android.systemui.statusbar.notification.NotificationActivityStarter; -import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinderImpl; -import com.android.systemui.statusbar.notification.collection.render.StatusBarNotifPanelEventSourceModule; -import com.android.systemui.statusbar.notification.stack.NotificationListContainer; -import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; -import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutListContainerModule; -import com.android.systemui.statusbar.phone.NotificationPanelViewController; -import com.android.systemui.statusbar.phone.NotificationShadeWindowView; -import com.android.systemui.statusbar.phone.NotificationShadeWindowViewController; -import com.android.systemui.statusbar.phone.SplitShadeHeaderController; -import com.android.systemui.statusbar.phone.StatusBarCommandQueueCallbacks; -import com.android.systemui.statusbar.phone.StatusBarHeadsUpChangeListener; -import com.android.systemui.statusbar.phone.StatusBarNotificationActivityStarterModule; -import com.android.systemui.statusbar.phone.StatusBarNotificationPresenterModule; -import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.util.Set; - -import javax.inject.Named; -import javax.inject.Scope; - -import dagger.Subcomponent; - -/** - * Dagger subcomponent for classes (semi-)related to the status bar. The component is created once - * inside {@link com.android.systemui.statusbar.phone.StatusBar} and never re-created. - * - * TODO(b/197137564): This should likely be re-factored a bit. It includes classes that aren't - * directly related to status bar functionality, like multiple notification classes. And, the fact - * that it has many getter methods indicates that we need to access many of these classes from - * outside the component. Should more items be moved *into* this component to avoid so many getters? - */ -@Subcomponent(modules = { - NotificationStackScrollLayoutListContainerModule.class, - StatusBarNotifPanelEventSourceModule.class, - StatusBarViewModule.class, - StatusBarNotificationActivityStarterModule.class, - StatusBarNotificationPresenterModule.class, -}) -@StatusBarComponent.StatusBarScope -public interface StatusBarComponent { - - /** - * Builder for {@link StatusBarComponent}. - */ - @Subcomponent.Factory - interface Factory { - StatusBarComponent create(); - } - - /** - * Scope annotation for singleton items within the StatusBarComponent. - */ - @Documented - @Retention(RUNTIME) - @Scope - @interface StatusBarScope {} - - /** - * Performs initialization logic after {@link StatusBarComponent} has been constructed. - */ - interface Startable { - void start(); - void stop(); - } - - /** - * Creates a {@link NotificationShadeWindowView}. - */ - NotificationShadeWindowView getNotificationShadeWindowView(); - - /** */ - NotificationShelfController getNotificationShelfController(); - - /** */ - NotificationStackScrollLayoutController getNotificationStackScrollLayoutController(); - - /** - * Creates a NotificationShadeWindowViewController. - */ - NotificationShadeWindowViewController getNotificationShadeWindowViewController(); - - /** - * Creates a NotificationPanelViewController. - */ - NotificationPanelViewController getNotificationPanelViewController(); - - /** - * Creates a LockIconViewController. Must be init after creation. - */ - LockIconViewController getLockIconViewController(); - - /** - * Creates an AuthRippleViewController. Must be init after creation. - */ - AuthRippleController getAuthRippleController(); - - /** - * Creates a StatusBarHeadsUpChangeListener. - */ - StatusBarHeadsUpChangeListener getStatusBarHeadsUpChangeListener(); - - /** - * Creates a StatusBarCommandQueueCallbacks. - */ - StatusBarCommandQueueCallbacks getStatusBarCommandQueueCallbacks(); - - /** - * Creates a SplitShadeHeaderController. - */ - SplitShadeHeaderController getSplitShadeHeaderController(); - - /** - * Creates a new {@link CollapsedStatusBarFragment} each time it's called. See - * {@link StatusBarViewModule#createCollapsedStatusBarFragment}. - */ - @Named(STATUS_BAR_FRAGMENT) - CollapsedStatusBarFragment createCollapsedStatusBarFragment(); - - /** - * Creates a StatusBarInitializer - */ - StatusBarInitializer getStatusBarInitializer(); - - /** - * Set of startables to be run after a StatusBarComponent has been constructed. - */ - Set getStartables(); - - NotificationActivityStarter getNotificationActivityStarter(); - - NotificationPresenter getNotificationPresenter(); - - NotificationRowBinderImpl.BindRowCallback getBindRowCallback(); - - NotificationListContainer getNotificationListContainer(); -} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java index 6bfafac10e9f..c024c7245c45 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java @@ -92,7 +92,7 @@ import com.android.systemui.statusbar.phone.PhoneStatusBarPolicy; import com.android.systemui.statusbar.phone.ScreenOffAnimationController; import com.android.systemui.statusbar.phone.ScrimController; import com.android.systemui.statusbar.phone.ShadeController; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.StatusBarHideIconsForBouncerManager; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.phone.StatusBarSignalPolicy; @@ -126,16 +126,16 @@ import dagger.Module; import dagger.Provides; /** - * Dagger Module providing {@link StatusBar}. + * Dagger Module providing {@link CentralSurfaces}. */ @Module public interface StatusBarPhoneModule { /** - * Provides our instance of StatusBar which is considered optional. + * Provides our instance of CentralSurfaces which is considered optional. */ @Provides @SysUISingleton - static StatusBar provideStatusBar( + static CentralSurfaces provideCentralSurfaces( Context context, NotificationsController notificationsController, FragmentService fragmentService, @@ -195,7 +195,7 @@ public interface StatusBarPhoneModule { DozeScrimController dozeScrimController, VolumeComponent volumeComponent, CommandQueue commandQueue, - StatusBarComponent.Factory statusBarComponentFactory, + CentralSurfacesComponent.Factory statusBarComponentFactory, PluginManager pluginManager, ShadeController shadeController, StatusBarKeyguardViewManager statusBarKeyguardViewManager, @@ -231,7 +231,7 @@ public interface StatusBarPhoneModule { DeviceStateManager deviceStateManager, DreamOverlayStateController dreamOverlayStateController, WiredChargingRippleController wiredChargingRippleController) { - return new StatusBar( + return new CentralSurfaces( context, notificationsController, fragmentService, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java index ebd58fb8ebed..fd3e3f61620e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java @@ -77,7 +77,7 @@ public abstract class StatusBarViewModule { /** */ @Provides - @StatusBarComponent.StatusBarScope + @CentralSurfacesComponent.CentralSurfacesScope public static NotificationShadeWindowView providesNotificationShadeWindowView( LayoutInflater layoutInflater) { NotificationShadeWindowView notificationShadeWindowView = (NotificationShadeWindowView) @@ -92,7 +92,7 @@ public abstract class StatusBarViewModule { /** */ @Provides - @StatusBarComponent.StatusBarScope + @CentralSurfacesComponent.CentralSurfacesScope public static NotificationStackScrollLayout providesNotificationStackScrollLayout( NotificationShadeWindowView notificationShadeWindowView) { return notificationShadeWindowView.findViewById(R.id.notification_stack_scroller); @@ -100,7 +100,7 @@ public abstract class StatusBarViewModule { /** */ @Provides - @StatusBarComponent.StatusBarScope + @CentralSurfacesComponent.CentralSurfacesScope public static NotificationShelf providesNotificationShelf(LayoutInflater layoutInflater, NotificationStackScrollLayout notificationStackScrollLayout) { NotificationShelf view = (NotificationShelf) layoutInflater.inflate( @@ -115,7 +115,7 @@ public abstract class StatusBarViewModule { /** */ @Provides - @StatusBarComponent.StatusBarScope + @CentralSurfacesComponent.CentralSurfacesScope public static NotificationShelfController providesStatusBarWindowView( NotificationShelfComponent.Builder notificationShelfComponentBuilder, NotificationShelf notificationShelf) { @@ -131,7 +131,7 @@ public abstract class StatusBarViewModule { /** */ @Provides - @StatusBarComponent.StatusBarScope + @CentralSurfacesComponent.CentralSurfacesScope public static NotificationPanelView getNotificationPanelView( NotificationShadeWindowView notificationShadeWindowView) { return notificationShadeWindowView.getNotificationPanelView(); @@ -139,7 +139,7 @@ public abstract class StatusBarViewModule { /** */ @Provides - @StatusBarComponent.StatusBarScope + @CentralSurfacesComponent.CentralSurfacesScope public static LockIconView getLockIconView( NotificationShadeWindowView notificationShadeWindowView) { return notificationShadeWindowView.findViewById(R.id.lock_icon_view); @@ -147,7 +147,7 @@ public abstract class StatusBarViewModule { /** */ @Provides - @StatusBarComponent.StatusBarScope + @CentralSurfacesComponent.CentralSurfacesScope @Nullable public static AuthRippleView getAuthRippleView( NotificationShadeWindowView notificationShadeWindowView) { @@ -157,7 +157,7 @@ public abstract class StatusBarViewModule { /** */ @Provides @Named(SPLIT_SHADE_HEADER) - @StatusBarComponent.StatusBarScope + @CentralSurfacesComponent.CentralSurfacesScope public static View getSplitShadeStatusBarView( NotificationShadeWindowView notificationShadeWindowView, FeatureFlags featureFlags) { @@ -172,7 +172,7 @@ public abstract class StatusBarViewModule { /** */ @Provides - @StatusBarComponent.StatusBarScope + @CentralSurfacesComponent.CentralSurfacesScope public static OngoingPrivacyChip getSplitShadeOngoingPrivacyChip( @Named(SPLIT_SHADE_HEADER) View header) { return header.findViewById(R.id.privacy_chip); @@ -180,21 +180,21 @@ public abstract class StatusBarViewModule { /** */ @Provides - @StatusBarComponent.StatusBarScope + @CentralSurfacesComponent.CentralSurfacesScope static StatusIconContainer providesStatusIconContainer(@Named(SPLIT_SHADE_HEADER) View header) { return header.findViewById(R.id.statusIcons); } /** */ @Provides - @StatusBarComponent.StatusBarScope + @CentralSurfacesComponent.CentralSurfacesScope @Named(SPLIT_SHADE_BATTERY_VIEW) static BatteryMeterView getBatteryMeterView(@Named(SPLIT_SHADE_HEADER) View view) { return view.findViewById(R.id.batteryRemainingIcon); } @Provides - @StatusBarComponent.StatusBarScope + @CentralSurfacesComponent.CentralSurfacesScope @Named(SPLIT_SHADE_BATTERY_CONTROLLER) static BatteryMeterViewController getBatteryMeterViewController( @Named(SPLIT_SHADE_BATTERY_VIEW) BatteryMeterView batteryMeterView, @@ -218,14 +218,14 @@ public abstract class StatusBarViewModule { /** */ @Provides - @StatusBarComponent.StatusBarScope + @CentralSurfacesComponent.CentralSurfacesScope public static TapAgainView getTapAgainView(NotificationPanelView npv) { return npv.getTapAgainView(); } /** */ @Provides - @StatusBarComponent.StatusBarScope + @CentralSurfacesComponent.CentralSurfacesScope public static NotificationsQuickSettingsContainer getNotificationsQuickSettingsContainer( NotificationShadeWindowView notificationShadeWindowView) { return notificationShadeWindowView.findViewById(R.id.notification_container_parent); @@ -235,9 +235,9 @@ public abstract class StatusBarViewModule { * Creates a new {@link CollapsedStatusBarFragment}. * * **IMPORTANT**: This method intentionally does not have - * {@link StatusBarComponent.StatusBarScope}, which means a new fragment *will* be created each - * time this method is called. This is intentional because we need fragments to re-created in - * certain lifecycle scenarios. + * {@link CentralSurfacesComponent.CentralSurfacesScope}, which means a new fragment *will* be + * created each time this method is called. This is intentional because we need fragments to + * re-created in certain lifecycle scenarios. * * This provider is {@link Named} such that it does not conflict with the provider inside of * {@link StatusBarFragmentComponent}. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentComponent.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentComponent.java index 22b7f649775e..2eba325ff63d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentComponent.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentComponent.java @@ -18,12 +18,14 @@ package com.android.systemui.statusbar.phone.fragment.dagger; import com.android.systemui.battery.BatteryMeterViewController; import com.android.systemui.dagger.qualifiers.RootView; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.HeadsUpAppearanceController; import com.android.systemui.statusbar.phone.LightsOutNotifController; import com.android.systemui.statusbar.phone.PhoneStatusBarTransitions; import com.android.systemui.statusbar.phone.PhoneStatusBarView; import com.android.systemui.statusbar.phone.PhoneStatusBarViewController; import com.android.systemui.statusbar.phone.StatusBarDemoMode; +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent; import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment; import dagger.BindsInstance; @@ -39,12 +41,6 @@ import dagger.Subcomponent; * * Anything that depends on {@link CollapsedStatusBarFragment} or {@link PhoneStatusBarView} * should be included here or in {@link StatusBarFragmentModule}. - * - * Note that this is completely separate from - * {@link com.android.systemui.statusbar.phone.dagger.StatusBarComponent}. This component gets - * re-created on each new fragment creation, whereas - * {@link com.android.systemui.statusbar.phone.dagger.StatusBarComponent} is only created once in - * {@link com.android.systemui.statusbar.phone.StatusBar} and never re-created. */ @Subcomponent(modules = {StatusBarFragmentModule.class}) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowStateController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowStateController.kt index 3a1491400f38..60f6df66cb5a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowStateController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowStateController.kt @@ -25,7 +25,7 @@ import android.util.Log import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.DisplayId import com.android.systemui.statusbar.CommandQueue -import com.android.systemui.statusbar.phone.StatusBar +import com.android.systemui.statusbar.phone.CentralSurfaces import javax.inject.Inject /** @@ -80,8 +80,8 @@ class StatusBarWindowStateController @Inject constructor( } windowState = state - if (StatusBar.DEBUG_WINDOW_STATE) { - Log.d(StatusBar.TAG, "Status bar " + windowStateToString(state)) + if (CentralSurfaces.DEBUG_WINDOW_STATE) { + Log.d(CentralSurfaces.TAG, "Status bar " + windowStateToString(state)) } listeners.forEach { it.onStatusBarWindowStateChanged(state) } } diff --git a/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt b/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt index e2374ada15d5..d6dfceac7a63 100644 --- a/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt @@ -26,7 +26,7 @@ import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.keyguard.WakefulnessLifecycle import com.android.systemui.statusbar.LightRevealScrim import com.android.systemui.statusbar.phone.ScreenOffAnimation -import com.android.systemui.statusbar.phone.StatusBar +import com.android.systemui.statusbar.phone.CentralSurfaces import com.android.systemui.statusbar.policy.CallbackController import com.android.systemui.unfold.FoldAodAnimationController.FoldAodAnimationStatus import com.android.systemui.util.settings.GlobalSettings @@ -50,7 +50,7 @@ constructor( private val globalSettings: GlobalSettings ) : CallbackController, ScreenOffAnimation, WakefulnessLifecycle.Observer { - private lateinit var statusBar: StatusBar + private lateinit var mCentralSurfaces: CentralSurfaces private var isFolded = false private var isFoldHandled = true @@ -66,14 +66,14 @@ constructor( private val statusListeners = arrayListOf() private val startAnimationRunnable = Runnable { - statusBar.notificationPanelViewController.startFoldToAodAnimation { + mCentralSurfaces.notificationPanelViewController.startFoldToAodAnimation { // End action setAnimationState(playing = false) } } - override fun initialize(statusBar: StatusBar, lightRevealScrim: LightRevealScrim) { - this.statusBar = statusBar + override fun initialize(centralSurfaces: CentralSurfaces, lightRevealScrim: LightRevealScrim) { + this.mCentralSurfaces = centralSurfaces deviceStateManager.registerCallback(executor, FoldListener()) wakefulnessLifecycle.addObserver(this) @@ -88,7 +88,7 @@ constructor( globalSettings.getString(Settings.Global.ANIMATOR_DURATION_SCALE) != "0" ) { setAnimationState(playing = true) - statusBar.notificationPanelViewController.prepareFoldToAodAnimation() + mCentralSurfaces.notificationPanelViewController.prepareFoldToAodAnimation() true } else { setAnimationState(playing = false) @@ -98,7 +98,7 @@ constructor( override fun onStartedWakingUp() { if (isAnimationPlaying) { handler.removeCallbacks(startAnimationRunnable) - statusBar.notificationPanelViewController.cancelFoldToAodAnimation() + mCentralSurfaces.notificationPanelViewController.cancelFoldToAodAnimation() } setAnimationState(playing = false) @@ -131,12 +131,14 @@ constructor( // We should play the folding to AOD animation setAnimationState(playing = true) - statusBar.notificationPanelViewController.prepareFoldToAodAnimation() + mCentralSurfaces.notificationPanelViewController.prepareFoldToAodAnimation() // We don't need to wait for the scrim as it is already displayed // but we should wait for the initial animation preparations to be drawn // (setting initial alpha/translation) - OneShotPreDrawListener.add(statusBar.notificationPanelViewController.view, onReady) + OneShotPreDrawListener.add( + mCentralSurfaces.notificationPanelViewController.view, onReady + ) } else { // No animation, call ready callback immediately onReady.run() diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthRippleControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthRippleControllerTest.kt index 5128ccc15d9d..ec2c1de49b4c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthRippleControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthRippleControllerTest.kt @@ -32,7 +32,7 @@ import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.statusbar.commandline.CommandRegistry import com.android.systemui.statusbar.phone.BiometricUnlockController import com.android.systemui.statusbar.phone.KeyguardBypassController -import com.android.systemui.statusbar.phone.StatusBar +import com.android.systemui.statusbar.phone.CentralSurfaces import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.leak.RotationUtils @@ -61,7 +61,7 @@ class AuthRippleControllerTest : SysuiTestCase() { private lateinit var staticMockSession: MockitoSession private lateinit var controller: AuthRippleController - @Mock private lateinit var statusBar: StatusBar + @Mock private lateinit var mCentralSurfaces: CentralSurfaces @Mock private lateinit var rippleView: AuthRippleView @Mock private lateinit var commandRegistry: CommandRegistry @Mock private lateinit var configurationController: ConfigurationController @@ -89,7 +89,7 @@ class AuthRippleControllerTest : SysuiTestCase() { `when`(udfpsControllerProvider.get()).thenReturn(udfpsController) controller = AuthRippleController( - statusBar, + mCentralSurfaces, context, authController, configurationController, @@ -105,7 +105,7 @@ class AuthRippleControllerTest : SysuiTestCase() { rippleView ) controller.init() - `when`(statusBar.lightRevealScrim).thenReturn(lightRevealScrim) + `when`(mCentralSurfaces.lightRevealScrim).thenReturn(lightRevealScrim) } @After diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java index 35e838bfca9a..1856fda14e1b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java @@ -65,7 +65,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.LockscreenShadeTransitionController; import com.android.systemui.statusbar.VibratorHelper; import com.android.systemui.statusbar.phone.KeyguardBypassController; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.phone.SystemUIDialogManager; import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController; @@ -121,7 +121,7 @@ public class UdfpsControllerTest extends SysuiTestCase { @Mock private StatusBarStateController mStatusBarStateController; @Mock - private StatusBar mStatusBar; + private CentralSurfaces mCentralSurfaces; @Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; @Mock diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java b/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java index d51151627be1..6e01541c75e0 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java @@ -40,7 +40,7 @@ import com.android.systemui.SysuiTestCase; import com.android.systemui.shared.system.InputChannelCompat; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.KeyguardBouncer; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.wm.shell.animation.FlingAnimationUtils; @@ -59,7 +59,7 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase { StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; @Mock - StatusBar mStatusBar; + CentralSurfaces mCentralSurfaces; @Mock NotificationShadeWindowController mNotificationShadeWindowController; @@ -103,7 +103,7 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase { mTouchHandler = new BouncerSwipeTouchHandler( mDisplayMetrics, mStatusBarKeyguardViewManager, - mStatusBar, + mCentralSurfaces, mNotificationShadeWindowController, mValueAnimatorCreator, mVelocityTrackerFactory, @@ -111,7 +111,7 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase { mFlingAnimationUtilsClosing, TOUCH_REGION); - when(mStatusBar.getDisplayHeight()).thenReturn((float) SCREEN_HEIGHT_PX); + when(mCentralSurfaces.getDisplayHeight()).thenReturn((float) SCREEN_HEIGHT_PX); when(mValueAnimatorCreator.create(anyFloat(), anyFloat())).thenReturn(mValueAnimator); when(mVelocityTrackerFactory.obtain()).thenReturn(mVelocityTracker); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java index 953be7d6f002..6fead9efa767 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java @@ -60,7 +60,7 @@ import com.android.systemui.plugins.GlobalActions; import com.android.systemui.settings.UserContextProvider; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.VibratorHelper; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.telephony.TelephonyListenerManager; @@ -113,7 +113,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { @Mock private Handler mHandler; @Mock private UserContextProvider mUserContextProvider; @Mock private VibratorHelper mVibratorHelper; - @Mock private StatusBar mStatusBar; + @Mock private CentralSurfaces mCentralSurfaces; @Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor; @Mock private DialogLaunchAnimator mDialogLaunchAnimator; @@ -158,7 +158,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { mRingerModeTracker, mHandler, mPackageManager, - Optional.of(mStatusBar), + Optional.of(mCentralSurfaces), mKeyguardUpdateMonitor, mDialogLaunchAnimator); mGlobalActionsDialogLite.setZeroDialogPressDelayForTesting(); @@ -227,7 +227,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayLockdown(any()); doReturn(true).when(mGlobalActionsDialogLite).shouldShowAction(any()); - doReturn(true).when(mStatusBar).isKeyguardShowing(); + doReturn(true).when(mCentralSurfaces).isKeyguardShowing(); String[] actions = { GlobalActionsDialogLite.GLOBAL_ACTION_KEY_EMERGENCY, GlobalActionsDialogLite.GLOBAL_ACTION_KEY_LOCKDOWN, @@ -242,7 +242,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { MotionEvent end = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 500, 0); gestureListener.onFling(start, end, 0, 1000); verifyLogPosted(GlobalActionsDialogLite.GlobalActionsEvent.GA_CLOSE_TAP_OUTSIDE); - verify(mStatusBar).animateExpandSettingsPanel(null); + verify(mCentralSurfaces).animateExpandSettingsPanel(null); } @Test @@ -251,7 +251,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayLockdown(any()); doReturn(true).when(mGlobalActionsDialogLite).shouldShowAction(any()); - doReturn(false).when(mStatusBar).isKeyguardShowing(); + doReturn(false).when(mCentralSurfaces).isKeyguardShowing(); String[] actions = { GlobalActionsDialogLite.GLOBAL_ACTION_KEY_EMERGENCY, GlobalActionsDialogLite.GLOBAL_ACTION_KEY_LOCKDOWN, @@ -266,7 +266,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { MotionEvent end = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 500, 0); gestureListener.onFling(start, end, 0, 1000); verifyLogPosted(GlobalActionsDialogLite.GlobalActionsEvent.GA_CLOSE_TAP_OUTSIDE); - verify(mStatusBar).animateExpandNotificationsPanel(); + verify(mCentralSurfaces).animateExpandNotificationsPanel(); } @Test @@ -432,7 +432,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems(); doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayLockdown(any()); doReturn(true).when(mGlobalActionsDialogLite).shouldShowAction(any()); - doReturn(false).when(mStatusBar).isKeyguardShowing(); + doReturn(false).when(mCentralSurfaces).isKeyguardShowing(); String[] actions = { GlobalActionsDialogLite.GLOBAL_ACTION_KEY_EMERGENCY, GlobalActionsDialogLite.GLOBAL_ACTION_KEY_LOCKDOWN, diff --git a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavBarHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavBarHelperTest.java index 3a95ed3da84d..634d9e4642b3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavBarHelperTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavBarHelperTest.java @@ -37,8 +37,7 @@ import com.android.systemui.assist.AssistManager; import com.android.systemui.dump.DumpManager; import com.android.systemui.recents.OverviewProxyService; import com.android.systemui.settings.UserTracker; -import com.android.systemui.statusbar.phone.StatusBar; -import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper; +import com.android.systemui.statusbar.phone.CentralSurfaces; import org.junit.Before; import org.junit.Test; @@ -91,7 +90,7 @@ public class NavBarHelperTest extends SysuiTestCase { mNavBarHelper = new NavBarHelper(mContext, mAccessibilityManager, mAccessibilityButtonModeObserver, mAccessibilityButtonTargetObserver, mSystemActions, mOverviewProxyService, mAssistManagerLazy, - () -> Optional.of(mock(StatusBar.class)), + () -> Optional.of(mock(CentralSurfaces.class)), mNavigationModeController, mUserTracker, mDumpManager); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarTest.java index 5a652fc15a48..eb1e1a2e3d04 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarTest.java @@ -94,7 +94,7 @@ import com.android.systemui.statusbar.phone.AutoHideController; import com.android.systemui.statusbar.phone.LightBarController; import com.android.systemui.statusbar.phone.NotificationShadeWindowView; import com.android.systemui.statusbar.phone.ShadeController; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.utils.leaks.LeakCheckedTest; @@ -160,7 +160,7 @@ public class NavigationBarTest extends SysuiTestCase { @Mock private AssistManager mAssistManager; @Mock - private StatusBar mStatusBar; + private CentralSurfaces mCentralSurfaces; @Rule public final LeakCheckedTest.SysuiLeakCheck mLeakCheck = new LeakCheckedTest.SysuiLeakCheck(); @@ -189,7 +189,7 @@ public class NavigationBarTest extends SysuiTestCase { mock(AccessibilityButtonModeObserver.class), mock(AccessibilityButtonTargetsObserver.class), mSystemActions, mOverviewProxyService, - () -> mock(AssistManager.class), () -> Optional.of(mStatusBar), + () -> mock(AssistManager.class), () -> Optional.of(mCentralSurfaces), mock(NavigationModeController.class), mock(UserTracker.class), mock(DumpManager.class))); mNavigationBar = createNavBar(mContext); @@ -282,7 +282,7 @@ public class NavigationBarTest extends SysuiTestCase { NotificationShadeWindowView mockShadeWindowView = mock(NotificationShadeWindowView.class); WindowInsets windowInsets = new WindowInsets.Builder().setVisible(ime(), false).build(); doReturn(windowInsets).when(mockShadeWindowView).getRootWindowInsets(); - doReturn(mockShadeWindowView).when(mStatusBar).getNotificationShadeWindowView(); + doReturn(mockShadeWindowView).when(mCentralSurfaces).getNotificationShadeWindowView(); doReturn(true).when(mockShadeWindowView).isAttachedToWindow(); doNothing().when(defaultNavBar).checkNavBarModes(); doNothing().when(externalNavBar).checkNavBarModes(); @@ -318,7 +318,7 @@ public class NavigationBarTest extends SysuiTestCase { @Test public void testSetImeWindowStatusWhenKeyguardLockingAndImeInsetsChange() { NotificationShadeWindowView mockShadeWindowView = mock(NotificationShadeWindowView.class); - doReturn(mockShadeWindowView).when(mStatusBar).getNotificationShadeWindowView(); + doReturn(mockShadeWindowView).when(mCentralSurfaces).getNotificationShadeWindowView(); doReturn(true).when(mockShadeWindowView).isAttachedToWindow(); doNothing().when(mNavigationBar).checkNavBarModes(); mNavigationBar.createView(null, /* initialVisibility= */ true); @@ -335,7 +335,7 @@ public class NavigationBarTest extends SysuiTestCase { // Verify navbar didn't alter and showing back icon when the keyguard is showing without // requesting IME insets visible. - doReturn(true).when(mStatusBar).isKeyguardShowing(); + doReturn(true).when(mCentralSurfaces).isKeyguardShowing(); mNavigationBar.setImeWindowStatus(DEFAULT_DISPLAY, null, IME_VISIBLE, BACK_DISPOSITION_DEFAULT, true); assertFalse((mNavigationBar.getNavigationIconHints() & NAVIGATION_HINT_BACK_ALT) != 0); @@ -401,7 +401,7 @@ public class NavigationBarTest extends SysuiTestCase { mCommandQueue, Optional.of(mock(Pip.class)), Optional.of(mock(Recents.class)), - () -> Optional.of(mStatusBar), + () -> Optional.of(mCentralSurfaces), mock(ShadeController.class), mock(NotificationRemoteInputManager.class), mock(NotificationShadeDepthController.class), diff --git a/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java b/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java index 721809c83cd8..373770ec976b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java @@ -48,7 +48,7 @@ import com.android.systemui.SysuiTestCase; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.power.PowerUI.WarningsUI; import com.android.systemui.statusbar.CommandQueue; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import org.junit.Before; import org.junit.Test; @@ -89,14 +89,14 @@ public class PowerUITest extends SysuiTestCase { private IThermalEventListener mSkinThermalEventListener; @Mock private BroadcastDispatcher mBroadcastDispatcher; @Mock private CommandQueue mCommandQueue; - @Mock private Lazy> mStatusBarOptionalLazy; - @Mock private StatusBar mStatusBar; + @Mock private Lazy> mCentralSurfacesOptionalLazy; + @Mock private CentralSurfaces mCentralSurfaces; @Before public void setup() { MockitoAnnotations.initMocks(this); - when(mStatusBarOptionalLazy.get()).thenReturn(Optional.of(mStatusBar)); + when(mCentralSurfacesOptionalLazy.get()).thenReturn(Optional.of(mCentralSurfaces)); createPowerUi(); mSkinThermalEventListener = mPowerUI.new SkinThermalEventListener(); @@ -685,7 +685,7 @@ public class PowerUITest extends SysuiTestCase { private void createPowerUi() { mPowerUI = new PowerUI( - mContext, mBroadcastDispatcher, mCommandQueue, mStatusBarOptionalLazy, + mContext, mBroadcastDispatcher, mCommandQueue, mCentralSurfacesOptionalLazy, mMockWarnings, mEnhancedEstimates, mPowerManager); mPowerUI.mThermalService = mThermalServiceMock; } diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java index 4ab39261e825..534c7e7f2029 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java @@ -56,7 +56,7 @@ import com.android.systemui.shared.plugins.PluginManager; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.phone.AutoTileManager; import com.android.systemui.statusbar.phone.KeyguardBypassController; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.StatusBarIconController; import com.android.systemui.statusbar.policy.Clock; import com.android.systemui.statusbar.policy.ConfigurationController; @@ -142,7 +142,7 @@ public class QSFragmentTest extends SysuiBaseFragmentTest { mock(QSFactoryImpl.class), new Handler(), Looper.myLooper(), mock(PluginManager.class), mock(TunerService.class), () -> mock(AutoTileManager.class), mock(DumpManager.class), - mock(BroadcastDispatcher.class), Optional.of(mock(StatusBar.class)), + mock(BroadcastDispatcher.class), Optional.of(mock(CentralSurfaces.class)), mock(QSLogger.class), mock(UiEventLogger.class), mock(UserTracker.class), mock(SecureSettings.class), mock(CustomTileStatePersister.class), mTileServiceRequestControllerBuilder, mock(TileLifecycleManager.Factory.class)); diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java index 8872e28647a7..e67d37ac3c72 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java @@ -65,7 +65,7 @@ import com.android.systemui.qs.tileimpl.QSTileImpl; import com.android.systemui.settings.UserTracker; import com.android.systemui.shared.plugins.PluginManager; import com.android.systemui.statusbar.phone.AutoTileManager; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.StatusBarIconController; import com.android.systemui.tuner.TunerService; import com.android.systemui.util.settings.FakeSettings; @@ -112,7 +112,7 @@ public class QSTileHostTest extends SysuiTestCase { @Mock private QSTile.State mMockState; @Mock - private StatusBar mStatusBar; + private CentralSurfaces mCentralSurfaces; @Mock private QSLogger mQSLogger; @Mock @@ -152,7 +152,7 @@ public class QSTileHostTest extends SysuiTestCase { QSTileHost.TILES_SETTING, "", "", false, mUserTracker.getUserId(), false); mQSTileHost = new TestQSTileHost(mContext, mIconController, mDefaultFactory, mHandler, mLooper.getLooper(), mPluginManager, mTunerService, mAutoTiles, mDumpManager, - mBroadcastDispatcher, mStatusBar, mQSLogger, mUiEventLogger, mUserTracker, + mBroadcastDispatcher, mCentralSurfaces, mQSLogger, mUiEventLogger, mUserTracker, mSecureSettings, mCustomTileStatePersister, mTileServiceRequestControllerBuilder, mTileLifecycleManagerFactory); setUpTileFactory(); @@ -437,15 +437,15 @@ public class QSTileHostTest extends SysuiTestCase { QSFactory defaultFactory, Handler mainHandler, Looper bgLooper, PluginManager pluginManager, TunerService tunerService, Provider autoTiles, DumpManager dumpManager, - BroadcastDispatcher broadcastDispatcher, StatusBar statusBar, QSLogger qsLogger, - UiEventLogger uiEventLogger, UserTracker userTracker, + BroadcastDispatcher broadcastDispatcher, CentralSurfaces centralSurfaces, + QSLogger qsLogger, UiEventLogger uiEventLogger, UserTracker userTracker, SecureSettings secureSettings, CustomTileStatePersister customTileStatePersister, TileServiceRequestController.Builder tileServiceRequestControllerBuilder, TileLifecycleManager.Factory tileLifecycleManagerFactory) { super(context, iconController, defaultFactory, mainHandler, bgLooper, pluginManager, tunerService, autoTiles, dumpManager, broadcastDispatcher, - Optional.of(statusBar), qsLogger, uiEventLogger, userTracker, secureSettings, - customTileStatePersister, tileServiceRequestControllerBuilder, + Optional.of(centralSurfaces), qsLogger, uiEventLogger, userTracker, + secureSettings, customTileStatePersister, tileServiceRequestControllerBuilder, tileLifecycleManagerFactory); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTest.java index e39d6a1bfc01..19a9863f6f5e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTest.java @@ -50,7 +50,7 @@ import com.android.systemui.qs.tileimpl.QSFactoryImpl; import com.android.systemui.settings.UserTracker; import com.android.systemui.shared.plugins.PluginManager; import com.android.systemui.statusbar.phone.AutoTileManager; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.StatusBarIconController; import com.android.systemui.statusbar.policy.BluetoothController; import com.android.systemui.statusbar.policy.KeyguardStateController; @@ -91,7 +91,7 @@ public class TileServicesTest extends SysuiTestCase { @Mock private DumpManager mDumpManager; @Mock - private StatusBar mStatusBar; + private CentralSurfaces mCentralSurfaces; @Mock private QSLogger mQSLogger; @Mock @@ -132,7 +132,7 @@ public class TileServicesTest extends SysuiTestCase { () -> mAutoTileManager, mDumpManager, mock(BroadcastDispatcher.class), - Optional.of(mStatusBar), + Optional.of(mCentralSurfaces), mQSLogger, mUiEventLogger, mUserTracker, diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ActionProxyReceiverTest.java b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ActionProxyReceiverTest.java index bfe875ccd60d..7ab49584f0e3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ActionProxyReceiverTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ActionProxyReceiverTest.java @@ -19,7 +19,7 @@ package com.android.systemui.screenshot; import static com.android.systemui.screenshot.ScreenshotController.ACTION_TYPE_SHARE; import static com.android.systemui.screenshot.ScreenshotController.EXTRA_ID; import static com.android.systemui.screenshot.ScreenshotController.EXTRA_SMART_ACTIONS_ENABLED; -import static com.android.systemui.statusbar.phone.StatusBar.SYSTEM_DIALOG_REASON_SCREENSHOT; +import static com.android.systemui.statusbar.phone.CentralSurfaces.SYSTEM_DIALOG_REASON_SCREENSHOT; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; @@ -41,7 +41,7 @@ import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; import com.android.systemui.shared.system.ActivityManagerWrapper; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import org.junit.Before; import org.junit.Test; @@ -59,7 +59,7 @@ import java.util.concurrent.TimeoutException; public class ActionProxyReceiverTest extends SysuiTestCase { @Mock - private StatusBar mMockStatusBar; + private CentralSurfaces mMockCentralSurfaces; @Mock private ActivityManagerWrapper mMockActivityManagerWrapper; @Mock @@ -83,7 +83,7 @@ public class ActionProxyReceiverTest extends SysuiTestCase { actionProxyReceiver.onReceive(mContext, mIntent); verify(mMockActivityManagerWrapper).closeSystemWindows(SYSTEM_DIALOG_REASON_SCREENSHOT); - verify(mMockStatusBar, never()).executeRunnableDismissingKeyguard( + verify(mMockCentralSurfaces, never()).executeRunnableDismissingKeyguard( any(Runnable.class), any(Runnable.class), anyBoolean(), anyBoolean(), anyBoolean()); verify(mMockPendingIntent).send( eq(mContext), anyInt(), isNull(), isNull(), isNull(), isNull(), any(Bundle.class)); @@ -96,13 +96,13 @@ public class ActionProxyReceiverTest extends SysuiTestCase { doAnswer((Answer) invocation -> { ((Runnable) invocation.getArgument(0)).run(); return null; - }).when(mMockStatusBar).executeRunnableDismissingKeyguard( + }).when(mMockCentralSurfaces).executeRunnableDismissingKeyguard( any(Runnable.class), isNull(), anyBoolean(), anyBoolean(), anyBoolean()); actionProxyReceiver.onReceive(mContext, mIntent); verify(mMockActivityManagerWrapper).closeSystemWindows(SYSTEM_DIALOG_REASON_SCREENSHOT); - verify(mMockStatusBar).executeRunnableDismissingKeyguard( + verify(mMockCentralSurfaces).executeRunnableDismissingKeyguard( any(Runnable.class), isNull(), eq(true), eq(true), eq(true)); verify(mMockPendingIntent).send( eq(mContext), anyInt(), isNull(), isNull(), isNull(), isNull(), any(Bundle.class)); @@ -135,7 +135,7 @@ public class ActionProxyReceiverTest extends SysuiTestCase { private ActionProxyReceiver constructActionProxyReceiver(boolean withStatusBar) { if (withStatusBar) { return new ActionProxyReceiver( - Optional.of(mMockStatusBar), mMockActivityManagerWrapper, + Optional.of(mMockCentralSurfaces), mMockActivityManagerWrapper, mMockScreenshotSmartActions); } else { return new ActionProxyReceiver( diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt index 75ccd8f03a01..25a5b900f15a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt @@ -22,7 +22,7 @@ import com.android.systemui.statusbar.phone.KeyguardBypassController import com.android.systemui.statusbar.phone.LSShadeTransitionLogger import com.android.systemui.statusbar.phone.NotificationPanelViewController import com.android.systemui.statusbar.phone.ScrimController -import com.android.systemui.statusbar.phone.StatusBar +import com.android.systemui.statusbar.phone.CentralSurfaces import com.android.systemui.statusbar.policy.FakeConfigurationController import org.junit.After import org.junit.Assert.assertFalse @@ -72,7 +72,7 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() { @Mock lateinit var depthController: NotificationShadeDepthController @Mock lateinit var stackscroller: NotificationStackScrollLayout @Mock lateinit var expandHelperCallback: ExpandHelper.Callback - @Mock lateinit var statusbar: StatusBar + @Mock lateinit var mCentralSurfaces: CentralSurfaces @Mock lateinit var qS: QS @JvmField @Rule val mockito = MockitoJUnit.rule() @@ -106,7 +106,7 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() { whenever(nsslController.view).thenReturn(stackscroller) whenever(nsslController.expandHelperCallback).thenReturn(expandHelperCallback) transitionController.notificationPanelController = notificationPanelController - transitionController.statusbar = statusbar + transitionController.centralSurfaces = mCentralSurfaces transitionController.qS = qS transitionController.setStackScroller(nsslController) whenever(statusbarStateController.state).thenReturn(StatusBarState.KEYGUARD) @@ -118,7 +118,7 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() { whenever(lockScreenUserManager.isLockscreenPublicMode(anyInt())).thenReturn(true) whenever(falsingCollector.shouldEnforceBouncer()).thenReturn(false) whenever(keyguardBypassController.bypassEnabled).thenReturn(false) - clearInvocations(statusbar) + clearInvocations(mCentralSurfaces) } @After @@ -175,7 +175,7 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() { @Test fun testDontGoWhenShadeDisabled() { - whenever(statusbar.isShadeDisabled).thenReturn(true) + whenever(mCentralSurfaces.isShadeDisabled).thenReturn(true) transitionController.goToLockedShade(null) verify(statusbarStateController, never()).setState(anyInt()) } @@ -194,7 +194,7 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() { transitionController.goToLockedShade(null) verify(statusbarStateController, never()).setState(anyInt()) verify(statusbarStateController).setLeaveOpenOnKeyguardHide(true) - verify(statusbar).showBouncerWithDimissAndCancelIfKeyguard(anyObject(), anyObject()) + verify(mCentralSurfaces).showBouncerWithDimissAndCancelIfKeyguard(anyObject(), anyObject()) } @Test @@ -203,7 +203,7 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() { transitionController.goToLockedShade(null) verify(statusbarStateController, never()).setState(anyInt()) verify(statusbarStateController).setLeaveOpenOnKeyguardHide(true) - verify(statusbar).showBouncerWithDimissAndCancelIfKeyguard(anyObject(), anyObject()) + verify(mCentralSurfaces).showBouncerWithDimissAndCancelIfKeyguard(anyObject(), anyObject()) } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java index 4213b070d0c2..a4ce9cd12f73 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java @@ -47,8 +47,8 @@ import org.mockito.MockitoAnnotations; /** * Verifies that particular sets of dependencies don't have dependencies on others. For example, - * code managing notifications shouldn't directly depend on StatusBar, since there are platforms - * which want to manage notifications, but don't use StatusBar. + * code managing notifications shouldn't directly depend on CentralSurfaces, since there are + * platforms which want to manage notifications, but don't use CentralSurfaces. */ @SmallTest @RunWith(AndroidTestingRunner.class) diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java index bd9f91f45e25..2691ff98f4ee 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java @@ -49,7 +49,7 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder; import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.policy.RemoteInputUriController; import com.google.android.collect.Sets; @@ -105,7 +105,7 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase { mVisibilityProvider, mEntryManager, mock(RemoteInputNotificationRebuilder.class), - () -> Optional.of(mock(StatusBar.class)), + () -> Optional.of(mock(CentralSurfaces.class)), mStateController, Handler.createAsync(Looper.myLooper()), mRemoteInputUriController, @@ -196,7 +196,7 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase { NotificationVisibilityProvider visibilityProvider, NotificationEntryManager notificationEntryManager, RemoteInputNotificationRebuilder rebuilder, - Lazy> statusBarOptionalLazy, + Lazy> centralSurfacesOptionalLazy, StatusBarStateController statusBarStateController, Handler mainHandler, RemoteInputUriController remoteInputUriController, @@ -211,7 +211,7 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase { visibilityProvider, notificationEntryManager, rebuilder, - statusBarOptionalLazy, + centralSurfacesOptionalLazy, statusBarStateController, mainHandler, remoteInputUriController, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/SmartReplyControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/SmartReplyControllerTest.java index e0689f3da081..3500e4d5f701 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/SmartReplyControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/SmartReplyControllerTest.java @@ -45,7 +45,7 @@ import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder; import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.policy.RemoteInputUriController; import org.junit.Before; @@ -103,7 +103,7 @@ public class SmartReplyControllerTest extends SysuiTestCase { mVisibilityProvider, mNotificationEntryManager, new RemoteInputNotificationRebuilder(mContext), - () -> Optional.of(mock(StatusBar.class)), + () -> Optional.of(mock(CentralSurfaces.class)), mStatusBarStateController, Handler.createAsync(Looper.myLooper()), mRemoteInputUriController, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java index 7d8e0d26464c..e9d8f5830131 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java @@ -82,8 +82,8 @@ import com.android.systemui.statusbar.notification.collection.provider.HighPrior import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier; import com.android.systemui.statusbar.notification.row.NotificationGutsManager.OnSettingsClickListener; import com.android.systemui.statusbar.notification.stack.NotificationListContainer; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.ShadeController; -import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.systemui.wmshell.BubblesManager; @@ -124,7 +124,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase { @Mock private NotificationInfo.CheckSaveListener mCheckSaveListener; @Mock private OnSettingsClickListener mOnSettingsClickListener; @Mock private DeviceProvisionedController mDeviceProvisionedController; - @Mock private StatusBar mStatusBar; + @Mock private CentralSurfaces mCentralSurfaces; @Mock private AccessibilityManager mAccessibilityManager; @Mock private HighPriorityProvider mHighPriorityProvider; @Mock private INotificationManager mINotificationManager; @@ -155,7 +155,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase { when(mAccessibilityManager.isTouchExplorationEnabled()).thenReturn(false); mGutsManager = new NotificationGutsManager(mContext, - () -> Optional.of(mStatusBar), mHandler, mHandler, mAccessibilityManager, + () -> Optional.of(mCentralSurfaces), mHandler, mHandler, mAccessibilityManager, mHighPriorityProvider, mINotificationManager, mNotificationEntryManager, mPeopleSpaceWidgetManager, mLauncherApps, mShortcutManager, mChannelEditorDialogController, mContextTracker, mAssistantFeedbackController, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutControllerTest.java index 6b93ae2f3667..1561b5a5d22e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutControllerTest.java @@ -73,7 +73,7 @@ import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.ScrimController; import com.android.systemui.statusbar.phone.ShadeController; -import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.systemui.statusbar.policy.ZenModeController; @@ -116,7 +116,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase { @Mock(answer = Answers.RETURNS_SELF) private NotificationSwipeHelper.Builder mNotificationSwipeHelperBuilder; @Mock private NotificationSwipeHelper mNotificationSwipeHelper; - @Mock private StatusBar mStatusBar; + @Mock private CentralSurfaces mCentralSurfaces; @Mock private ScrimController mScrimController; @Mock private NotificationGroupManagerLegacy mLegacyGroupManager; @Mock private SectionHeaderController mSilentHeaderController; @@ -168,7 +168,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase { new FalsingManagerFake(), mResources, mNotificationSwipeHelperBuilder, - mStatusBar, + mCentralSurfaces, mScrimController, mLegacyGroupManager, mLegacyGroupManager, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index 4f731ed5f72c..eafcc354fac4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -61,9 +61,9 @@ import com.android.systemui.statusbar.notification.collection.render.GroupExpans import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.FooterView; +import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.ShadeController; -import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController; import org.junit.Assert; @@ -89,7 +89,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { private AmbientState mAmbientState; @Rule public MockitoRule mockito = MockitoJUnit.rule(); - @Mock private StatusBar mBar; + @Mock private CentralSurfaces mCentralSurfaces; @Mock private SysuiStatusBarStateController mBarState; @Mock private NotificationGroupManagerLegacy mGroupMembershipManger; @Mock private NotificationGroupManagerLegacy mGroupExpansionManager; @@ -141,7 +141,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { mStackScrollerInternal.initView(getContext(), mNotificationSwipeHelper); mStackScroller = spy(mStackScrollerInternal); mStackScroller.setShelfController(notificationShelfController); - mStackScroller.setStatusBar(mBar); + mStackScroller.setCentralSurfaces(mCentralSurfaces); mStackScroller.setEmptyShadeView(mEmptyShadeView); when(mStackScrollLayoutController.isHistoryEnabled()).thenReturn(true); when(mStackScrollLayoutController.getNoticationRoundessManager()) @@ -149,7 +149,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { mStackScroller.setController(mStackScrollLayoutController); // Stub out functionality that isn't necessary to test. - doNothing().when(mBar) + doNothing().when(mCentralSurfaces) .executeRunnableDismissingKeyguard(any(Runnable.class), any(Runnable.class), anyBoolean(), diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java new file mode 100644 index 000000000000..9bfb2c4ce00c --- /dev/null +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java @@ -0,0 +1,172 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.phone; + +import static android.view.Display.DEFAULT_DISPLAY; + +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import android.app.StatusBarManager; +import android.os.PowerManager; +import android.os.Vibrator; +import android.testing.AndroidTestingRunner; + +import androidx.test.filters.SmallTest; + +import com.android.internal.logging.MetricsLogger; +import com.android.internal.logging.testing.FakeMetricsLogger; +import com.android.keyguard.KeyguardUpdateMonitor; +import com.android.systemui.SysuiTestCase; +import com.android.systemui.assist.AssistManager; +import com.android.systemui.keyguard.WakefulnessLifecycle; +import com.android.systemui.statusbar.CommandQueue; +import com.android.systemui.statusbar.DisableFlagsLogger; +import com.android.systemui.statusbar.StatusBarStateControllerImpl; +import com.android.systemui.statusbar.VibratorHelper; +import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; +import com.android.systemui.statusbar.policy.DeviceProvisionedController; +import com.android.systemui.statusbar.policy.KeyguardStateController; +import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.mockito.stubbing.Answer; + +import java.util.Optional; + +@SmallTest +@RunWith(AndroidTestingRunner.class) +public class CentralSurfacesCommandQueueCallbacksTest extends SysuiTestCase { + @Mock private CentralSurfaces mCentralSurfaces; + @Mock private ShadeController mShadeController; + @Mock private CommandQueue mCommandQueue; + @Mock private NotificationPanelViewController mNotificationPanelViewController; + @Mock private RemoteInputQuickSettingsDisabler mRemoteInputQuickSettingsDisabler; + private final MetricsLogger mMetricsLogger = new FakeMetricsLogger(); + @Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor; + @Mock private KeyguardStateController mKeyguardStateController; + @Mock private HeadsUpManagerPhone mHeadsUpManager; + @Mock private WakefulnessLifecycle mWakefulnessLifecycle; + @Mock private DeviceProvisionedController mDeviceProvisionedController; + @Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; + @Mock private AssistManager mAssistManager; + @Mock private DozeServiceHost mDozeServiceHost; + @Mock private StatusBarStateControllerImpl mStatusBarStateController; + @Mock private NotificationShadeWindowView mNotificationShadeWindowView; + @Mock private NotificationStackScrollLayoutController mNotificationStackScrollLayoutController; + @Mock private PowerManager mPowerManager; + @Mock private VibratorHelper mVibratorHelper; + @Mock private Vibrator mVibrator; + @Mock private LightBarController mLightBarController; + @Mock private StatusBarHideIconsForBouncerManager mStatusBarHideIconsForBouncerManager; + + CentralSurfacesCommandQueueCallbacks mSbcqCallbacks; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + + mSbcqCallbacks = new CentralSurfacesCommandQueueCallbacks( + mCentralSurfaces, + mContext, + mContext.getResources(), + mShadeController, + mCommandQueue, + mNotificationPanelViewController, + mRemoteInputQuickSettingsDisabler, + mMetricsLogger, + mKeyguardUpdateMonitor, + mKeyguardStateController, + mHeadsUpManager, + mWakefulnessLifecycle, + mDeviceProvisionedController, + mStatusBarKeyguardViewManager, + mAssistManager, + mDozeServiceHost, + mStatusBarStateController, + mNotificationShadeWindowView, + mNotificationStackScrollLayoutController, + mStatusBarHideIconsForBouncerManager, + mPowerManager, + mVibratorHelper, + Optional.of(mVibrator), + mLightBarController, + new DisableFlagsLogger(), + DEFAULT_DISPLAY); + + when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); + when(mRemoteInputQuickSettingsDisabler.adjustDisableFlags(anyInt())) + .thenAnswer((Answer) invocation -> invocation.getArgument(0)); + } + + @Test + public void testDisableNotificationShade() { + when(mCentralSurfaces.getDisabled1()).thenReturn(StatusBarManager.DISABLE_NONE); + when(mCentralSurfaces.getDisabled2()).thenReturn(StatusBarManager.DISABLE_NONE); + when(mCommandQueue.panelsEnabled()).thenReturn(false); + mSbcqCallbacks.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_NONE, + StatusBarManager.DISABLE2_NOTIFICATION_SHADE, false); + + verify(mCentralSurfaces).updateQsExpansionEnabled(); + verify(mShadeController).animateCollapsePanels(); + + // Trying to open it does nothing. + mSbcqCallbacks.animateExpandNotificationsPanel(); + verify(mNotificationPanelViewController, never()).expandWithoutQs(); + mSbcqCallbacks.animateExpandSettingsPanel(null); + verify(mNotificationPanelViewController, never()).expand(anyBoolean()); + } + + @Test + public void testEnableNotificationShade() { + when(mCentralSurfaces.getDisabled1()).thenReturn(StatusBarManager.DISABLE_NONE); + when(mCentralSurfaces.getDisabled2()) + .thenReturn(StatusBarManager.DISABLE2_NOTIFICATION_SHADE); + when(mCommandQueue.panelsEnabled()).thenReturn(true); + mSbcqCallbacks.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_NONE, + StatusBarManager.DISABLE2_NONE, false); + verify(mCentralSurfaces).updateQsExpansionEnabled(); + verify(mShadeController, never()).animateCollapsePanels(); + + // Can now be opened. + mSbcqCallbacks.animateExpandNotificationsPanel(); + verify(mNotificationPanelViewController).expandWithoutQs(); + mSbcqCallbacks.animateExpandSettingsPanel(null); + verify(mNotificationPanelViewController).expandWithQs(); + } + + @Test + public void testSuppressAmbientDisplay_suppress() { + mSbcqCallbacks.suppressAmbientDisplay(true); + verify(mDozeServiceHost).setAlwaysOnSuppressed(true); + } + + @Test + public void testSuppressAmbientDisplay_unsuppress() { + mSbcqCallbacks.suppressAmbientDisplay(false); + verify(mDozeServiceHost).setAlwaysOnSuppressed(false); + } + + +} diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesTest.java new file mode 100644 index 000000000000..953a330d2e65 --- /dev/null +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesTest.java @@ -0,0 +1,1001 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.phone; + +import static android.app.NotificationManager.IMPORTANCE_HIGH; +import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK; + +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertTrue; +import static junit.framework.TestCase.fail; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.clearInvocations; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import android.app.IWallpaperManager; +import android.app.Notification; +import android.app.WallpaperManager; +import android.app.trust.TrustManager; +import android.content.BroadcastReceiver; +import android.content.ContentResolver; +import android.content.IntentFilter; +import android.hardware.devicestate.DeviceStateManager; +import android.hardware.display.AmbientDisplayConfiguration; +import android.hardware.fingerprint.FingerprintManager; +import android.metrics.LogMaker; +import android.os.Binder; +import android.os.Handler; +import android.os.IPowerManager; +import android.os.IThermalService; +import android.os.Looper; +import android.os.PowerManager; +import android.os.RemoteException; +import android.os.UserHandle; +import android.service.dreams.IDreamManager; +import android.support.test.metricshelper.MetricsAsserts; +import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; +import android.testing.TestableLooper.RunWithLooper; +import android.util.DisplayMetrics; +import android.util.SparseArray; +import android.view.ViewGroup; +import android.view.ViewGroup.LayoutParams; +import android.view.WindowManager; + +import androidx.test.filters.SmallTest; + +import com.android.internal.colorextraction.ColorExtractor; +import com.android.internal.jank.InteractionJankMonitor; +import com.android.internal.logging.nano.MetricsProto.MetricsEvent; +import com.android.internal.logging.testing.FakeMetricsLogger; +import com.android.internal.statusbar.IStatusBarService; +import com.android.keyguard.KeyguardUpdateMonitor; +import com.android.keyguard.ViewMediatorCallback; +import com.android.systemui.InitController; +import com.android.systemui.R; +import com.android.systemui.SysuiTestCase; +import com.android.systemui.accessibility.floatingmenu.AccessibilityFloatingMenuController; +import com.android.systemui.animation.ActivityLaunchAnimator; +import com.android.systemui.assist.AssistManager; +import com.android.systemui.broadcast.BroadcastDispatcher; +import com.android.systemui.classifier.FalsingCollectorFake; +import com.android.systemui.classifier.FalsingManagerFake; +import com.android.systemui.colorextraction.SysuiColorExtractor; +import com.android.systemui.demomode.DemoModeController; +import com.android.systemui.dreams.DreamOverlayStateController; +import com.android.systemui.dump.DumpManager; +import com.android.systemui.flags.FeatureFlags; +import com.android.systemui.fragments.FragmentService; +import com.android.systemui.keyguard.KeyguardUnlockAnimationController; +import com.android.systemui.keyguard.KeyguardViewMediator; +import com.android.systemui.keyguard.ScreenLifecycle; +import com.android.systemui.keyguard.WakefulnessLifecycle; +import com.android.systemui.navigationbar.NavigationBarController; +import com.android.systemui.plugins.ActivityStarter.OnDismissAction; +import com.android.systemui.plugins.PluginDependencyProvider; +import com.android.systemui.plugins.statusbar.StatusBarStateController; +import com.android.systemui.recents.ScreenPinningRequest; +import com.android.systemui.settings.brightness.BrightnessSliderController; +import com.android.systemui.shared.plugins.PluginManager; +import com.android.systemui.statusbar.CommandQueue; +import com.android.systemui.statusbar.KeyguardIndicationController; +import com.android.systemui.statusbar.LockscreenShadeTransitionController; +import com.android.systemui.statusbar.NotificationListener; +import com.android.systemui.statusbar.NotificationLockscreenUserManager; +import com.android.systemui.statusbar.NotificationMediaManager; +import com.android.systemui.statusbar.NotificationRemoteInputManager; +import com.android.systemui.statusbar.NotificationShadeDepthController; +import com.android.systemui.statusbar.NotificationShadeWindowController; +import com.android.systemui.statusbar.NotificationViewHierarchyManager; +import com.android.systemui.statusbar.OperatorNameViewController; +import com.android.systemui.statusbar.PulseExpansionHandler; +import com.android.systemui.statusbar.StatusBarState; +import com.android.systemui.statusbar.StatusBarStateControllerImpl; +import com.android.systemui.statusbar.charging.WiredChargingRippleController; +import com.android.systemui.statusbar.connectivity.NetworkController; +import com.android.systemui.statusbar.notification.DynamicPrivacyController; +import com.android.systemui.statusbar.notification.NotifPipelineFlags; +import com.android.systemui.statusbar.notification.NotificationEntryManager; +import com.android.systemui.statusbar.notification.NotificationFilter; +import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; +import com.android.systemui.statusbar.notification.collection.NotifLiveDataStore; +import com.android.systemui.statusbar.notification.collection.NotifPipeline; +import com.android.systemui.statusbar.notification.collection.NotificationEntry; +import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder; +import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager; +import com.android.systemui.statusbar.notification.collection.render.NotifShadeEventSource; +import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; +import com.android.systemui.statusbar.notification.init.NotificationsController; +import com.android.systemui.statusbar.notification.interruption.NotificationInterruptLogger; +import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProviderImpl; +import com.android.systemui.statusbar.notification.logging.NotificationLogger; +import com.android.systemui.statusbar.notification.logging.NotificationPanelLoggerFake; +import com.android.systemui.statusbar.notification.row.NotificationGutsManager; +import com.android.systemui.statusbar.notification.stack.NotificationListContainer; +import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; +import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; +import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent; +import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallController; +import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager; +import com.android.systemui.statusbar.policy.BatteryController; +import com.android.systemui.statusbar.policy.ConfigurationController; +import com.android.systemui.statusbar.policy.DeviceProvisionedController; +import com.android.systemui.statusbar.policy.ExtensionController; +import com.android.systemui.statusbar.policy.HeadsUpManager; +import com.android.systemui.statusbar.policy.KeyguardStateController; +import com.android.systemui.statusbar.policy.UserInfoControllerImpl; +import com.android.systemui.statusbar.policy.UserSwitcherController; +import com.android.systemui.statusbar.window.StatusBarWindowController; +import com.android.systemui.statusbar.window.StatusBarWindowStateController; +import com.android.systemui.util.WallpaperController; +import com.android.systemui.util.concurrency.FakeExecutor; +import com.android.systemui.util.concurrency.MessageRouterImpl; +import com.android.systemui.util.time.FakeSystemClock; +import com.android.systemui.volume.VolumeComponent; +import com.android.systemui.wmshell.BubblesManager; +import com.android.wm.shell.bubbles.Bubbles; +import com.android.wm.shell.startingsurface.StartingSurface; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import java.io.ByteArrayOutputStream; +import java.io.PrintWriter; +import java.util.Optional; + +import dagger.Lazy; + +@SmallTest +@RunWith(AndroidTestingRunner.class) +@RunWithLooper(setAsMainLooper = true) +public class CentralSurfacesTest extends SysuiTestCase { + + private static final int FOLD_STATE_FOLDED = 0; + private static final int FOLD_STATE_UNFOLDED = 1; + + private CentralSurfaces mCentralSurfaces; + private FakeMetricsLogger mMetricsLogger; + private PowerManager mPowerManager; + private TestableNotificationInterruptStateProviderImpl mNotificationInterruptStateProvider; + + @Mock private NotificationsController mNotificationsController; + @Mock private LightBarController mLightBarController; + @Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; + @Mock private KeyguardStateController mKeyguardStateController; + @Mock private KeyguardIndicationController mKeyguardIndicationController; + @Mock private NotificationStackScrollLayout mStackScroller; + @Mock private NotificationStackScrollLayoutController mStackScrollerController; + @Mock private NotificationListContainer mNotificationListContainer; + @Mock private HeadsUpManagerPhone mHeadsUpManager; + @Mock private NotificationPanelViewController mNotificationPanelViewController; + @Mock private NotificationPanelView mNotificationPanelView; + @Mock private IStatusBarService mBarService; + @Mock private IDreamManager mDreamManager; + @Mock private ScrimController mScrimController; + @Mock private DozeScrimController mDozeScrimController; + @Mock private Lazy mBiometricUnlockControllerLazy; + @Mock private BiometricUnlockController mBiometricUnlockController; + @Mock private VisualStabilityManager mVisualStabilityManager; + @Mock private NotificationListener mNotificationListener; + @Mock private KeyguardViewMediator mKeyguardViewMediator; + @Mock private NotificationLockscreenUserManager mLockscreenUserManager; + @Mock private NotificationRemoteInputManager mRemoteInputManager; + @Mock private StatusBarStateControllerImpl mStatusBarStateController; + @Mock private BatteryController mBatteryController; + @Mock private DeviceProvisionedController mDeviceProvisionedController; + @Mock private StatusBarNotificationPresenter mNotificationPresenter; + @Mock private NotificationFilter mNotificationFilter; + @Mock private AmbientDisplayConfiguration mAmbientDisplayConfiguration; + @Mock private NotificationLogger.ExpansionStateLogger mExpansionStateLogger; + @Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor; + @Mock private StatusBarSignalPolicy mStatusBarSignalPolicy; + @Mock private NotificationShadeWindowView mNotificationShadeWindowView; + @Mock private BroadcastDispatcher mBroadcastDispatcher; + @Mock private AssistManager mAssistManager; + @Mock private NotifShadeEventSource mNotifShadeEventSource; + @Mock private NotificationEntryManager mNotificationEntryManager; + @Mock private NotificationGutsManager mNotificationGutsManager; + @Mock private NotificationMediaManager mNotificationMediaManager; + @Mock private NavigationBarController mNavigationBarController; + @Mock private AccessibilityFloatingMenuController mAccessibilityFloatingMenuController; + @Mock private SysuiColorExtractor mColorExtractor; + @Mock private ColorExtractor.GradientColors mGradientColors; + @Mock private PulseExpansionHandler mPulseExpansionHandler; + @Mock private NotificationWakeUpCoordinator mNotificationWakeUpCoordinator; + @Mock private KeyguardBypassController mKeyguardBypassController; + @Mock private DynamicPrivacyController mDynamicPrivacyController; + @Mock private AutoHideController mAutoHideController; + @Mock private StatusBarWindowController mStatusBarWindowController; + @Mock private StatusBarWindowStateController mStatusBarWindowStateController; + @Mock private NotificationViewHierarchyManager mNotificationViewHierarchyManager; + @Mock private UserSwitcherController mUserSwitcherController; + @Mock private NetworkController mNetworkController; + @Mock private BubblesManager mBubblesManager; + @Mock private Bubbles mBubbles; + @Mock private NotificationShadeWindowController mNotificationShadeWindowController; + @Mock private NotificationIconAreaController mNotificationIconAreaController; + @Mock private NotificationShadeWindowViewController mNotificationShadeWindowViewController; + @Mock private DozeParameters mDozeParameters; + @Mock private Lazy mLockscreenWallpaperLazy; + @Mock private LockscreenGestureLogger mLockscreenGestureLogger; + @Mock private LockscreenWallpaper mLockscreenWallpaper; + @Mock private DozeServiceHost mDozeServiceHost; + @Mock private ViewMediatorCallback mKeyguardVieMediatorCallback; + @Mock private VolumeComponent mVolumeComponent; + @Mock private CommandQueue mCommandQueue; + @Mock private CentralSurfacesComponent.Factory mStatusBarComponentFactory; + @Mock private CentralSurfacesComponent mCentralSurfacesComponent; + @Mock private PluginManager mPluginManager; + @Mock private ViewMediatorCallback mViewMediatorCallback; + @Mock private StatusBarTouchableRegionManager mStatusBarTouchableRegionManager; + @Mock private ScreenPinningRequest mScreenPinningRequest; + @Mock private PluginDependencyProvider mPluginDependencyProvider; + @Mock private KeyguardDismissUtil mKeyguardDismissUtil; + @Mock private ExtensionController mExtensionController; + @Mock private UserInfoControllerImpl mUserInfoControllerImpl; + @Mock private PhoneStatusBarPolicy mPhoneStatusBarPolicy; + @Mock private DemoModeController mDemoModeController; + @Mock private Lazy mNotificationShadeDepthControllerLazy; + @Mock private BrightnessSliderController.Factory mBrightnessSliderFactory; + @Mock private WallpaperController mWallpaperController; + @Mock private OngoingCallController mOngoingCallController; + @Mock private StatusBarHideIconsForBouncerManager mStatusBarHideIconsForBouncerManager; + @Mock private LockscreenShadeTransitionController mLockscreenTransitionController; + @Mock private FeatureFlags mFeatureFlags; + @Mock private NotificationVisibilityProvider mVisibilityProvider; + @Mock private WallpaperManager mWallpaperManager; + @Mock private IWallpaperManager mIWallpaperManager; + @Mock private KeyguardUnlockAnimationController mKeyguardUnlockAnimationController; + @Mock private ScreenOffAnimationController mScreenOffAnimationController; + @Mock private StartingSurface mStartingSurface; + @Mock private OperatorNameViewController mOperatorNameViewController; + @Mock private OperatorNameViewController.Factory mOperatorNameViewControllerFactory; + @Mock private ActivityLaunchAnimator mActivityLaunchAnimator; + @Mock private NotifPipelineFlags mNotifPipelineFlags; + @Mock private NotifLiveDataStore mNotifLiveDataStore; + @Mock private InteractionJankMonitor mJankMonitor; + @Mock private DeviceStateManager mDeviceStateManager; + @Mock private DreamOverlayStateController mDreamOverlayStateController; + @Mock private WiredChargingRippleController mWiredChargingRippleController; + private ShadeController mShadeController; + private final FakeSystemClock mFakeSystemClock = new FakeSystemClock(); + private FakeExecutor mMainExecutor = new FakeExecutor(mFakeSystemClock); + private FakeExecutor mUiBgExecutor = new FakeExecutor(mFakeSystemClock); + private InitController mInitController = new InitController(); + private final DumpManager mDumpManager = new DumpManager(); + + @Before + public void setup() throws Exception { + MockitoAnnotations.initMocks(this); + mDependency.injectTestDependency(NotificationFilter.class, mNotificationFilter); + + IPowerManager powerManagerService = mock(IPowerManager.class); + IThermalService thermalService = mock(IThermalService.class); + mPowerManager = new PowerManager(mContext, powerManagerService, thermalService, + Handler.createAsync(Looper.myLooper())); + + mNotificationInterruptStateProvider = + new TestableNotificationInterruptStateProviderImpl(mContext.getContentResolver(), + mPowerManager, + mDreamManager, mAmbientDisplayConfiguration, mNotificationFilter, + mStatusBarStateController, mBatteryController, mHeadsUpManager, + mock(NotificationInterruptLogger.class), + new Handler(TestableLooper.get(this).getLooper())); + + mContext.addMockSystemService(TrustManager.class, mock(TrustManager.class)); + mContext.addMockSystemService(FingerprintManager.class, mock(FingerprintManager.class)); + + mMetricsLogger = new FakeMetricsLogger(); + NotificationLogger notificationLogger = new NotificationLogger( + mNotificationListener, + mUiBgExecutor, + mNotifPipelineFlags, + mNotifLiveDataStore, + mVisibilityProvider, + mock(NotificationEntryManager.class), + mock(NotifPipeline.class), + mStatusBarStateController, + mExpansionStateLogger, + new NotificationPanelLoggerFake() + ); + notificationLogger.setVisibilityReporter(mock(Runnable.class)); + + when(mCommandQueue.asBinder()).thenReturn(new Binder()); + + mContext.setTheme(R.style.Theme_SystemUI_LightWallpaper); + + when(mStackScrollerController.getView()).thenReturn(mStackScroller); + when(mStackScroller.generateLayoutParams(any())).thenReturn(new LayoutParams(0, 0)); + when(mNotificationPanelViewController.getView()).thenReturn(mNotificationPanelView); + when(mNotificationPanelView.getLayoutParams()).thenReturn(new LayoutParams(0, 0)); + when(powerManagerService.isInteractive()).thenReturn(true); + when(mStackScroller.getActivatedChild()).thenReturn(null); + + doAnswer(invocation -> { + OnDismissAction onDismissAction = (OnDismissAction) invocation.getArguments()[0]; + onDismissAction.onDismiss(); + return null; + }).when(mStatusBarKeyguardViewManager).dismissWithAction(any(), any(), anyBoolean()); + + doAnswer(invocation -> { + Runnable runnable = (Runnable) invocation.getArguments()[0]; + runnable.run(); + return null; + }).when(mStatusBarKeyguardViewManager).addAfterKeyguardGoneRunnable(any()); + + WakefulnessLifecycle wakefulnessLifecycle = + new WakefulnessLifecycle(mContext, mIWallpaperManager, mDumpManager); + wakefulnessLifecycle.dispatchStartedWakingUp(PowerManager.WAKE_REASON_UNKNOWN); + wakefulnessLifecycle.dispatchFinishedWakingUp(); + + when(mGradientColors.supportsDarkText()).thenReturn(true); + when(mColorExtractor.getNeutralColors()).thenReturn(mGradientColors); + ConfigurationController configurationController = new ConfigurationControllerImpl(mContext); + + when(mLockscreenWallpaperLazy.get()).thenReturn(mLockscreenWallpaper); + when(mBiometricUnlockControllerLazy.get()).thenReturn(mBiometricUnlockController); + + when(mStatusBarComponentFactory.create()).thenReturn(mCentralSurfacesComponent); + when(mCentralSurfacesComponent.getNotificationShadeWindowViewController()).thenReturn( + mNotificationShadeWindowViewController); + doAnswer(invocation -> { + ((Runnable) invocation.getArgument(0)).run(); + return null; + }).when(mNotificationShadeWindowController).batchApplyWindowLayoutParams(any()); + + mShadeController = new ShadeControllerImpl(mCommandQueue, + mStatusBarStateController, mNotificationShadeWindowController, + mStatusBarKeyguardViewManager, mContext.getSystemService(WindowManager.class), + () -> Optional.of(mCentralSurfaces), () -> mAssistManager); + + when(mOperatorNameViewControllerFactory.create(any())) + .thenReturn(mOperatorNameViewController); + + mCentralSurfaces = new CentralSurfaces( + mContext, + mNotificationsController, + mock(FragmentService.class), + mLightBarController, + mAutoHideController, + mStatusBarWindowController, + mStatusBarWindowStateController, + mKeyguardUpdateMonitor, + mStatusBarSignalPolicy, + mPulseExpansionHandler, + mNotificationWakeUpCoordinator, + mKeyguardBypassController, + mKeyguardStateController, + mHeadsUpManager, + mDynamicPrivacyController, + new FalsingManagerFake(), + new FalsingCollectorFake(), + mBroadcastDispatcher, + mNotifShadeEventSource, + mNotificationEntryManager, + mNotificationGutsManager, + notificationLogger, + mNotificationInterruptStateProvider, + mNotificationViewHierarchyManager, + new PanelExpansionStateManager(), + mKeyguardViewMediator, + new DisplayMetrics(), + mMetricsLogger, + mUiBgExecutor, + mNotificationMediaManager, + mLockscreenUserManager, + mRemoteInputManager, + mUserSwitcherController, + mNetworkController, + mBatteryController, + mColorExtractor, + new ScreenLifecycle(mDumpManager), + wakefulnessLifecycle, + mStatusBarStateController, + Optional.of(mBubblesManager), + Optional.of(mBubbles), + mVisualStabilityManager, + mDeviceProvisionedController, + mNavigationBarController, + mAccessibilityFloatingMenuController, + () -> mAssistManager, + configurationController, + mNotificationShadeWindowController, + mDozeParameters, + mScrimController, + mLockscreenWallpaperLazy, + mLockscreenGestureLogger, + mBiometricUnlockControllerLazy, + mDozeServiceHost, + mPowerManager, mScreenPinningRequest, + mDozeScrimController, + mVolumeComponent, + mCommandQueue, + mStatusBarComponentFactory, + mPluginManager, + mShadeController, + mStatusBarKeyguardViewManager, + mViewMediatorCallback, + mInitController, + new Handler(TestableLooper.get(this).getLooper()), + mPluginDependencyProvider, + mKeyguardDismissUtil, + mExtensionController, + mUserInfoControllerImpl, + mPhoneStatusBarPolicy, + mKeyguardIndicationController, + mDemoModeController, + mNotificationShadeDepthControllerLazy, + mStatusBarTouchableRegionManager, + mNotificationIconAreaController, + mBrightnessSliderFactory, + mScreenOffAnimationController, + mWallpaperController, + mOngoingCallController, + mStatusBarHideIconsForBouncerManager, + mLockscreenTransitionController, + mFeatureFlags, + mKeyguardUnlockAnimationController, + new Handler(TestableLooper.get(this).getLooper()), + mMainExecutor, + new MessageRouterImpl(mMainExecutor), + mWallpaperManager, + Optional.of(mStartingSurface), + mActivityLaunchAnimator, + mNotifPipelineFlags, + mJankMonitor, + mDeviceStateManager, + mDreamOverlayStateController, + mWiredChargingRippleController); + when(mKeyguardViewMediator.registerCentralSurfaces( + any(CentralSurfaces.class), + any(NotificationPanelViewController.class), + any(PanelExpansionStateManager.class), + any(BiometricUnlockController.class), + any(ViewGroup.class), + any(KeyguardBypassController.class))) + .thenReturn(mStatusBarKeyguardViewManager); + + when(mKeyguardViewMediator.getViewMediatorCallback()).thenReturn( + mKeyguardVieMediatorCallback); + + // TODO: we should be able to call mCentralSurfaces.start() and have all the below values + // initialized automatically. + mCentralSurfaces.mNotificationShadeWindowView = mNotificationShadeWindowView; + mCentralSurfaces.mNotificationPanelViewController = mNotificationPanelViewController; + mCentralSurfaces.mDozeScrimController = mDozeScrimController; + mCentralSurfaces.mPresenter = mNotificationPresenter; + mCentralSurfaces.mKeyguardIndicationController = mKeyguardIndicationController; + mCentralSurfaces.mBarService = mBarService; + mCentralSurfaces.mStackScroller = mStackScroller; + mCentralSurfaces.startKeyguard(); + mInitController.executePostInitTasks(); + notificationLogger.setUpWithContainer(mNotificationListContainer); + } + + @Test + public void testSetBouncerShowing_noCrash() { + mCentralSurfaces.setBouncerShowing(true); + } + + @Test + public void executeRunnableDismissingKeyguard_nullRunnable_showingAndOccluded() { + when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); + when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(true); + + mCentralSurfaces.executeRunnableDismissingKeyguard(null, null, false, false, false); + } + + @Test + public void executeRunnableDismissingKeyguard_nullRunnable_showing() { + when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); + when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); + + mCentralSurfaces.executeRunnableDismissingKeyguard(null, null, false, false, false); + } + + @Test + public void executeRunnableDismissingKeyguard_nullRunnable_notShowing() { + when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false); + when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); + + mCentralSurfaces.executeRunnableDismissingKeyguard(null, null, false, false, false); + } + + @Test + public void lockscreenStateMetrics_notShowing() { + // uninteresting state, except that fingerprint must be non-zero + when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); + when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true); + // interesting state + when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false); + when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); + when(mKeyguardStateController.isMethodSecure()).thenReturn(false); + mCentralSurfaces.onKeyguardViewManagerStatesUpdated(); + + MetricsAsserts.assertHasLog("missing hidden insecure lockscreen log", + mMetricsLogger.getLogs(), + new LogMaker(MetricsEvent.LOCKSCREEN) + .setType(MetricsEvent.TYPE_CLOSE) + .setSubtype(0)); + } + + @Test + public void lockscreenStateMetrics_notShowing_secure() { + // uninteresting state, except that fingerprint must be non-zero + when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); + when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true); + // interesting state + when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false); + when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); + when(mKeyguardStateController.isMethodSecure()).thenReturn(true); + + mCentralSurfaces.onKeyguardViewManagerStatesUpdated(); + + MetricsAsserts.assertHasLog("missing hidden secure lockscreen log", + mMetricsLogger.getLogs(), + new LogMaker(MetricsEvent.LOCKSCREEN) + .setType(MetricsEvent.TYPE_CLOSE) + .setSubtype(1)); + } + + @Test + public void lockscreenStateMetrics_isShowing() { + // uninteresting state, except that fingerprint must be non-zero + when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); + when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true); + // interesting state + when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); + when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); + when(mKeyguardStateController.isMethodSecure()).thenReturn(false); + + mCentralSurfaces.onKeyguardViewManagerStatesUpdated(); + + MetricsAsserts.assertHasLog("missing insecure lockscreen showing", + mMetricsLogger.getLogs(), + new LogMaker(MetricsEvent.LOCKSCREEN) + .setType(MetricsEvent.TYPE_OPEN) + .setSubtype(0)); + } + + @Test + public void lockscreenStateMetrics_isShowing_secure() { + // uninteresting state, except that fingerprint must be non-zero + when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); + when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true); + // interesting state + when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); + when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); + when(mKeyguardStateController.isMethodSecure()).thenReturn(true); + + mCentralSurfaces.onKeyguardViewManagerStatesUpdated(); + + MetricsAsserts.assertHasLog("missing secure lockscreen showing log", + mMetricsLogger.getLogs(), + new LogMaker(MetricsEvent.LOCKSCREEN) + .setType(MetricsEvent.TYPE_OPEN) + .setSubtype(1)); + } + + @Test + public void lockscreenStateMetrics_isShowingBouncer() { + // uninteresting state, except that fingerprint must be non-zero + when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); + when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true); + // interesting state + when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); + when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(true); + when(mKeyguardStateController.isMethodSecure()).thenReturn(true); + + mCentralSurfaces.onKeyguardViewManagerStatesUpdated(); + + MetricsAsserts.assertHasLog("missing bouncer log", + mMetricsLogger.getLogs(), + new LogMaker(MetricsEvent.BOUNCER) + .setType(MetricsEvent.TYPE_OPEN) + .setSubtype(1)); + } + + @Test + public void testShouldHeadsUp_nonSuppressedGroupSummary() throws Exception { + when(mPowerManager.isScreenOn()).thenReturn(true); + when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); + when(mNotificationFilter.shouldFilterOut(any())).thenReturn(false); + when(mDreamManager.isDreaming()).thenReturn(false); + + Notification n = new Notification.Builder(getContext(), "a") + .setGroup("a") + .setGroupSummary(true) + .setGroupAlertBehavior(Notification.GROUP_ALERT_SUMMARY) + .build(); + + NotificationEntry entry = new NotificationEntryBuilder() + .setPkg("a") + .setOpPkg("a") + .setTag("a") + .setNotification(n) + .setImportance(IMPORTANCE_HIGH) + .build(); + + assertTrue(mNotificationInterruptStateProvider.shouldHeadsUp(entry)); + } + + @Test + public void testShouldHeadsUp_suppressedGroupSummary() throws Exception { + when(mPowerManager.isScreenOn()).thenReturn(true); + when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); + when(mNotificationFilter.shouldFilterOut(any())).thenReturn(false); + when(mDreamManager.isDreaming()).thenReturn(false); + + Notification n = new Notification.Builder(getContext(), "a") + .setGroup("a") + .setGroupSummary(true) + .setGroupAlertBehavior(Notification.GROUP_ALERT_CHILDREN) + .build(); + + NotificationEntry entry = new NotificationEntryBuilder() + .setPkg("a") + .setOpPkg("a") + .setTag("a") + .setNotification(n) + .setImportance(IMPORTANCE_HIGH) + .build(); + + assertFalse(mNotificationInterruptStateProvider.shouldHeadsUp(entry)); + } + + @Test + public void testShouldHeadsUp_suppressedHeadsUp() throws Exception { + when(mPowerManager.isScreenOn()).thenReturn(true); + when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); + when(mNotificationFilter.shouldFilterOut(any())).thenReturn(false); + when(mDreamManager.isDreaming()).thenReturn(false); + + Notification n = new Notification.Builder(getContext(), "a").build(); + + NotificationEntry entry = new NotificationEntryBuilder() + .setPkg("a") + .setOpPkg("a") + .setTag("a") + .setNotification(n) + .setImportance(IMPORTANCE_HIGH) + .setSuppressedVisualEffects(SUPPRESSED_EFFECT_PEEK) + .build(); + + assertFalse(mNotificationInterruptStateProvider.shouldHeadsUp(entry)); + } + + @Test + public void testShouldHeadsUp_noSuppressedHeadsUp() throws Exception { + when(mPowerManager.isScreenOn()).thenReturn(true); + when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); + when(mNotificationFilter.shouldFilterOut(any())).thenReturn(false); + when(mDreamManager.isDreaming()).thenReturn(false); + + Notification n = new Notification.Builder(getContext(), "a").build(); + + NotificationEntry entry = new NotificationEntryBuilder() + .setPkg("a") + .setOpPkg("a") + .setTag("a") + .setNotification(n) + .setImportance(IMPORTANCE_HIGH) + .build(); + + assertTrue(mNotificationInterruptStateProvider.shouldHeadsUp(entry)); + } + + @Test + public void testLogHidden() { + try { + mCentralSurfaces.handleVisibleToUserChanged(false); + mUiBgExecutor.runAllReady(); + verify(mBarService, times(1)).onPanelHidden(); + verify(mBarService, never()).onPanelRevealed(anyBoolean(), anyInt()); + } catch (RemoteException e) { + fail(); + } + } + + @Test + public void testPanelOpenForHeadsUp() { + when(mDeviceProvisionedController.isDeviceProvisioned()).thenReturn(true); + when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true); + when(mNotificationsController.getActiveNotificationsCount()).thenReturn(5); + when(mNotificationPresenter.isPresenterFullyCollapsed()).thenReturn(true); + mCentralSurfaces.setBarStateForTest(StatusBarState.SHADE); + + try { + mCentralSurfaces.handleVisibleToUserChanged(true); + mUiBgExecutor.runAllReady(); + verify(mBarService, never()).onPanelHidden(); + verify(mBarService, times(1)).onPanelRevealed(false, 1); + } catch (RemoteException e) { + fail(); + } + mMainExecutor.runAllReady(); + } + + @Test + public void testPanelOpenAndClear() { + when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false); + when(mNotificationsController.getActiveNotificationsCount()).thenReturn(5); + + when(mNotificationPresenter.isPresenterFullyCollapsed()).thenReturn(false); + mCentralSurfaces.setBarStateForTest(StatusBarState.SHADE); + + try { + mCentralSurfaces.handleVisibleToUserChanged(true); + mUiBgExecutor.runAllReady(); + verify(mBarService, never()).onPanelHidden(); + verify(mBarService, times(1)).onPanelRevealed(true, 5); + } catch (RemoteException e) { + fail(); + } + mMainExecutor.runAllReady(); + } + + @Test + public void testPanelOpenAndNoClear() { + when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false); + when(mNotificationsController.getActiveNotificationsCount()).thenReturn(5); + when(mNotificationPresenter.isPresenterFullyCollapsed()).thenReturn(false); + mCentralSurfaces.setBarStateForTest(StatusBarState.KEYGUARD); + + try { + mCentralSurfaces.handleVisibleToUserChanged(true); + mUiBgExecutor.runAllReady(); + verify(mBarService, never()).onPanelHidden(); + verify(mBarService, times(1)).onPanelRevealed(false, 5); + } catch (RemoteException e) { + fail(); + } + mMainExecutor.runAllReady(); + } + + @Test + public void testDump_DoesNotCrash() { + mCentralSurfaces.dump(null, new PrintWriter(new ByteArrayOutputStream()), null); + } + + @Test + public void testDumpBarTransitions_DoesNotCrash() { + CentralSurfaces.dumpBarTransitions( + new PrintWriter(new ByteArrayOutputStream()), "var", /* transitions= */ null); + } + + @Test + public void testFingerprintNotification_UpdatesScrims() { + mCentralSurfaces.notifyBiometricAuthModeChanged(); + verify(mScrimController).transitionTo(any(), any()); + } + + @Test + public void testFingerprintUnlock_UpdatesScrims() { + // Simulate unlocking from AoD with fingerprint. + when(mBiometricUnlockController.getMode()) + .thenReturn(BiometricUnlockController.MODE_WAKE_AND_UNLOCK); + mCentralSurfaces.updateScrimController(); + verify(mScrimController).transitionTo(eq(ScrimState.UNLOCKED), any()); + } + + @Test + public void testTransitionLaunch_goesToUnlocked() { + mCentralSurfaces.setBarStateForTest(StatusBarState.KEYGUARD); + mCentralSurfaces.showKeyguardImpl(); + + // Starting a pulse should change the scrim controller to the pulsing state + when(mNotificationPanelViewController.isLaunchTransitionRunning()).thenReturn(true); + when(mNotificationPanelViewController.isLaunchingAffordanceWithPreview()).thenReturn(true); + mCentralSurfaces.updateScrimController(); + verify(mScrimController).transitionTo(eq(ScrimState.UNLOCKED), any()); + } + + @Test + public void testSetExpansionAffectsAlpha_whenKeyguardShowingButGoingAwayForAnyReason() { + mCentralSurfaces.updateScrimController(); + verify(mScrimController).setExpansionAffectsAlpha(eq(true)); + + clearInvocations(mScrimController); + when(mKeyguardStateController.isShowing()).thenReturn(true); + when(mKeyguardStateController.isKeyguardGoingAway()).thenReturn(false); + mCentralSurfaces.updateScrimController(); + verify(mScrimController).setExpansionAffectsAlpha(eq(true)); + + clearInvocations(mScrimController); + when(mKeyguardStateController.isShowing()).thenReturn(true); + when(mKeyguardStateController.isKeyguardGoingAway()).thenReturn(true); + mCentralSurfaces.updateScrimController(); + verify(mScrimController).setExpansionAffectsAlpha(eq(false)); + + clearInvocations(mScrimController); + when(mKeyguardStateController.isShowing()).thenReturn(true); + when(mKeyguardStateController.isKeyguardFadingAway()).thenReturn(true); + mCentralSurfaces.updateScrimController(); + verify(mScrimController).setExpansionAffectsAlpha(eq(false)); + } + + @Test + public void testTransitionLaunch_noPreview_doesntGoUnlocked() { + mCentralSurfaces.setBarStateForTest(StatusBarState.KEYGUARD); + mCentralSurfaces.showKeyguardImpl(); + + // Starting a pulse should change the scrim controller to the pulsing state + when(mNotificationPanelViewController.isLaunchTransitionRunning()).thenReturn(true); + when(mNotificationPanelViewController.isLaunchingAffordanceWithPreview()).thenReturn(false); + mCentralSurfaces.updateScrimController(); + verify(mScrimController).transitionTo(eq(ScrimState.KEYGUARD)); + } + + @Test + public void testSetOccluded_propagatesToScrimController() { + mCentralSurfaces.setOccluded(true); + verify(mScrimController).setKeyguardOccluded(eq(true)); + + reset(mScrimController); + mCentralSurfaces.setOccluded(false); + verify(mScrimController).setKeyguardOccluded(eq(false)); + } + + @Test + public void testPulseWhileDozing_updatesScrimController() { + mCentralSurfaces.setBarStateForTest(StatusBarState.KEYGUARD); + mCentralSurfaces.showKeyguardImpl(); + + // Starting a pulse should change the scrim controller to the pulsing state + when(mDozeServiceHost.isPulsing()).thenReturn(true); + mCentralSurfaces.updateScrimController(); + verify(mScrimController).transitionTo(eq(ScrimState.PULSING), any()); + + // Ending a pulse should take it back to keyguard state + when(mDozeServiceHost.isPulsing()).thenReturn(false); + mCentralSurfaces.updateScrimController(); + verify(mScrimController).transitionTo(eq(ScrimState.KEYGUARD)); + } + + @Test + public void testShowKeyguardImplementation_setsState() { + when(mLockscreenUserManager.getCurrentProfiles()).thenReturn(new SparseArray<>()); + + mCentralSurfaces.setBarStateForTest(StatusBarState.SHADE); + + // By default, showKeyguardImpl sets state to KEYGUARD. + mCentralSurfaces.showKeyguardImpl(); + verify(mStatusBarStateController).setState( + eq(StatusBarState.KEYGUARD), eq(false) /* force */); + } + + @Test + public void testOnStartedWakingUp_isNotDozing() { + mCentralSurfaces.setBarStateForTest(StatusBarState.KEYGUARD); + when(mStatusBarStateController.isKeyguardRequested()).thenReturn(true); + when(mDozeServiceHost.getDozingRequested()).thenReturn(true); + mCentralSurfaces.updateIsKeyguard(); + // TODO: mNotificationPanelView.expand(false) gets called twice. Should be once. + verify(mNotificationPanelViewController, times(2)).expand(eq(false)); + clearInvocations(mNotificationPanelViewController); + + mCentralSurfaces.mWakefulnessObserver.onStartedWakingUp(); + verify(mDozeServiceHost).stopDozing(); + verify(mNotificationPanelViewController).expand(eq(false)); + } + + @Test + public void testOnStartedWakingUp_doesNotDismissBouncer_whenPulsing() { + mCentralSurfaces.setBarStateForTest(StatusBarState.KEYGUARD); + when(mStatusBarStateController.isKeyguardRequested()).thenReturn(true); + when(mDozeServiceHost.getDozingRequested()).thenReturn(true); + mCentralSurfaces.updateIsKeyguard(); + clearInvocations(mNotificationPanelViewController); + + mCentralSurfaces.setBouncerShowing(true); + mCentralSurfaces.mWakefulnessObserver.onStartedWakingUp(); + verify(mNotificationPanelViewController, never()).expand(anyBoolean()); + } + + @Test + public void testRegisterBroadcastsonDispatcher() { + mCentralSurfaces.registerBroadcastReceiver(); + verify(mBroadcastDispatcher).registerReceiver( + any(BroadcastReceiver.class), + any(IntentFilter.class), + eq(null), + any(UserHandle.class)); + } + + @Test + public void testUpdateResources_updatesBouncer() { + mCentralSurfaces.updateResources(); + + verify(mStatusBarKeyguardViewManager).updateResources(); + } + + @Test + public void deviceStateChange_unfolded_shadeOpen_setsLeaveOpenOnKeyguardHide() { + setFoldedStates(FOLD_STATE_FOLDED); + setGoToSleepStates(FOLD_STATE_FOLDED); + when(mNotificationPanelViewController.isFullyExpanded()).thenReturn(true); + + setDeviceState(FOLD_STATE_UNFOLDED); + + verify(mStatusBarStateController).setLeaveOpenOnKeyguardHide(true); + } + + @Test + public void deviceStateChange_unfolded_shadeClose_doesNotSetLeaveOpenOnKeyguardHide() { + setFoldedStates(FOLD_STATE_FOLDED); + setGoToSleepStates(FOLD_STATE_FOLDED); + when(mNotificationPanelViewController.isFullyExpanded()).thenReturn(false); + + setDeviceState(FOLD_STATE_UNFOLDED); + + verify(mStatusBarStateController, never()).setLeaveOpenOnKeyguardHide(true); + } + + private void setDeviceState(int state) { + ArgumentCaptor callbackCaptor = + ArgumentCaptor.forClass(DeviceStateManager.DeviceStateCallback.class); + verify(mDeviceStateManager).registerCallback(any(), callbackCaptor.capture()); + callbackCaptor.getValue().onStateChanged(state); + } + + private void setGoToSleepStates(int... states) { + mContext.getOrCreateTestableResources().addOverride( + com.android.internal.R.array.config_deviceStatesOnWhichToSleep, + states); + } + + private void setFoldedStates(int... states) { + mContext.getOrCreateTestableResources().addOverride( + com.android.internal.R.array.config_foldedDeviceStates, + states); + } + + public static class TestableNotificationInterruptStateProviderImpl extends + NotificationInterruptStateProviderImpl { + + TestableNotificationInterruptStateProviderImpl( + ContentResolver contentResolver, + PowerManager powerManager, + IDreamManager dreamManager, + AmbientDisplayConfiguration ambientDisplayConfiguration, + NotificationFilter filter, + StatusBarStateController controller, + BatteryController batteryController, + HeadsUpManager headsUpManager, + NotificationInterruptLogger logger, + Handler mainHandler) { + super(contentResolver, powerManager, dreamManager, ambientDisplayConfiguration, filter, + batteryController, controller, headsUpManager, logger, mainHandler); + mUseHeadsUp = true; + } + } +} diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java index 6ce3b4b7b6f9..26ac70c70e7f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java @@ -82,7 +82,7 @@ public class DozeServiceHostTest extends SysuiTestCase { @Mock private NotificationShadeWindowController mNotificationShadeWindowController; @Mock private PowerManager mPowerManager; @Mock private WakefulnessLifecycle mWakefullnessLifecycle; - @Mock private StatusBar mStatusBar; + @Mock private CentralSurfaces mCentralSurfaces; @Mock private NotificationIconAreaController mNotificationIconAreaController; @Mock private NotificationShadeWindowViewController mNotificationShadeWindowViewController; @Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; @@ -103,7 +103,7 @@ public class DozeServiceHostTest extends SysuiTestCase { mAuthController, mNotificationIconAreaController); mDozeServiceHost.initialize( - mStatusBar, + mCentralSurfaces, mStatusBarKeyguardViewManager, mNotificationShadeWindowViewController, mNotificationPanel, @@ -119,7 +119,7 @@ public class DozeServiceHostTest extends SysuiTestCase { mDozeServiceHost.startDozing(); verify(mStatusBarStateController).setIsDozing(eq(true)); - verify(mStatusBar).updateIsKeyguard(); + verify(mCentralSurfaces).updateIsKeyguard(); mDozeServiceHost.stopDozing(); verify(mStatusBarStateController).setIsDozing(eq(false)); @@ -128,8 +128,8 @@ public class DozeServiceHostTest extends SysuiTestCase { @Test public void testPulseWhileDozing_updatesScrimController() { - mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD); - mStatusBar.showKeyguardImpl(); + mCentralSurfaces.setBarStateForTest(StatusBarState.KEYGUARD); + mCentralSurfaces.showKeyguardImpl(); // Keep track of callback to be able to stop the pulse // DozeHost.PulseCallback[] pulseCallback = new DozeHost.PulseCallback[1]; @@ -154,12 +154,12 @@ public class DozeServiceHostTest extends SysuiTestCase { verify(mDozeScrimController).pulse( pulseCallbackArgumentCaptor.capture(), eq(DozeLog.PULSE_REASON_NOTIFICATION)); - verify(mStatusBar).updateScrimController(); - reset(mStatusBar); + verify(mCentralSurfaces).updateScrimController(); + reset(mCentralSurfaces); pulseCallbackArgumentCaptor.getValue().onPulseFinished(); assertFalse(mDozeScrimController.isPulsing()); - verify(mStatusBar).updateScrimController(); + verify(mCentralSurfaces).updateScrimController(); } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java index 421d8f6a1889..db5741c90ebc 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java @@ -63,7 +63,6 @@ public class HeadsUpManagerPhoneTest extends AlertingNotificationManagerTest { @Mock private NotificationGroupManagerLegacy mGroupManager; @Mock private View mNotificationShadeWindowView; @Mock private VisualStabilityProvider mVSProvider; - @Mock private StatusBar mBar; @Mock private StatusBarStateController mStatusBarStateController; @Mock private KeyguardBypassController mBypassController; @Mock private ConfigurationControllerImpl mConfigurationController; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaTest.kt index 3257a84f14d6..31465f45af42 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaTest.kt @@ -25,7 +25,7 @@ import java.util.concurrent.Executor class KeyguardBottomAreaTest : SysuiTestCase() { @Mock - private lateinit var mStatusBar: StatusBar + private lateinit var mCentralSurfaces: CentralSurfaces private lateinit var mKeyguardBottomArea: KeyguardBottomAreaView @Before @@ -42,7 +42,7 @@ class KeyguardBottomAreaTest : SysuiTestCase() { mKeyguardBottomArea = LayoutInflater.from(mContext).inflate( R.layout.keyguard_bottom_area, null, false) as KeyguardBottomAreaView - mKeyguardBottomArea.setStatusBar(mStatusBar) + mKeyguardBottomArea.setCentralSurfaces(mCentralSurfaces) } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java index b44eb65ca83c..38412fd1fa9b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java @@ -169,7 +169,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { private static final int NOTIFICATION_SCRIM_TOP_PADDING_IN_SPLIT_SHADE = 50; @Mock - private StatusBar mStatusBar; + private CentralSurfaces mCentralSurfaces; @Mock private NotificationStackScrollLayout mNotificationStackScrollLayout; @Mock @@ -548,7 +548,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { mKeyguardUnlockAnimationController, mNotificationListContainer); mNotificationPanelViewController.initDependencies( - mStatusBar, + mCentralSurfaces, () -> {}, mNotificationShelfController); mNotificationPanelViewController.setHeadsUpManager(mHeadsUpManager); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewControllerTest.kt index 26fafdf3982a..093f92646115 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewControllerTest.kt @@ -61,7 +61,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() { @Mock private lateinit var mStatusBarStateController: SysuiStatusBarStateController @Mock - private lateinit var mStatusBar: StatusBar + private lateinit var mCentralSurfaces: CentralSurfaces @Mock private lateinit var mDockManager: DockManager @Mock @@ -108,7 +108,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() { mStatusBarWindowStateController, mLockIconViewController, Optional.of(mLowLightClockController), - mStatusBar, + mCentralSurfaces, mNotificationShadeWindowController ) mController.setupExpandedStatusBar() diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewTest.java index f9a1bdd09f7b..62a1bcdc0184 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewTest.java @@ -71,7 +71,7 @@ public class NotificationShadeWindowViewTest extends SysuiTestCase { @Mock private DragDownHelper mDragDownHelper; @Mock private SysuiStatusBarStateController mStatusBarStateController; @Mock private ShadeController mShadeController; - @Mock private StatusBar mStatusBar; + @Mock private CentralSurfaces mCentralSurfaces; @Mock private DockManager mDockManager; @Mock private NotificationPanelViewController mNotificationPanelViewController; @Mock private NotificationStackScrollLayout mNotificationStackScrollLayout; @@ -116,7 +116,7 @@ public class NotificationShadeWindowViewTest extends SysuiTestCase { mStatusBarWindowStateController, mLockIconViewController, Optional.of(mLowLightClockController), - mStatusBar, + mCentralSurfaces, mNotificationShadeWindowController); mController.setupExpandedStatusBar(); mController.setDragDownHelper(mDragDownHelper); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarCommandQueueCallbacksTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarCommandQueueCallbacksTest.java deleted file mode 100644 index 54d9cece90fc..000000000000 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarCommandQueueCallbacksTest.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (C) 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.statusbar.phone; - -import static android.view.Display.DEFAULT_DISPLAY; - -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import android.app.StatusBarManager; -import android.os.PowerManager; -import android.os.Vibrator; -import android.testing.AndroidTestingRunner; - -import androidx.test.filters.SmallTest; - -import com.android.internal.logging.MetricsLogger; -import com.android.internal.logging.testing.FakeMetricsLogger; -import com.android.keyguard.KeyguardUpdateMonitor; -import com.android.systemui.SysuiTestCase; -import com.android.systemui.assist.AssistManager; -import com.android.systemui.keyguard.WakefulnessLifecycle; -import com.android.systemui.statusbar.CommandQueue; -import com.android.systemui.statusbar.DisableFlagsLogger; -import com.android.systemui.statusbar.StatusBarStateControllerImpl; -import com.android.systemui.statusbar.VibratorHelper; -import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; -import com.android.systemui.statusbar.policy.DeviceProvisionedController; -import com.android.systemui.statusbar.policy.KeyguardStateController; -import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.mockito.stubbing.Answer; - -import java.util.Optional; - -@SmallTest -@RunWith(AndroidTestingRunner.class) -public class StatusBarCommandQueueCallbacksTest extends SysuiTestCase { - @Mock private StatusBar mStatusBar; - @Mock private ShadeController mShadeController; - @Mock private CommandQueue mCommandQueue; - @Mock private NotificationPanelViewController mNotificationPanelViewController; - @Mock private RemoteInputQuickSettingsDisabler mRemoteInputQuickSettingsDisabler; - private final MetricsLogger mMetricsLogger = new FakeMetricsLogger(); - @Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor; - @Mock private KeyguardStateController mKeyguardStateController; - @Mock private HeadsUpManagerPhone mHeadsUpManager; - @Mock private WakefulnessLifecycle mWakefulnessLifecycle; - @Mock private DeviceProvisionedController mDeviceProvisionedController; - @Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; - @Mock private AssistManager mAssistManager; - @Mock private DozeServiceHost mDozeServiceHost; - @Mock private StatusBarStateControllerImpl mStatusBarStateController; - @Mock private NotificationShadeWindowView mNotificationShadeWindowView; - @Mock private NotificationStackScrollLayoutController mNotificationStackScrollLayoutController; - @Mock private PowerManager mPowerManager; - @Mock private VibratorHelper mVibratorHelper; - @Mock private Vibrator mVibrator; - @Mock private LightBarController mLightBarController; - @Mock private StatusBarHideIconsForBouncerManager mStatusBarHideIconsForBouncerManager; - - StatusBarCommandQueueCallbacks mSbcqCallbacks; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - - mSbcqCallbacks = new StatusBarCommandQueueCallbacks( - mStatusBar, - mContext, - mContext.getResources(), - mShadeController, - mCommandQueue, - mNotificationPanelViewController, - mRemoteInputQuickSettingsDisabler, - mMetricsLogger, - mKeyguardUpdateMonitor, - mKeyguardStateController, - mHeadsUpManager, - mWakefulnessLifecycle, - mDeviceProvisionedController, - mStatusBarKeyguardViewManager, - mAssistManager, - mDozeServiceHost, - mStatusBarStateController, - mNotificationShadeWindowView, - mNotificationStackScrollLayoutController, - mStatusBarHideIconsForBouncerManager, - mPowerManager, - mVibratorHelper, - Optional.of(mVibrator), - mLightBarController, - new DisableFlagsLogger(), - DEFAULT_DISPLAY); - - when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); - when(mRemoteInputQuickSettingsDisabler.adjustDisableFlags(anyInt())) - .thenAnswer((Answer) invocation -> invocation.getArgument(0)); - } - - @Test - public void testDisableNotificationShade() { - when(mStatusBar.getDisabled1()).thenReturn(StatusBarManager.DISABLE_NONE); - when(mStatusBar.getDisabled2()).thenReturn(StatusBarManager.DISABLE_NONE); - when(mCommandQueue.panelsEnabled()).thenReturn(false); - mSbcqCallbacks.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_NONE, - StatusBarManager.DISABLE2_NOTIFICATION_SHADE, false); - - verify(mStatusBar).updateQsExpansionEnabled(); - verify(mShadeController).animateCollapsePanels(); - - // Trying to open it does nothing. - mSbcqCallbacks.animateExpandNotificationsPanel(); - verify(mNotificationPanelViewController, never()).expandWithoutQs(); - mSbcqCallbacks.animateExpandSettingsPanel(null); - verify(mNotificationPanelViewController, never()).expand(anyBoolean()); - } - - @Test - public void testEnableNotificationShade() { - when(mStatusBar.getDisabled1()).thenReturn(StatusBarManager.DISABLE_NONE); - when(mStatusBar.getDisabled2()).thenReturn(StatusBarManager.DISABLE2_NOTIFICATION_SHADE); - when(mCommandQueue.panelsEnabled()).thenReturn(true); - mSbcqCallbacks.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_NONE, - StatusBarManager.DISABLE2_NONE, false); - verify(mStatusBar).updateQsExpansionEnabled(); - verify(mShadeController, never()).animateCollapsePanels(); - - // Can now be opened. - mSbcqCallbacks.animateExpandNotificationsPanel(); - verify(mNotificationPanelViewController).expandWithoutQs(); - mSbcqCallbacks.animateExpandSettingsPanel(null); - verify(mNotificationPanelViewController).expandWithQs(); - } - - @Test - public void testSuppressAmbientDisplay_suppress() { - mSbcqCallbacks.suppressAmbientDisplay(true); - verify(mDozeServiceHost).setAlwaysOnSuppressed(true); - } - - @Test - public void testSuppressAmbientDisplay_unsuppress() { - mSbcqCallbacks.suppressAmbientDisplay(false); - verify(mDozeServiceHost).setAlwaysOnSuppressed(false); - } - - -} diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java index 8b93de571cc9..f4f55ccefd09 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java @@ -75,7 +75,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { @Mock private KeyguardStateController mKeyguardStateController; @Mock - private StatusBar mStatusBar; + private CentralSurfaces mCentralSurfaces; @Mock private ViewGroup mContainer; @Mock @@ -118,7 +118,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { any(ViewGroup.class), any(KeyguardBouncer.BouncerExpansionCallback.class))) .thenReturn(mBouncer); - when(mStatusBar.getBouncerContainer()).thenReturn(mContainer); + when(mCentralSurfaces.getBouncerContainer()).thenReturn(mContainer); when(mContainer.findViewById(anyInt())).thenReturn(mKeyguardMessageArea); mStatusBarKeyguardViewManager = new StatusBarKeyguardViewManager( getContext(), @@ -138,8 +138,8 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { Optional.of(mSysUiUnfoldComponent), () -> mShadeController, mLatencyTracker); - mStatusBarKeyguardViewManager.registerStatusBar( - mStatusBar, + mStatusBarKeyguardViewManager.registerCentralSurfaces( + mCentralSurfaces, mNotificationPanelView, new PanelExpansionStateManager(), mBiometricUnlockController, @@ -261,7 +261,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { @Test public void onPanelExpansionChanged_neverTranslatesBouncerWhenLaunchingApp() { - when(mStatusBar.isInLaunchTransition()).thenReturn(true); + when(mCentralSurfaces.isInLaunchTransition()).thenReturn(true); mStatusBarKeyguardViewManager.onPanelExpansionChanged( /* fraction= */ KeyguardBouncer.EXPANSION_VISIBLE, /* expanded= */ true, @@ -272,12 +272,12 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { @Test public void setOccluded_animatesPanelExpansion_onlyIfBouncerHidden() { mStatusBarKeyguardViewManager.setOccluded(false /* occluded */, true /* animated */); - verify(mStatusBar).animateKeyguardUnoccluding(); + verify(mCentralSurfaces).animateKeyguardUnoccluding(); when(mBouncer.isShowing()).thenReturn(true); - clearInvocations(mStatusBar); + clearInvocations(mCentralSurfaces); mStatusBarKeyguardViewManager.setOccluded(false /* occluded */, true /* animated */); - verify(mStatusBar, never()).animateKeyguardUnoccluding(); + verify(mCentralSurfaces, never()).animateKeyguardUnoccluding(); } @Test @@ -303,7 +303,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { @Test public void setOccluded_isInLaunchTransition_onKeyguardOccludedChangedCalled() { - when(mStatusBar.isInLaunchTransition()).thenReturn(true); + when(mCentralSurfaces.isInLaunchTransition()).thenReturn(true); mStatusBarKeyguardViewManager.show(null); mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animated */); @@ -312,7 +312,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { @Test public void setOccluded_isLaunchingActivityOverLockscreen_onKeyguardOccludedChangedCalled() { - when(mStatusBar.isLaunchingActivityOverLockscreen()).thenReturn(true); + when(mCentralSurfaces.isLaunchingActivityOverLockscreen()).thenReturn(true); mStatusBarKeyguardViewManager.show(null); mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animated */); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java index 107c46f09fac..ace7415f2c17 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java @@ -113,7 +113,7 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { @Mock private NotificationRemoteInputManager mRemoteInputManager; @Mock - private StatusBar mStatusBar; + private CentralSurfaces mCentralSurfaces; @Mock private KeyguardStateController mKeyguardStateController; @Mock @@ -233,7 +233,7 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { mock(MetricsLogger.class), mock(StatusBarNotificationActivityStarterLogger.class), mOnUserInteractionCallback, - mStatusBar, + mCentralSurfaces, mock(NotificationPresenter.class), mock(NotificationPanelViewController.class), mActivityLaunchAnimator, @@ -267,7 +267,7 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { sbn.getNotification().flags |= Notification.FLAG_AUTO_CANCEL; when(mKeyguardStateController.isShowing()).thenReturn(true); - when(mStatusBar.isOccluded()).thenReturn(true); + when(mCentralSurfaces.isOccluded()).thenReturn(true); // When mNotificationActivityStarter.onNotificationClicked(sbn, mNotificationRow); @@ -326,7 +326,7 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { // Given sbn.getNotification().contentIntent = null; when(mKeyguardStateController.isShowing()).thenReturn(true); - when(mStatusBar.isOccluded()).thenReturn(true); + when(mCentralSurfaces.isOccluded()).thenReturn(true); // When mNotificationActivityStarter.onNotificationClicked(sbn, mBubbleNotificationRow); @@ -356,7 +356,7 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { // Given sbn.getNotification().contentIntent = mContentIntent; when(mKeyguardStateController.isShowing()).thenReturn(true); - when(mStatusBar.isOccluded()).thenReturn(true); + when(mCentralSurfaces.isOccluded()).thenReturn(true); // When mNotificationActivityStarter.onNotificationClicked(sbn, mBubbleNotificationRow); @@ -400,6 +400,6 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { mNotificationActivityStarter.handleFullScreenIntent(entry); // THEN display should try wake up for the full screen intent - verify(mStatusBar).wakeUpForFullScreenIntent(); + verify(mCentralSurfaces).wakeUpForFullScreenIntent(); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.java index b7a5490527f9..1a3dd3a7a2a5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.java @@ -80,7 +80,7 @@ public class StatusBarNotificationPresenterTest extends SysuiTestCase { private CommandQueue mCommandQueue; private FakeMetricsLogger mMetricsLogger; private ShadeController mShadeController = mock(ShadeController.class); - private StatusBar mStatusBar = mock(StatusBar.class); + private CentralSurfaces mCentralSurfaces = mock(CentralSurfaces.class); private InitController mInitController = new InitController(); @Before @@ -117,7 +117,7 @@ public class StatusBarNotificationPresenterTest extends SysuiTestCase { mock(DynamicPrivacyController.class), mock(KeyguardStateController.class), mock(KeyguardIndicationController.class), - mStatusBar, + mCentralSurfaces, mock(ShadeControllerImpl.class), mock(LockscreenShadeTransitionController.class), mCommandQueue, @@ -203,9 +203,9 @@ public class StatusBarNotificationPresenterTest extends SysuiTestCase { .setTag("a") .setNotification(n) .build(); - when(mStatusBar.areNotificationAlertsDisabled()).thenReturn(true); + when(mCentralSurfaces.areNotificationAlertsDisabled()).thenReturn(true); - assertTrue("StatusBar alerts disabled shouldn't allow interruptions", + assertTrue("CentralSurfaces alerts disabled shouldn't allow interruptions", mInterruptSuppressor.suppressInterruptions(entry)); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java deleted file mode 100644 index b5210b937ce1..000000000000 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java +++ /dev/null @@ -1,1001 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.statusbar.phone; - -import static android.app.NotificationManager.IMPORTANCE_HIGH; -import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK; - -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; -import static junit.framework.TestCase.fail; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.clearInvocations; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import android.app.IWallpaperManager; -import android.app.Notification; -import android.app.WallpaperManager; -import android.app.trust.TrustManager; -import android.content.BroadcastReceiver; -import android.content.ContentResolver; -import android.content.IntentFilter; -import android.hardware.devicestate.DeviceStateManager; -import android.hardware.display.AmbientDisplayConfiguration; -import android.hardware.fingerprint.FingerprintManager; -import android.metrics.LogMaker; -import android.os.Binder; -import android.os.Handler; -import android.os.IPowerManager; -import android.os.IThermalService; -import android.os.Looper; -import android.os.PowerManager; -import android.os.RemoteException; -import android.os.UserHandle; -import android.service.dreams.IDreamManager; -import android.support.test.metricshelper.MetricsAsserts; -import android.testing.AndroidTestingRunner; -import android.testing.TestableLooper; -import android.testing.TestableLooper.RunWithLooper; -import android.util.DisplayMetrics; -import android.util.SparseArray; -import android.view.ViewGroup; -import android.view.ViewGroup.LayoutParams; -import android.view.WindowManager; - -import androidx.test.filters.SmallTest; - -import com.android.internal.colorextraction.ColorExtractor; -import com.android.internal.jank.InteractionJankMonitor; -import com.android.internal.logging.nano.MetricsProto.MetricsEvent; -import com.android.internal.logging.testing.FakeMetricsLogger; -import com.android.internal.statusbar.IStatusBarService; -import com.android.keyguard.KeyguardUpdateMonitor; -import com.android.keyguard.ViewMediatorCallback; -import com.android.systemui.InitController; -import com.android.systemui.R; -import com.android.systemui.SysuiTestCase; -import com.android.systemui.accessibility.floatingmenu.AccessibilityFloatingMenuController; -import com.android.systemui.animation.ActivityLaunchAnimator; -import com.android.systemui.assist.AssistManager; -import com.android.systemui.broadcast.BroadcastDispatcher; -import com.android.systemui.classifier.FalsingCollectorFake; -import com.android.systemui.classifier.FalsingManagerFake; -import com.android.systemui.colorextraction.SysuiColorExtractor; -import com.android.systemui.demomode.DemoModeController; -import com.android.systemui.dreams.DreamOverlayStateController; -import com.android.systemui.dump.DumpManager; -import com.android.systemui.flags.FeatureFlags; -import com.android.systemui.fragments.FragmentService; -import com.android.systemui.keyguard.KeyguardUnlockAnimationController; -import com.android.systemui.keyguard.KeyguardViewMediator; -import com.android.systemui.keyguard.ScreenLifecycle; -import com.android.systemui.keyguard.WakefulnessLifecycle; -import com.android.systemui.navigationbar.NavigationBarController; -import com.android.systemui.plugins.ActivityStarter.OnDismissAction; -import com.android.systemui.plugins.PluginDependencyProvider; -import com.android.systemui.plugins.statusbar.StatusBarStateController; -import com.android.systemui.recents.ScreenPinningRequest; -import com.android.systemui.settings.brightness.BrightnessSliderController; -import com.android.systemui.shared.plugins.PluginManager; -import com.android.systemui.statusbar.CommandQueue; -import com.android.systemui.statusbar.KeyguardIndicationController; -import com.android.systemui.statusbar.LockscreenShadeTransitionController; -import com.android.systemui.statusbar.NotificationListener; -import com.android.systemui.statusbar.NotificationLockscreenUserManager; -import com.android.systemui.statusbar.NotificationMediaManager; -import com.android.systemui.statusbar.NotificationRemoteInputManager; -import com.android.systemui.statusbar.NotificationShadeDepthController; -import com.android.systemui.statusbar.NotificationShadeWindowController; -import com.android.systemui.statusbar.NotificationViewHierarchyManager; -import com.android.systemui.statusbar.OperatorNameViewController; -import com.android.systemui.statusbar.PulseExpansionHandler; -import com.android.systemui.statusbar.StatusBarState; -import com.android.systemui.statusbar.StatusBarStateControllerImpl; -import com.android.systemui.statusbar.charging.WiredChargingRippleController; -import com.android.systemui.statusbar.connectivity.NetworkController; -import com.android.systemui.statusbar.notification.DynamicPrivacyController; -import com.android.systemui.statusbar.notification.NotifPipelineFlags; -import com.android.systemui.statusbar.notification.NotificationEntryManager; -import com.android.systemui.statusbar.notification.NotificationFilter; -import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; -import com.android.systemui.statusbar.notification.collection.NotifLiveDataStore; -import com.android.systemui.statusbar.notification.collection.NotifPipeline; -import com.android.systemui.statusbar.notification.collection.NotificationEntry; -import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder; -import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager; -import com.android.systemui.statusbar.notification.collection.render.NotifShadeEventSource; -import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; -import com.android.systemui.statusbar.notification.init.NotificationsController; -import com.android.systemui.statusbar.notification.interruption.NotificationInterruptLogger; -import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProviderImpl; -import com.android.systemui.statusbar.notification.logging.NotificationLogger; -import com.android.systemui.statusbar.notification.logging.NotificationPanelLoggerFake; -import com.android.systemui.statusbar.notification.row.NotificationGutsManager; -import com.android.systemui.statusbar.notification.stack.NotificationListContainer; -import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; -import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; -import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallController; -import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager; -import com.android.systemui.statusbar.policy.BatteryController; -import com.android.systemui.statusbar.policy.ConfigurationController; -import com.android.systemui.statusbar.policy.DeviceProvisionedController; -import com.android.systemui.statusbar.policy.ExtensionController; -import com.android.systemui.statusbar.policy.HeadsUpManager; -import com.android.systemui.statusbar.policy.KeyguardStateController; -import com.android.systemui.statusbar.policy.UserInfoControllerImpl; -import com.android.systemui.statusbar.policy.UserSwitcherController; -import com.android.systemui.statusbar.window.StatusBarWindowController; -import com.android.systemui.statusbar.window.StatusBarWindowStateController; -import com.android.systemui.util.WallpaperController; -import com.android.systemui.util.concurrency.FakeExecutor; -import com.android.systemui.util.concurrency.MessageRouterImpl; -import com.android.systemui.util.time.FakeSystemClock; -import com.android.systemui.volume.VolumeComponent; -import com.android.systemui.wmshell.BubblesManager; -import com.android.wm.shell.bubbles.Bubbles; -import com.android.wm.shell.startingsurface.StartingSurface; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import java.io.ByteArrayOutputStream; -import java.io.PrintWriter; -import java.util.Optional; - -import dagger.Lazy; - -@SmallTest -@RunWith(AndroidTestingRunner.class) -@RunWithLooper(setAsMainLooper = true) -public class StatusBarTest extends SysuiTestCase { - - private static final int FOLD_STATE_FOLDED = 0; - private static final int FOLD_STATE_UNFOLDED = 1; - - private StatusBar mStatusBar; - private FakeMetricsLogger mMetricsLogger; - private PowerManager mPowerManager; - private TestableNotificationInterruptStateProviderImpl mNotificationInterruptStateProvider; - - @Mock private NotificationsController mNotificationsController; - @Mock private LightBarController mLightBarController; - @Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; - @Mock private KeyguardStateController mKeyguardStateController; - @Mock private KeyguardIndicationController mKeyguardIndicationController; - @Mock private NotificationStackScrollLayout mStackScroller; - @Mock private NotificationStackScrollLayoutController mStackScrollerController; - @Mock private NotificationListContainer mNotificationListContainer; - @Mock private HeadsUpManagerPhone mHeadsUpManager; - @Mock private NotificationPanelViewController mNotificationPanelViewController; - @Mock private NotificationPanelView mNotificationPanelView; - @Mock private IStatusBarService mBarService; - @Mock private IDreamManager mDreamManager; - @Mock private ScrimController mScrimController; - @Mock private DozeScrimController mDozeScrimController; - @Mock private Lazy mBiometricUnlockControllerLazy; - @Mock private BiometricUnlockController mBiometricUnlockController; - @Mock private VisualStabilityManager mVisualStabilityManager; - @Mock private NotificationListener mNotificationListener; - @Mock private KeyguardViewMediator mKeyguardViewMediator; - @Mock private NotificationLockscreenUserManager mLockscreenUserManager; - @Mock private NotificationRemoteInputManager mRemoteInputManager; - @Mock private StatusBarStateControllerImpl mStatusBarStateController; - @Mock private BatteryController mBatteryController; - @Mock private DeviceProvisionedController mDeviceProvisionedController; - @Mock private StatusBarNotificationPresenter mNotificationPresenter; - @Mock private NotificationFilter mNotificationFilter; - @Mock private AmbientDisplayConfiguration mAmbientDisplayConfiguration; - @Mock private NotificationLogger.ExpansionStateLogger mExpansionStateLogger; - @Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor; - @Mock private StatusBarSignalPolicy mStatusBarSignalPolicy; - @Mock private NotificationShadeWindowView mNotificationShadeWindowView; - @Mock private BroadcastDispatcher mBroadcastDispatcher; - @Mock private AssistManager mAssistManager; - @Mock private NotifShadeEventSource mNotifShadeEventSource; - @Mock private NotificationEntryManager mNotificationEntryManager; - @Mock private NotificationGutsManager mNotificationGutsManager; - @Mock private NotificationMediaManager mNotificationMediaManager; - @Mock private NavigationBarController mNavigationBarController; - @Mock private AccessibilityFloatingMenuController mAccessibilityFloatingMenuController; - @Mock private SysuiColorExtractor mColorExtractor; - @Mock private ColorExtractor.GradientColors mGradientColors; - @Mock private PulseExpansionHandler mPulseExpansionHandler; - @Mock private NotificationWakeUpCoordinator mNotificationWakeUpCoordinator; - @Mock private KeyguardBypassController mKeyguardBypassController; - @Mock private DynamicPrivacyController mDynamicPrivacyController; - @Mock private AutoHideController mAutoHideController; - @Mock private StatusBarWindowController mStatusBarWindowController; - @Mock private StatusBarWindowStateController mStatusBarWindowStateController; - @Mock private NotificationViewHierarchyManager mNotificationViewHierarchyManager; - @Mock private UserSwitcherController mUserSwitcherController; - @Mock private NetworkController mNetworkController; - @Mock private BubblesManager mBubblesManager; - @Mock private Bubbles mBubbles; - @Mock private NotificationShadeWindowController mNotificationShadeWindowController; - @Mock private NotificationIconAreaController mNotificationIconAreaController; - @Mock private NotificationShadeWindowViewController mNotificationShadeWindowViewController; - @Mock private DozeParameters mDozeParameters; - @Mock private Lazy mLockscreenWallpaperLazy; - @Mock private LockscreenGestureLogger mLockscreenGestureLogger; - @Mock private LockscreenWallpaper mLockscreenWallpaper; - @Mock private DozeServiceHost mDozeServiceHost; - @Mock private ViewMediatorCallback mKeyguardVieMediatorCallback; - @Mock private VolumeComponent mVolumeComponent; - @Mock private CommandQueue mCommandQueue; - @Mock private StatusBarComponent.Factory mStatusBarComponentFactory; - @Mock private StatusBarComponent mStatusBarComponent; - @Mock private PluginManager mPluginManager; - @Mock private ViewMediatorCallback mViewMediatorCallback; - @Mock private StatusBarTouchableRegionManager mStatusBarTouchableRegionManager; - @Mock private ScreenPinningRequest mScreenPinningRequest; - @Mock private PluginDependencyProvider mPluginDependencyProvider; - @Mock private KeyguardDismissUtil mKeyguardDismissUtil; - @Mock private ExtensionController mExtensionController; - @Mock private UserInfoControllerImpl mUserInfoControllerImpl; - @Mock private PhoneStatusBarPolicy mPhoneStatusBarPolicy; - @Mock private DemoModeController mDemoModeController; - @Mock private Lazy mNotificationShadeDepthControllerLazy; - @Mock private BrightnessSliderController.Factory mBrightnessSliderFactory; - @Mock private WallpaperController mWallpaperController; - @Mock private OngoingCallController mOngoingCallController; - @Mock private StatusBarHideIconsForBouncerManager mStatusBarHideIconsForBouncerManager; - @Mock private LockscreenShadeTransitionController mLockscreenTransitionController; - @Mock private FeatureFlags mFeatureFlags; - @Mock private NotificationVisibilityProvider mVisibilityProvider; - @Mock private WallpaperManager mWallpaperManager; - @Mock private IWallpaperManager mIWallpaperManager; - @Mock private KeyguardUnlockAnimationController mKeyguardUnlockAnimationController; - @Mock private ScreenOffAnimationController mScreenOffAnimationController; - @Mock private StartingSurface mStartingSurface; - @Mock private OperatorNameViewController mOperatorNameViewController; - @Mock private OperatorNameViewController.Factory mOperatorNameViewControllerFactory; - @Mock private ActivityLaunchAnimator mActivityLaunchAnimator; - @Mock private NotifPipelineFlags mNotifPipelineFlags; - @Mock private NotifLiveDataStore mNotifLiveDataStore; - @Mock private InteractionJankMonitor mJankMonitor; - @Mock private DeviceStateManager mDeviceStateManager; - @Mock private DreamOverlayStateController mDreamOverlayStateController; - @Mock private WiredChargingRippleController mWiredChargingRippleController; - private ShadeController mShadeController; - private final FakeSystemClock mFakeSystemClock = new FakeSystemClock(); - private FakeExecutor mMainExecutor = new FakeExecutor(mFakeSystemClock); - private FakeExecutor mUiBgExecutor = new FakeExecutor(mFakeSystemClock); - private InitController mInitController = new InitController(); - private final DumpManager mDumpManager = new DumpManager(); - - @Before - public void setup() throws Exception { - MockitoAnnotations.initMocks(this); - mDependency.injectTestDependency(NotificationFilter.class, mNotificationFilter); - - IPowerManager powerManagerService = mock(IPowerManager.class); - IThermalService thermalService = mock(IThermalService.class); - mPowerManager = new PowerManager(mContext, powerManagerService, thermalService, - Handler.createAsync(Looper.myLooper())); - - mNotificationInterruptStateProvider = - new TestableNotificationInterruptStateProviderImpl(mContext.getContentResolver(), - mPowerManager, - mDreamManager, mAmbientDisplayConfiguration, mNotificationFilter, - mStatusBarStateController, mBatteryController, mHeadsUpManager, - mock(NotificationInterruptLogger.class), - new Handler(TestableLooper.get(this).getLooper())); - - mContext.addMockSystemService(TrustManager.class, mock(TrustManager.class)); - mContext.addMockSystemService(FingerprintManager.class, mock(FingerprintManager.class)); - - mMetricsLogger = new FakeMetricsLogger(); - NotificationLogger notificationLogger = new NotificationLogger( - mNotificationListener, - mUiBgExecutor, - mNotifPipelineFlags, - mNotifLiveDataStore, - mVisibilityProvider, - mock(NotificationEntryManager.class), - mock(NotifPipeline.class), - mStatusBarStateController, - mExpansionStateLogger, - new NotificationPanelLoggerFake() - ); - notificationLogger.setVisibilityReporter(mock(Runnable.class)); - - when(mCommandQueue.asBinder()).thenReturn(new Binder()); - - mContext.setTheme(R.style.Theme_SystemUI_LightWallpaper); - - when(mStackScrollerController.getView()).thenReturn(mStackScroller); - when(mStackScroller.generateLayoutParams(any())).thenReturn(new LayoutParams(0, 0)); - when(mNotificationPanelViewController.getView()).thenReturn(mNotificationPanelView); - when(mNotificationPanelView.getLayoutParams()).thenReturn(new LayoutParams(0, 0)); - when(powerManagerService.isInteractive()).thenReturn(true); - when(mStackScroller.getActivatedChild()).thenReturn(null); - - doAnswer(invocation -> { - OnDismissAction onDismissAction = (OnDismissAction) invocation.getArguments()[0]; - onDismissAction.onDismiss(); - return null; - }).when(mStatusBarKeyguardViewManager).dismissWithAction(any(), any(), anyBoolean()); - - doAnswer(invocation -> { - Runnable runnable = (Runnable) invocation.getArguments()[0]; - runnable.run(); - return null; - }).when(mStatusBarKeyguardViewManager).addAfterKeyguardGoneRunnable(any()); - - WakefulnessLifecycle wakefulnessLifecycle = - new WakefulnessLifecycle(mContext, mIWallpaperManager, mDumpManager); - wakefulnessLifecycle.dispatchStartedWakingUp(PowerManager.WAKE_REASON_UNKNOWN); - wakefulnessLifecycle.dispatchFinishedWakingUp(); - - when(mGradientColors.supportsDarkText()).thenReturn(true); - when(mColorExtractor.getNeutralColors()).thenReturn(mGradientColors); - ConfigurationController configurationController = new ConfigurationControllerImpl(mContext); - - when(mLockscreenWallpaperLazy.get()).thenReturn(mLockscreenWallpaper); - when(mBiometricUnlockControllerLazy.get()).thenReturn(mBiometricUnlockController); - - when(mStatusBarComponentFactory.create()).thenReturn(mStatusBarComponent); - when(mStatusBarComponent.getNotificationShadeWindowViewController()).thenReturn( - mNotificationShadeWindowViewController); - doAnswer(invocation -> { - ((Runnable) invocation.getArgument(0)).run(); - return null; - }).when(mNotificationShadeWindowController).batchApplyWindowLayoutParams(any()); - - mShadeController = new ShadeControllerImpl(mCommandQueue, - mStatusBarStateController, mNotificationShadeWindowController, - mStatusBarKeyguardViewManager, mContext.getSystemService(WindowManager.class), - () -> Optional.of(mStatusBar), () -> mAssistManager); - - when(mOperatorNameViewControllerFactory.create(any())) - .thenReturn(mOperatorNameViewController); - - mStatusBar = new StatusBar( - mContext, - mNotificationsController, - mock(FragmentService.class), - mLightBarController, - mAutoHideController, - mStatusBarWindowController, - mStatusBarWindowStateController, - mKeyguardUpdateMonitor, - mStatusBarSignalPolicy, - mPulseExpansionHandler, - mNotificationWakeUpCoordinator, - mKeyguardBypassController, - mKeyguardStateController, - mHeadsUpManager, - mDynamicPrivacyController, - new FalsingManagerFake(), - new FalsingCollectorFake(), - mBroadcastDispatcher, - mNotifShadeEventSource, - mNotificationEntryManager, - mNotificationGutsManager, - notificationLogger, - mNotificationInterruptStateProvider, - mNotificationViewHierarchyManager, - new PanelExpansionStateManager(), - mKeyguardViewMediator, - new DisplayMetrics(), - mMetricsLogger, - mUiBgExecutor, - mNotificationMediaManager, - mLockscreenUserManager, - mRemoteInputManager, - mUserSwitcherController, - mNetworkController, - mBatteryController, - mColorExtractor, - new ScreenLifecycle(mDumpManager), - wakefulnessLifecycle, - mStatusBarStateController, - Optional.of(mBubblesManager), - Optional.of(mBubbles), - mVisualStabilityManager, - mDeviceProvisionedController, - mNavigationBarController, - mAccessibilityFloatingMenuController, - () -> mAssistManager, - configurationController, - mNotificationShadeWindowController, - mDozeParameters, - mScrimController, - mLockscreenWallpaperLazy, - mLockscreenGestureLogger, - mBiometricUnlockControllerLazy, - mDozeServiceHost, - mPowerManager, mScreenPinningRequest, - mDozeScrimController, - mVolumeComponent, - mCommandQueue, - mStatusBarComponentFactory, - mPluginManager, - mShadeController, - mStatusBarKeyguardViewManager, - mViewMediatorCallback, - mInitController, - new Handler(TestableLooper.get(this).getLooper()), - mPluginDependencyProvider, - mKeyguardDismissUtil, - mExtensionController, - mUserInfoControllerImpl, - mPhoneStatusBarPolicy, - mKeyguardIndicationController, - mDemoModeController, - mNotificationShadeDepthControllerLazy, - mStatusBarTouchableRegionManager, - mNotificationIconAreaController, - mBrightnessSliderFactory, - mScreenOffAnimationController, - mWallpaperController, - mOngoingCallController, - mStatusBarHideIconsForBouncerManager, - mLockscreenTransitionController, - mFeatureFlags, - mKeyguardUnlockAnimationController, - new Handler(TestableLooper.get(this).getLooper()), - mMainExecutor, - new MessageRouterImpl(mMainExecutor), - mWallpaperManager, - Optional.of(mStartingSurface), - mActivityLaunchAnimator, - mNotifPipelineFlags, - mJankMonitor, - mDeviceStateManager, - mDreamOverlayStateController, - mWiredChargingRippleController); - when(mKeyguardViewMediator.registerStatusBar( - any(StatusBar.class), - any(NotificationPanelViewController.class), - any(PanelExpansionStateManager.class), - any(BiometricUnlockController.class), - any(ViewGroup.class), - any(KeyguardBypassController.class))) - .thenReturn(mStatusBarKeyguardViewManager); - - when(mKeyguardViewMediator.getViewMediatorCallback()).thenReturn( - mKeyguardVieMediatorCallback); - - // TODO: we should be able to call mStatusBar.start() and have all the below values - // initialized automatically. - mStatusBar.mNotificationShadeWindowView = mNotificationShadeWindowView; - mStatusBar.mNotificationPanelViewController = mNotificationPanelViewController; - mStatusBar.mDozeScrimController = mDozeScrimController; - mStatusBar.mPresenter = mNotificationPresenter; - mStatusBar.mKeyguardIndicationController = mKeyguardIndicationController; - mStatusBar.mBarService = mBarService; - mStatusBar.mStackScroller = mStackScroller; - mStatusBar.startKeyguard(); - mInitController.executePostInitTasks(); - notificationLogger.setUpWithContainer(mNotificationListContainer); - } - - @Test - public void testSetBouncerShowing_noCrash() { - mStatusBar.setBouncerShowing(true); - } - - @Test - public void executeRunnableDismissingKeyguard_nullRunnable_showingAndOccluded() { - when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); - when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(true); - - mStatusBar.executeRunnableDismissingKeyguard(null, null, false, false, false); - } - - @Test - public void executeRunnableDismissingKeyguard_nullRunnable_showing() { - when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); - when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); - - mStatusBar.executeRunnableDismissingKeyguard(null, null, false, false, false); - } - - @Test - public void executeRunnableDismissingKeyguard_nullRunnable_notShowing() { - when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false); - when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); - - mStatusBar.executeRunnableDismissingKeyguard(null, null, false, false, false); - } - - @Test - public void lockscreenStateMetrics_notShowing() { - // uninteresting state, except that fingerprint must be non-zero - when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); - when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true); - // interesting state - when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false); - when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); - when(mKeyguardStateController.isMethodSecure()).thenReturn(false); - mStatusBar.onKeyguardViewManagerStatesUpdated(); - - MetricsAsserts.assertHasLog("missing hidden insecure lockscreen log", - mMetricsLogger.getLogs(), - new LogMaker(MetricsEvent.LOCKSCREEN) - .setType(MetricsEvent.TYPE_CLOSE) - .setSubtype(0)); - } - - @Test - public void lockscreenStateMetrics_notShowing_secure() { - // uninteresting state, except that fingerprint must be non-zero - when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); - when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true); - // interesting state - when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false); - when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); - when(mKeyguardStateController.isMethodSecure()).thenReturn(true); - - mStatusBar.onKeyguardViewManagerStatesUpdated(); - - MetricsAsserts.assertHasLog("missing hidden secure lockscreen log", - mMetricsLogger.getLogs(), - new LogMaker(MetricsEvent.LOCKSCREEN) - .setType(MetricsEvent.TYPE_CLOSE) - .setSubtype(1)); - } - - @Test - public void lockscreenStateMetrics_isShowing() { - // uninteresting state, except that fingerprint must be non-zero - when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); - when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true); - // interesting state - when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); - when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); - when(mKeyguardStateController.isMethodSecure()).thenReturn(false); - - mStatusBar.onKeyguardViewManagerStatesUpdated(); - - MetricsAsserts.assertHasLog("missing insecure lockscreen showing", - mMetricsLogger.getLogs(), - new LogMaker(MetricsEvent.LOCKSCREEN) - .setType(MetricsEvent.TYPE_OPEN) - .setSubtype(0)); - } - - @Test - public void lockscreenStateMetrics_isShowing_secure() { - // uninteresting state, except that fingerprint must be non-zero - when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); - when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true); - // interesting state - when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); - when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); - when(mKeyguardStateController.isMethodSecure()).thenReturn(true); - - mStatusBar.onKeyguardViewManagerStatesUpdated(); - - MetricsAsserts.assertHasLog("missing secure lockscreen showing log", - mMetricsLogger.getLogs(), - new LogMaker(MetricsEvent.LOCKSCREEN) - .setType(MetricsEvent.TYPE_OPEN) - .setSubtype(1)); - } - - @Test - public void lockscreenStateMetrics_isShowingBouncer() { - // uninteresting state, except that fingerprint must be non-zero - when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); - when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true); - // interesting state - when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); - when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(true); - when(mKeyguardStateController.isMethodSecure()).thenReturn(true); - - mStatusBar.onKeyguardViewManagerStatesUpdated(); - - MetricsAsserts.assertHasLog("missing bouncer log", - mMetricsLogger.getLogs(), - new LogMaker(MetricsEvent.BOUNCER) - .setType(MetricsEvent.TYPE_OPEN) - .setSubtype(1)); - } - - @Test - public void testShouldHeadsUp_nonSuppressedGroupSummary() throws Exception { - when(mPowerManager.isScreenOn()).thenReturn(true); - when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); - when(mNotificationFilter.shouldFilterOut(any())).thenReturn(false); - when(mDreamManager.isDreaming()).thenReturn(false); - - Notification n = new Notification.Builder(getContext(), "a") - .setGroup("a") - .setGroupSummary(true) - .setGroupAlertBehavior(Notification.GROUP_ALERT_SUMMARY) - .build(); - - NotificationEntry entry = new NotificationEntryBuilder() - .setPkg("a") - .setOpPkg("a") - .setTag("a") - .setNotification(n) - .setImportance(IMPORTANCE_HIGH) - .build(); - - assertTrue(mNotificationInterruptStateProvider.shouldHeadsUp(entry)); - } - - @Test - public void testShouldHeadsUp_suppressedGroupSummary() throws Exception { - when(mPowerManager.isScreenOn()).thenReturn(true); - when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); - when(mNotificationFilter.shouldFilterOut(any())).thenReturn(false); - when(mDreamManager.isDreaming()).thenReturn(false); - - Notification n = new Notification.Builder(getContext(), "a") - .setGroup("a") - .setGroupSummary(true) - .setGroupAlertBehavior(Notification.GROUP_ALERT_CHILDREN) - .build(); - - NotificationEntry entry = new NotificationEntryBuilder() - .setPkg("a") - .setOpPkg("a") - .setTag("a") - .setNotification(n) - .setImportance(IMPORTANCE_HIGH) - .build(); - - assertFalse(mNotificationInterruptStateProvider.shouldHeadsUp(entry)); - } - - @Test - public void testShouldHeadsUp_suppressedHeadsUp() throws Exception { - when(mPowerManager.isScreenOn()).thenReturn(true); - when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); - when(mNotificationFilter.shouldFilterOut(any())).thenReturn(false); - when(mDreamManager.isDreaming()).thenReturn(false); - - Notification n = new Notification.Builder(getContext(), "a").build(); - - NotificationEntry entry = new NotificationEntryBuilder() - .setPkg("a") - .setOpPkg("a") - .setTag("a") - .setNotification(n) - .setImportance(IMPORTANCE_HIGH) - .setSuppressedVisualEffects(SUPPRESSED_EFFECT_PEEK) - .build(); - - assertFalse(mNotificationInterruptStateProvider.shouldHeadsUp(entry)); - } - - @Test - public void testShouldHeadsUp_noSuppressedHeadsUp() throws Exception { - when(mPowerManager.isScreenOn()).thenReturn(true); - when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); - when(mNotificationFilter.shouldFilterOut(any())).thenReturn(false); - when(mDreamManager.isDreaming()).thenReturn(false); - - Notification n = new Notification.Builder(getContext(), "a").build(); - - NotificationEntry entry = new NotificationEntryBuilder() - .setPkg("a") - .setOpPkg("a") - .setTag("a") - .setNotification(n) - .setImportance(IMPORTANCE_HIGH) - .build(); - - assertTrue(mNotificationInterruptStateProvider.shouldHeadsUp(entry)); - } - - @Test - public void testLogHidden() { - try { - mStatusBar.handleVisibleToUserChanged(false); - mUiBgExecutor.runAllReady(); - verify(mBarService, times(1)).onPanelHidden(); - verify(mBarService, never()).onPanelRevealed(anyBoolean(), anyInt()); - } catch (RemoteException e) { - fail(); - } - } - - @Test - public void testPanelOpenForHeadsUp() { - when(mDeviceProvisionedController.isDeviceProvisioned()).thenReturn(true); - when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true); - when(mNotificationsController.getActiveNotificationsCount()).thenReturn(5); - when(mNotificationPresenter.isPresenterFullyCollapsed()).thenReturn(true); - mStatusBar.setBarStateForTest(StatusBarState.SHADE); - - try { - mStatusBar.handleVisibleToUserChanged(true); - mUiBgExecutor.runAllReady(); - verify(mBarService, never()).onPanelHidden(); - verify(mBarService, times(1)).onPanelRevealed(false, 1); - } catch (RemoteException e) { - fail(); - } - mMainExecutor.runAllReady(); - } - - @Test - public void testPanelOpenAndClear() { - when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false); - when(mNotificationsController.getActiveNotificationsCount()).thenReturn(5); - - when(mNotificationPresenter.isPresenterFullyCollapsed()).thenReturn(false); - mStatusBar.setBarStateForTest(StatusBarState.SHADE); - - try { - mStatusBar.handleVisibleToUserChanged(true); - mUiBgExecutor.runAllReady(); - verify(mBarService, never()).onPanelHidden(); - verify(mBarService, times(1)).onPanelRevealed(true, 5); - } catch (RemoteException e) { - fail(); - } - mMainExecutor.runAllReady(); - } - - @Test - public void testPanelOpenAndNoClear() { - when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false); - when(mNotificationsController.getActiveNotificationsCount()).thenReturn(5); - when(mNotificationPresenter.isPresenterFullyCollapsed()).thenReturn(false); - mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD); - - try { - mStatusBar.handleVisibleToUserChanged(true); - mUiBgExecutor.runAllReady(); - verify(mBarService, never()).onPanelHidden(); - verify(mBarService, times(1)).onPanelRevealed(false, 5); - } catch (RemoteException e) { - fail(); - } - mMainExecutor.runAllReady(); - } - - @Test - public void testDump_DoesNotCrash() { - mStatusBar.dump(null, new PrintWriter(new ByteArrayOutputStream()), null); - } - - @Test - public void testDumpBarTransitions_DoesNotCrash() { - StatusBar.dumpBarTransitions( - new PrintWriter(new ByteArrayOutputStream()), "var", /* transitions= */ null); - } - - @Test - public void testFingerprintNotification_UpdatesScrims() { - mStatusBar.notifyBiometricAuthModeChanged(); - verify(mScrimController).transitionTo(any(), any()); - } - - @Test - public void testFingerprintUnlock_UpdatesScrims() { - // Simulate unlocking from AoD with fingerprint. - when(mBiometricUnlockController.getMode()) - .thenReturn(BiometricUnlockController.MODE_WAKE_AND_UNLOCK); - mStatusBar.updateScrimController(); - verify(mScrimController).transitionTo(eq(ScrimState.UNLOCKED), any()); - } - - @Test - public void testTransitionLaunch_goesToUnlocked() { - mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD); - mStatusBar.showKeyguardImpl(); - - // Starting a pulse should change the scrim controller to the pulsing state - when(mNotificationPanelViewController.isLaunchTransitionRunning()).thenReturn(true); - when(mNotificationPanelViewController.isLaunchingAffordanceWithPreview()).thenReturn(true); - mStatusBar.updateScrimController(); - verify(mScrimController).transitionTo(eq(ScrimState.UNLOCKED), any()); - } - - @Test - public void testSetExpansionAffectsAlpha_whenKeyguardShowingButGoingAwayForAnyReason() { - mStatusBar.updateScrimController(); - verify(mScrimController).setExpansionAffectsAlpha(eq(true)); - - clearInvocations(mScrimController); - when(mKeyguardStateController.isShowing()).thenReturn(true); - when(mKeyguardStateController.isKeyguardGoingAway()).thenReturn(false); - mStatusBar.updateScrimController(); - verify(mScrimController).setExpansionAffectsAlpha(eq(true)); - - clearInvocations(mScrimController); - when(mKeyguardStateController.isShowing()).thenReturn(true); - when(mKeyguardStateController.isKeyguardGoingAway()).thenReturn(true); - mStatusBar.updateScrimController(); - verify(mScrimController).setExpansionAffectsAlpha(eq(false)); - - clearInvocations(mScrimController); - when(mKeyguardStateController.isShowing()).thenReturn(true); - when(mKeyguardStateController.isKeyguardFadingAway()).thenReturn(true); - mStatusBar.updateScrimController(); - verify(mScrimController).setExpansionAffectsAlpha(eq(false)); - } - - @Test - public void testTransitionLaunch_noPreview_doesntGoUnlocked() { - mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD); - mStatusBar.showKeyguardImpl(); - - // Starting a pulse should change the scrim controller to the pulsing state - when(mNotificationPanelViewController.isLaunchTransitionRunning()).thenReturn(true); - when(mNotificationPanelViewController.isLaunchingAffordanceWithPreview()).thenReturn(false); - mStatusBar.updateScrimController(); - verify(mScrimController).transitionTo(eq(ScrimState.KEYGUARD)); - } - - @Test - public void testSetOccluded_propagatesToScrimController() { - mStatusBar.setOccluded(true); - verify(mScrimController).setKeyguardOccluded(eq(true)); - - reset(mScrimController); - mStatusBar.setOccluded(false); - verify(mScrimController).setKeyguardOccluded(eq(false)); - } - - @Test - public void testPulseWhileDozing_updatesScrimController() { - mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD); - mStatusBar.showKeyguardImpl(); - - // Starting a pulse should change the scrim controller to the pulsing state - when(mDozeServiceHost.isPulsing()).thenReturn(true); - mStatusBar.updateScrimController(); - verify(mScrimController).transitionTo(eq(ScrimState.PULSING), any()); - - // Ending a pulse should take it back to keyguard state - when(mDozeServiceHost.isPulsing()).thenReturn(false); - mStatusBar.updateScrimController(); - verify(mScrimController).transitionTo(eq(ScrimState.KEYGUARD)); - } - - @Test - public void testShowKeyguardImplementation_setsState() { - when(mLockscreenUserManager.getCurrentProfiles()).thenReturn(new SparseArray<>()); - - mStatusBar.setBarStateForTest(StatusBarState.SHADE); - - // By default, showKeyguardImpl sets state to KEYGUARD. - mStatusBar.showKeyguardImpl(); - verify(mStatusBarStateController).setState( - eq(StatusBarState.KEYGUARD), eq(false) /* force */); - } - - @Test - public void testOnStartedWakingUp_isNotDozing() { - mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD); - when(mStatusBarStateController.isKeyguardRequested()).thenReturn(true); - when(mDozeServiceHost.getDozingRequested()).thenReturn(true); - mStatusBar.updateIsKeyguard(); - // TODO: mNotificationPanelView.expand(false) gets called twice. Should be once. - verify(mNotificationPanelViewController, times(2)).expand(eq(false)); - clearInvocations(mNotificationPanelViewController); - - mStatusBar.mWakefulnessObserver.onStartedWakingUp(); - verify(mDozeServiceHost).stopDozing(); - verify(mNotificationPanelViewController).expand(eq(false)); - } - - @Test - public void testOnStartedWakingUp_doesNotDismissBouncer_whenPulsing() { - mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD); - when(mStatusBarStateController.isKeyguardRequested()).thenReturn(true); - when(mDozeServiceHost.getDozingRequested()).thenReturn(true); - mStatusBar.updateIsKeyguard(); - clearInvocations(mNotificationPanelViewController); - - mStatusBar.setBouncerShowing(true); - mStatusBar.mWakefulnessObserver.onStartedWakingUp(); - verify(mNotificationPanelViewController, never()).expand(anyBoolean()); - } - - @Test - public void testRegisterBroadcastsonDispatcher() { - mStatusBar.registerBroadcastReceiver(); - verify(mBroadcastDispatcher).registerReceiver( - any(BroadcastReceiver.class), - any(IntentFilter.class), - eq(null), - any(UserHandle.class)); - } - - @Test - public void testUpdateResources_updatesBouncer() { - mStatusBar.updateResources(); - - verify(mStatusBarKeyguardViewManager).updateResources(); - } - - @Test - public void deviceStateChange_unfolded_shadeOpen_setsLeaveOpenOnKeyguardHide() { - setFoldedStates(FOLD_STATE_FOLDED); - setGoToSleepStates(FOLD_STATE_FOLDED); - when(mNotificationPanelViewController.isFullyExpanded()).thenReturn(true); - - setDeviceState(FOLD_STATE_UNFOLDED); - - verify(mStatusBarStateController).setLeaveOpenOnKeyguardHide(true); - } - - @Test - public void deviceStateChange_unfolded_shadeClose_doesNotSetLeaveOpenOnKeyguardHide() { - setFoldedStates(FOLD_STATE_FOLDED); - setGoToSleepStates(FOLD_STATE_FOLDED); - when(mNotificationPanelViewController.isFullyExpanded()).thenReturn(false); - - setDeviceState(FOLD_STATE_UNFOLDED); - - verify(mStatusBarStateController, never()).setLeaveOpenOnKeyguardHide(true); - } - - private void setDeviceState(int state) { - ArgumentCaptor callbackCaptor = - ArgumentCaptor.forClass(DeviceStateManager.DeviceStateCallback.class); - verify(mDeviceStateManager).registerCallback(any(), callbackCaptor.capture()); - callbackCaptor.getValue().onStateChanged(state); - } - - private void setGoToSleepStates(int... states) { - mContext.getOrCreateTestableResources().addOverride( - com.android.internal.R.array.config_deviceStatesOnWhichToSleep, - states); - } - - private void setFoldedStates(int... states) { - mContext.getOrCreateTestableResources().addOverride( - com.android.internal.R.array.config_foldedDeviceStates, - states); - } - - public static class TestableNotificationInterruptStateProviderImpl extends - NotificationInterruptStateProviderImpl { - - TestableNotificationInterruptStateProviderImpl( - ContentResolver contentResolver, - PowerManager powerManager, - IDreamManager dreamManager, - AmbientDisplayConfiguration ambientDisplayConfiguration, - NotificationFilter filter, - StatusBarStateController controller, - BatteryController batteryController, - HeadsUpManager headsUpManager, - NotificationInterruptLogger logger, - Handler mainHandler) { - super(contentResolver, powerManager, dreamManager, ambientDisplayConfiguration, filter, - batteryController, controller, headsUpManager, logger, mainHandler); - mUseHeadsUp = true; - } - } -} diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt index 71b32c0bd106..050563a5707c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt @@ -61,7 +61,7 @@ class UnlockedScreenOffAnimationControllerTest : SysuiTestCase() { @Mock private lateinit var globalSettings: GlobalSettings @Mock - private lateinit var statusBar: StatusBar + private lateinit var mCentralSurfaces: CentralSurfaces @Mock private lateinit var notificationPanelViewController: NotificationPanelViewController @Mock @@ -93,8 +93,8 @@ class UnlockedScreenOffAnimationControllerTest : SysuiTestCase() { powerManager, handler = handler ) - controller.initialize(statusBar, lightRevealScrim) - `when`(statusBar.notificationPanelViewController).thenReturn( + controller.initialize(mCentralSurfaces, lightRevealScrim) + `when`(mCentralSurfaces.notificationPanelViewController).thenReturn( notificationPanelViewController) // Screen off does not run if the panel is expanded, so we should say it's collapsed to test diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java index 593b97e55739..82880febc7f0 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java @@ -1221,7 +1221,7 @@ public class BubblesTest extends SysuiTestCase { final Context userContext = setUpContextWithPackageManager(workPkg, mock(ApplicationInfo.class)); - // If things are working correctly, StatusBar.getPackageManagerForUser will call this + // If things are working correctly, CentralSurfaces.getPackageManagerForUser will call this when(context.createPackageContextAsUser(eq(workPkg), anyInt(), eq(workUser))) .thenReturn(userContext); -- cgit v1.2.3-59-g8ed1b