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 a160e1099dfd5..58dea4f502516 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 @@ -1462,6 +1462,11 @@ public class NotificationStackScrollLayoutController { mView.setExtraTopInsetForFullShadeTransition(extraTopInset); } + /** */ + public void setWillExpand(boolean willExpand) { + mView.setWillExpand(willExpand); + } + /** * Set a listener to when scrolling changes. */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index ef8f798813f6f..f2725103cfd7f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -18,7 +18,6 @@ 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.WindowType; import static android.app.StatusBarManager.WindowVisibleState; import static android.app.StatusBarManager.windowStateToString; import static android.view.InsetsState.ITYPE_STATUS_BAR; @@ -32,8 +31,6 @@ 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.keyguard.WakefulnessLifecycle.WAKEFULNESS_AWAKE; -import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_WAKING; 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; @@ -69,13 +66,10 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.content.res.Configuration; -import android.content.res.Resources; import android.graphics.Point; import android.graphics.PointF; -import android.media.AudioAttributes; import android.metrics.LogMaker; import android.net.Uri; -import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.os.Looper; @@ -87,8 +81,6 @@ import android.os.SystemClock; import android.os.SystemProperties; import android.os.Trace; import android.os.UserHandle; -import android.os.VibrationEffect; -import android.os.Vibrator; import android.provider.Settings; import android.service.dreams.DreamService; import android.service.dreams.IDreamManager; @@ -103,8 +95,6 @@ import android.util.Slog; import android.view.Display; import android.view.IRemoteAnimationRunner; import android.view.IWindowManager; -import android.view.InsetsState.InternalInsetsType; -import android.view.InsetsVisibilities; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.RemoteAnimationAdapter; @@ -112,7 +102,6 @@ import android.view.ThreadedRenderer; import android.view.View; import android.view.ViewGroup; import android.view.WindowInsetsController.Appearance; -import android.view.WindowInsetsController.Behavior; import android.view.WindowManager; import android.view.WindowManagerGlobal; import android.view.accessibility.AccessibilityManager; @@ -132,7 +121,6 @@ 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.internal.view.AppearanceRegion; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.keyguard.ViewMediatorCallback; @@ -145,7 +133,6 @@ import com.android.systemui.InitController; import com.android.systemui.Prefs; import com.android.systemui.R; import com.android.systemui.SystemUI; -import com.android.systemui.accessibility.floatingmenu.AccessibilityFloatingMenuController; import com.android.systemui.animation.ActivityLaunchAnimator; import com.android.systemui.animation.DelegateLaunchAnimatorController; import com.android.systemui.assist.AssistManager; @@ -160,7 +147,6 @@ import com.android.systemui.demomode.DemoModeController; import com.android.systemui.emergency.EmergencyGesture; import com.android.systemui.fragments.ExtensionFragmentListener; import com.android.systemui.fragments.FragmentHostManager; -import com.android.systemui.keyguard.DismissCallbackRegistry; import com.android.systemui.keyguard.KeyguardService; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.keyguard.KeyguardViewMediator; @@ -207,14 +193,11 @@ import com.android.systemui.statusbar.PulseExpansionHandler; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.SuperStatusBarViewFactory; import com.android.systemui.statusbar.SysuiStatusBarStateController; -import com.android.systemui.statusbar.VibratorHelper; -import com.android.systemui.statusbar.charging.WiredChargingRippleController; import com.android.systemui.statusbar.events.SystemStatusAnimationScheduler; import com.android.systemui.statusbar.notification.DynamicPrivacyController; import com.android.systemui.statusbar.notification.NotificationActivityStarter; import com.android.systemui.statusbar.notification.NotificationLaunchAnimatorControllerProvider; import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; -import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager; import com.android.systemui.statusbar.notification.init.NotificationsController; import com.android.systemui.statusbar.notification.interruption.BypassHeadsUpNotifier; @@ -237,7 +220,6 @@ import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceP import com.android.systemui.statusbar.policy.ExtensionController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.statusbar.policy.NetworkController; -import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler; import com.android.systemui.statusbar.policy.UserInfoControllerImpl; import com.android.systemui.statusbar.policy.UserSwitcherController; import com.android.systemui.unfold.UnfoldLightRevealOverlayAnimation; @@ -266,7 +248,6 @@ import dagger.Lazy; /** */ public class StatusBar extends SystemUI implements ActivityStarter, - CommandQueue.Callbacks, ColorExtractor.OnColorsChangedListener, ConfigurationListener, StatusBarStateController.StateListener, LifecycleOwner, BatteryController.BatteryStateChangeCallback, @@ -280,7 +261,6 @@ public class StatusBar extends SystemUI implements protected static final int MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU = 1027; // Should match the values in PhoneWindowManager - public static final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey"; public static final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; static public final String SYSTEM_DIALOG_REASON_SCREENSHOT = "screenshot"; @@ -312,7 +292,7 @@ public class StatusBar extends SystemUI implements // 1020-1040 reserved for BaseStatusBar // Time after we abort the launch transition. - private static final long LAUNCH_TRANSITION_TIMEOUT_MS = 5000; + static final long LAUNCH_TRANSITION_TIMEOUT_MS = 5000; protected static final boolean CLOSE_PANEL_WHEN_EMPTIED = true; @@ -321,11 +301,6 @@ public class StatusBar extends SystemUI implements */ private static final int HINT_RESET_DELAY_MS = 1200; - private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder() - .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) - .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) - .build(); - 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; @@ -351,14 +326,113 @@ public class StatusBar extends SystemUI implements try { IPackageManager packageManager = IPackageManager.Stub.asInterface(ServiceManager.getService("package")); - onlyCoreApps = packageManager.isOnlyCoreApps(); + onlyCoreApps = packageManager != null && packageManager.isOnlyCoreApps(); } catch (RemoteException e) { onlyCoreApps = false; } ONLY_CORE_APPS = onlyCoreApps; } - private LockscreenShadeTransitionController mLockscreenShadeTransitionController; + private final LockscreenShadeTransitionController mLockscreenShadeTransitionController; + private StatusBarCommandQueueCallbacks mCommandQueueCallbacks; + + void setWindowState(int state) { + mStatusBarWindowState = state; + mStatusBarWindowHidden = state == WINDOW_STATE_HIDDEN; + } + + 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; + } + + boolean getWereIconsJustHidden() { + return mWereIconsJustHidden; + } + + void setWereIconsJustHidden(boolean justHidden) { + mWereIconsJustHidden = justHidden; + } + + void resetHandlerMsg(int msg) { + mHandler.removeMessages(msg); + mHandler.sendEmptyMessage(msg); + } + + Handler getHandler() { + return mHandler; + } + + 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 interface ExpansionChangedListener { void onExpansionChanged(float expansion, boolean expanded); @@ -370,8 +444,7 @@ public class StatusBar extends SystemUI implements protected int mState; // TODO: remove this. Just use StatusBarStateController protected boolean mBouncerShowing; - private PhoneStatusBarPolicy mIconPolicy; - private StatusBarSignalPolicy mSignalPolicy; + private final PhoneStatusBarPolicy mIconPolicy; private final VolumeComponent mVolumeComponent; private BrightnessMirrorController mBrightnessMirrorController; @@ -382,8 +455,6 @@ public class StatusBar extends SystemUI implements @Nullable protected LockscreenWallpaper mLockscreenWallpaper; private final AutoHideController mAutoHideController; - @Nullable - private final KeyguardLiftController mKeyguardLiftController; private final Point mCurrentDisplaySize = new Point(); @@ -400,7 +471,6 @@ public class StatusBar extends SystemUI implements private boolean mWakeUpComingFromTouch; private PointF mWakeUpTouchLocation; private LightRevealScrim mLightRevealScrim; - private WiredChargingRippleController mChargingRippleAnimationController; private PowerButtonReveal mPowerButtonReveal; private final Object mQueueLock = new Object(); @@ -434,9 +504,8 @@ public class StatusBar extends SystemUI implements private final KeyguardDismissUtil mKeyguardDismissUtil; private final ExtensionController mExtensionController; private final UserInfoControllerImpl mUserInfoControllerImpl; - private final DismissCallbackRegistry mDismissCallbackRegistry; private final DemoModeController mDemoModeController; - private NotificationsController mNotificationsController; + private final NotificationsController mNotificationsController; private final OngoingCallController mOngoingCallController; private final SystemStatusAnimationScheduler mAnimationScheduler; private final StatusBarLocationPublisher mStatusBarLocationPublisher; @@ -451,8 +520,6 @@ public class StatusBar extends SystemUI implements KeyguardIndicationController mKeyguardIndicationController; - private final RemoteInputQuickSettingsDisabler mRemoteInputQuickSettingsDisabler; - private View mReportRejectedTouch; private boolean mExpandedVisible; @@ -469,15 +536,17 @@ public class StatusBar extends SystemUI implements private final UnfoldTransitionConfig mUnfoldTransitionConfig; private final Lazy mUnfoldLightRevealOverlayAnimation; private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController; + private final WallpaperManager mWallpaperManager; private final UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController; private final List mExpansionChangedListeners; - // for disabling the status bar + // 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) */ + /** @see android.view.WindowInsetsController#setSystemBarsAppearance(int, int) */ private @Appearance int mAppearance; private boolean mTransientShown; @@ -563,7 +632,7 @@ public class StatusBar extends SystemUI implements private int mInteractingWindows; private @TransitionMode int mStatusBarMode; - private ViewMediatorCallback mKeyguardViewMediatorCallback; + private final ViewMediatorCallback mKeyguardViewMediatorCallback; private final ScrimController mScrimController; protected DozeScrimController mDozeScrimController; private final Executor mUiBgExecutor; @@ -583,8 +652,7 @@ public class StatusBar extends SystemUI implements Log.wtf(TAG, "WallpaperManager not supported"); return; } - WallpaperManager wallpaperManager = context.getSystemService(WallpaperManager.class); - WallpaperInfo info = wallpaperManager.getWallpaperInfo(UserHandle.USER_CURRENT); + WallpaperInfo info = mWallpaperManager.getWallpaperInfo(UserHandle.USER_CURRENT); final boolean deviceSupportsAodWallpaper = mContext.getResources().getBoolean( com.android.internal.R.bool.config_dozeSupportsAodWallpaper); // If WallpaperInfo is null, it must be ImageWallpaper. @@ -599,22 +667,17 @@ public class StatusBar extends SystemUI implements BroadcastReceiver mTaskbarChangeReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - if (mBubblesOptional.isPresent()) { - mBubblesOptional.get().onTaskbarChanged(intent.getExtras()); - } + mBubblesOptional.ifPresent(bubbles -> bubbles.onTaskbarChanged(intent.getExtras())); } }; private Runnable mLaunchTransitionEndRunnable; - private NotificationEntry mDraggedDownEntry; private boolean mLaunchCameraWhenFinishedWaking; private boolean mLaunchCameraOnFinishedGoingToSleep; private boolean mLaunchEmergencyActionWhenFinishedWaking; private boolean mLaunchEmergencyActionOnFinishedGoingToSleep; private int mLastCameraLaunchSource; protected PowerManager.WakeLock mGestureWakeLock; - private Vibrator mVibrator; - private VibrationEffect mCameraLaunchGestureVibrationEffect; private final int[] mTmpInt2 = new int[2]; @@ -698,19 +761,17 @@ public class StatusBar extends SystemUI implements private final Handler mMainThreadHandler = new Handler(Looper.getMainLooper()); private HeadsUpAppearanceController mHeadsUpAppearanceController; - private boolean mVibrateOnOpening; - private final VibratorHelper mVibratorHelper; private ActivityLaunchAnimator mActivityLaunchAnimator; private NotificationLaunchAnimatorControllerProvider mNotificationAnimationProvider; protected StatusBarNotificationPresenter mPresenter; private NotificationActivityStarter mNotificationActivityStarter; - private Lazy mNotificationShadeDepthControllerLazy; + private final Lazy mNotificationShadeDepthControllerLazy; private final Optional mBubblesManagerOptional; private final Optional mBubblesOptional; private final Bubbles.BubbleExpandListener mBubbleExpandListener; private final Optional mStartingSurfaceOptional; - private ActivityIntentHelper mActivityIntentHelper; + private final ActivityIntentHelper mActivityIntentHelper; private NotificationStackScrollLayoutController mStackScrollerController; /** @@ -726,7 +787,6 @@ public class StatusBar extends SystemUI implements LightBarController lightBarController, AutoHideController autoHideController, KeyguardUpdateMonitor keyguardUpdateMonitor, - StatusBarSignalPolicy signalPolicy, PulseExpansionHandler pulseExpansionHandler, NotificationWakeUpCoordinator notificationWakeUpCoordinator, KeyguardBypassController keyguardBypassController, @@ -737,7 +797,6 @@ public class StatusBar extends SystemUI implements FalsingManager falsingManager, FalsingCollector falsingCollector, BroadcastDispatcher broadcastDispatcher, - RemoteInputQuickSettingsDisabler remoteInputQuickSettingsDisabler, NotificationGutsManager notificationGutsManager, NotificationLogger notificationLogger, NotificationInterruptStateProvider notificationInterruptStateProvider, @@ -756,19 +815,16 @@ public class StatusBar extends SystemUI implements ScreenLifecycle screenLifecycle, WakefulnessLifecycle wakefulnessLifecycle, SysuiStatusBarStateController statusBarStateController, - VibratorHelper vibratorHelper, Optional bubblesManagerOptional, Optional bubblesOptional, VisualStabilityManager visualStabilityManager, DeviceProvisionedController deviceProvisionedController, NavigationBarController navigationBarController, - AccessibilityFloatingMenuController accessibilityFloatingMenuController, Lazy assistManagerLazy, ConfigurationController configurationController, NotificationShadeWindowController notificationShadeWindowController, DozeParameters dozeParameters, ScrimController scrimController, - @Nullable KeyguardLiftController keyguardLiftController, Lazy lockscreenWallpaperLazy, Lazy biometricUnlockControllerLazy, DozeServiceHost dozeServiceHost, @@ -795,13 +851,11 @@ public class StatusBar extends SystemUI implements UserInfoControllerImpl userInfoControllerImpl, PhoneStatusBarPolicy phoneStatusBarPolicy, KeyguardIndicationController keyguardIndicationController, - DismissCallbackRegistry dismissCallbackRegistry, DemoModeController demoModeController, Lazy notificationShadeDepthControllerLazy, StatusBarTouchableRegionManager statusBarTouchableRegionManager, NotificationIconAreaController notificationIconAreaController, BrightnessSlider.Factory brightnessSliderFactory, - WiredChargingRippleController chargingRippleAnimationController, UnfoldTransitionConfig unfoldTransitionConfig, Lazy unfoldLightRevealOverlayAnimation, OngoingCallController ongoingCallController, @@ -811,6 +865,7 @@ public class StatusBar extends SystemUI implements LockscreenShadeTransitionController lockscreenShadeTransitionController, FeatureFlags featureFlags, KeyguardUnlockAnimationController keyguardUnlockAnimationController, + WallpaperManager wallpaperManager, UnlockedScreenOffAnimationController unlockedScreenOffAnimationController, Optional startingSurfaceOptional) { super(context); @@ -818,7 +873,6 @@ public class StatusBar extends SystemUI implements mLightBarController = lightBarController; mAutoHideController = autoHideController; mKeyguardUpdateMonitor = keyguardUpdateMonitor; - mSignalPolicy = signalPolicy; mPulseExpansionHandler = pulseExpansionHandler; mWakeUpCoordinator = notificationWakeUpCoordinator; mKeyguardBypassController = keyguardBypassController; @@ -831,7 +885,6 @@ public class StatusBar extends SystemUI implements mFalsingCollector = falsingCollector; mFalsingManager = falsingManager; mBroadcastDispatcher = broadcastDispatcher; - mRemoteInputQuickSettingsDisabler = remoteInputQuickSettingsDisabler; mGutsManager = notificationGutsManager; mNotificationLogger = notificationLogger; mNotificationInterruptStateProvider = notificationInterruptStateProvider; @@ -850,7 +903,6 @@ public class StatusBar extends SystemUI implements mScreenLifecycle = screenLifecycle; mWakefulnessLifecycle = wakefulnessLifecycle; mStatusBarStateController = statusBarStateController; - mVibratorHelper = vibratorHelper; mBubblesManagerOptional = bubblesManagerOptional; mBubblesOptional = bubblesOptional; mVisualStabilityManager = visualStabilityManager; @@ -863,7 +915,6 @@ public class StatusBar extends SystemUI implements mPowerManager = powerManager; mDozeParameters = dozeParameters; mScrimController = scrimController; - mKeyguardLiftController = keyguardLiftController; mLockscreenWallpaperLazy = lockscreenWallpaperLazy; mScreenPinningRequest = screenPinningRequest; mDozeScrimController = dozeScrimController; @@ -886,11 +937,9 @@ public class StatusBar extends SystemUI implements mExtensionController = extensionController; mUserInfoControllerImpl = userInfoControllerImpl; mIconPolicy = phoneStatusBarPolicy; - mDismissCallbackRegistry = dismissCallbackRegistry; mDemoModeController = demoModeController; mNotificationIconAreaController = notificationIconAreaController; mBrightnessSliderFactory = brightnessSliderFactory; - mChargingRippleAnimationController = chargingRippleAnimationController; mUnfoldTransitionConfig = unfoldTransitionConfig; mUnfoldLightRevealOverlayAnimation = unfoldLightRevealOverlayAnimation; mOngoingCallController = ongoingCallController; @@ -899,6 +948,7 @@ public class StatusBar extends SystemUI implements mStatusBarIconController = statusBarIconController; mFeatureFlags = featureFlags; mKeyguardUnlockAnimationController = keyguardUnlockAnimationController; + mWallpaperManager = wallpaperManager; mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController; mLockscreenShadeTransitionController = lockscreenShadeTransitionController; @@ -908,12 +958,10 @@ public class StatusBar extends SystemUI implements mExpansionChangedListeners = new ArrayList<>(); mBubbleExpandListener = - (isExpanding, key) -> { - mContext.getMainExecutor().execute(() -> { - mNotificationsController.requestNotificationUpdate("onBubbleExpandChanged"); - updateScrimController(); - }); - }; + (isExpanding, key) -> mContext.getMainExecutor().execute(() -> { + mNotificationsController.requestNotificationUpdate("onBubbleExpandChanged"); + updateScrimController(); + }); mActivityIntentHelper = new ActivityIntentHelper(mContext); DateTimeView.setReceiverHandler(timeTickHandler); @@ -941,13 +989,10 @@ public class StatusBar extends SystemUI implements mDreamManager = IDreamManager.Stub.asInterface( ServiceManager.checkService(DreamService.DREAM_SERVICE)); - mDisplay = mWindowManager.getDefaultDisplay(); + mDisplay = mContext.getDisplay(); mDisplayId = mDisplay.getDisplayId(); updateDisplaySize(); - mVibrateOnOpening = mContext.getResources().getBoolean( - R.bool.config_vibrateOnIconAnimation); - // start old BaseStatusBar.start(). mWindowManagerService = WindowManagerGlobal.getWindowManagerService(); mDevicePolicyManager = (DevicePolicyManager) mContext.getSystemService( @@ -961,12 +1006,7 @@ public class StatusBar extends SystemUI implements ServiceManager.getService(Context.STATUS_BAR_SERVICE)); mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); - mWallpaperSupported = - mContext.getSystemService(WallpaperManager.class).isWallpaperSupported(); - - // Connect in to the status bar manager service - mCommandQueue.addCallback(this); - + mWallpaperSupported = mWallpaperManager.isWallpaperSupported(); RegisterStatusBarResult result = null; try { @@ -993,13 +1033,13 @@ public class StatusBar extends SystemUI implements if (containsType(result.mTransientBarTypes, ITYPE_STATUS_BAR)) { showTransientUnchecked(); } - onSystemBarAttributesChanged(mDisplayId, result.mAppearance, result.mAppearanceRegions, - result.mNavbarColorManagedByIme, result.mBehavior, result.mRequestedVisibilities, - result.mPackageName); + 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. - setImeWindowStatus(mDisplayId, result.mImeToken, result.mImeWindowVis, - result.mImeBackDisposition, result.mShowImeSwitcher); + mCommandQueueCallbacks.setImeWindowStatus(mDisplayId, result.mImeToken, + result.mImeWindowVis, result.mImeBackDisposition, result.mShowImeSwitcher); // Set up the initial icon state int numIcons = result.mIcons.size(); @@ -1075,7 +1115,7 @@ public class StatusBar extends SystemUI implements mPluginManager.addPluginListener( new PluginListener() { - private ArraySet mOverlays = new ArraySet<>(); + private final ArraySet mOverlays = new ArraySet<>(); @Override public void onPluginConnected(OverlayPlugin plugin, Context pluginContext) { @@ -1124,7 +1164,6 @@ public class StatusBar extends SystemUI implements // Constructing the view // ================================================================================ protected void makeStatusBarView(@Nullable RegisterStatusBarResult result) { - final Context context = mContext; updateDisplaySize(); // populates mDisplayMetrics updateResources(); updateTheme(); @@ -1346,14 +1385,11 @@ public class StatusBar extends SystemUI implements }); } - if (!mPowerManager.isScreenOn()) { + if (!mPowerManager.isInteractive()) { mBroadcastReceiver.onReceive(mContext, new Intent(Intent.ACTION_SCREEN_OFF)); } mGestureWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, - "GestureWakeLock"); - mVibrator = mContext.getSystemService(Vibrator.class); - mCameraLaunchGestureVibrationEffect = getCameraGestureVibrationEffect( - mVibrator, context.getResources()); + "sysui:GestureWakeLock"); // receive broadcasts registerBroadcastReceiver(); @@ -1362,7 +1398,7 @@ public class StatusBar extends SystemUI implements if (DEBUG_MEDIA_FAKE_ARTWORK) { demoFilter.addAction(ACTION_FAKE_ARTWORK); } - context.registerReceiverAsUser(mDemoReceiver, UserHandle.ALL, demoFilter, + mContext.registerReceiverAsUser(mDemoReceiver, UserHandle.ALL, demoFilter, android.Manifest.permission.DUMP, null); // listen for USER_SETUP_COMPLETE setting (per-user) @@ -1599,8 +1635,17 @@ public class StatusBar extends SystemUI implements mHeadsUpManager.addListener(statusBarComponent.getStatusBarHeadsUpChangeListener()); + mHeadsUpManager.addListener(statusBarComponent.getStatusBarHeadsUpChangeListener()); + // Listen for demo mode changes mDemoModeController.addCallback(statusBarComponent.getStatusBarDemoMode()); + + if (mCommandQueueCallbacks != null) { + mCommandQueue.removeCallback(mCommandQueueCallbacks); + } + mCommandQueueCallbacks = statusBarComponent.getStatusBarCommandQueueCallbacks(); + // Connect in to the status bar manager service + mCommandQueue.addCallback(mCommandQueueCallbacks); } protected void startKeyguard() { @@ -1650,7 +1695,7 @@ public class StatusBar extends SystemUI implements Trace.endSection(); } - protected View getStatusBarView() { + protected PhoneStatusBarView getStatusBarView() { return mStatusBarView; } @@ -1712,7 +1757,7 @@ public class StatusBar extends SystemUI implements * 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. */ - private void updateQsExpansionEnabled() { + void updateQsExpansionEnabled() { final boolean expandEnabled = mDeviceProvisionedController.isDeviceProvisioned() && (mUserSetup || mUserSwitcherController == null || !mUserSwitcherController.isSimpleUserSwitcher()) @@ -1728,22 +1773,6 @@ public class StatusBar extends SystemUI implements return (mDisabled2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE) != 0; } - public void addQsTile(ComponentName tile) { - if (mQSPanelController != null && mQSPanelController.getHost() != null) { - mQSPanelController.getHost().addTile(tile); - } - } - - public void remQsTile(ComponentName tile) { - if (mQSPanelController != null && mQSPanelController.getHost() != null) { - mQSPanelController.getHost().removeTile(tile); - } - } - - public void clickTile(ComponentName tile) { - mQSPanelController.clickTile(tile); - } - /** * Request a notification update * @param reason why we're requesting a notification update @@ -1769,94 +1798,6 @@ public class StatusBar extends SystemUI implements && mFalsingCollector.isReportingEnabled() ? View.VISIBLE : View.INVISIBLE); } - /** - * 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; - } - state2 = mRemoteInputQuickSettingsDisabler.adjustDisableFlags(state2); - - animate &= mStatusBarWindowState != WINDOW_STATE_HIDDEN; - final int old1 = mDisabled1; - final int diff1 = state1 ^ old1; - mDisabled1 = state1; - - final int old2 = mDisabled2; - final int diff2 = state2 ^ old2; - mDisabled2 = state2; - - if (DEBUG) { - Log.d(TAG, String.format("disable1: 0x%08x -> 0x%08x (diff1: 0x%08x)", - old1, state1, diff1)); - Log.d(TAG, String.format("disable2: 0x%08x -> 0x%08x (diff2: 0x%08x)", - old2, state2, diff2)); - } - - StringBuilder flagdbg = new StringBuilder(); - flagdbg.append("disable<"); - flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_EXPAND)) ? 'E' : 'e'); - flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_EXPAND)) ? '!' : ' '); - flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS)) ? 'I' : 'i'); - flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS)) ? '!' : ' '); - flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS)) ? 'A' : 'a'); - flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS)) ? '!' : ' '); - flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_SYSTEM_INFO)) ? 'S' : 's'); - flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_SYSTEM_INFO)) ? '!' : ' '); - flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_BACK)) ? 'B' : 'b'); - flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_BACK)) ? '!' : ' '); - flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_HOME)) ? 'H' : 'h'); - flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_HOME)) ? '!' : ' '); - flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_RECENT)) ? 'R' : 'r'); - flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_RECENT)) ? '!' : ' '); - flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_CLOCK)) ? 'C' : 'c'); - flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_CLOCK)) ? '!' : ' '); - flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_SEARCH)) ? 'S' : 's'); - flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_SEARCH)) ? '!' : ' '); - flagdbg.append("> disable2<"); - flagdbg.append(0 != ((state2 & StatusBarManager.DISABLE2_QUICK_SETTINGS)) ? 'Q' : 'q'); - flagdbg.append(0 != ((diff2 & StatusBarManager.DISABLE2_QUICK_SETTINGS)) ? '!' : ' '); - flagdbg.append(0 != ((state2 & StatusBarManager.DISABLE2_SYSTEM_ICONS)) ? 'I' : 'i'); - flagdbg.append(0 != ((diff2 & StatusBarManager.DISABLE2_SYSTEM_ICONS)) ? '!' : ' '); - flagdbg.append(0 != ((state2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE)) ? 'N' : 'n'); - flagdbg.append(0 != ((diff2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE)) ? '!' : ' '); - flagdbg.append('>'); - Log.d(TAG, flagdbg.toString()); - - if ((diff1 & StatusBarManager.DISABLE_EXPAND) != 0) { - if ((state1 & StatusBarManager.DISABLE_EXPAND) != 0) { - mShadeController.animateCollapsePanels(); - } - } - - if ((diff1 & StatusBarManager.DISABLE_RECENT) != 0) { - if ((state1 & StatusBarManager.DISABLE_RECENT) != 0) { - // close recents if it's visible - mHandler.removeMessages(MSG_HIDE_RECENT_APPS); - mHandler.sendEmptyMessage(MSG_HIDE_RECENT_APPS); - } - } - - if ((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) { - if (areNotificationAlertsDisabled()) { - mHeadsUpManager.releaseAllImmediately(); - } - } - - if ((diff2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) != 0) { - updateQsExpansionEnabled(); - } - - if ((diff2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE) != 0) { - updateQsExpansionEnabled(); - if ((state2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE) != 0) { - mShadeController.animateCollapsePanels(); - } - } - } - boolean areNotificationAlertsDisabled() { return (mDisabled1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0; } @@ -1993,7 +1934,7 @@ public class StatusBar extends SystemUI implements * * @param animate should the change of the icons be animated. */ - private void updateHideIconsForBouncer(boolean animate) { + void updateHideIconsForBouncer(boolean animate) { boolean hideBecauseApp = mTopHidesStatusBar && mIsOccluded && (mStatusBarWindowHidden || mBouncerShowing); boolean hideBecauseKeyguard = !mPanelExpanded && !mIsOccluded && mBouncerShowing; @@ -2107,15 +2048,14 @@ public class StatusBar extends SystemUI implements mState = state; } - @VisibleForTesting - void setUserSetupForTest(boolean userSetup) { - mUserSetup = userSetup; - } - /** * All changes to the status bar and notifications funnel through here and are batched. */ protected class H extends Handler { + H() { + super(Looper.myLooper()); + } + @Override public void handleMessage(Message m) { switch (m.what) { @@ -2127,10 +2067,10 @@ public class StatusBar extends SystemUI implements break; // End old BaseStatusBar.H handling. case MSG_OPEN_NOTIFICATION_PANEL: - animateExpandNotificationsPanel(); + mCommandQueueCallbacks.animateExpandNotificationsPanel(); break; case MSG_OPEN_SETTINGS_PANEL: - animateExpandSettingsPanel((String) m.obj); + mCommandQueueCallbacks.animateExpandSettingsPanel((String) m.obj); break; case MSG_CLOSE_PANELS: mShadeController.animateCollapsePanels(); @@ -2162,59 +2102,6 @@ public class StatusBar extends SystemUI implements mHeadsUpManager.releaseAllImmediately(); } - /** - * 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 (SPEW) Log.d(TAG, "handleNavigationKey: " + key); - if (!mCommandQueue.panelsEnabled() || !mKeyguardUpdateMonitor.isDeviceInteractive() - || mKeyguardStateController.isShowing() && !mKeyguardStateController.isOccluded()) { - return; - } - - // Panels are not available in setup - if (!mUserSetup) 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 */); - mStackScroller.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 showPinningEnterExitToast(boolean entering) { - if (getNavigationBarView() != null) { - getNavigationBarView().showPinningEnterExitToast(entering); - } - } - - @Override - public void showPinningEscapeToast() { - if (getNavigationBarView() != null) { - getNavigationBarView().showPinningEscapeToast(); - } - } - void makeExpandedVisible(boolean force) { if (SPEW) Log.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible); if (!force && (mExpandedVisible || !mCommandQueue.panelsEnabled())) { @@ -2245,21 +2132,6 @@ public class StatusBar extends SystemUI implements mHandler.sendEmptyMessage(MSG_OPEN_SETTINGS_PANEL); } - @Override - public void togglePanel() { - if (mPanelExpanded) { - mShadeController.animateCollapsePanels(); - } else { - animateExpandNotificationsPanel(); - } - } - - @Override - public void animateCollapsePanels(int flags, boolean force) { - mShadeController.animateCollapsePanels(flags, force, false /* delayed */, - 1.0f /* speedUpFactor */); - } - /** * Called by {@link ShadeController} when it calls * {@link ShadeController#animateCollapsePanels(int, boolean, boolean, float)}. @@ -2294,36 +2166,6 @@ public class StatusBar extends SystemUI implements } } - @Override - public void animateExpandNotificationsPanel() { - if (SPEW) Log.d(TAG, "animateExpand: mExpandedVisible=" + mExpandedVisible); - if (!mCommandQueue.panelsEnabled()) { - return ; - } - - mNotificationPanelViewController.expandWithoutQs(); - - if (false) postStartTracing(); - } - - @Override - public void animateExpandSettingsPanel(@Nullable String subPanel) { - if (SPEW) Log.d(TAG, "animateExpand: mExpandedVisible=" + mExpandedVisible); - if (!mCommandQueue.panelsEnabled()) { - return; - } - - // Settings are not available in setup - if (!mUserSetup) return; - - if (subPanel != null) { - mQSPanelController.openDetails(subPanel); - } - mNotificationPanelViewController.expandWithQs(); - - if (false) postStartTracing(); - } - public void animateCollapseQuickSettings() { if (mState == StatusBarState.SHADE) { mStatusBarView.collapsePanel(true, false /* delayed */, 1.0f /* speedUpFactor */); @@ -2403,11 +2245,7 @@ public class StatusBar extends SystemUI implements final boolean upOrCancel = event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL; - if (upOrCancel && !mExpandedVisible) { - setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false); - } else { - setInteracting(StatusBarManager.WINDOW_STATUS_BAR, true); - } + setInteracting(StatusBarManager.WINDOW_STATUS_BAR, !upOrCancel || mExpandedVisible); } return false; } @@ -2424,63 +2262,7 @@ public class StatusBar extends SystemUI implements return mBiometricUnlockController; } - @Override // CommandQueue - public void setWindowState( - int displayId, @WindowType int window, @WindowVisibleState int state) { - if (displayId != mDisplayId) { - return; - } - boolean showing = state == WINDOW_STATE_SHOWING; - if (mNotificationShadeWindowView != null - && window == StatusBarManager.WINDOW_STATUS_BAR - && mStatusBarWindowState != state) { - mStatusBarWindowState = state; - if (DEBUG_WINDOW_STATE) Log.d(TAG, "Status bar " + windowStateToString(state)); - if (mStatusBarView != null) { - if (!showing && mState == StatusBarState.SHADE) { - mStatusBarView.collapsePanel(false /* animate */, false /* delayed */, - 1.0f /* speedUpFactor */); - } - mStatusBarWindowHidden = state == WINDOW_STATE_HIDDEN; - updateHideIconsForBouncer(false /* animate */); - } - } - - updateBubblesVisibility(); - } - - @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 = false; - if (mAppearance != appearance) { - mAppearance = appearance; - barModeChanged = updateBarMode(barMode(mTransientShown, appearance)); - } - mLightBarController.onStatusBarAppearanceChanged(appearanceRegions, barModeChanged, - mStatusBarMode, navbarColorManagedByIme); - - updateBubblesVisibility(); - mStatusBarStateController.setSystemBarAttributes( - appearance, behavior, requestedVisibilities, packageName); - } - - @Override - public void showTransient(int displayId, @InternalInsetsType int[] types) { - if (displayId != mDisplayId) { - return; - } - if (!containsType(types, ITYPE_STATUS_BAR)) { - return; - } - showTransientUnchecked(); - } - - private void showTransientUnchecked() { + void showTransientUnchecked() { if (!mTransientShown) { mTransientShown = true; mNoAnimationOnNextBarModeChange = true; @@ -2488,18 +2270,8 @@ public class StatusBar extends SystemUI implements } } - @Override - public void abortTransient(int displayId, @InternalInsetsType int[] types) { - if (displayId != mDisplayId) { - return; - } - if (!containsType(types, ITYPE_STATUS_BAR)) { - return; - } - clearTransient(); - } - private void clearTransient() { + void clearTransient() { if (mTransientShown) { mTransientShown = false; handleTransientChanged(); @@ -2541,8 +2313,7 @@ public class StatusBar extends SystemUI implements } } - @Override - public void showWirelessChargingAnimation(int batteryLevel) { + protected void showWirelessChargingAnimation(int batteryLevel) { showChargingAnimation(batteryLevel, UNKNOWN_BATTERY_LEVEL, 0); } @@ -2563,11 +2334,6 @@ public class StatusBar extends SystemUI implements }, false, sUiEventLogger).show(animationDelay); } - @Override - public void onRecentsAnimationStateChanged(boolean running) { - setInteracting(StatusBarManager.WINDOW_NAVIGATION_BAR, running); - } - protected BarTransitions getStatusBarTransitions() { return mNotificationShadeWindowViewController.getBarTransitions(); } @@ -2587,13 +2353,11 @@ public class StatusBar extends SystemUI implements } /** Temporarily hides Bubbles if the status bar is hidden. */ - private void updateBubblesVisibility() { - if (mBubblesOptional.isPresent()) { - mBubblesOptional.get().onStatusBarVisibilityChanged( - mStatusBarMode != MODE_LIGHTS_OUT - && mStatusBarMode != MODE_LIGHTS_OUT_TRANSPARENT - && !mStatusBarWindowHidden); - } + 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, @@ -2677,7 +2441,7 @@ public class StatusBar extends SystemUI implements mNotificationPanelViewController.dump(fd, pw, args); } pw.println(" mStackScroller: "); - if (mStackScroller instanceof Dumpable) { + if (mStackScroller != null) { pw.print (" "); ((Dumpable) mStackScroller).dump(fd, pw, args); } @@ -2710,19 +2474,6 @@ public class StatusBar extends SystemUI implements mNotificationsController.dump(fd, pw, args, DUMPTRUCK); - if (DUMPTRUCK) { - if (false) { - pw.println("see the logcat for a dump of the views we have created."); - // must happen on ui thread - mHandler.post(() -> { - mStatusBarView.getLocationOnScreen(mAbsPos); - Log.d(TAG, "mStatusBarView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] + - ") " + mStatusBarView.getWidth() + "x" + getStatusBarHeight()); - mStatusBarView.debug(); - }); - } - } - if (DEBUG_GESTURES) { pw.print(" status bar gestures: "); mGestureRec.dump(fd, pw, args); @@ -2753,7 +2504,7 @@ public class StatusBar extends SystemUI implements pw.println(" Insecure camera: " + CameraIntents.getInsecureCameraIntent(mContext)); pw.println(" Secure camera: " + CameraIntents.getSecureCameraIntent(mContext)); pw.println(" Override package: " - + String.valueOf(CameraIntents.getOverrideCameraPackage(mContext))); + + CameraIntents.getOverrideCameraPackage(mContext)); } public static void dumpBarTransitions( @@ -2814,7 +2565,7 @@ public class StatusBar extends SystemUI implements startActivityDismissingKeyguard(intent, onlyProvisioned, dismissShade, 0); } - private void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned, + void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned, final boolean dismissShade, final boolean disallowEnterPictureInPictureWhileLaunching, final Callback callback, int flags, @Nullable ActivityLaunchAnimator.Controller animationController) { @@ -2859,7 +2610,7 @@ public class StatusBar extends SystemUI implements options.setRotationAnimationHint( WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS); } - if (intent.getAction() == Settings.Panel.ACTION_VOLUME) { + if (intent.getAction().equals(Settings.Panel.ACTION_VOLUME)) { // Settings Panel is implemented as activity(not a dialog), so // underlying app is paused and may enter picture-in-picture mode // as a result. @@ -2958,7 +2709,7 @@ public class StatusBar extends SystemUI implements && mStatusBarKeyguardViewManager.isOccluded()) { mStatusBarKeyguardViewManager.addAfterKeyguardGoneRunnable(runnable); } else { - AsyncTask.execute(runnable); + mHandler.post(runnable); } } if (dismissShade) { @@ -3241,37 +2992,6 @@ public class StatusBar extends SystemUI implements | ((currentlyInsecure ? 1 : 0) << 12); } - // - // tracing - // - - void postStartTracing() { - mHandler.postDelayed(mStartTracing, 3000); - } - - void vibrate() { - android.os.Vibrator vib = (android.os.Vibrator)mContext.getSystemService( - Context.VIBRATOR_SERVICE); - vib.vibrate(250, VIBRATION_ATTRIBUTES); - } - - final Runnable mStartTracing = new Runnable() { - @Override - public void run() { - vibrate(); - SystemClock.sleep(250); - Log.d(TAG, "startTracing"); - android.os.Debug.startMethodTracing("/data/statusbar-traces/trace"); - mHandler.postDelayed(mStopTracing, 10000); - } - }; - - final Runnable mStopTracing = () -> { - android.os.Debug.stopMethodTracing(); - Log.d(TAG, "stopTracing"); - vibrate(); - }; - @Override public void postQSRunnableDismissingKeyguard(final Runnable runnable) { mHandler.post(() -> { @@ -3452,7 +3172,7 @@ public class StatusBar extends SystemUI implements */ public void animateKeyguardUnoccluding() { mNotificationPanelViewController.setExpandedFraction(0f); - animateExpandNotificationsPanel(); + mCommandQueueCallbacks.animateExpandNotificationsPanel(); } /** @@ -3623,7 +3343,7 @@ public class StatusBar extends SystemUI implements /** * While IME is active and a BACK event is detected, check with - * {@link StatusBarKeyguardViewManager#dispatchBackKeyEventPreIme(KeyEvent)} to see if the event + * {@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. */ @@ -3949,7 +3669,8 @@ public class StatusBar extends SystemUI implements // This gets executed before we will show Keyguard, so post it in order that the state // is correct. - mHandler.post(() -> onCameraLaunchGestureDetected(mLastCameraLaunchSource)); + mHandler.post(() -> mCommandQueueCallbacks.onCameraLaunchGestureDetected( + mLastCameraLaunchSource)); } if (mLaunchEmergencyActionOnFinishedGoingToSleep) { @@ -3957,7 +3678,8 @@ public class StatusBar extends SystemUI implements // This gets executed before we will show Keyguard, so post it in order that the // state is correct. - mHandler.post(() -> onEmergencyActionLaunchGestureDetected()); + mHandler.post( + () -> mCommandQueueCallbacks.onEmergencyActionLaunchGestureDetected()); } updateIsKeyguard(); } @@ -4070,36 +3792,6 @@ public class StatusBar extends SystemUI implements return mWakefulnessLifecycle.getWakefulness(); } - private void vibrateForCameraGesture() { - // Make sure to pass -1 for repeat so VibratorService doesn't stop us when going to sleep. - mVibrator.vibrate(mCameraLaunchGestureVibrationEffect, VIBRATION_ATTRIBUTES); - } - - private static VibrationEffect getCameraGestureVibrationEffect(Vibrator vibrator, - Resources resources) { - if (vibrator.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 (vibrator.hasAmplitudeControl()) { - return VibrationEffect.createWaveform( - CAMERA_LAUNCH_GESTURE_VIBRATION_TIMINGS, - 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); - } - /** * @return true if the screen is currently fully off, i.e. has finished turning off and has * since not started turning on. @@ -4108,139 +3800,11 @@ public class StatusBar extends SystemUI implements return mScreenLifecycle.getScreenState() == ScreenLifecycle.SCREEN_OFF; } - @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. - showScreenPinningRequest(taskId, true); - } - public void showScreenPinningRequest(int taskId, boolean allowCancel) { mScreenPinningRequest.showPrompt(taskId, allowCancel); } - @Override - public void appTransitionCancelled(int displayId) { - if (displayId == mDisplayId) { - mSplitScreenOptional.ifPresent(splitScreen -> splitScreen.onAppTransitionFinished()); - } - } - - @Override - public void appTransitionFinished(int displayId) { - if (displayId == mDisplayId) { - mSplitScreenOptional.ifPresent(splitScreen -> splitScreen.onAppTransitionFinished()); - } - } - - @Override - public void onCameraLaunchGestureDetected(int source) { - mLastCameraLaunchSource = source; - if (isGoingToSleep()) { - if (DEBUG_CAMERA_LIFT) Slog.d(TAG, "Finish going to sleep before launching camera"); - mLaunchCameraOnFinishedGoingToSleep = true; - return; - } - if (!mNotificationPanelViewController.canCameraGestureBeLaunched()) { - if (DEBUG_CAMERA_LIFT) Slog.d(TAG, "Can't launch camera right now"); - return; - } - if (!mDeviceInteractive) { - 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(TAG, "Camera launch"); - mKeyguardUpdateMonitor.onCameraLaunched(); - } - - if (!mStatusBarKeyguardViewManager.isShowing()) { - final Intent cameraIntent = CameraIntents.getInsecureCameraIntent(mContext); - startActivityDismissingKeyguard(cameraIntent, - false /* onlyProvisioned */, true /* dismissShade */, - true /* disallowEnterPictureInPictureWhileLaunching */, null /* callback */, 0, - null /* animationController */); - } else { - if (!mDeviceInteractive) { - // Avoid flickering of the scrim when we instant launch the camera and the bouncer - // comes on. - mGestureWakeLock.acquire(LAUNCH_TRANSITION_TIMEOUT_MS + 1000L); - } - if (isWakingUpOrAwake()) { - if (DEBUG_CAMERA_LIFT) Slog.d(TAG, "Launching camera"); - if (mStatusBarKeyguardViewManager.isBouncerShowing()) { - mStatusBarKeyguardViewManager.reset(true /* hide */); - } - mNotificationPanelViewController.launchCamera( - mDeviceInteractive /* animate */, source); - 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 (DEBUG_CAMERA_LIFT) Slog.d(TAG, "Deferring until screen turns on"); - mLaunchCameraWhenFinishedWaking = true; - } - } - } - - @Override - public void onEmergencyActionLaunchGestureDetected() { - Intent emergencyIntent = getEmergencyActionIntent(); - - if (emergencyIntent == null) { - Log.wtf(TAG, "Couldn't find an app to process the emergency intent."); - return; - } - - if (isGoingToSleep()) { - mLaunchEmergencyActionOnFinishedGoingToSleep = true; - return; - } - - if (!mDeviceInteractive) { - 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()) { - startActivityDismissingKeyguard(emergencyIntent, - false /* onlyProvisioned */, true /* dismissShade */, - true /* disallowEnterPictureInPictureWhileLaunching */, null /* callback */, 0, - null /* animationController */); - return; - } - - if (!mDeviceInteractive) { - // Avoid flickering of the scrim when we instant launch the camera and the bouncer - // comes on. - mGestureWakeLock.acquire(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) - mLaunchEmergencyActionWhenFinishedWaking = true; - } - - private @Nullable Intent getEmergencyActionIntent() { + @Nullable Intent getEmergencyActionIntent() { Intent emergencyIntent = new Intent(EmergencyGesture.ACTION_LAUNCH_EMERGENCY); PackageManager pm = mContext.getPackageManager(); List emergencyActivities = pm.queryIntentActivities(emergencyIntent, @@ -4298,16 +3862,11 @@ public class StatusBar extends SystemUI implements return true; } - private boolean isGoingToSleep() { + boolean isGoingToSleep() { return mWakefulnessLifecycle.getWakefulness() == WakefulnessLifecycle.WAKEFULNESS_GOING_TO_SLEEP; } - private boolean isWakingUpOrAwake() { - return mWakefulnessLifecycle.getWakefulness() == WAKEFULNESS_AWAKE - || mWakefulnessLifecycle.getWakefulness() == WAKEFULNESS_WAKING; - } - public void notifyBiometricAuthModeChanged() { mDozeServiceHost.updateDozing(); updateScrimController(); @@ -4458,10 +4017,6 @@ public class StatusBar extends SystemUI implements mNotificationsController.setNotificationSnoozed(sbn, snoozeOption); } - @Override - public void toggleSplitScreen() { - toggleSplitScreenMode(-1 /* metricsDockAction */, -1 /* metricsUndockAction */); - } public void awakenDreams() { mUiBgExecutor.execute(() -> { @@ -4473,46 +4028,6 @@ public class StatusBar extends SystemUI implements }); } - @Override - public void preloadRecentApps() { - int msg = MSG_PRELOAD_RECENT_APPS; - mHandler.removeMessages(msg); - mHandler.sendEmptyMessage(msg); - } - - @Override - public void cancelPreloadRecentApps() { - int msg = MSG_CANCEL_PRELOAD_RECENT_APPS; - mHandler.removeMessages(msg); - mHandler.sendEmptyMessage(msg); - } - - @Override - public void dismissKeyboardShortcutsMenu() { - int msg = MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU; - mHandler.removeMessages(msg); - mHandler.sendEmptyMessage(msg); - } - - @Override - public void toggleKeyboardShortcutsMenu(int deviceId) { - int msg = MSG_TOGGLE_KEYBOARD_SHORTCUTS_MENU; - mHandler.removeMessages(msg); - mHandler.obtainMessage(msg, deviceId, 0).sendToTarget(); - } - - @Override - public void setTopAppHidesStatusBar(boolean topAppHidesStatusBar) { - mTopHidesStatusBar = topAppHidesStatusBar; - if (!topAppHidesStatusBar && mWereIconsJustHidden) { - // Immediately update the icon hidden state, since that should only apply if we're - // staying fullscreen. - mWereIconsJustHidden = false; - mCommandQueue.recomputeDisableFlags(mDisplayId, true); - } - updateHideIconsForBouncer(true /* animate */); - } - protected void toggleKeyboardShortcuts(int deviceId) { KeyboardShortcuts.toggle(mContext, deviceId); } @@ -4774,34 +4289,19 @@ public class StatusBar extends SystemUI implements } return mStatusBarKeyguardViewManager.isSecure(); } - - @Override - public void showAssistDisclosure() { - mAssistManagerLazy.get().showDisclosure(); - } - public NotificationPanelViewController getPanelController() { return mNotificationPanelViewController; } - - @Override - public void startAssist(Bundle args) { - mAssistManagerLazy.get().startAssist(args); - } // End Extra BaseStatusBarMethods. public NotificationGutsManager getGutsManager() { return mGutsManager; } - private boolean isTransientShown() { + boolean isTransientShown() { return mTransientShown; } - @Override - public void suppressAmbientDisplay(boolean suppressed) { - mDozeServiceHost.setDozeSuppressed(suppressed); - } public void addExpansionChangedListener(@NonNull ExpansionChangedListener listener) { mExpansionChangedListeners.add(listener); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarCommandQueueCallbacks.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarCommandQueueCallbacks.java new file mode 100644 index 0000000000000..95f2d0a868c68 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarCommandQueueCallbacks.java @@ -0,0 +1,690 @@ +/* + * 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.app.StatusBarManager.WINDOW_STATE_SHOWING; +import static android.app.StatusBarManager.windowStateToString; +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.media.AudioAttributes; +import android.os.Bundle; +import android.os.PowerManager; +import android.os.SystemClock; +import android.os.UserHandle; +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.StatusBarState; +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 com.android.wm.shell.legacysplitscreen.LegacySplitScreen; + +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 Optional mSplitScreenOptional; + 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 PowerManager mPowerManager; + private final VibratorHelper mVibratorHelper; + private final Optional mVibratorOptional; + private final LightBarController mLightBarController; + private final int mDisplayId; + private final boolean mVibrateOnOpening; + private final VibrationEffect mCameraLaunchGestureVibrationEffect; + + + private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder() + .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) + .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) + .build(); + + @Inject + StatusBarCommandQueueCallbacks( + StatusBar statusBar, + Context context, + @Main Resources resources, + ShadeController shadeController, + CommandQueue commandQueue, + NotificationPanelViewController notificationPanelViewController, + Optional splitScreenOptional, + 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, + PowerManager powerManager, + VibratorHelper vibratorHelper, + Optional vibratorOptional, + LightBarController lightBarController, + @DisplayId int displayId) { + + mStatusBar = statusBar; + mContext = context; + mShadeController = shadeController; + mCommandQueue = commandQueue; + mNotificationPanelViewController = notificationPanelViewController; + mSplitScreenOptional = splitScreenOptional; + 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; + mPowerManager = powerManager; + mVibratorHelper = vibratorHelper; + mVibratorOptional = vibratorOptional; + mLightBarController = lightBarController; + 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; + + + QSPanelController qsPanelController = mStatusBar.getQSPanelController(); + if (subPanel != null && qsPanelController != null) { + qsPanelController.openDetails(subPanel); + } + mNotificationPanelViewController.expandWithQs(); + } + + @Override + public void appTransitionCancelled(int displayId) { + if (displayId == mDisplayId) { + mSplitScreenOptional.ifPresent(LegacySplitScreen::onAppTransitionFinished); + } + } + + @Override + public void appTransitionFinished(int displayId) { + if (displayId == mDisplayId) { + mSplitScreenOptional.ifPresent(LegacySplitScreen::onAppTransitionFinished); + } + } + + @Override + public void preloadRecentApps() { + mStatusBar.resetHandlerMsg(StatusBar.MSG_PRELOAD_RECENT_APPS); + } + + @Override + public void cancelPreloadRecentApps() { + mStatusBar.resetHandlerMsg(StatusBar.MSG_CANCEL_PRELOAD_RECENT_APPS); + } + + @Override + public void dismissKeyboardShortcutsMenu() { + mStatusBar.resetHandlerMsg(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; + } + state2 = mRemoteInputQuickSettingsDisabler.adjustDisableFlags(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 (StatusBar.DEBUG) { + Log.d(StatusBar.TAG, String.format("disable1: 0x%08x -> 0x%08x (diff1: 0x%08x)", + old1, state1, diff1)); + Log.d(StatusBar.TAG, String.format("disable2: 0x%08x -> 0x%08x (diff2: 0x%08x)", + old2, state2, diff2)); + } + + StringBuilder flagdbg = new StringBuilder(); + flagdbg.append("disable<"); + flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_EXPAND)) ? 'E' : 'e'); + flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_EXPAND)) ? '!' : ' '); + flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS)) ? 'I' : 'i'); + flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS)) ? '!' : ' '); + flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS)) ? 'A' : 'a'); + flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS)) ? '!' : ' '); + flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_SYSTEM_INFO)) ? 'S' : 's'); + flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_SYSTEM_INFO)) ? '!' : ' '); + flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_BACK)) ? 'B' : 'b'); + flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_BACK)) ? '!' : ' '); + flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_HOME)) ? 'H' : 'h'); + flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_HOME)) ? '!' : ' '); + flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_RECENT)) ? 'R' : 'r'); + flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_RECENT)) ? '!' : ' '); + flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_CLOCK)) ? 'C' : 'c'); + flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_CLOCK)) ? '!' : ' '); + flagdbg.append(0 != ((state1 & StatusBarManager.DISABLE_SEARCH)) ? 'S' : 's'); + flagdbg.append(0 != ((diff1 & StatusBarManager.DISABLE_SEARCH)) ? '!' : ' '); + flagdbg.append("> disable2<"); + flagdbg.append(0 != ((state2 & StatusBarManager.DISABLE2_QUICK_SETTINGS)) ? 'Q' : 'q'); + flagdbg.append(0 != ((diff2 & StatusBarManager.DISABLE2_QUICK_SETTINGS)) ? '!' : ' '); + flagdbg.append(0 != ((state2 & StatusBarManager.DISABLE2_SYSTEM_ICONS)) ? 'I' : 'i'); + flagdbg.append(0 != ((diff2 & StatusBarManager.DISABLE2_SYSTEM_ICONS)) ? '!' : ' '); + flagdbg.append(0 != ((state2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE)) ? 'N' : 'n'); + flagdbg.append(0 != ((diff2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE)) ? '!' : ' '); + flagdbg.append('>'); + Log.d(StatusBar.TAG, flagdbg.toString()); + + if ((diff1 & StatusBarManager.DISABLE_EXPAND) != 0) { + if ((state1 & StatusBarManager.DISABLE_EXPAND) != 0) { + mShadeController.animateCollapsePanels(); + } + } + + if ((diff1 & StatusBarManager.DISABLE_RECENT) != 0) { + if ((state1 & StatusBarManager.DISABLE_RECENT) != 0) { + // close recents if it's visible + mStatusBar.resetHandlerMsg(StatusBar.MSG_HIDE_RECENT_APPS); + } + } + + 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) { + if (displayId != mDisplayId) { + return; + } + if (!containsType(types, ITYPE_STATUS_BAR)) { + return; + } + mStatusBar.showTransientUnchecked(); + } + + @Override + public void toggleKeyboardShortcutsMenu(int deviceId) { + int msg = StatusBar.MSG_TOGGLE_KEYBOARD_SHORTCUTS_MENU; + mStatusBar.getHandler().removeMessages(msg); + mStatusBar.getHandler().obtainMessage(msg, deviceId, 0).sendToTarget(); + } + + @Override + public void setTopAppHidesStatusBar(boolean topAppHidesStatusBar) { + mStatusBar.setTopHidesStatusBar(topAppHidesStatusBar); + if (!topAppHidesStatusBar && mStatusBar.getWereIconsJustHidden()) { + // Immediately update the icon hidden state, since that should only apply if we're + // staying fullscreen. + mStatusBar.setWereIconsJustHidden(false); + mCommandQueue.recomputeDisableFlags(mDisplayId, true); + } + mStatusBar.updateHideIconsForBouncer(true /* animate */); + } + + @Override + public void setWindowState( + int displayId, @StatusBarManager.WindowType int window, + @StatusBarManager.WindowVisibleState int state) { + if (displayId != mDisplayId) { + return; + } + boolean showing = state == WINDOW_STATE_SHOWING; + if (mNotificationShadeWindowView != null + && window == StatusBarManager.WINDOW_STATUS_BAR + && !mStatusBar.isSameStatusBarState(state)) { + mStatusBar.setWindowState(state); + if (StatusBar.DEBUG_WINDOW_STATE) { + Log.d(StatusBar.TAG, "Status bar " + windowStateToString(state)); + } + if (mStatusBar.getStatusBarView() != null) { + if (!showing && mStatusBarStateController.getState() == StatusBarState.SHADE) { + mStatusBar.getStatusBarView().collapsePanel( + false /* animate */, false /* delayed */, 1.0f /* speedUpFactor */); + } + + mStatusBar.updateHideIconsForBouncer(false /* animate */); + } + } + + mStatusBar.updateBubblesVisibility(); + } + + @Override + public void showAssistDisclosure() { + mAssistManager.showDisclosure(); + } + + @Override + public void showPinningEnterExitToast(boolean entering) { + if (mStatusBar.getNavigationBarView() != null) { + mStatusBar.getNavigationBarView().showPinningEnterExitToast(entering); + } + } + + @Override + public void showPinningEscapeToast() { + if (mStatusBar.getNavigationBarView() != null) { + mStatusBar.getNavigationBarView().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.setDozeSuppressed(suppressed); + } + + @Override + public void togglePanel() { + if (mStatusBar.isPanelExpanded()) { + mShadeController.animateCollapsePanels(); + } else { + animateExpandNotificationsPanel(); + } + } + + @Override + public void toggleSplitScreen() { + mStatusBar.toggleSplitScreenMode(-1 /* metricsDockAction */, -1 /* metricsUndockAction */); + } + + 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() { + // Make sure to pass -1 for repeat so VibratorService doesn't stop us when going to sleep. + mVibratorOptional.ifPresent( + v -> v.vibrate(mCameraLaunchGestureVibrationEffect, 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()) { + 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/dagger/StatusBarComponent.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java index d71fc9ea6b787..d408c0cc32670 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java @@ -24,6 +24,7 @@ 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.StatusBarDemoMode; import com.android.systemui.statusbar.phone.StatusBarHeadsUpChangeListener; import com.android.systemui.statusbar.phone.StatusBarWindowController; @@ -102,6 +103,12 @@ public interface StatusBarComponent { @StatusBarScope StatusBarHeadsUpChangeListener getStatusBarHeadsUpChangeListener(); + /** + * Creates a StatusBarCommandQueueCallbacks. + */ + @StatusBarScope + StatusBarCommandQueueCallbacks getStatusBarCommandQueueCallbacks(); + /** * Creates a SplitShadeHeaderController. */ 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 5e8eecbd9acbb..c21dbc992933e 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 @@ -18,18 +18,16 @@ package com.android.systemui.statusbar.phone.dagger; import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME; +import android.app.WallpaperManager; import android.content.Context; import android.os.Handler; import android.os.PowerManager; import android.util.DisplayMetrics; -import androidx.annotation.Nullable; - import com.android.internal.logging.MetricsLogger; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.ViewMediatorCallback; import com.android.systemui.InitController; -import com.android.systemui.accessibility.floatingmenu.AccessibilityFloatingMenuController; import com.android.systemui.assist.AssistManager; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.classifier.FalsingCollector; @@ -37,7 +35,6 @@ import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.UiBackground; import com.android.systemui.demomode.DemoModeController; -import com.android.systemui.keyguard.DismissCallbackRegistry; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.keyguard.ScreenLifecycle; @@ -48,7 +45,6 @@ import com.android.systemui.plugins.PluginDependencyProvider; import com.android.systemui.recents.ScreenPinningRequest; import com.android.systemui.settings.brightness.BrightnessSlider; import com.android.systemui.shared.plugins.PluginManager; -import com.android.unfold.config.UnfoldTransitionConfig; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.FeatureFlags; import com.android.systemui.statusbar.KeyguardIndicationController; @@ -62,8 +58,6 @@ import com.android.systemui.statusbar.NotificationViewHierarchyManager; import com.android.systemui.statusbar.PulseExpansionHandler; import com.android.systemui.statusbar.SuperStatusBarViewFactory; import com.android.systemui.statusbar.SysuiStatusBarStateController; -import com.android.systemui.statusbar.VibratorHelper; -import com.android.systemui.statusbar.charging.WiredChargingRippleController; import com.android.systemui.statusbar.events.SystemStatusAnimationScheduler; import com.android.systemui.statusbar.notification.DynamicPrivacyController; import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; @@ -81,7 +75,6 @@ import com.android.systemui.statusbar.phone.DozeServiceHost; import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.KeyguardDismissUtil; -import com.android.systemui.statusbar.phone.KeyguardLiftController; import com.android.systemui.statusbar.phone.LightBarController; import com.android.systemui.statusbar.phone.LightsOutNotifController; import com.android.systemui.statusbar.phone.LockscreenWallpaper; @@ -94,7 +87,6 @@ import com.android.systemui.statusbar.phone.StatusBarIconController; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.phone.StatusBarLocationPublisher; import com.android.systemui.statusbar.phone.StatusBarNotificationActivityStarter; -import com.android.systemui.statusbar.phone.StatusBarSignalPolicy; import com.android.systemui.statusbar.phone.StatusBarTouchableRegionManager; import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController; import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallController; @@ -104,12 +96,12 @@ import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.systemui.statusbar.policy.ExtensionController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.statusbar.policy.NetworkController; -import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler; import com.android.systemui.statusbar.policy.UserInfoControllerImpl; import com.android.systemui.statusbar.policy.UserSwitcherController; import com.android.systemui.unfold.UnfoldLightRevealOverlayAnimation; import com.android.systemui.volume.VolumeComponent; import com.android.systemui.wmshell.BubblesManager; +import com.android.unfold.config.UnfoldTransitionConfig; import com.android.wm.shell.bubbles.Bubbles; import com.android.wm.shell.legacysplitscreen.LegacySplitScreen; import com.android.wm.shell.startingsurface.StartingSurface; @@ -140,7 +132,6 @@ public interface StatusBarPhoneModule { LightBarController lightBarController, AutoHideController autoHideController, KeyguardUpdateMonitor keyguardUpdateMonitor, - StatusBarSignalPolicy signalPolicy, PulseExpansionHandler pulseExpansionHandler, NotificationWakeUpCoordinator notificationWakeUpCoordinator, KeyguardBypassController keyguardBypassController, @@ -151,7 +142,6 @@ public interface StatusBarPhoneModule { FalsingManager falsingManager, FalsingCollector falsingCollector, BroadcastDispatcher broadcastDispatcher, - RemoteInputQuickSettingsDisabler remoteInputQuickSettingsDisabler, NotificationGutsManager notificationGutsManager, NotificationLogger notificationLogger, NotificationInterruptStateProvider notificationInterruptStateProvider, @@ -170,19 +160,16 @@ public interface StatusBarPhoneModule { ScreenLifecycle screenLifecycle, WakefulnessLifecycle wakefulnessLifecycle, SysuiStatusBarStateController statusBarStateController, - VibratorHelper vibratorHelper, Optional bubblesManagerOptional, Optional bubblesOptional, VisualStabilityManager visualStabilityManager, DeviceProvisionedController deviceProvisionedController, NavigationBarController navigationBarController, - AccessibilityFloatingMenuController accessibilityFloatingMenuController, Lazy assistManagerLazy, ConfigurationController configurationController, NotificationShadeWindowController notificationShadeWindowController, DozeParameters dozeParameters, ScrimController scrimController, - @Nullable KeyguardLiftController keyguardLiftController, Lazy lockscreenWallpaperLazy, Lazy biometricUnlockControllerLazy, DozeServiceHost dozeServiceHost, @@ -211,11 +198,9 @@ public interface StatusBarPhoneModule { KeyguardIndicationController keyguardIndicationController, DemoModeController demoModeController, Lazy notificationShadeDepthController, - DismissCallbackRegistry dismissCallbackRegistry, StatusBarTouchableRegionManager statusBarTouchableRegionManager, NotificationIconAreaController notificationIconAreaController, BrightnessSlider.Factory brightnessSliderFactory, - WiredChargingRippleController chargingRippleAnimationController, UnfoldTransitionConfig unfoldTransitionConfig, Lazy unfoldLightRevealOverlayAnimation, OngoingCallController ongoingCallController, @@ -225,6 +210,7 @@ public interface StatusBarPhoneModule { LockscreenShadeTransitionController transitionController, FeatureFlags featureFlags, KeyguardUnlockAnimationController keyguardUnlockAnimationController, + WallpaperManager wallpaperManager, UnlockedScreenOffAnimationController unlockedScreenOffAnimationController, Optional startingSurfaceOptional) { return new StatusBar( @@ -233,7 +219,6 @@ public interface StatusBarPhoneModule { lightBarController, autoHideController, keyguardUpdateMonitor, - signalPolicy, pulseExpansionHandler, notificationWakeUpCoordinator, keyguardBypassController, @@ -244,7 +229,6 @@ public interface StatusBarPhoneModule { falsingManager, falsingCollector, broadcastDispatcher, - remoteInputQuickSettingsDisabler, notificationGutsManager, notificationLogger, notificationInterruptStateProvider, @@ -263,19 +247,16 @@ public interface StatusBarPhoneModule { screenLifecycle, wakefulnessLifecycle, statusBarStateController, - vibratorHelper, bubblesManagerOptional, bubblesOptional, visualStabilityManager, deviceProvisionedController, navigationBarController, - accessibilityFloatingMenuController, assistManagerLazy, configurationController, notificationShadeWindowController, dozeParameters, scrimController, - keyguardLiftController, lockscreenWallpaperLazy, biometricUnlockControllerLazy, dozeServiceHost, @@ -301,13 +282,11 @@ public interface StatusBarPhoneModule { userInfoControllerImpl, phoneStatusBarPolicy, keyguardIndicationController, - dismissCallbackRegistry, demoModeController, notificationShadeDepthController, statusBarTouchableRegionManager, notificationIconAreaController, brightnessSliderFactory, - chargingRippleAnimationController, unfoldTransitionConfig, unfoldLightRevealOverlayAnimation, ongoingCallController, @@ -317,6 +296,7 @@ public interface StatusBarPhoneModule { transitionController, featureFlags, keyguardUnlockAnimationController, + wallpaperManager, unlockedScreenOffAnimationController, startingSurfaceOptional); } 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 new file mode 100644 index 0000000000000..52538c7f54965 --- /dev/null +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarCommandQueueCallbacksTest.java @@ -0,0 +1,170 @@ +/* + * 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.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 com.android.wm.shell.legacysplitscreen.LegacySplitScreen; + +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 LegacySplitScreen mLegacySplitScreen; + @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; + + StatusBarCommandQueueCallbacks mSbcqCallbacks; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + + mSbcqCallbacks = new StatusBarCommandQueueCallbacks( + mStatusBar, + mContext, + mContext.getResources(), + mShadeController, + mCommandQueue, + mNotificationPanelViewController, + Optional.of(mLegacySplitScreen), + mRemoteInputQuickSettingsDisabler, + mMetricsLogger, + mKeyguardUpdateMonitor, + mKeyguardStateController, + mHeadsUpManager, + mWakefulnessLifecycle, + mDeviceProvisionedController, + mStatusBarKeyguardViewManager, + mAssistManager, + mDozeServiceHost, + mStatusBarStateController, + mNotificationShadeWindowView, + mNotificationStackScrollLayoutController, + mPowerManager, + mVibratorHelper, + Optional.of(mVibrator), + mLightBarController, + 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).setDozeSuppressed(true); + } + + @Test + public void testSuppressAmbientDisplay_unsuppress() { + mSbcqCallbacks.suppressAmbientDisplay(false); + verify(mDozeServiceHost).setDozeSuppressed(false); + } + + +} 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 index 2a58f7c8e98db..0d0a2caa3ea04 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java @@ -18,7 +18,6 @@ package com.android.systemui.statusbar.phone; import static android.app.NotificationManager.IMPORTANCE_HIGH; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK; -import static android.view.Display.DEFAULT_DISPLAY; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; @@ -40,7 +39,7 @@ import static org.mockito.Mockito.when; import android.app.IWallpaperManager; import android.app.Notification; -import android.app.StatusBarManager; +import android.app.WallpaperManager; import android.app.trust.TrustManager; import android.content.BroadcastReceiver; import android.content.ContentResolver; @@ -78,27 +77,23 @@ 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.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.keyguard.DismissCallbackRegistry; 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.DarkIconDispatcher; 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.BrightnessSlider; import com.android.systemui.shared.plugins.PluginManager; -import com.android.unfold.config.UnfoldTransitionConfig; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.FeatureFlags; import com.android.systemui.statusbar.KeyguardIndicationController; @@ -114,11 +109,8 @@ import com.android.systemui.statusbar.PulseExpansionHandler; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.StatusBarStateControllerImpl; import com.android.systemui.statusbar.SuperStatusBarViewFactory; -import com.android.systemui.statusbar.VibratorHelper; -import com.android.systemui.statusbar.charging.WiredChargingRippleController; import com.android.systemui.statusbar.events.SystemStatusAnimationScheduler; import com.android.systemui.statusbar.notification.DynamicPrivacyController; -import com.android.systemui.statusbar.notification.NotificationEntryListener; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.NotificationFilter; import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; @@ -143,7 +135,6 @@ 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.NetworkController; -import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler; import com.android.systemui.statusbar.policy.UserInfoControllerImpl; import com.android.systemui.statusbar.policy.UserSwitcherController; import com.android.systemui.unfold.UnfoldLightRevealOverlayAnimation; @@ -151,6 +142,7 @@ import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.time.FakeSystemClock; import com.android.systemui.volume.VolumeComponent; import com.android.systemui.wmshell.BubblesManager; +import com.android.unfold.config.UnfoldTransitionConfig; import com.android.wm.shell.bubbles.Bubbles; import com.android.wm.shell.legacysplitscreen.LegacySplitScreen; import com.android.wm.shell.startingsurface.StartingSurface; @@ -181,7 +173,6 @@ public class StatusBarTest extends SysuiTestCase { @Mock private NotificationsController mNotificationsController; @Mock private LightBarController mLightBarController; - @Mock private StatusBarSignalPolicy mStatusBarSignalPolicy; @Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; @Mock private KeyguardStateController mKeyguardStateController; @Mock private KeyguardIndicationController mKeyguardIndicationController; @@ -206,7 +197,6 @@ public class StatusBarTest extends SysuiTestCase { @Mock private BatteryController mBatteryController; @Mock private DeviceProvisionedController mDeviceProvisionedController; @Mock private StatusBarNotificationPresenter mNotificationPresenter; - @Mock private NotificationEntryListener mEntryListener; @Mock private NotificationFilter mNotificationFilter; @Mock private AmbientDisplayConfiguration mAmbientDisplayConfiguration; @Mock private NotificationLogger.ExpansionStateLogger mExpansionStateLogger; @@ -217,7 +207,6 @@ public class StatusBarTest extends SysuiTestCase { @Mock private NotificationGutsManager mNotificationGutsManager; @Mock private NotificationMediaManager mNotificationMediaManager; @Mock private NavigationBarController mNavigationBarController; - @Mock private AccessibilityFloatingMenuController mAccessibilityFloatingMenuController; @Mock private BypassHeadsUpNotifier mBypassHeadsUpNotifier; @Mock private SysuiColorExtractor mColorExtractor; @Mock private ColorExtractor.GradientColors mGradientColors; @@ -229,7 +218,6 @@ public class StatusBarTest extends SysuiTestCase { @Mock private NotificationViewHierarchyManager mNotificationViewHierarchyManager; @Mock private UserSwitcherController mUserSwitcherController; @Mock private NetworkController mNetworkController; - @Mock private VibratorHelper mVibratorHelper; @Mock private BubblesManager mBubblesManager; @Mock private Bubbles mBubbles; @Mock private NotificationShadeWindowController mNotificationShadeWindowController; @@ -240,7 +228,6 @@ public class StatusBarTest extends SysuiTestCase { @Mock private LockscreenWallpaper mLockscreenWallpaper; @Mock private DozeServiceHost mDozeServiceHost; @Mock private ViewMediatorCallback mKeyguardVieMediatorCallback; - @Mock private KeyguardLiftController mKeyguardLiftController; @Mock private VolumeComponent mVolumeComponent; @Mock private CommandQueue mCommandQueue; @Mock private Provider mStatusBarComponentBuilderProvider; @@ -251,12 +238,10 @@ public class StatusBarTest extends SysuiTestCase { @Mock private SuperStatusBarViewFactory mSuperStatusBarViewFactory; @Mock private LightsOutNotifController mLightsOutNotifController; @Mock private ViewMediatorCallback mViewMediatorCallback; - @Mock private DismissCallbackRegistry mDismissCallbackRegistry; @Mock private StatusBarTouchableRegionManager mStatusBarTouchableRegionManager; @Mock private ScreenPinningRequest mScreenPinningRequest; @Mock private StatusBarNotificationActivityStarter.Builder mStatusBarNotificationActivityStarterBuilder; - @Mock private DarkIconDispatcher mDarkIconDispatcher; @Mock private PluginDependencyProvider mPluginDependencyProvider; @Mock private KeyguardDismissUtil mKeyguardDismissUtil; @Mock private ExtensionController mExtensionController; @@ -265,7 +250,6 @@ public class StatusBarTest extends SysuiTestCase { @Mock private DemoModeController mDemoModeController; @Mock private Lazy mNotificationShadeDepthControllerLazy; @Mock private BrightnessSlider.Factory mBrightnessSliderFactory; - @Mock private WiredChargingRippleController mWiredChargingRippleController; @Mock private UnfoldTransitionConfig mUnfoldTransitionConfig; @Mock private Lazy mUnfoldLightRevealOverlayAnimationLazy; @Mock private OngoingCallController mOngoingCallController; @@ -274,7 +258,8 @@ public class StatusBarTest extends SysuiTestCase { @Mock private StatusBarIconController mIconController; @Mock private LockscreenShadeTransitionController mLockscreenTransitionController; @Mock private FeatureFlags mFeatureFlags; - @Mock private IWallpaperManager mWallpaperManager; + @Mock private WallpaperManager mWallpaperManager; + @Mock private IWallpaperManager mIWallpaperManager; @Mock private KeyguardUnlockAnimationController mKeyguardUnlockAnimationController; @Mock private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController; @Mock private StartingSurface mStartingSurface; @@ -335,7 +320,7 @@ public class StatusBarTest extends SysuiTestCase { }).when(mStatusBarKeyguardViewManager).addAfterKeyguardGoneRunnable(any()); WakefulnessLifecycle wakefulnessLifecycle = - new WakefulnessLifecycle(mContext, mWallpaperManager); + new WakefulnessLifecycle(mContext, mIWallpaperManager); wakefulnessLifecycle.dispatchStartedWakingUp(PowerManager.WAKE_REASON_UNKNOWN); wakefulnessLifecycle.dispatchFinishedWakingUp(); @@ -362,7 +347,6 @@ public class StatusBarTest extends SysuiTestCase { mLightBarController, mAutoHideController, mKeyguardUpdateMonitor, - mStatusBarSignalPolicy, mPulseExpansionHandler, mNotificationWakeUpCoordinator, mKeyguardBypassController, @@ -373,11 +357,6 @@ public class StatusBarTest extends SysuiTestCase { new FalsingManagerFake(), new FalsingCollectorFake(), mBroadcastDispatcher, - new RemoteInputQuickSettingsDisabler( - mContext, - configurationController, - mCommandQueue - ), mNotificationGutsManager, notificationLogger, mNotificationInterruptStateProvider, @@ -396,19 +375,16 @@ public class StatusBarTest extends SysuiTestCase { new ScreenLifecycle(), wakefulnessLifecycle, mStatusBarStateController, - mVibratorHelper, Optional.of(mBubblesManager), Optional.of(mBubbles), mVisualStabilityManager, mDeviceProvisionedController, mNavigationBarController, - mAccessibilityFloatingMenuController, () -> mAssistManager, configurationController, mNotificationShadeWindowController, mDozeParameters, mScrimController, - mKeyguardLiftController, mLockscreenWallpaperLazy, mBiometricUnlockControllerLazy, mDozeServiceHost, @@ -433,13 +409,11 @@ public class StatusBarTest extends SysuiTestCase { mUserInfoControllerImpl, mPhoneStatusBarPolicy, mKeyguardIndicationController, - mDismissCallbackRegistry, mDemoModeController, mNotificationShadeDepthControllerLazy, mStatusBarTouchableRegionManager, mNotificationIconAreaController, mBrightnessSliderFactory, - mWiredChargingRippleController, mUnfoldTransitionConfig, mUnfoldLightRevealOverlayAnimationLazy, mOngoingCallController, @@ -449,6 +423,7 @@ public class StatusBarTest extends SysuiTestCase { mLockscreenTransitionController, mFeatureFlags, mKeyguardUnlockAnimationController, + mWallpaperManager, mUnlockedScreenOffAnimationController, Optional.of(mStartingSurface)); when(mKeyguardViewMediator.registerStatusBar(any(StatusBar.class), any(ViewGroup.class), @@ -753,31 +728,6 @@ public class StatusBarTest extends SysuiTestCase { TestableLooper.get(this).processAllMessages(); } - @Test - public void testDisableExpandStatusBar() { - mStatusBar.setBarStateForTest(StatusBarState.SHADE); - mStatusBar.setUserSetupForTest(true); - when(mDeviceProvisionedController.isDeviceProvisioned()).thenReturn(true); - - when(mCommandQueue.panelsEnabled()).thenReturn(false); - mStatusBar.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_NONE, - StatusBarManager.DISABLE2_NOTIFICATION_SHADE, false); - verify(mNotificationPanelViewController).setQsExpansionEnabledPolicy(false); - mStatusBar.animateExpandNotificationsPanel(); - verify(mNotificationPanelViewController, never()).expand(anyBoolean()); - mStatusBar.animateExpandSettingsPanel(null); - verify(mNotificationPanelViewController, never()).expand(anyBoolean()); - - when(mCommandQueue.panelsEnabled()).thenReturn(true); - mStatusBar.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_NONE, - StatusBarManager.DISABLE2_NONE, false); - verify(mNotificationPanelViewController).setQsExpansionEnabledPolicy(true); - mStatusBar.animateExpandNotificationsPanel(); - verify(mNotificationPanelViewController).expandWithoutQs(); - mStatusBar.animateExpandSettingsPanel(null); - verify(mNotificationPanelViewController).expandWithQs(); - } - @Test public void testDump_DoesNotCrash() { mStatusBar.dump(null, new PrintWriter(new ByteArrayOutputStream()), null); @@ -904,18 +854,6 @@ public class StatusBarTest extends SysuiTestCase { any(UserHandle.class)); } - @Test - public void testSuppressAmbientDisplay_suppress() { - mStatusBar.suppressAmbientDisplay(true); - verify(mDozeServiceHost).setDozeSuppressed(true); - } - - @Test - public void testSuppressAmbientDisplay_unsuppress() { - mStatusBar.suppressAmbientDisplay(false); - verify(mDozeServiceHost).setDozeSuppressed(false); - } - @Test public void testUpdateResources_updatesBouncer() { mStatusBar.updateResources();