Merge changes from topic "b190746471-status-bar-refactor" into sc-v2-dev

* changes:
  Remove custom Handler from StatusBar.
  Move ActivityLaunchAnimator.KeyguardHandler internal to StatusBar.
  Move BatteryStateChangeCallback internal to StatusBar.
  Move ConfigurationListener to internal field in StatusBar.
This commit is contained in:
Dave Mankoff
2021-08-18 15:37:07 +00:00
committed by Android (Google) Code Review
5 changed files with 262 additions and 293 deletions

View File

@@ -118,10 +118,6 @@ public class ShadeControllerImpl implements ShadeController {
+ " flags=" + flags);
}
if ((flags & CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL) == 0) {
getStatusBar().postHideRecentApps();
}
// TODO(b/62444020): remove when this bug is fixed
Log.v(TAG, "NotificationShadeWindow: " + getNotificationShadeWindowView()
+ " canPanelBeCollapsed(): "

View File

@@ -73,7 +73,6 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -143,6 +142,7 @@ import com.android.systemui.camera.CameraIntents;
import com.android.systemui.charging.WirelessChargingAnimation;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dagger.qualifiers.UiBackground;
import com.android.systemui.demomode.DemoModeController;
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.tuner.TunerService;
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.wmshell.BubblesManager;
import com.android.unfold.config.UnfoldTransitionConfig;
@@ -252,16 +254,9 @@ import dagger.Lazy;
/** */
public class StatusBar extends SystemUI implements
ActivityStarter,
ConfigurationListener,
StatusBarStateController.StateListener,
LifecycleOwner, BatteryController.BatteryStateChangeCallback,
ActivityLaunchAnimator.Callback {
LifecycleOwner {
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;
// Should match the values in PhoneWindowManager
@@ -289,8 +284,6 @@ public class StatusBar extends SystemUI implements
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_LAUNCH_TRANSITION_TIMEOUT = 1003;
// 1020-1040 reserved for BaseStatusBar
@@ -370,13 +363,14 @@ public class StatusBar extends SystemUI implements
mWereIconsJustHidden = justHidden;
}
void resetHandlerMsg(int msg) {
mHandler.removeMessages(msg);
mHandler.sendEmptyMessage(msg);
void resendMessage(int msg) {
mMessageRouter.cancelMessages(msg);
mMessageRouter.sendMessage(msg);
}
Handler getHandler() {
return mHandler;
void resendMessage(Object msg) {
mMessageRouter.cancelMessages(msg.getClass());
mMessageRouter.sendMessage(msg);
}
int getDisabled1() {
@@ -544,6 +538,7 @@ public class StatusBar extends SystemUI implements
private final UnfoldTransitionConfig mUnfoldTransitionConfig;
private final Lazy<UnfoldLightRevealOverlayAnimation> mUnfoldLightRevealOverlayAnimation;
private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController;
private final MessageRouter mMessageRouter;
private final WallpaperManager mWallpaperManager;
private final UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
private final TunerService mTunerService;
@@ -636,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 @TransitionMode int mStatusBarMode;
@@ -767,8 +763,6 @@ public class StatusBar extends SystemUI implements
}
};
private final Handler mMainThreadHandler = new Handler(Looper.getMainLooper());
private HeadsUpAppearanceController mHeadsUpAppearanceController;
private ActivityLaunchAnimator mActivityLaunchAnimator;
private NotificationLaunchAnimatorControllerProvider mNotificationAnimationProvider;
@@ -787,6 +781,174 @@ public class StatusBar extends SystemUI implements
private final ColorExtractor.OnColorsChangedListener mOnColorsChangedListener =
(extractor, which) -> updateTheme();
private final ConfigurationListener mConfigurationListener = new ConfigurationListener() {
@Override
public void onConfigChanged(Configuration newConfig) {
updateResources();
updateDisplaySize(); // populates mDisplayMetrics
if (DEBUG) {
Log.v(TAG, "configuration changed: " + mContext.getResources().getConfiguration());
}
mViewHierarchyManager.updateRowStates();
mScreenPinningRequest.onConfigurationChanged();
}
@Override
public void onDensityOrFontScaleChanged() {
// TODO: Remove this.
if (mBrightnessMirrorController != null) {
mBrightnessMirrorController.onDensityOrFontScaleChanged();
}
// TODO: Bring these out of StatusBar.
mUserInfoControllerImpl.onDensityOrFontScaleChanged();
mUserSwitcherController.onDensityOrFontScaleChanged();
mNotificationIconAreaController.onDensityOrFontScaleChanged(mContext);
mHeadsUpManager.onDensityOrFontScaleChanged();
}
@Override
public void onThemeChanged() {
if (mStatusBarKeyguardViewManager != null) {
mStatusBarKeyguardViewManager.onThemeChanged();
}
if (mAmbientIndicationContainer instanceof AutoReinflateContainer) {
((AutoReinflateContainer) mAmbientIndicationContainer).inflateLayout();
}
mNotificationIconAreaController.onThemeChanged();
}
@Override
public void onOverlayChanged() {
if (mBrightnessMirrorController != null) {
mBrightnessMirrorController.onOverlayChanged();
}
// We need the new R.id.keyguard_indication_area before recreating
// mKeyguardIndicationController
mNotificationPanelViewController.onThemeChanged();
onThemeChanged();
}
@Override
public void onUiModeChanged() {
if (mBrightnessMirrorController != null) {
mBrightnessMirrorController.onUiModeChanged();
}
}
};
private StatusBarStateController.StateListener mStateListener =
new StatusBarStateController.StateListener() {
@Override
public void onStatePreChange(int oldState, int newState) {
// If we're visible and switched to SHADE_LOCKED (the user dragged
// down on the lockscreen), clear notification LED, vibration,
// ringing.
// Other transitions are covered in handleVisibleToUserChanged().
if (mVisible && (newState == StatusBarState.SHADE_LOCKED
|| mStatusBarStateController.goingToFullShade())) {
clearNotificationEffects();
}
if (newState == StatusBarState.KEYGUARD) {
mRemoteInputManager.onPanelCollapsed();
maybeEscalateHeadsUp();
}
}
@Override
public void onStateChanged(int newState) {
mState = newState;
updateReportRejectedTouchVisibility();
mDozeServiceHost.updateDozing();
updateTheme();
mNavigationBarController.touchAutoDim(mDisplayId);
Trace.beginSection("StatusBar#updateKeyguardState");
if (mState == StatusBarState.KEYGUARD && mStatusBarView != null) {
mStatusBarView.removePendingHideExpandedRunnables();
}
updateDozingState();
checkBarModes();
updateScrimController();
mPresenter.updateMediaMetaData(false, mState != StatusBarState.KEYGUARD);
updateKeyguardState();
Trace.endSection();
}
@Override
public void onDozeAmountChanged(float linear, float eased) {
if (mFeatureFlags.useNewLockscreenAnimations()
&& !(mLightRevealScrim.getRevealEffect() instanceof CircleReveal)) {
mLightRevealScrim.setRevealAmount(1f - linear);
}
}
@Override
public void onDozingChanged(boolean isDozing) {
Trace.beginSection("StatusBar#updateDozing");
mDozing = isDozing;
// Collapse the notification panel if open
boolean dozingAnimated = mDozeServiceHost.getDozingRequested()
&& mDozeParameters.shouldControlScreenOff();
mNotificationPanelViewController.resetViews(dozingAnimated);
updateQsExpansionEnabled();
mKeyguardViewMediator.setDozing(mDozing);
mNotificationsController.requestNotificationUpdate("onDozingChanged");
updateDozingState();
mDozeServiceHost.updateDozing();
updateScrimController();
updateReportRejectedTouchVisibility();
Trace.endSection();
}
};
private final BatteryController.BatteryStateChangeCallback mBatteryStateChangeCallback =
new BatteryController.BatteryStateChangeCallback() {
@Override
public void onPowerSaveChanged(boolean isPowerSave) {
mMainExecutor.execute(mCheckBarModes);
if (mDozeServiceHost != null) {
mDozeServiceHost.firePowerSaveChanged(isPowerSave);
}
}
};
private final ActivityLaunchAnimator.Callback mKeyguardHandler =
new ActivityLaunchAnimator.Callback() {
@Override
public boolean isOnKeyguard() {
return mKeyguardStateController.isShowing();
}
@Override
public void hideKeyguardWithAnimation(IRemoteAnimationRunner runner) {
// We post to the main thread for 2 reasons:
// 1. KeyguardViewMediator is not thread-safe.
// 2. To ensure that ViewMediatorCallback#keyguardDonePending is called before
// ViewMediatorCallback#readyForKeyguardDone. The wrong order could occur when
// doing dismissKeyguardThenExecute { hideKeyguardWithAnimation(runner) }.
mMainExecutor.execute(() -> mKeyguardViewMediator.hideWithAnimation(runner));
}
@Override
public void setBlursDisabledForAppLaunch(boolean disabled) {
mKeyguardViewMediator.setBlursDisabledForAppLaunch(disabled);
}
@Override
public int getBackgroundColor(TaskInfo task) {
if (!mStartingSurfaceOptional.isPresent()) {
Log.w(TAG, "No starting surface, defaulting to SystemBGColor");
return SplashscreenContentDrawer.getSystemBGColor();
}
return mStartingSurfaceOptional.get().getBackgroundColor(task);
}
};
/**
* Public constructor for StatusBar.
*
@@ -881,6 +1043,9 @@ public class StatusBar extends SystemUI implements
LockscreenShadeTransitionController lockscreenShadeTransitionController,
FeatureFlags featureFlags,
KeyguardUnlockAnimationController keyguardUnlockAnimationController,
@Main Handler mainHandler,
@Main DelayableExecutor delayableExecutor,
@Main MessageRouter messageRouter,
WallpaperManager wallpaperManager,
UnlockedScreenOffAnimationController unlockedScreenOffAnimationController,
Optional<StartingSurface> startingSurfaceOptional,
@@ -968,6 +1133,9 @@ public class StatusBar extends SystemUI implements
mStatusBarIconController = statusBarIconController;
mFeatureFlags = featureFlags;
mKeyguardUnlockAnimationController = keyguardUnlockAnimationController;
mMainHandler = mainHandler;
mMainExecutor = delayableExecutor;
mMessageRouter = messageRouter;
mWallpaperManager = wallpaperManager;
mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
mTunerService = tunerService;
@@ -985,7 +1153,18 @@ public class StatusBar extends SystemUI implements
});
mActivityIntentHelper = new ActivityIntentHelper(mContext);
// TODO(b/190746471): Find a better home for this.
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
@@ -1003,7 +1182,7 @@ public class StatusBar extends SystemUI implements
mKeyguardIndicationController.init();
mColorExtractor.addOnColorsChangedListener(mOnColorsChangedListener);
mStatusBarStateController.addCallback(this,
mStatusBarStateController.addCallback(mStateListener,
SysuiStatusBarStateController.RANK_STATUS_BAR);
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
@@ -1117,9 +1296,9 @@ public class StatusBar extends SystemUI implements
mAmbientIndicationContainer);
mDozeParameters.addCallback(this::updateLightRevealScrimVisibility);
mConfigurationController.addCallback(this);
mConfigurationController.addCallback(mConfigurationListener);
mBatteryController.observe(mLifecycle, this);
mBatteryController.observe(mLifecycle, mBatteryStateChangeCallback);
mLifecycle.setCurrentState(RESUMED);
// set the initial view visibility
@@ -1140,7 +1319,7 @@ public class StatusBar extends SystemUI implements
@Override
public void onPluginConnected(OverlayPlugin plugin, Context pluginContext) {
mMainThreadHandler.post(
mMainExecutor.execute(
() -> plugin.setup(getNotificationShadeWindowView(),
getNavigationBarView(),
new Callback(plugin), mDozeParameters));
@@ -1148,7 +1327,7 @@ public class StatusBar extends SystemUI implements
@Override
public void onPluginDisconnected(OverlayPlugin plugin) {
mMainThreadHandler.post(() -> {
mMainExecutor.execute(() -> {
mOverlays.remove(plugin);
mNotificationShadeWindowController
.setForcePluginOpen(mOverlays.size() != 0, this);
@@ -1169,7 +1348,7 @@ public class StatusBar extends SystemUI implements
} else {
mOverlays.remove(mPlugin);
}
mMainThreadHandler.post(() -> {
mMainExecutor.execute(() -> {
mNotificationShadeWindowController
.setStateListener(b -> mOverlays.forEach(
o -> o.setCollapseDesired(b)));
@@ -1231,7 +1410,7 @@ public class StatusBar extends SystemUI implements
mConfigurationController,
mTunerService,
mBroadcastDispatcher,
mMainThreadHandler,
mMainHandler,
mContext.getContentResolver()
);
mBatteryMeterViewController.init();
@@ -1487,19 +1666,6 @@ public class StatusBar extends SystemUI implements
return mLifecycle;
}
@Override
public void onPowerSaveChanged(boolean isPowerSave) {
mHandler.post(mCheckBarModes);
if (mDozeServiceHost != null) {
mDozeServiceHost.firePowerSaveChanged(isPowerSave);
}
}
@Override
public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {
// noop
}
@VisibleForTesting
protected void registerBroadcastReceiver() {
IntentFilter filter = new IntentFilter();
@@ -1515,7 +1681,7 @@ public class StatusBar extends SystemUI implements
private void setUpPresenter() {
// Set up the initial notification state.
mActivityLaunchAnimator = new ActivityLaunchAnimator(this, mContext);
mActivityLaunchAnimator = new ActivityLaunchAnimator(mKeyguardHandler, mContext);
mNotificationAnimationProvider = new NotificationLaunchAnimatorControllerProvider(
mNotificationShadeWindowViewController,
mStackScrollerController.getNotificationListContainer(),
@@ -1631,48 +1797,6 @@ public class StatusBar extends SystemUI implements
.getNotificationShelfController(mStackScroller);
}
@Override
public void onDensityOrFontScaleChanged() {
// TODO: Remove this.
if (mBrightnessMirrorController != null) {
mBrightnessMirrorController.onDensityOrFontScaleChanged();
}
// TODO: Bring these out of StatusBar.
mUserInfoControllerImpl.onDensityOrFontScaleChanged();
mUserSwitcherController.onDensityOrFontScaleChanged();
mNotificationIconAreaController.onDensityOrFontScaleChanged(mContext);
mHeadsUpManager.onDensityOrFontScaleChanged();
}
@Override
public void onThemeChanged() {
if (mStatusBarKeyguardViewManager != null) {
mStatusBarKeyguardViewManager.onThemeChanged();
}
if (mAmbientIndicationContainer instanceof AutoReinflateContainer) {
((AutoReinflateContainer) mAmbientIndicationContainer).inflateLayout();
}
mNotificationIconAreaController.onThemeChanged();
}
@Override
public void onOverlayChanged() {
if (mBrightnessMirrorController != null) {
mBrightnessMirrorController.onOverlayChanged();
}
// We need the new R.id.keyguard_indication_area before recreating
// mKeyguardIndicationController
mNotificationPanelViewController.onThemeChanged();
onThemeChanged();
}
@Override
public void onUiModeChanged() {
if (mBrightnessMirrorController != null) {
mBrightnessMirrorController.onUiModeChanged();
}
}
private void inflateStatusBarWindow() {
mNotificationShadeWindowView = mSuperStatusBarViewFactory.getNotificationShadeWindowView();
StatusBarComponent statusBarComponent = mStatusBarComponentBuilder.get()
@@ -1858,10 +1982,6 @@ public class StatusBar extends SystemUI implements
return (mDisabled1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0;
}
protected H createHandler() {
return new StatusBar.H();
}
@Override
public void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade,
int flags) {
@@ -1996,7 +2116,7 @@ public class StatusBar extends SystemUI implements
// 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.
mWereIconsJustHidden = true;
mHandler.postDelayed(() -> {
mMainExecutor.executeDelayed(() -> {
mWereIconsJustHidden = false;
mCommandQueue.recomputeDisableFlags(mDisplayId, true);
}, 500);
@@ -2056,36 +2176,6 @@ public class StatusBar extends SystemUI implements
return isActivityIntent && KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation;
}
@Override
public boolean isOnKeyguard() {
return mKeyguardStateController.isShowing();
}
@Override
public void hideKeyguardWithAnimation(IRemoteAnimationRunner runner) {
// We post to the main thread for 2 reasons:
// 1. KeyguardViewMediator is not thread-safe.
// 2. To ensure that ViewMediatorCallback#keyguardDonePending is called before
// ViewMediatorCallback#readyForKeyguardDone. The wrong order could occur when doing
// dismissKeyguardThenExecute { hideKeyguardWithAnimation(runner) }.
mMainThreadHandler.post(() -> mKeyguardViewMediator.hideWithAnimation(runner));
}
@Override
public void setBlursDisabledForAppLaunch(boolean disabled) {
mKeyguardViewMediator.setBlursDisabledForAppLaunch(disabled);
}
@Override
public int getBackgroundColor(TaskInfo task) {
if (!mStartingSurfaceOptional.isPresent()) {
Log.w(TAG, "No starting surface, defaulting to SystemBGColor");
return SplashscreenContentDrawer.getSystemBGColor();
}
return mStartingSurfaceOptional.get().getBackgroundColor(task);
}
public boolean isDeviceInVrMode() {
return mPresenter.isDeviceInVrMode();
}
@@ -2099,37 +2189,19 @@ public class StatusBar extends SystemUI implements
mState = state;
}
/**
* All changes to the status bar and notifications funnel through here and are batched.
*/
protected class H extends Handler {
H() {
super(Looper.myLooper());
}
static class KeyboardShortcutsData {
final int mDeviceId;
@Override
public void handleMessage(Message m) {
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;
}
KeyboardShortcutsData(int deviceId) {
mDeviceId = deviceId;
}
}
static class AnimateExpandSettingsPanelData {
final String mSubpanel;
AnimateExpandSettingsPanelData(String subpanel) {
mSubpanel = subpanel;
}
}
@@ -2171,27 +2243,17 @@ public class StatusBar extends SystemUI implements
}
public void postAnimateCollapsePanels() {
mHandler.post(mShadeController::animateCollapsePanels);
mMainExecutor.execute(mShadeController::animateCollapsePanels);
}
public void postAnimateForceCollapsePanels() {
mHandler.post(() -> mShadeController.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE,
mMainExecutor.execute(
() -> mShadeController.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE,
true /* force */));
}
public void postAnimateOpenPanels() {
mHandler.sendEmptyMessage(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);
}
mMessageRouter.sendMessage(MSG_OPEN_SETTINGS_PANEL);
}
public boolean isExpandedVisible() {
@@ -2760,7 +2822,7 @@ public class StatusBar extends SystemUI implements
&& mStatusBarKeyguardViewManager.isOccluded()) {
mStatusBarKeyguardViewManager.addAfterKeyguardGoneRunnable(runnable);
} else {
mHandler.post(runnable);
mMainExecutor.execute(runnable);
}
}
if (dismissShade) {
@@ -2772,7 +2834,7 @@ public class StatusBar extends SystemUI implements
// Do it after DismissAction has been processed to conserve the needed
// ordering.
mHandler.post(mShadeController::runPostCollapseRunnables);
mMainExecutor.execute(mShadeController::runPostCollapseRunnables);
}
} else if (StatusBar.this.isInLaunchTransition()
&& mNotificationPanelViewController.isLaunchTransitionFinished()) {
@@ -2781,7 +2843,7 @@ public class StatusBar extends SystemUI implements
// finished,
// so nobody will call readyForKeyguardDone anymore. Post it such that
// keyguardDonePending gets called first.
mHandler.post(mStatusBarKeyguardViewManager::readyForKeyguardDone);
mMainExecutor.execute(mStatusBarKeyguardViewManager::readyForKeyguardDone);
}
return deferred;
}
@@ -2820,8 +2882,8 @@ public class StatusBar extends SystemUI implements
mNotificationShadeWindowController.setNotTouchable(false);
}
if (mBubblesOptional.isPresent() && mBubblesOptional.get().isStackExpanded()) {
// Post to main thread handler, since updating the UI.
mMainThreadHandler.post(() -> mBubblesOptional.get().collapseStack());
// Post to main thread, since updating the UI.
mMainExecutor.execute(() -> mBubblesOptional.get().collapseStack());
}
finishBarAnimations();
resetUserExpandedStates();
@@ -2882,20 +2944,6 @@ public class StatusBar extends SystemUI implements
action.onDismiss();
}
}
@Override
public void onConfigChanged(Configuration newConfig) {
updateResources();
updateDisplaySize(); // populates mDisplayMetrics
if (DEBUG) {
Log.v(TAG, "configuration changed: " + mContext.getResources().getConfiguration());
}
mViewHierarchyManager.updateRowStates();
mScreenPinningRequest.onConfigurationChanged();
}
/**
* Notify the shade controller that the current user changed
*
@@ -3045,10 +3093,10 @@ public class StatusBar extends SystemUI implements
@Override
public void postQSRunnableDismissingKeyguard(final Runnable runnable) {
mHandler.post(() -> {
mMainExecutor.execute(() -> {
mStatusBarStateController.setLeaveOpenOnKeyguardHide(true);
executeRunnableDismissingKeyguard(() -> mHandler.post(runnable), null, false, false,
false);
executeRunnableDismissingKeyguard(
() -> mMainExecutor.execute(runnable), null, false, false, false);
});
}
@@ -3060,7 +3108,7 @@ public class StatusBar extends SystemUI implements
@Override
public void postStartActivityDismissingKeyguard(final PendingIntent intent,
@Nullable ActivityLaunchAnimator.Controller animationController) {
mHandler.post(() -> startPendingIntentDismissingKeyguard(intent,
mMainExecutor.execute(() -> startPendingIntentDismissingKeyguard(intent,
null /* intentSentUiThreadCallback */, animationController));
}
@@ -3072,7 +3120,7 @@ public class StatusBar extends SystemUI implements
@Override
public void postStartActivityDismissingKeyguard(Intent intent, int delay,
@Nullable ActivityLaunchAnimator.Controller animationController) {
mHandler.postDelayed(
mMainExecutor.executeDelayed(
() ->
startActivityDismissingKeyguard(intent, true /* onlyProvisioned */,
true /* dismissShade */,
@@ -3142,7 +3190,7 @@ public class StatusBar extends SystemUI implements
mNotificationPanelViewController.cancelAnimation();
onLaunchTransitionFadingEnded();
}
mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT);
mMessageRouter.cancelMessages(MSG_LAUNCH_TRANSITION_TIMEOUT);
if (mUserSwitcherController != null && mUserSwitcherController.useFullscreenUserSwitcher()) {
mStatusBarStateController.setState(StatusBarState.FULLSCREEN_USER_SWITCHER);
} else if (!mPulseExpansionHandler.isWakingToShadeLocked()) {
@@ -3183,7 +3231,7 @@ public class StatusBar extends SystemUI implements
*/
public void fadeKeyguardAfterLaunchTransition(final Runnable beforeFading,
Runnable endRunnable) {
mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT);
mMessageRouter.cancelMessages(MSG_LAUNCH_TRANSITION_TIMEOUT);
mLaunchTransitionEndRunnable = endRunnable;
Runnable hideRunnable = () -> {
mKeyguardStateController.setLaunchTransitionFadingAway(true);
@@ -3232,8 +3280,8 @@ public class StatusBar extends SystemUI implements
* because the launched app crashed or something else went wrong.
*/
public void startLaunchTransitionTimeout() {
mHandler.sendEmptyMessageDelayed(MSG_LAUNCH_TRANSITION_TIMEOUT,
LAUNCH_TRANSITION_TIMEOUT_MS);
mMessageRouter.sendMessageDelayed(
MSG_LAUNCH_TRANSITION_TIMEOUT, LAUNCH_TRANSITION_TIMEOUT_MS);
}
private void onLaunchTransitionTimeout() {
@@ -3288,7 +3336,7 @@ public class StatusBar extends SystemUI implements
if (mQSPanelController != null) {
mQSPanelController.refreshAllTiles();
}
mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT);
mMessageRouter.cancelMessages(MSG_LAUNCH_TRANSITION_TIMEOUT);
releaseGestureWakeLock();
mNotificationPanelViewController.onAffordanceLaunchEnded();
mNotificationPanelViewController.cancelAnimation();
@@ -3516,69 +3564,7 @@ public class StatusBar extends SystemUI implements
mNotificationPanelViewController.collapseWithDuration(duration);
}
@Override
public void onStatePreChange(int oldState, int newState) {
// If we're visible and switched to SHADE_LOCKED (the user dragged
// down on the lockscreen), clear notification LED, vibration,
// ringing.
// Other transitions are covered in handleVisibleToUserChanged().
if (mVisible && (newState == StatusBarState.SHADE_LOCKED
|| mStatusBarStateController.goingToFullShade())) {
clearNotificationEffects();
}
if (newState == StatusBarState.KEYGUARD) {
mRemoteInputManager.onPanelCollapsed();
maybeEscalateHeadsUp();
}
}
@Override
public void onStateChanged(int newState) {
mState = newState;
updateReportRejectedTouchVisibility();
mDozeServiceHost.updateDozing();
updateTheme();
mNavigationBarController.touchAutoDim(mDisplayId);
Trace.beginSection("StatusBar#updateKeyguardState");
if (mState == StatusBarState.KEYGUARD && mStatusBarView != null) {
mStatusBarView.removePendingHideExpandedRunnables();
}
updateDozingState();
checkBarModes();
updateScrimController();
mPresenter.updateMediaMetaData(false, mState != StatusBarState.KEYGUARD);
updateKeyguardState();
Trace.endSection();
}
@Override
public void onDozeAmountChanged(float linear, float eased) {
if (mFeatureFlags.useNewLockscreenAnimations()
&& !(mLightRevealScrim.getRevealEffect() instanceof CircleReveal)) {
mLightRevealScrim.setRevealAmount(1f - linear);
}
}
@Override
public void onDozingChanged(boolean isDozing) {
Trace.beginSection("StatusBar#updateDozing");
mDozing = isDozing;
// Collapse the notification panel if open
boolean dozingAnimated = mDozeServiceHost.getDozingRequested()
&& mDozeParameters.shouldControlScreenOff();
mNotificationPanelViewController.resetViews(dozingAnimated);
updateQsExpansionEnabled();
mKeyguardViewMediator.setDozing(mDozing);
mNotificationsController.requestNotificationUpdate("onDozingChanged");
updateDozingState();
mDozeServiceHost.updateDozing();
updateScrimController();
updateReportRejectedTouchVisibility();
Trace.endSection();
}
/**
* Updates the light reveal effect to reflect the reason we're waking or sleeping (for example,
@@ -3720,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
// is correct.
mHandler.post(() -> mCommandQueueCallbacks.onCameraLaunchGestureDetected(
mMainExecutor.execute(() -> mCommandQueueCallbacks.onCameraLaunchGestureDetected(
mLastCameraLaunchSource));
}
@@ -3729,7 +3715,7 @@ 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(
mMainExecutor.execute(
() -> mCommandQueueCallbacks.onEmergencyActionLaunchGestureDetected());
}
updateIsKeyguard();
@@ -4198,7 +4184,7 @@ public class StatusBar extends SystemUI implements
}
private void postOnUiThread(Runnable runnable) {
mMainThreadHandler.post(runnable);
mMainExecutor.execute(runnable);
}
/**

View File

@@ -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
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.
@@ -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 (mStatusBar.areNotificationAlertsDisabled()) {
mHeadsUpManager.releaseAllImmediately();
@@ -544,9 +527,7 @@ public class StatusBarCommandQueueCallbacks implements CommandQueue.Callbacks {
@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();
mStatusBar.resendMessage(new StatusBar.KeyboardShortcutsData(deviceId));
}
@Override

View File

@@ -33,6 +33,7 @@ import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dagger.qualifiers.UiBackground;
import com.android.systemui.demomode.DemoModeController;
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.tuner.TunerService;
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.wmshell.BubblesManager;
import com.android.unfold.config.UnfoldTransitionConfig;
@@ -217,6 +220,9 @@ public interface StatusBarPhoneModule {
LockscreenShadeTransitionController transitionController,
FeatureFlags featureFlags,
KeyguardUnlockAnimationController keyguardUnlockAnimationController,
@Main Handler mainHandler,
@Main DelayableExecutor delayableExecutor,
@Main MessageRouter messageRouter,
WallpaperManager wallpaperManager,
UnlockedScreenOffAnimationController unlockedScreenOffAnimationController,
Optional<StartingSurface> startingSurfaceOptional,
@@ -307,6 +313,9 @@ public interface StatusBarPhoneModule {
transitionController,
featureFlags,
keyguardUnlockAnimationController,
mainHandler,
delayableExecutor,
messageRouter,
wallpaperManager,
unlockedScreenOffAnimationController,
startingSurfaceOptional,

View File

@@ -141,6 +141,7 @@ import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.unfold.UnfoldLightRevealOverlayAnimation;
import com.android.systemui.util.concurrency.FakeExecutor;
import com.android.systemui.util.concurrency.MessageRouterImpl;
import com.android.systemui.util.time.FakeSystemClock;
import com.android.systemui.volume.VolumeComponent;
import com.android.systemui.wmshell.BubblesManager;
@@ -271,7 +272,9 @@ public class StatusBarTest extends SysuiTestCase {
@Mock private OperatorNameViewController mOperatorNameViewController;
@Mock private OperatorNameViewController.Factory mOperatorNameViewControllerFactory;
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();
@Before
@@ -436,6 +439,9 @@ public class StatusBarTest extends SysuiTestCase {
mLockscreenTransitionController,
mFeatureFlags,
mKeyguardUnlockAnimationController,
new Handler(TestableLooper.get(this).getLooper()),
mMainExecutor,
new MessageRouterImpl(mMainExecutor),
mWallpaperManager,
mUnlockedScreenOffAnimationController,
Optional.of(mStartingSurface),
@@ -702,7 +708,7 @@ public class StatusBarTest extends SysuiTestCase {
} catch (RemoteException e) {
fail();
}
TestableLooper.get(this).processAllMessages();
mMainExecutor.runAllReady();
}
@Test
@@ -721,7 +727,7 @@ public class StatusBarTest extends SysuiTestCase {
} catch (RemoteException e) {
fail();
}
TestableLooper.get(this).processAllMessages();
mMainExecutor.runAllReady();
}
@Test
@@ -739,7 +745,7 @@ public class StatusBarTest extends SysuiTestCase {
} catch (RemoteException e) {
fail();
}
TestableLooper.get(this).processAllMessages();
mMainExecutor.runAllReady();
}
@Test
@@ -753,15 +759,6 @@ public class StatusBarTest extends SysuiTestCase {
new PrintWriter(new ByteArrayOutputStream()), "var", /* transitions= */ null);
}
@Test
@RunWithLooper(setAsMainLooper = true)
public void testUpdateKeyguardState_DoesNotCrash() {
mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD);
when(mLockscreenUserManager.getCurrentProfiles()).thenReturn(
new SparseArray<>());
mStatusBar.onStateChanged(StatusBarState.SHADE);
}
@Test
public void testFingerprintNotification_UpdatesScrims() {
mStatusBar.notifyBiometricAuthModeChanged();