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

Commit be3f39d1 authored by Dave Mankoff's avatar Dave Mankoff
Browse files

Remove custom Handler from StatusBar.

Replaces the custom "H" subclass from StatusBar and replaces
it with MessageRouter.

Remove a few spurious messages that would be passed to it, but never
processed. These are MSG_PRELOAD_RECENT_APPS,
MSG_CANCEL_PRELOAD_RECENT_APPS, and MSG_HIDE_RECENT_APPS.

Also, replace various mHandler#post calls with mMainExecutor#execute.
Virtually all usages of Handler inside of StatusBar are now
elimanted.

Bug: 190746471
Test: atest SystemUITests
Change-Id: I6a3b2b226108ef3abed96a1007978491ec50fcb0
parent da9d2fcc
Loading
Loading
Loading
Loading
+0 −4
Original line number Original line Diff line number Diff line
@@ -118,10 +118,6 @@ public class ShadeControllerImpl implements ShadeController {
                    + " flags=" + flags);
                    + " flags=" + flags);
        }
        }


        if ((flags & CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL) == 0) {
            getStatusBar().postHideRecentApps();
        }

        // TODO(b/62444020): remove when this bug is fixed
        // TODO(b/62444020): remove when this bug is fixed
        Log.v(TAG, "NotificationShadeWindow: " + getNotificationShadeWindowView()
        Log.v(TAG, "NotificationShadeWindow: " + getNotificationShadeWindowView()
                + " canPanelBeCollapsed(): "
                + " canPanelBeCollapsed(): "
+69 −87
Original line number Original line Diff line number Diff line
@@ -73,7 +73,6 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler;
import android.os.Looper;
import android.os.Looper;
import android.os.Message;
import android.os.PowerManager;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager;
@@ -143,6 +142,7 @@ import com.android.systemui.camera.CameraIntents;
import com.android.systemui.charging.WirelessChargingAnimation;
import com.android.systemui.charging.WirelessChargingAnimation;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dagger.qualifiers.UiBackground;
import com.android.systemui.dagger.qualifiers.UiBackground;
import com.android.systemui.demomode.DemoModeController;
import com.android.systemui.demomode.DemoModeController;
import com.android.systemui.emergency.EmergencyGesture;
import com.android.systemui.emergency.EmergencyGesture;
@@ -227,6 +227,8 @@ import com.android.systemui.statusbar.policy.UserInfoControllerImpl;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.unfold.UnfoldLightRevealOverlayAnimation;
import com.android.systemui.unfold.UnfoldLightRevealOverlayAnimation;
import com.android.systemui.util.concurrency.DelayableExecutor;
import com.android.systemui.util.concurrency.MessageRouter;
import com.android.systemui.volume.VolumeComponent;
import com.android.systemui.volume.VolumeComponent;
import com.android.systemui.wmshell.BubblesManager;
import com.android.systemui.wmshell.BubblesManager;
import com.android.unfold.config.UnfoldTransitionConfig;
import com.android.unfold.config.UnfoldTransitionConfig;
@@ -255,10 +257,6 @@ public class StatusBar extends SystemUI implements
        LifecycleOwner {
        LifecycleOwner {
    public static final boolean MULTIUSER_DEBUG = false;
    public static final boolean MULTIUSER_DEBUG = false;


    protected static final int MSG_HIDE_RECENT_APPS = 1020;
    protected static final int MSG_PRELOAD_RECENT_APPS = 1022;
    protected static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 1023;
    protected static final int MSG_TOGGLE_KEYBOARD_SHORTCUTS_MENU = 1026;
    protected static final int MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU = 1027;
    protected static final int MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU = 1027;


    // Should match the values in PhoneWindowManager
    // Should match the values in PhoneWindowManager
@@ -286,8 +284,6 @@ public class StatusBar extends SystemUI implements


    public static final String ACTION_FAKE_ARTWORK = "fake_artwork";
    public static final String ACTION_FAKE_ARTWORK = "fake_artwork";


    private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000;
    private static final int MSG_CLOSE_PANELS = 1001;
    private static final int MSG_OPEN_SETTINGS_PANEL = 1002;
    private static final int MSG_OPEN_SETTINGS_PANEL = 1002;
    private static final int MSG_LAUNCH_TRANSITION_TIMEOUT = 1003;
    private static final int MSG_LAUNCH_TRANSITION_TIMEOUT = 1003;
    // 1020-1040 reserved for BaseStatusBar
    // 1020-1040 reserved for BaseStatusBar
@@ -367,13 +363,14 @@ public class StatusBar extends SystemUI implements
        mWereIconsJustHidden = justHidden;
        mWereIconsJustHidden = justHidden;
    }
    }


    void resetHandlerMsg(int msg) {
    void resendMessage(int msg) {
        mHandler.removeMessages(msg);
        mMessageRouter.cancelMessages(msg);
        mHandler.sendEmptyMessage(msg);
        mMessageRouter.sendMessage(msg);
    }
    }


    Handler getHandler() {
    void resendMessage(Object msg) {
        return mHandler;
        mMessageRouter.cancelMessages(msg.getClass());
        mMessageRouter.sendMessage(msg);
    }
    }


    int getDisabled1() {
    int getDisabled1() {
@@ -541,6 +538,7 @@ public class StatusBar extends SystemUI implements
    private final UnfoldTransitionConfig mUnfoldTransitionConfig;
    private final UnfoldTransitionConfig mUnfoldTransitionConfig;
    private final Lazy<UnfoldLightRevealOverlayAnimation> mUnfoldLightRevealOverlayAnimation;
    private final Lazy<UnfoldLightRevealOverlayAnimation> mUnfoldLightRevealOverlayAnimation;
    private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController;
    private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController;
    private final MessageRouter mMessageRouter;
    private final WallpaperManager mWallpaperManager;
    private final WallpaperManager mWallpaperManager;
    private final UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
    private final UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
    private final TunerService mTunerService;
    private final TunerService mTunerService;
@@ -633,7 +631,8 @@ public class StatusBar extends SystemUI implements
        }
        }
    }
    }


    protected final H mHandler = createHandler();
    private Handler mMainHandler;
    private final DelayableExecutor mMainExecutor;


    private int mInteractingWindows;
    private int mInteractingWindows;
    private @TransitionMode int mStatusBarMode;
    private @TransitionMode int mStatusBarMode;
@@ -764,8 +763,6 @@ public class StatusBar extends SystemUI implements
                }
                }
            };
            };


    private final Handler mMainThreadHandler = new Handler(Looper.getMainLooper());

    private HeadsUpAppearanceController mHeadsUpAppearanceController;
    private HeadsUpAppearanceController mHeadsUpAppearanceController;
    private ActivityLaunchAnimator mActivityLaunchAnimator;
    private ActivityLaunchAnimator mActivityLaunchAnimator;
    private NotificationLaunchAnimatorControllerProvider mNotificationAnimationProvider;
    private NotificationLaunchAnimatorControllerProvider mNotificationAnimationProvider;
@@ -912,7 +909,7 @@ public class StatusBar extends SystemUI implements
            new BatteryController.BatteryStateChangeCallback() {
            new BatteryController.BatteryStateChangeCallback() {
                @Override
                @Override
                public void onPowerSaveChanged(boolean isPowerSave) {
                public void onPowerSaveChanged(boolean isPowerSave) {
                    mHandler.post(mCheckBarModes);
                    mMainExecutor.execute(mCheckBarModes);
                    if (mDozeServiceHost != null) {
                    if (mDozeServiceHost != null) {
                        mDozeServiceHost.firePowerSaveChanged(isPowerSave);
                        mDozeServiceHost.firePowerSaveChanged(isPowerSave);
                    }
                    }
@@ -933,7 +930,7 @@ public class StatusBar extends SystemUI implements
            //   2. To ensure that ViewMediatorCallback#keyguardDonePending is called before
            //   2. To ensure that ViewMediatorCallback#keyguardDonePending is called before
            //      ViewMediatorCallback#readyForKeyguardDone. The wrong order could occur when
            //      ViewMediatorCallback#readyForKeyguardDone. The wrong order could occur when
            //      doing dismissKeyguardThenExecute { hideKeyguardWithAnimation(runner) }.
            //      doing dismissKeyguardThenExecute { hideKeyguardWithAnimation(runner) }.
            mMainThreadHandler.post(() -> mKeyguardViewMediator.hideWithAnimation(runner));
            mMainExecutor.execute(() -> mKeyguardViewMediator.hideWithAnimation(runner));
        }
        }


        @Override
        @Override
@@ -1046,6 +1043,9 @@ public class StatusBar extends SystemUI implements
            LockscreenShadeTransitionController lockscreenShadeTransitionController,
            LockscreenShadeTransitionController lockscreenShadeTransitionController,
            FeatureFlags featureFlags,
            FeatureFlags featureFlags,
            KeyguardUnlockAnimationController keyguardUnlockAnimationController,
            KeyguardUnlockAnimationController keyguardUnlockAnimationController,
            @Main Handler mainHandler,
            @Main DelayableExecutor delayableExecutor,
            @Main MessageRouter messageRouter,
            WallpaperManager wallpaperManager,
            WallpaperManager wallpaperManager,
            UnlockedScreenOffAnimationController unlockedScreenOffAnimationController,
            UnlockedScreenOffAnimationController unlockedScreenOffAnimationController,
            Optional<StartingSurface> startingSurfaceOptional,
            Optional<StartingSurface> startingSurfaceOptional,
@@ -1133,6 +1133,9 @@ public class StatusBar extends SystemUI implements
        mStatusBarIconController = statusBarIconController;
        mStatusBarIconController = statusBarIconController;
        mFeatureFlags = featureFlags;
        mFeatureFlags = featureFlags;
        mKeyguardUnlockAnimationController = keyguardUnlockAnimationController;
        mKeyguardUnlockAnimationController = keyguardUnlockAnimationController;
        mMainHandler = mainHandler;
        mMainExecutor = delayableExecutor;
        mMessageRouter = messageRouter;
        mWallpaperManager = wallpaperManager;
        mWallpaperManager = wallpaperManager;
        mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
        mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
        mTunerService = tunerService;
        mTunerService = tunerService;
@@ -1150,7 +1153,18 @@ public class StatusBar extends SystemUI implements
                });
                });


        mActivityIntentHelper = new ActivityIntentHelper(mContext);
        mActivityIntentHelper = new ActivityIntentHelper(mContext);

        // TODO(b/190746471): Find a better home for this.
        DateTimeView.setReceiverHandler(timeTickHandler);
        DateTimeView.setReceiverHandler(timeTickHandler);

        mMessageRouter.subscribeTo(KeyboardShortcutsData.class,
                data -> toggleKeyboardShortcuts(data.mDeviceId));
        mMessageRouter.subscribeTo(MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU,
                id -> dismissKeyboardShortcuts());
        mMessageRouter.subscribeTo(AnimateExpandSettingsPanelData.class,
                data -> mCommandQueueCallbacks.animateExpandSettingsPanel(data.mSubpanel));
        mMessageRouter.subscribeTo(MSG_LAUNCH_TRANSITION_TIMEOUT,
                id -> onLaunchTransitionTimeout());
    }
    }


    @Override
    @Override
@@ -1305,7 +1319,7 @@ public class StatusBar extends SystemUI implements


                    @Override
                    @Override
                    public void onPluginConnected(OverlayPlugin plugin, Context pluginContext) {
                    public void onPluginConnected(OverlayPlugin plugin, Context pluginContext) {
                        mMainThreadHandler.post(
                        mMainExecutor.execute(
                                () -> plugin.setup(getNotificationShadeWindowView(),
                                () -> plugin.setup(getNotificationShadeWindowView(),
                                        getNavigationBarView(),
                                        getNavigationBarView(),
                                        new Callback(plugin), mDozeParameters));
                                        new Callback(plugin), mDozeParameters));
@@ -1313,7 +1327,7 @@ public class StatusBar extends SystemUI implements


                    @Override
                    @Override
                    public void onPluginDisconnected(OverlayPlugin plugin) {
                    public void onPluginDisconnected(OverlayPlugin plugin) {
                        mMainThreadHandler.post(() -> {
                        mMainExecutor.execute(() -> {
                            mOverlays.remove(plugin);
                            mOverlays.remove(plugin);
                            mNotificationShadeWindowController
                            mNotificationShadeWindowController
                                    .setForcePluginOpen(mOverlays.size() != 0, this);
                                    .setForcePluginOpen(mOverlays.size() != 0, this);
@@ -1334,7 +1348,7 @@ public class StatusBar extends SystemUI implements
                            } else {
                            } else {
                                mOverlays.remove(mPlugin);
                                mOverlays.remove(mPlugin);
                            }
                            }
                            mMainThreadHandler.post(() -> {
                            mMainExecutor.execute(() -> {
                                mNotificationShadeWindowController
                                mNotificationShadeWindowController
                                        .setStateListener(b -> mOverlays.forEach(
                                        .setStateListener(b -> mOverlays.forEach(
                                                o -> o.setCollapseDesired(b)));
                                                o -> o.setCollapseDesired(b)));
@@ -1396,7 +1410,7 @@ public class StatusBar extends SystemUI implements
                            mConfigurationController,
                            mConfigurationController,
                            mTunerService,
                            mTunerService,
                            mBroadcastDispatcher,
                            mBroadcastDispatcher,
                            mMainThreadHandler,
                            mMainHandler,
                            mContext.getContentResolver()
                            mContext.getContentResolver()
                    );
                    );
                    mBatteryMeterViewController.init();
                    mBatteryMeterViewController.init();
@@ -1968,10 +1982,6 @@ public class StatusBar extends SystemUI implements
        return (mDisabled1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0;
        return (mDisabled1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0;
    }
    }


    protected H createHandler() {
        return new StatusBar.H();
    }

    @Override
    @Override
    public void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade,
    public void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade,
            int flags) {
            int flags) {
@@ -2106,7 +2116,7 @@ public class StatusBar extends SystemUI implements
                // We're delaying the showing, since most of the time the fullscreen app will
                // We're delaying the showing, since most of the time the fullscreen app will
                // hide the icons again and we don't want them to fade in and out immediately again.
                // hide the icons again and we don't want them to fade in and out immediately again.
                mWereIconsJustHidden = true;
                mWereIconsJustHidden = true;
                mHandler.postDelayed(() -> {
                mMainExecutor.executeDelayed(() -> {
                    mWereIconsJustHidden = false;
                    mWereIconsJustHidden = false;
                    mCommandQueue.recomputeDisableFlags(mDisplayId, true);
                    mCommandQueue.recomputeDisableFlags(mDisplayId, true);
                }, 500);
                }, 500);
@@ -2179,38 +2189,20 @@ public class StatusBar extends SystemUI implements
        mState = state;
        mState = state;
    }
    }


    /**
    static class KeyboardShortcutsData {
     * All changes to the status bar and notifications funnel through here and are batched.
        final int mDeviceId;
     */
    protected class H extends Handler {
        H() {
            super(Looper.myLooper());
        }


        @Override
        KeyboardShortcutsData(int deviceId) {
        public void handleMessage(Message m) {
            mDeviceId = deviceId;
            switch (m.what) {
                case MSG_TOGGLE_KEYBOARD_SHORTCUTS_MENU:
                    toggleKeyboardShortcuts(m.arg1);
                    break;
                case MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU:
                    dismissKeyboardShortcuts();
                    break;
                // End old BaseStatusBar.H handling.
                case MSG_OPEN_NOTIFICATION_PANEL:
                    mCommandQueueCallbacks.animateExpandNotificationsPanel();
                    break;
                case MSG_OPEN_SETTINGS_PANEL:
                    mCommandQueueCallbacks.animateExpandSettingsPanel((String) m.obj);
                    break;
                case MSG_CLOSE_PANELS:
                    mShadeController.animateCollapsePanels();
                    break;
                case MSG_LAUNCH_TRANSITION_TIMEOUT:
                    onLaunchTransitionTimeout();
                    break;
        }
        }
    }
    }

    static class AnimateExpandSettingsPanelData {
        final String mSubpanel;

        AnimateExpandSettingsPanelData(String subpanel) {
            mSubpanel = subpanel;
        }
    }
    }


    public void maybeEscalateHeadsUp() {
    public void maybeEscalateHeadsUp() {
@@ -2251,27 +2243,17 @@ public class StatusBar extends SystemUI implements
    }
    }


    public void postAnimateCollapsePanels() {
    public void postAnimateCollapsePanels() {
        mHandler.post(mShadeController::animateCollapsePanels);
        mMainExecutor.execute(mShadeController::animateCollapsePanels);
    }
    }


    public void postAnimateForceCollapsePanels() {
    public void postAnimateForceCollapsePanels() {
        mHandler.post(() -> mShadeController.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE,
        mMainExecutor.execute(
                () -> mShadeController.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE,
                true /* force */));
                true /* force */));
    }
    }


    public void postAnimateOpenPanels() {
    public void postAnimateOpenPanels() {
        mHandler.sendEmptyMessage(MSG_OPEN_SETTINGS_PANEL);
        mMessageRouter.sendMessage(MSG_OPEN_SETTINGS_PANEL);
    }

    /**
     * Called by {@link ShadeController} when it calls
     * {@link ShadeController#animateCollapsePanels(int, boolean, boolean, float)}.
     */
    void postHideRecentApps() {
        if (!mHandler.hasMessages(MSG_HIDE_RECENT_APPS)) {
            mHandler.removeMessages(MSG_HIDE_RECENT_APPS);
            mHandler.sendEmptyMessage(MSG_HIDE_RECENT_APPS);
        }
    }
    }


    public boolean isExpandedVisible() {
    public boolean isExpandedVisible() {
@@ -2840,7 +2822,7 @@ public class StatusBar extends SystemUI implements
                            && mStatusBarKeyguardViewManager.isOccluded()) {
                            && mStatusBarKeyguardViewManager.isOccluded()) {
                        mStatusBarKeyguardViewManager.addAfterKeyguardGoneRunnable(runnable);
                        mStatusBarKeyguardViewManager.addAfterKeyguardGoneRunnable(runnable);
                    } else {
                    } else {
                        mHandler.post(runnable);
                        mMainExecutor.execute(runnable);
                    }
                    }
                }
                }
                if (dismissShade) {
                if (dismissShade) {
@@ -2852,7 +2834,7 @@ public class StatusBar extends SystemUI implements


                        // Do it after DismissAction has been processed to conserve the needed
                        // Do it after DismissAction has been processed to conserve the needed
                        // ordering.
                        // ordering.
                        mHandler.post(mShadeController::runPostCollapseRunnables);
                        mMainExecutor.execute(mShadeController::runPostCollapseRunnables);
                    }
                    }
                } else if (StatusBar.this.isInLaunchTransition()
                } else if (StatusBar.this.isInLaunchTransition()
                        && mNotificationPanelViewController.isLaunchTransitionFinished()) {
                        && mNotificationPanelViewController.isLaunchTransitionFinished()) {
@@ -2861,7 +2843,7 @@ public class StatusBar extends SystemUI implements
                    // finished,
                    // finished,
                    // so nobody will call readyForKeyguardDone anymore. Post it such that
                    // so nobody will call readyForKeyguardDone anymore. Post it such that
                    // keyguardDonePending gets called first.
                    // keyguardDonePending gets called first.
                    mHandler.post(mStatusBarKeyguardViewManager::readyForKeyguardDone);
                    mMainExecutor.execute(mStatusBarKeyguardViewManager::readyForKeyguardDone);
                }
                }
                return deferred;
                return deferred;
            }
            }
@@ -2900,8 +2882,8 @@ public class StatusBar extends SystemUI implements
                    mNotificationShadeWindowController.setNotTouchable(false);
                    mNotificationShadeWindowController.setNotTouchable(false);
                }
                }
                if (mBubblesOptional.isPresent() && mBubblesOptional.get().isStackExpanded()) {
                if (mBubblesOptional.isPresent() && mBubblesOptional.get().isStackExpanded()) {
                    // Post to main thread handler, since updating the UI.
                    // Post to main thread, since updating the UI.
                    mMainThreadHandler.post(() -> mBubblesOptional.get().collapseStack());
                    mMainExecutor.execute(() -> mBubblesOptional.get().collapseStack());
                }
                }
                finishBarAnimations();
                finishBarAnimations();
                resetUserExpandedStates();
                resetUserExpandedStates();
@@ -3111,10 +3093,10 @@ public class StatusBar extends SystemUI implements


    @Override
    @Override
    public void postQSRunnableDismissingKeyguard(final Runnable runnable) {
    public void postQSRunnableDismissingKeyguard(final Runnable runnable) {
        mHandler.post(() -> {
        mMainExecutor.execute(() -> {
            mStatusBarStateController.setLeaveOpenOnKeyguardHide(true);
            mStatusBarStateController.setLeaveOpenOnKeyguardHide(true);
            executeRunnableDismissingKeyguard(() -> mHandler.post(runnable), null, false, false,
            executeRunnableDismissingKeyguard(
                    false);
                    () -> mMainExecutor.execute(runnable), null, false, false, false);
        });
        });
    }
    }


@@ -3126,7 +3108,7 @@ public class StatusBar extends SystemUI implements
    @Override
    @Override
    public void postStartActivityDismissingKeyguard(final PendingIntent intent,
    public void postStartActivityDismissingKeyguard(final PendingIntent intent,
            @Nullable ActivityLaunchAnimator.Controller animationController) {
            @Nullable ActivityLaunchAnimator.Controller animationController) {
        mHandler.post(() -> startPendingIntentDismissingKeyguard(intent,
        mMainExecutor.execute(() -> startPendingIntentDismissingKeyguard(intent,
                null /* intentSentUiThreadCallback */, animationController));
                null /* intentSentUiThreadCallback */, animationController));
    }
    }


@@ -3138,7 +3120,7 @@ public class StatusBar extends SystemUI implements
    @Override
    @Override
    public void postStartActivityDismissingKeyguard(Intent intent, int delay,
    public void postStartActivityDismissingKeyguard(Intent intent, int delay,
            @Nullable ActivityLaunchAnimator.Controller animationController) {
            @Nullable ActivityLaunchAnimator.Controller animationController) {
        mHandler.postDelayed(
        mMainExecutor.executeDelayed(
                () ->
                () ->
                        startActivityDismissingKeyguard(intent, true /* onlyProvisioned */,
                        startActivityDismissingKeyguard(intent, true /* onlyProvisioned */,
                                true /* dismissShade */,
                                true /* dismissShade */,
@@ -3208,7 +3190,7 @@ public class StatusBar extends SystemUI implements
            mNotificationPanelViewController.cancelAnimation();
            mNotificationPanelViewController.cancelAnimation();
            onLaunchTransitionFadingEnded();
            onLaunchTransitionFadingEnded();
        }
        }
        mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT);
        mMessageRouter.cancelMessages(MSG_LAUNCH_TRANSITION_TIMEOUT);
        if (mUserSwitcherController != null && mUserSwitcherController.useFullscreenUserSwitcher()) {
        if (mUserSwitcherController != null && mUserSwitcherController.useFullscreenUserSwitcher()) {
            mStatusBarStateController.setState(StatusBarState.FULLSCREEN_USER_SWITCHER);
            mStatusBarStateController.setState(StatusBarState.FULLSCREEN_USER_SWITCHER);
        } else if (!mPulseExpansionHandler.isWakingToShadeLocked()) {
        } else if (!mPulseExpansionHandler.isWakingToShadeLocked()) {
@@ -3249,7 +3231,7 @@ public class StatusBar extends SystemUI implements
     */
     */
    public void fadeKeyguardAfterLaunchTransition(final Runnable beforeFading,
    public void fadeKeyguardAfterLaunchTransition(final Runnable beforeFading,
            Runnable endRunnable) {
            Runnable endRunnable) {
        mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT);
        mMessageRouter.cancelMessages(MSG_LAUNCH_TRANSITION_TIMEOUT);
        mLaunchTransitionEndRunnable = endRunnable;
        mLaunchTransitionEndRunnable = endRunnable;
        Runnable hideRunnable = () -> {
        Runnable hideRunnable = () -> {
            mKeyguardStateController.setLaunchTransitionFadingAway(true);
            mKeyguardStateController.setLaunchTransitionFadingAway(true);
@@ -3298,8 +3280,8 @@ public class StatusBar extends SystemUI implements
     * because the launched app crashed or something else went wrong.
     * because the launched app crashed or something else went wrong.
     */
     */
    public void startLaunchTransitionTimeout() {
    public void startLaunchTransitionTimeout() {
        mHandler.sendEmptyMessageDelayed(MSG_LAUNCH_TRANSITION_TIMEOUT,
        mMessageRouter.sendMessageDelayed(
                LAUNCH_TRANSITION_TIMEOUT_MS);
                MSG_LAUNCH_TRANSITION_TIMEOUT, LAUNCH_TRANSITION_TIMEOUT_MS);
    }
    }


    private void onLaunchTransitionTimeout() {
    private void onLaunchTransitionTimeout() {
@@ -3354,7 +3336,7 @@ public class StatusBar extends SystemUI implements
        if (mQSPanelController != null) {
        if (mQSPanelController != null) {
            mQSPanelController.refreshAllTiles();
            mQSPanelController.refreshAllTiles();
        }
        }
        mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT);
        mMessageRouter.cancelMessages(MSG_LAUNCH_TRANSITION_TIMEOUT);
        releaseGestureWakeLock();
        releaseGestureWakeLock();
        mNotificationPanelViewController.onAffordanceLaunchEnded();
        mNotificationPanelViewController.onAffordanceLaunchEnded();
        mNotificationPanelViewController.cancelAnimation();
        mNotificationPanelViewController.cancelAnimation();
@@ -3724,7 +3706,7 @@ public class StatusBar extends SystemUI implements


                // This gets executed before we will show Keyguard, so post it in order that the state
                // This gets executed before we will show Keyguard, so post it in order that the state
                // is correct.
                // is correct.
                mHandler.post(() -> mCommandQueueCallbacks.onCameraLaunchGestureDetected(
                mMainExecutor.execute(() -> mCommandQueueCallbacks.onCameraLaunchGestureDetected(
                        mLastCameraLaunchSource));
                        mLastCameraLaunchSource));
            }
            }


@@ -3733,7 +3715,7 @@ public class StatusBar extends SystemUI implements


                // This gets executed before we will show Keyguard, so post it in order that the
                // This gets executed before we will show Keyguard, so post it in order that the
                // state is correct.
                // state is correct.
                mHandler.post(
                mMainExecutor.execute(
                        () -> mCommandQueueCallbacks.onEmergencyActionLaunchGestureDetected());
                        () -> mCommandQueueCallbacks.onEmergencyActionLaunchGestureDetected());
            }
            }
            updateIsKeyguard();
            updateIsKeyguard();
@@ -4202,7 +4184,7 @@ public class StatusBar extends SystemUI implements
    }
    }


    private void postOnUiThread(Runnable runnable) {
    private void postOnUiThread(Runnable runnable) {
        mMainThreadHandler.post(runnable);
        mMainExecutor.execute(runnable);
    }
    }


    /**
    /**
+2 −21
Original line number Original line Diff line number Diff line
@@ -255,19 +255,9 @@ public class StatusBarCommandQueueCallbacks implements CommandQueue.Callbacks {
        }
        }
    }
    }


    @Override
    public void preloadRecentApps() {
        mStatusBar.resetHandlerMsg(StatusBar.MSG_PRELOAD_RECENT_APPS);
    }

    @Override
    public void cancelPreloadRecentApps() {
        mStatusBar.resetHandlerMsg(StatusBar.MSG_CANCEL_PRELOAD_RECENT_APPS);
    }

    @Override
    @Override
    public void dismissKeyboardShortcutsMenu() {
    public void dismissKeyboardShortcutsMenu() {
        mStatusBar.resetHandlerMsg(StatusBar.MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU);
        mStatusBar.resendMessage(StatusBar.MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU);
    }
    }
    /**
    /**
     * State is one or more of the DISABLE constants from StatusBarManager.
     * State is one or more of the DISABLE constants from StatusBarManager.
@@ -330,13 +320,6 @@ public class StatusBarCommandQueueCallbacks implements CommandQueue.Callbacks {
            }
            }
        }
        }


        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 ((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) {
            if (mStatusBar.areNotificationAlertsDisabled()) {
            if (mStatusBar.areNotificationAlertsDisabled()) {
                mHeadsUpManager.releaseAllImmediately();
                mHeadsUpManager.releaseAllImmediately();
@@ -544,9 +527,7 @@ public class StatusBarCommandQueueCallbacks implements CommandQueue.Callbacks {


    @Override
    @Override
    public void toggleKeyboardShortcutsMenu(int deviceId) {
    public void toggleKeyboardShortcutsMenu(int deviceId) {
        int msg = StatusBar.MSG_TOGGLE_KEYBOARD_SHORTCUTS_MENU;
        mStatusBar.resendMessage(new StatusBar.KeyboardShortcutsData(deviceId));
        mStatusBar.getHandler().removeMessages(msg);
        mStatusBar.getHandler().obtainMessage(msg, deviceId, 0).sendToTarget();
    }
    }


    @Override
    @Override
+9 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dagger.qualifiers.UiBackground;
import com.android.systemui.dagger.qualifiers.UiBackground;
import com.android.systemui.demomode.DemoModeController;
import com.android.systemui.demomode.DemoModeController;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.FeatureFlags;
@@ -103,6 +104,8 @@ import com.android.systemui.statusbar.policy.UserInfoControllerImpl;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.unfold.UnfoldLightRevealOverlayAnimation;
import com.android.systemui.unfold.UnfoldLightRevealOverlayAnimation;
import com.android.systemui.util.concurrency.DelayableExecutor;
import com.android.systemui.util.concurrency.MessageRouter;
import com.android.systemui.volume.VolumeComponent;
import com.android.systemui.volume.VolumeComponent;
import com.android.systemui.wmshell.BubblesManager;
import com.android.systemui.wmshell.BubblesManager;
import com.android.unfold.config.UnfoldTransitionConfig;
import com.android.unfold.config.UnfoldTransitionConfig;
@@ -217,6 +220,9 @@ public interface StatusBarPhoneModule {
            LockscreenShadeTransitionController transitionController,
            LockscreenShadeTransitionController transitionController,
            FeatureFlags featureFlags,
            FeatureFlags featureFlags,
            KeyguardUnlockAnimationController keyguardUnlockAnimationController,
            KeyguardUnlockAnimationController keyguardUnlockAnimationController,
            @Main Handler mainHandler,
            @Main DelayableExecutor delayableExecutor,
            @Main MessageRouter messageRouter,
            WallpaperManager wallpaperManager,
            WallpaperManager wallpaperManager,
            UnlockedScreenOffAnimationController unlockedScreenOffAnimationController,
            UnlockedScreenOffAnimationController unlockedScreenOffAnimationController,
            Optional<StartingSurface> startingSurfaceOptional,
            Optional<StartingSurface> startingSurfaceOptional,
@@ -307,6 +313,9 @@ public interface StatusBarPhoneModule {
                transitionController,
                transitionController,
                featureFlags,
                featureFlags,
                keyguardUnlockAnimationController,
                keyguardUnlockAnimationController,
                mainHandler,
                delayableExecutor,
                messageRouter,
                wallpaperManager,
                wallpaperManager,
                unlockedScreenOffAnimationController,
                unlockedScreenOffAnimationController,
                startingSurfaceOptional,
                startingSurfaceOptional,
+10 −4
Original line number Original line Diff line number Diff line
@@ -141,6 +141,7 @@ import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.unfold.UnfoldLightRevealOverlayAnimation;
import com.android.systemui.unfold.UnfoldLightRevealOverlayAnimation;
import com.android.systemui.util.concurrency.FakeExecutor;
import com.android.systemui.util.concurrency.FakeExecutor;
import com.android.systemui.util.concurrency.MessageRouterImpl;
import com.android.systemui.util.time.FakeSystemClock;
import com.android.systemui.util.time.FakeSystemClock;
import com.android.systemui.volume.VolumeComponent;
import com.android.systemui.volume.VolumeComponent;
import com.android.systemui.wmshell.BubblesManager;
import com.android.systemui.wmshell.BubblesManager;
@@ -271,7 +272,9 @@ public class StatusBarTest extends SysuiTestCase {
    @Mock private OperatorNameViewController mOperatorNameViewController;
    @Mock private OperatorNameViewController mOperatorNameViewController;
    @Mock private OperatorNameViewController.Factory mOperatorNameViewControllerFactory;
    @Mock private OperatorNameViewController.Factory mOperatorNameViewControllerFactory;
    private ShadeController mShadeController;
    private ShadeController mShadeController;
    private FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock());
    private final FakeSystemClock mFakeSystemClock = new FakeSystemClock();
    private FakeExecutor mMainExecutor = new FakeExecutor(mFakeSystemClock);
    private FakeExecutor mUiBgExecutor = new FakeExecutor(mFakeSystemClock);
    private InitController mInitController = new InitController();
    private InitController mInitController = new InitController();


    @Before
    @Before
@@ -436,6 +439,9 @@ public class StatusBarTest extends SysuiTestCase {
                mLockscreenTransitionController,
                mLockscreenTransitionController,
                mFeatureFlags,
                mFeatureFlags,
                mKeyguardUnlockAnimationController,
                mKeyguardUnlockAnimationController,
                new Handler(TestableLooper.get(this).getLooper()),
                mMainExecutor,
                new MessageRouterImpl(mMainExecutor),
                mWallpaperManager,
                mWallpaperManager,
                mUnlockedScreenOffAnimationController,
                mUnlockedScreenOffAnimationController,
                Optional.of(mStartingSurface),
                Optional.of(mStartingSurface),
@@ -702,7 +708,7 @@ public class StatusBarTest extends SysuiTestCase {
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            fail();
            fail();
        }
        }
        TestableLooper.get(this).processAllMessages();
        mMainExecutor.runAllReady();
    }
    }


    @Test
    @Test
@@ -721,7 +727,7 @@ public class StatusBarTest extends SysuiTestCase {
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            fail();
            fail();
        }
        }
        TestableLooper.get(this).processAllMessages();
        mMainExecutor.runAllReady();
    }
    }


    @Test
    @Test
@@ -739,7 +745,7 @@ public class StatusBarTest extends SysuiTestCase {
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            fail();
            fail();
        }
        }
        TestableLooper.get(this).processAllMessages();
        mMainExecutor.runAllReady();
    }
    }


    @Test
    @Test