Merge changes from topic "b249277686_shadeCs" into udc-qpr-dev am: 2904a18287

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23492374

Change-Id: I94fd7341854a75f6cc0f7e99f167667fb449a8af
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2023-06-02 00:19:44 +00:00
committed by Automerger Merge Worker
22 changed files with 338 additions and 264 deletions

View File

@@ -133,6 +133,9 @@ public interface ActivityStarter {
boolean willAnimateOnKeyguard, boolean willAnimateOnKeyguard,
@Nullable String customMessage); @Nullable String customMessage);
/** Whether we should animate an activity launch. */
boolean shouldAnimateLaunch(boolean isActivityIntent);
interface Callback { interface Callback {
void onActivityStarted(int resultCode); void onActivityStarted(int resultCode);
} }

View File

@@ -485,13 +485,11 @@ public class SystemActions implements CoreStartable {
} }
private void handleNotifications() { private void handleNotifications() {
mCentralSurfacesOptionalLazy.get().ifPresent( mShadeController.animateExpandShade();
CentralSurfaces::animateExpandNotificationsPanel);
} }
private void handleQuickSettings() { private void handleQuickSettings() {
mCentralSurfacesOptionalLazy.get().ifPresent( mShadeController.animateExpandQs();
centralSurfaces -> centralSurfaces.animateExpandSettingsPanel(null));
} }
private void handlePowerDialog() { private void handlePowerDialog() {

View File

@@ -125,6 +125,7 @@ import com.android.systemui.plugins.GlobalActions.GlobalActionsManager;
import com.android.systemui.plugins.GlobalActionsPanelPlugin; import com.android.systemui.plugins.GlobalActionsPanelPlugin;
import com.android.systemui.scrim.ScrimDrawable; import com.android.systemui.scrim.ScrimDrawable;
import com.android.systemui.settings.UserTracker; import com.android.systemui.settings.UserTracker;
import com.android.systemui.shade.ShadeController;
import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.VibratorHelper; import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.CentralSurfaces;
@@ -250,6 +251,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
protected Handler mMainHandler; protected Handler mMainHandler;
private int mSmallestScreenWidthDp; private int mSmallestScreenWidthDp;
private final Optional<CentralSurfaces> mCentralSurfacesOptional; private final Optional<CentralSurfaces> mCentralSurfacesOptional;
private final ShadeController mShadeController;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private final DialogLaunchAnimator mDialogLaunchAnimator; private final DialogLaunchAnimator mDialogLaunchAnimator;
@@ -360,6 +362,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
@Main Handler handler, @Main Handler handler,
PackageManager packageManager, PackageManager packageManager,
Optional<CentralSurfaces> centralSurfacesOptional, Optional<CentralSurfaces> centralSurfacesOptional,
ShadeController shadeController,
KeyguardUpdateMonitor keyguardUpdateMonitor, KeyguardUpdateMonitor keyguardUpdateMonitor,
DialogLaunchAnimator dialogLaunchAnimator) { DialogLaunchAnimator dialogLaunchAnimator) {
mContext = context; mContext = context;
@@ -392,6 +395,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
mMainHandler = handler; mMainHandler = handler;
mSmallestScreenWidthDp = resources.getConfiguration().smallestScreenWidthDp; mSmallestScreenWidthDp = resources.getConfiguration().smallestScreenWidthDp;
mCentralSurfacesOptional = centralSurfacesOptional; mCentralSurfacesOptional = centralSurfacesOptional;
mShadeController = shadeController;
mKeyguardUpdateMonitor = keyguardUpdateMonitor; mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mDialogLaunchAnimator = dialogLaunchAnimator; mDialogLaunchAnimator = dialogLaunchAnimator;
@@ -700,7 +704,9 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
mAdapter, mOverflowAdapter, mSysuiColorExtractor, mStatusBarService, mAdapter, mOverflowAdapter, mSysuiColorExtractor, mStatusBarService,
mLightBarController, mLightBarController,
mNotificationShadeWindowController, this::onRefresh, mKeyguardShowing, mNotificationShadeWindowController, this::onRefresh, mKeyguardShowing,
mPowerAdapter, mUiEventLogger, mCentralSurfacesOptional, mKeyguardUpdateMonitor, mPowerAdapter, mUiEventLogger, mCentralSurfacesOptional,
mShadeController,
mKeyguardUpdateMonitor,
mLockPatternUtils); mLockPatternUtils);
dialog.setOnDismissListener(this); dialog.setOnDismissListener(this);
@@ -2205,6 +2211,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
private UiEventLogger mUiEventLogger; private UiEventLogger mUiEventLogger;
private GestureDetector mGestureDetector; private GestureDetector mGestureDetector;
private Optional<CentralSurfaces> mCentralSurfacesOptional; private Optional<CentralSurfaces> mCentralSurfacesOptional;
private final ShadeController mShadeController;
private KeyguardUpdateMonitor mKeyguardUpdateMonitor; private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private LockPatternUtils mLockPatternUtils; private LockPatternUtils mLockPatternUtils;
private float mWindowDimAmount; private float mWindowDimAmount;
@@ -2278,6 +2285,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
Runnable onRefreshCallback, boolean keyguardShowing, Runnable onRefreshCallback, boolean keyguardShowing,
MyPowerOptionsAdapter powerAdapter, UiEventLogger uiEventLogger, MyPowerOptionsAdapter powerAdapter, UiEventLogger uiEventLogger,
Optional<CentralSurfaces> centralSurfacesOptional, Optional<CentralSurfaces> centralSurfacesOptional,
ShadeController shadeController,
KeyguardUpdateMonitor keyguardUpdateMonitor, KeyguardUpdateMonitor keyguardUpdateMonitor,
LockPatternUtils lockPatternUtils) { LockPatternUtils lockPatternUtils) {
// We set dismissOnDeviceLock to false because we have a custom broadcast receiver to // We set dismissOnDeviceLock to false because we have a custom broadcast receiver to
@@ -2295,6 +2303,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
mKeyguardShowing = keyguardShowing; mKeyguardShowing = keyguardShowing;
mUiEventLogger = uiEventLogger; mUiEventLogger = uiEventLogger;
mCentralSurfacesOptional = centralSurfacesOptional; mCentralSurfacesOptional = centralSurfacesOptional;
mShadeController = shadeController;
mKeyguardUpdateMonitor = keyguardUpdateMonitor; mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mLockPatternUtils = lockPatternUtils; mLockPatternUtils = lockPatternUtils;
mGestureDetector = new GestureDetector(mContext, mGestureListener); mGestureDetector = new GestureDetector(mContext, mGestureListener);
@@ -2342,12 +2351,10 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
mUiEventLogger.log(GlobalActionsEvent.GA_CLOSE_TAP_OUTSIDE); mUiEventLogger.log(GlobalActionsEvent.GA_CLOSE_TAP_OUTSIDE);
if (mCentralSurfacesOptional.map(CentralSurfaces::isKeyguardShowing).orElse(false)) { if (mCentralSurfacesOptional.map(CentralSurfaces::isKeyguardShowing).orElse(false)) {
// match existing lockscreen behavior to open QS when swiping from status bar // match existing lockscreen behavior to open QS when swiping from status bar
mCentralSurfacesOptional.ifPresent( mShadeController.animateExpandQs();
centralSurfaces -> centralSurfaces.animateExpandSettingsPanel(null));
} else { } else {
// otherwise, swiping down should expand notification shade // otherwise, swiping down should expand notification shade
mCentralSurfacesOptional.ifPresent( mShadeController.animateExpandShade();
centralSurfaces -> centralSurfaces.animateExpandNotificationsPanel());
} }
dismiss(); dismiss();
} }

View File

@@ -52,8 +52,8 @@ import com.android.systemui.qs.pipeline.data.repository.CustomTileAddedRepositor
import com.android.systemui.qs.pipeline.domain.interactor.PanelInteractor; import com.android.systemui.qs.pipeline.domain.interactor.PanelInteractor;
import com.android.systemui.settings.UserFileManager; import com.android.systemui.settings.UserFileManager;
import com.android.systemui.settings.UserTracker; import com.android.systemui.settings.UserTracker;
import com.android.systemui.shade.ShadeController;
import com.android.systemui.statusbar.phone.AutoTileManager; import com.android.systemui.statusbar.phone.AutoTileManager;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.tuner.TunerService; import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable; import com.android.systemui.tuner.TunerService.Tunable;
import com.android.systemui.util.settings.SecureSettings; import com.android.systemui.util.settings.SecureSettings;
@@ -66,7 +66,6 @@ import java.util.Collection;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.function.Predicate; import java.util.function.Predicate;
@@ -108,7 +107,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, P
private AutoTileManager mAutoTiles; private AutoTileManager mAutoTiles;
private final ArrayList<QSFactory> mQsFactories = new ArrayList<>(); private final ArrayList<QSFactory> mQsFactories = new ArrayList<>();
private int mCurrentUser; private int mCurrentUser;
private final Optional<CentralSurfaces> mCentralSurfacesOptional; private final ShadeController mShadeController;
private Context mUserContext; private Context mUserContext;
private UserTracker mUserTracker; private UserTracker mUserTracker;
private SecureSettings mSecureSettings; private SecureSettings mSecureSettings;
@@ -129,7 +128,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, P
PluginManager pluginManager, PluginManager pluginManager,
TunerService tunerService, TunerService tunerService,
Provider<AutoTileManager> autoTiles, Provider<AutoTileManager> autoTiles,
Optional<CentralSurfaces> centralSurfacesOptional, ShadeController shadeController,
QSLogger qsLogger, QSLogger qsLogger,
UserTracker userTracker, UserTracker userTracker,
SecureSettings secureSettings, SecureSettings secureSettings,
@@ -148,7 +147,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, P
mUserFileManager = userFileManager; mUserFileManager = userFileManager;
mFeatureFlags = featureFlags; mFeatureFlags = featureFlags;
mCentralSurfacesOptional = centralSurfacesOptional; mShadeController = shadeController;
mQsFactories.add(defaultFactory); mQsFactories.add(defaultFactory);
pluginManager.addPluginListener(this, QSFactory.class, true); pluginManager.addPluginListener(this, QSFactory.class, true);
@@ -209,17 +208,17 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, P
@Override @Override
public void collapsePanels() { public void collapsePanels() {
mCentralSurfacesOptional.ifPresent(CentralSurfaces::postAnimateCollapsePanels); mShadeController.postAnimateCollapseShade();
} }
@Override @Override
public void forceCollapsePanels() { public void forceCollapsePanels() {
mCentralSurfacesOptional.ifPresent(CentralSurfaces::postAnimateForceCollapsePanels); mShadeController.postAnimateForceCollapseShade();
} }
@Override @Override
public void openPanels() { public void openPanels() {
mCentralSurfacesOptional.ifPresent(CentralSurfaces::postAnimateOpenPanels); mShadeController.postAnimateExpandQs();
} }
@Override @Override

View File

@@ -16,8 +16,7 @@
package com.android.systemui.qs.pipeline.domain.interactor package com.android.systemui.qs.pipeline.domain.interactor
import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.statusbar.phone.CentralSurfaces import com.android.systemui.shade.ShadeController
import java.util.Optional
import javax.inject.Inject import javax.inject.Inject
/** Encapsulates business logic for interacting with the QS panel. */ /** Encapsulates business logic for interacting with the QS panel. */
@@ -37,17 +36,17 @@ interface PanelInteractor {
class PanelInteractorImpl class PanelInteractorImpl
@Inject @Inject
constructor( constructor(
private val centralSurfaces: Optional<CentralSurfaces>, private val shadeController: ShadeController,
) : PanelInteractor { ) : PanelInteractor {
override fun collapsePanels() { override fun collapsePanels() {
centralSurfaces.ifPresent { it.postAnimateCollapsePanels() } shadeController.postAnimateCollapseShade()
} }
override fun forceCollapsePanels() { override fun forceCollapsePanels() {
centralSurfaces.ifPresent { it.postAnimateForceCollapsePanels() } shadeController.postAnimateForceCollapseShade()
} }
override fun openPanels() { override fun openPanels() {
centralSurfaces.ifPresent { it.postAnimateOpenPanels() } shadeController.postAnimateExpandQs()
} }
} }

View File

@@ -360,7 +360,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
@Override @Override
public void toggleNotificationPanel() { public void toggleNotificationPanel() {
verifyCallerAndClearCallingIdentityPostMain("toggleNotificationPanel", () -> verifyCallerAndClearCallingIdentityPostMain("toggleNotificationPanel", () ->
mCentralSurfacesOptionalLazy.get().ifPresent(CentralSurfaces::togglePanel)); mCommandQueue.togglePanel());
} }
private boolean verifyCaller(String reason) { private boolean verifyCaller(String reason) {

View File

@@ -38,23 +38,38 @@ public interface ShadeController {
/** Collapse the shade instantly with no animation. */ /** Collapse the shade instantly with no animation. */
void instantCollapseShade(); void instantCollapseShade();
/** See {@link #animateCollapsePanels(int, boolean, boolean, float)}. */ /** See {@link #animateCollapseShade(int, boolean, boolean, float)}. */
void animateCollapseShade(); void animateCollapseShade();
/** See {@link #animateCollapsePanels(int, boolean, boolean, float)}. */ /** See {@link #animateCollapseShade(int, boolean, boolean, float)}. */
void animateCollapseShade(int flags); void animateCollapseShade(int flags);
/** See {@link #animateCollapsePanels(int, boolean, boolean, float)}. */ /** See {@link #animateCollapseShade(int, boolean, boolean, float)}. */
void animateCollapseShadeForced(); void animateCollapseShadeForced();
/** See {@link #animateCollapsePanels(int, boolean, boolean, float)}. */ /** See {@link #animateCollapseShade(int, boolean, boolean, float)}. */
void animateCollapseShadeDelayed(); void animateCollapseShadeForcedDelayed();
/** /**
* Collapse the shade animated, showing the bouncer when on {@link StatusBarState#KEYGUARD} or * Collapse the shade animated, showing the bouncer when on {@link StatusBarState#KEYGUARD} or
* dismissing status bar when on {@link StatusBarState#SHADE}. * dismissing status bar when on {@link StatusBarState#SHADE}.
*/ */
void animateCollapsePanels(int flags, boolean force, boolean delayed, float speedUpFactor); void animateCollapseShade(int flags, boolean force, boolean delayed, float speedUpFactor);
/** Expand the shade with an animation. */
void animateExpandShade();
/** Expand the shade with quick settings expanded with an animation. */
void animateExpandQs();
/** Posts a request to collapse the shade. */
void postAnimateCollapseShade();
/** Posts a request to force collapse the shade. */
void postAnimateForceCollapseShade();
/** Posts a request to expand the shade to quick settings. */
void postAnimateExpandQs();
/** /**
* If the shade is not fully expanded, collapse it animated. * If the shade is not fully expanded, collapse it animated.
@@ -115,6 +130,9 @@ public interface ShadeController {
*/ */
void collapseShade(boolean animate); void collapseShade(boolean animate);
/** Calls #collapseShade if already on the main thread. If not, posts a call to it. */
void collapseOnMainThread();
/** Makes shade expanded but not visible. */ /** Makes shade expanded but not visible. */
void makeExpandedInvisible(); void makeExpandedInvisible();
@@ -127,8 +145,11 @@ public interface ShadeController {
/** Handle status bar touch event. */ /** Handle status bar touch event. */
void onStatusBarTouch(MotionEvent event); void onStatusBarTouch(MotionEvent event);
/** Called when the shade finishes collapsing. */ /** Called when a launch animation was cancelled. */
void onClosingFinished(); void onLaunchAnimationCancelled(boolean isLaunchForActivity);
/** Called when a launch animation ends. */
void onLaunchAnimationEnd(boolean launchIsFullScreen);
/** Sets the listener for when the visibility of the shade changes. */ /** Sets the listener for when the visibility of the shade changes. */
void setVisibilityListener(ShadeVisibilityListener listener); void setVisibilityListener(ShadeVisibilityListener listener);

View File

@@ -17,6 +17,7 @@
package com.android.systemui.shade; package com.android.systemui.shade;
import android.content.ComponentCallbacks2; import android.content.ComponentCallbacks2;
import android.os.Looper;
import android.util.Log; import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
@@ -25,6 +26,7 @@ import android.view.WindowManagerGlobal;
import com.android.systemui.assist.AssistManager; import com.android.systemui.assist.AssistManager;
import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.NotificationPresenter; import com.android.systemui.statusbar.NotificationPresenter;
@@ -32,12 +34,14 @@ import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager; import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.window.StatusBarWindowController; import com.android.systemui.statusbar.window.StatusBarWindowController;
import dagger.Lazy; import dagger.Lazy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.Executor;
import javax.inject.Inject; import javax.inject.Inject;
@@ -51,11 +55,13 @@ public final class ShadeControllerImpl implements ShadeController {
private final int mDisplayId; private final int mDisplayId;
private final CommandQueue mCommandQueue; private final CommandQueue mCommandQueue;
private final Executor mMainExecutor;
private final KeyguardStateController mKeyguardStateController; private final KeyguardStateController mKeyguardStateController;
private final NotificationShadeWindowController mNotificationShadeWindowController; private final NotificationShadeWindowController mNotificationShadeWindowController;
private final StatusBarStateController mStatusBarStateController; private final StatusBarStateController mStatusBarStateController;
private final StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; private final StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
private final StatusBarWindowController mStatusBarWindowController; private final StatusBarWindowController mStatusBarWindowController;
private final DeviceProvisionedController mDeviceProvisionedController;
private final Lazy<AssistManager> mAssistManagerLazy; private final Lazy<AssistManager> mAssistManagerLazy;
private final Lazy<NotificationGutsManager> mGutsManager; private final Lazy<NotificationGutsManager> mGutsManager;
@@ -72,18 +78,22 @@ public final class ShadeControllerImpl implements ShadeController {
@Inject @Inject
public ShadeControllerImpl( public ShadeControllerImpl(
CommandQueue commandQueue, CommandQueue commandQueue,
@Main Executor mainExecutor,
KeyguardStateController keyguardStateController, KeyguardStateController keyguardStateController,
StatusBarStateController statusBarStateController, StatusBarStateController statusBarStateController,
StatusBarKeyguardViewManager statusBarKeyguardViewManager, StatusBarKeyguardViewManager statusBarKeyguardViewManager,
StatusBarWindowController statusBarWindowController, StatusBarWindowController statusBarWindowController,
DeviceProvisionedController deviceProvisionedController,
NotificationShadeWindowController notificationShadeWindowController, NotificationShadeWindowController notificationShadeWindowController,
WindowManager windowManager, WindowManager windowManager,
Lazy<AssistManager> assistManagerLazy, Lazy<AssistManager> assistManagerLazy,
Lazy<NotificationGutsManager> gutsManager Lazy<NotificationGutsManager> gutsManager
) { ) {
mCommandQueue = commandQueue; mCommandQueue = commandQueue;
mMainExecutor = mainExecutor;
mStatusBarStateController = statusBarStateController; mStatusBarStateController = statusBarStateController;
mStatusBarWindowController = statusBarWindowController; mStatusBarWindowController = statusBarWindowController;
mDeviceProvisionedController = deviceProvisionedController;
mGutsManager = gutsManager; mGutsManager = gutsManager;
mNotificationShadeWindowController = notificationShadeWindowController; mNotificationShadeWindowController = notificationShadeWindowController;
mStatusBarKeyguardViewManager = statusBarKeyguardViewManager; mStatusBarKeyguardViewManager = statusBarKeyguardViewManager;
@@ -107,21 +117,21 @@ public final class ShadeControllerImpl implements ShadeController {
@Override @Override
public void animateCollapseShade(int flags) { public void animateCollapseShade(int flags) {
animateCollapsePanels(flags, false, false, 1.0f); animateCollapseShade(flags, false, false, 1.0f);
} }
@Override @Override
public void animateCollapseShadeForced() { public void animateCollapseShadeForced() {
animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true, false, 1.0f); animateCollapseShade(CommandQueue.FLAG_EXCLUDE_NONE, true, false, 1.0f);
} }
@Override @Override
public void animateCollapseShadeDelayed() { public void animateCollapseShadeForcedDelayed() {
animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true, true, 1.0f); animateCollapseShade(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true, true, 1.0f);
} }
@Override @Override
public void animateCollapsePanels(int flags, boolean force, boolean delayed, public void animateCollapseShade(int flags, boolean force, boolean delayed,
float speedUpFactor) { float speedUpFactor) {
if (!force && mStatusBarStateController.getState() != StatusBarState.SHADE) { if (!force && mStatusBarStateController.getState() != StatusBarState.SHADE) {
runPostCollapseRunnables(); runPostCollapseRunnables();
@@ -142,6 +152,25 @@ public final class ShadeControllerImpl implements ShadeController {
} }
} }
@Override
public void animateExpandShade() {
if (!mCommandQueue.panelsEnabled()) {
return;
}
mNotificationPanelViewController.expandToNotifications();
}
@Override
public void animateExpandQs() {
if (!mCommandQueue.panelsEnabled()) {
return;
}
// Settings are not available in setup
if (!mDeviceProvisionedController.isCurrentUserSetup()) return;
mNotificationPanelViewController.expandToQs();
}
@Override @Override
public boolean closeShadeIfOpen() { public boolean closeShadeIfOpen() {
if (!mNotificationPanelViewController.isFullyCollapsed()) { if (!mNotificationPanelViewController.isFullyCollapsed()) {
@@ -167,6 +196,20 @@ public final class ShadeControllerImpl implements ShadeController {
public boolean isExpandingOrCollapsing() { public boolean isExpandingOrCollapsing() {
return mNotificationPanelViewController.isExpandingOrCollapsing(); return mNotificationPanelViewController.isExpandingOrCollapsing();
} }
@Override
public void postAnimateCollapseShade() {
mMainExecutor.execute(this::animateCollapseShade);
}
@Override
public void postAnimateForceCollapseShade() {
mMainExecutor.execute(this::animateCollapseShadeForced);
}
@Override
public void postAnimateExpandQs() {
mMainExecutor.execute(this::animateExpandQs);
}
@Override @Override
public void postOnShadeExpanded(Runnable executable) { public void postOnShadeExpanded(Runnable executable) {
@@ -202,7 +245,7 @@ public final class ShadeControllerImpl implements ShadeController {
public boolean collapseShade() { public boolean collapseShade() {
if (!mNotificationPanelViewController.isFullyCollapsed()) { if (!mNotificationPanelViewController.isFullyCollapsed()) {
// close the shade if it was open // close the shade if it was open
animateCollapseShadeDelayed(); animateCollapseShadeForcedDelayed();
notifyVisibilityChanged(false); notifyVisibilityChanged(false);
return true; return true;
@@ -226,6 +269,15 @@ public final class ShadeControllerImpl implements ShadeController {
} }
} }
@Override
public void collapseOnMainThread() {
if (Looper.getMainLooper().isCurrentThread()) {
collapseShade();
} else {
mMainExecutor.execute(this::collapseShade);
}
}
@Override @Override
public void onStatusBarTouch(MotionEvent event) { public void onStatusBarTouch(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) { if (event.getAction() == MotionEvent.ACTION_UP) {
@@ -235,8 +287,7 @@ public final class ShadeControllerImpl implements ShadeController {
} }
} }
@Override private void onClosingFinished() {
public void onClosingFinished() {
runPostCollapseRunnables(); runPostCollapseRunnables();
if (!mPresenter.isPresenterFullyCollapsed()) { if (!mPresenter.isPresenterFullyCollapsed()) {
// if we set it not to be focusable when collapsing, we have to undo it when we aborted // if we set it not to be focusable when collapsing, we have to undo it when we aborted
@@ -245,6 +296,27 @@ public final class ShadeControllerImpl implements ShadeController {
} }
} }
@Override
public void onLaunchAnimationCancelled(boolean isLaunchForActivity) {
if (mPresenter.isPresenterFullyCollapsed()
&& !mPresenter.isCollapsing()
&& isLaunchForActivity) {
onClosingFinished();
} else {
collapseShade(true /* animate */);
}
}
@Override
public void onLaunchAnimationEnd(boolean launchIsFullScreen) {
if (!mPresenter.isCollapsing()) {
onClosingFinished();
}
if (launchIsFullScreen) {
instantCollapseShade();
}
}
@Override @Override
public void instantCollapseShade() { public void instantCollapseShade() {
mNotificationPanelViewController.instantCollapse(); mNotificationPanelViewController.instantCollapse();

View File

@@ -148,7 +148,7 @@ public class ExpandableNotificationRowDragController {
private void dismissShade() { private void dismissShade() {
// Speed up dismissing the shade since the drag needs to be handled by // Speed up dismissing the shade since the drag needs to be handled by
// the shell layer underneath // the shell layer underneath
mShadeController.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */, mShadeController.animateCollapseShade(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */,
false /* delayed */, 1.1f /* speedUpFactor */); false /* delayed */, 1.1f /* speedUpFactor */);
} }

View File

@@ -388,6 +388,35 @@ constructor(
mainExecutor.executeDelayed(runnable, delay.toLong()) mainExecutor.executeDelayed(runnable, delay.toLong())
} }
/**
* Whether we should animate an activity launch.
*
* Note: This method must be called *before* dismissing the keyguard.
*/
private fun shouldAnimateLaunch(
isActivityIntent: Boolean,
showOverLockscreen: Boolean,
): Boolean {
// TODO(b/184121838): Support launch animations when occluded.
if (keyguardStateController.isOccluded) {
return false
}
// Always animate if we are not showing the keyguard or if we animate over the lockscreen
// (without unlocking it).
if (showOverLockscreen || !keyguardStateController.isShowing) {
return true
}
// We don't animate non-activity launches as they can break the animation.
// TODO(b/184121838): Support non activity launches on the lockscreen.
return isActivityIntent
}
override fun shouldAnimateLaunch(isActivityIntent: Boolean): Boolean {
return shouldAnimateLaunch(isActivityIntent, false)
}
/** /**
* Encapsulates the activity logic for activity starter. * Encapsulates the activity logic for activity starter.
* *
@@ -419,7 +448,7 @@ constructor(
val animate = val animate =
animationController != null && animationController != null &&
!willLaunchResolverActivity && !willLaunchResolverActivity &&
centralSurfaces?.shouldAnimateLaunch(true /* isActivityIntent */) == true shouldAnimateLaunch(isActivityIntent = true)
val animController = val animController =
wrapAnimationController( wrapAnimationController(
animationController = animationController, animationController = animationController,
@@ -538,7 +567,7 @@ constructor(
val animate = val animate =
!willLaunchResolverActivity && !willLaunchResolverActivity &&
animationController != null && animationController != null &&
centralSurfaces?.shouldAnimateLaunch(intent.isActivity) == true shouldAnimateLaunch(intent.isActivity)
// If we animate, don't collapse the shade and defer the keyguard dismiss (in case we // If we animate, don't collapse the shade and defer the keyguard dismiss (in case we
// run the animation on the keyguard). The animation will take care of (instantly) // run the animation on the keyguard). The animation will take care of (instantly)
@@ -595,7 +624,7 @@ constructor(
Log.w(TAG, "Sending intent failed: $e") Log.w(TAG, "Sending intent failed: $e")
if (!collapse) { if (!collapse) {
// executeRunnableDismissingKeyguard did not collapse for us already. // executeRunnableDismissingKeyguard did not collapse for us already.
centralSurfaces?.collapsePanelOnMainThread() shadeControllerLazy.get().collapseOnMainThread()
} }
// TODO: Dismiss Keyguard. // TODO: Dismiss Keyguard.
} }
@@ -637,7 +666,7 @@ constructor(
val animate = val animate =
animationController != null && animationController != null &&
centralSurfaces?.shouldAnimateLaunch( shouldAnimateLaunch(
/* isActivityIntent= */ true, /* isActivityIntent= */ true,
showOverLockscreenWhenLocked showOverLockscreenWhenLocked
) == true ) == true
@@ -804,7 +833,7 @@ constructor(
shadeControllerLazy.get().isExpandedVisible && shadeControllerLazy.get().isExpandedVisible &&
!statusBarKeyguardViewManagerLazy.get().isBouncerShowing !statusBarKeyguardViewManagerLazy.get().isBouncerShowing
) { ) {
shadeControllerLazy.get().animateCollapseShadeDelayed() shadeControllerLazy.get().animateCollapseShadeForcedDelayed()
} else { } else {
// Do it after DismissAction has been processed to conserve the // Do it after DismissAction has been processed to conserve the
// needed ordering. // needed ordering.
@@ -867,7 +896,8 @@ constructor(
if (dismissShade) { if (dismissShade) {
return StatusBarLaunchAnimatorController( return StatusBarLaunchAnimatorController(
animationController, animationController,
it, it.shadeViewController,
shadeControllerLazy.get(),
notifShadeWindowControllerLazy.get(), notifShadeWindowControllerLazy.get(),
isLaunchForActivity isLaunchForActivity
) )

View File

@@ -185,14 +185,6 @@ public interface CentralSurfaces extends Dumpable, LifecycleOwner {
return contextForUser.getPackageManager(); return contextForUser.getPackageManager();
} }
void animateExpandNotificationsPanel();
void animateExpandSettingsPanel(@Nullable String subpanel);
void collapsePanelOnMainThread();
void togglePanel();
void start(); void start();
boolean updateIsKeyguard(); boolean updateIsKeyguard();
@@ -228,25 +220,10 @@ public interface CentralSurfaces extends Dumpable, LifecycleOwner {
boolean isOccluded(); boolean isOccluded();
//TODO: These can / should probably be moved to NotificationPresenter or ShadeController
void onLaunchAnimationCancelled(boolean isLaunchForActivity);
void onLaunchAnimationEnd(boolean launchIsFullScreen);
boolean shouldAnimateLaunch(boolean isActivityIntent, boolean showOverLockscreen);
boolean shouldAnimateLaunch(boolean isActivityIntent);
boolean isDeviceInVrMode(); boolean isDeviceInVrMode();
NotificationPresenter getPresenter(); NotificationPresenter getPresenter();
void postAnimateCollapsePanels();
void postAnimateForceCollapsePanels();
void postAnimateOpenPanels();
boolean isPanelExpanded(); boolean isPanelExpanded();
/** /**
@@ -264,8 +241,6 @@ public interface CentralSurfaces extends Dumpable, LifecycleOwner {
*/ */
default void onStatusBarTrackpadEvent(MotionEvent event) {} default void onStatusBarTrackpadEvent(MotionEvent event) {}
void animateCollapseQuickSettings();
/** */ /** */
boolean getCommandQueuePanelsEnabled(); boolean getCommandQueuePanelsEnabled();

View File

@@ -208,7 +208,7 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba
@Override @Override
public void animateCollapsePanels(int flags, boolean force) { public void animateCollapsePanels(int flags, boolean force) {
mShadeController.animateCollapsePanels(flags, force, false /* delayed */, mShadeController.animateCollapseShade(flags, force, false /* delayed */,
1.0f /* speedUpFactor */); 1.0f /* speedUpFactor */);
} }
@@ -218,11 +218,7 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba
Log.d(CentralSurfaces.TAG, Log.d(CentralSurfaces.TAG,
"animateExpand: mExpandedVisible=" + mShadeController.isExpandedVisible()); "animateExpand: mExpandedVisible=" + mShadeController.isExpandedVisible());
} }
if (!mCommandQueue.panelsEnabled()) { mShadeController.animateExpandShade();
return;
}
mShadeViewController.expandToNotifications();
} }
@Override @Override
@@ -231,14 +227,7 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba
Log.d(CentralSurfaces.TAG, Log.d(CentralSurfaces.TAG,
"animateExpand: mExpandedVisible=" + mShadeController.isExpandedVisible()); "animateExpand: mExpandedVisible=" + mShadeController.isExpandedVisible());
} }
if (!mCommandQueue.panelsEnabled()) { mShadeController.animateExpandQs();
return;
}
// Settings are not available in setup
if (!mDeviceProvisionedController.isCurrentUserSetup()) return;
mShadeViewController.expandToQs();
} }
@Override @Override
@@ -559,7 +548,7 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba
if (mCentralSurfaces.isPanelExpanded()) { if (mCentralSurfaces.isPanelExpanded()) {
mShadeController.animateCollapseShade(); mShadeController.animateCollapseShade();
} else { } else {
animateExpandNotificationsPanel(); mShadeController.animateExpandShade();
} }
} }

View File

@@ -69,7 +69,6 @@ import android.net.Uri;
import android.os.Binder; import android.os.Binder;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Looper;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.ServiceManager; import android.os.ServiceManager;
@@ -411,24 +410,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
return mQSPanelController; return mQSPanelController;
} }
/** */
@Override
public void animateExpandNotificationsPanel() {
mCommandQueueCallbacks.animateExpandNotificationsPanel();
}
/** */
@Override
public void animateExpandSettingsPanel(@Nullable String subpanel) {
mCommandQueueCallbacks.animateExpandSettingsPanel(subpanel);
}
/** */
@Override
public void togglePanel() {
mCommandQueueCallbacks.togglePanel();
}
/** /**
* The {@link StatusBarState} of the status bar. * The {@link StatusBarState} of the status bar.
*/ */
@@ -1822,58 +1803,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
return mKeyguardStateController.isOccluded(); return mKeyguardStateController.isOccluded();
} }
/** A launch animation was cancelled. */
//TODO: These can / should probably be moved to NotificationPresenter or ShadeController
@Override
public void onLaunchAnimationCancelled(boolean isLaunchForActivity) {
if (mPresenter.isPresenterFullyCollapsed() && !mPresenter.isCollapsing()
&& isLaunchForActivity) {
mShadeController.onClosingFinished();
} else {
mShadeController.collapseShade(true /* animate */);
}
}
/** A launch animation ended. */
@Override
public void onLaunchAnimationEnd(boolean launchIsFullScreen) {
if (!mPresenter.isCollapsing()) {
mShadeController.onClosingFinished();
}
if (launchIsFullScreen) {
mShadeController.instantCollapseShade();
}
}
/**
* Whether we should animate an activity launch.
*
* Note: This method must be called *before* dismissing the keyguard.
*/
@Override
public boolean shouldAnimateLaunch(boolean isActivityIntent, boolean showOverLockscreen) {
// TODO(b/184121838): Support launch animations when occluded.
if (isOccluded()) {
return false;
}
// Always animate if we are not showing the keyguard or if we animate over the lockscreen
// (without unlocking it).
if (showOverLockscreen || !mKeyguardStateController.isShowing()) {
return true;
}
// We don't animate non-activity launches as they can break the animation.
// TODO(b/184121838): Support non activity launches on the lockscreen.
return isActivityIntent;
}
/** Whether we should animate an activity launch. */
@Override
public boolean shouldAnimateLaunch(boolean isActivityIntent) {
return shouldAnimateLaunch(isActivityIntent, false /* showOverLockscreen */);
}
@Override @Override
public boolean isDeviceInVrMode() { public boolean isDeviceInVrMode() {
return mPresenter.isDeviceInVrMode(); return mPresenter.isDeviceInVrMode();
@@ -1929,21 +1858,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
} }
} }
@Override
public void postAnimateCollapsePanels() {
mMainExecutor.execute(mShadeController::animateCollapseShade);
}
@Override
public void postAnimateForceCollapsePanels() {
mMainExecutor.execute(mShadeController::animateCollapseShadeForced);
}
@Override
public void postAnimateOpenPanels() {
mMessageRouter.sendMessage(MSG_OPEN_SETTINGS_PANEL);
}
@Override @Override
public boolean isPanelExpanded() { public boolean isPanelExpanded() {
return mPanelExpanded; return mPanelExpanded;
@@ -1970,14 +1884,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
mCentralSurfacesComponent.getNotificationPanelViewController().handleExternalTouch(event); mCentralSurfacesComponent.getNotificationPanelViewController().handleExternalTouch(event);
} }
@Override
public void animateCollapseQuickSettings() {
if (mState == StatusBarState.SHADE) {
mShadeSurface.collapse(
true, false /* delayed */, 1.0f /* speedUpFactor */);
}
}
private void onExpandedInvisible() { private void onExpandedInvisible() {
setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false); setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false);
if (!mNotificationActivityStarter.isCollapsingToShowActivityOverLockscreen()) { if (!mNotificationActivityStarter.isCollapsingToShowActivityOverLockscreen()) {
@@ -2956,19 +2862,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
} }
} }
/**
* Collapse the panel directly if we are on the main thread, post the collapsing on the main
* thread if we are not.
*/
@Override
public void collapsePanelOnMainThread() {
if (Looper.getMainLooper().isCurrentThread()) {
mShadeController.collapseShade();
} else {
mContext.getMainExecutor().execute(mShadeController::collapseShade);
}
}
/** /**
* Updates the light reveal effect to reflect the reason we're waking or sleeping (for example, * Updates the light reveal effect to reflect the reason we're waking or sleeping (for example,
* from the power button). * from the power button).
@@ -3768,8 +3661,9 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
if (userSetup != mUserSetup) { if (userSetup != mUserSetup) {
mUserSetup = userSetup; mUserSetup = userSetup;
if (!mUserSetup) { if (!mUserSetup && mState == StatusBarState.SHADE) {
animateCollapseQuickSettings(); mShadeSurface.collapse(true /* animate */, false /* delayed */,
1.0f /* speedUpFactor */);
} }
updateQsExpansionEnabled(); updateQsExpansionEnabled();
} }

View File

@@ -3,6 +3,8 @@ package com.android.systemui.statusbar.phone
import android.view.View import android.view.View
import com.android.systemui.animation.ActivityLaunchAnimator import com.android.systemui.animation.ActivityLaunchAnimator
import com.android.systemui.animation.LaunchAnimator import com.android.systemui.animation.LaunchAnimator
import com.android.systemui.shade.ShadeController
import com.android.systemui.shade.ShadeViewController
import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.statusbar.NotificationShadeWindowController
/** /**
@@ -11,7 +13,8 @@ import com.android.systemui.statusbar.NotificationShadeWindowController
*/ */
class StatusBarLaunchAnimatorController( class StatusBarLaunchAnimatorController(
private val delegate: ActivityLaunchAnimator.Controller, private val delegate: ActivityLaunchAnimator.Controller,
private val centralSurfaces: CentralSurfaces, private val shadeViewController: ShadeViewController,
private val shadeController: ShadeController,
private val notificationShadeWindowController: NotificationShadeWindowController, private val notificationShadeWindowController: NotificationShadeWindowController,
private val isLaunchForActivity: Boolean = true private val isLaunchForActivity: Boolean = true
) : ActivityLaunchAnimator.Controller by delegate { ) : ActivityLaunchAnimator.Controller by delegate {
@@ -23,25 +26,25 @@ class StatusBarLaunchAnimatorController(
override fun onIntentStarted(willAnimate: Boolean) { override fun onIntentStarted(willAnimate: Boolean) {
delegate.onIntentStarted(willAnimate) delegate.onIntentStarted(willAnimate)
if (willAnimate) { if (willAnimate) {
centralSurfaces.shadeViewController.setIsLaunchAnimationRunning(true) shadeViewController.setIsLaunchAnimationRunning(true)
} else { } else {
centralSurfaces.collapsePanelOnMainThread() shadeController.collapseOnMainThread()
} }
} }
override fun onLaunchAnimationStart(isExpandingFullyAbove: Boolean) { override fun onLaunchAnimationStart(isExpandingFullyAbove: Boolean) {
delegate.onLaunchAnimationStart(isExpandingFullyAbove) delegate.onLaunchAnimationStart(isExpandingFullyAbove)
centralSurfaces.shadeViewController.setIsLaunchAnimationRunning(true) shadeViewController.setIsLaunchAnimationRunning(true)
if (!isExpandingFullyAbove) { if (!isExpandingFullyAbove) {
centralSurfaces.shadeViewController.collapseWithDuration( shadeViewController.collapseWithDuration(
ActivityLaunchAnimator.TIMINGS.totalDuration.toInt()) ActivityLaunchAnimator.TIMINGS.totalDuration.toInt())
} }
} }
override fun onLaunchAnimationEnd(isExpandingFullyAbove: Boolean) { override fun onLaunchAnimationEnd(isExpandingFullyAbove: Boolean) {
delegate.onLaunchAnimationEnd(isExpandingFullyAbove) delegate.onLaunchAnimationEnd(isExpandingFullyAbove)
centralSurfaces.shadeViewController.setIsLaunchAnimationRunning(false) shadeViewController.setIsLaunchAnimationRunning(false)
centralSurfaces.onLaunchAnimationEnd(isExpandingFullyAbove) shadeController.onLaunchAnimationEnd(isExpandingFullyAbove)
} }
override fun onLaunchAnimationProgress( override fun onLaunchAnimationProgress(
@@ -50,12 +53,12 @@ class StatusBarLaunchAnimatorController(
linearProgress: Float linearProgress: Float
) { ) {
delegate.onLaunchAnimationProgress(state, progress, linearProgress) delegate.onLaunchAnimationProgress(state, progress, linearProgress)
centralSurfaces.shadeViewController.applyLaunchAnimationProgress(linearProgress) shadeViewController.applyLaunchAnimationProgress(linearProgress)
} }
override fun onLaunchAnimationCancelled(newKeyguardOccludedState: Boolean?) { override fun onLaunchAnimationCancelled(newKeyguardOccludedState: Boolean?) {
delegate.onLaunchAnimationCancelled() delegate.onLaunchAnimationCancelled()
centralSurfaces.shadeViewController.setIsLaunchAnimationRunning(false) shadeViewController.setIsLaunchAnimationRunning(false)
centralSurfaces.onLaunchAnimationCancelled(isLaunchForActivity) shadeController.onLaunchAnimationCancelled(isLaunchForActivity)
} }
} }

View File

@@ -122,7 +122,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte
private final CentralSurfaces mCentralSurfaces; private final CentralSurfaces mCentralSurfaces;
private final NotificationPresenter mPresenter; private final NotificationPresenter mPresenter;
private final ShadeViewController mNotificationPanel; private final ShadeViewController mShadeViewController;
private final NotificationShadeWindowController mNotificationShadeWindowController; private final NotificationShadeWindowController mNotificationShadeWindowController;
private final ActivityLaunchAnimator mActivityLaunchAnimator; private final ActivityLaunchAnimator mActivityLaunchAnimator;
private final NotificationLaunchAnimatorControllerProvider mNotificationAnimationProvider; private final NotificationLaunchAnimatorControllerProvider mNotificationAnimationProvider;
@@ -158,7 +158,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte
OnUserInteractionCallback onUserInteractionCallback, OnUserInteractionCallback onUserInteractionCallback,
CentralSurfaces centralSurfaces, CentralSurfaces centralSurfaces,
NotificationPresenter presenter, NotificationPresenter presenter,
ShadeViewController panel, ShadeViewController shadeViewController,
NotificationShadeWindowController notificationShadeWindowController, NotificationShadeWindowController notificationShadeWindowController,
ActivityLaunchAnimator activityLaunchAnimator, ActivityLaunchAnimator activityLaunchAnimator,
NotificationLaunchAnimatorControllerProvider notificationAnimationProvider, NotificationLaunchAnimatorControllerProvider notificationAnimationProvider,
@@ -193,7 +193,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte
// TODO: use KeyguardStateController#isOccluded to remove this dependency // TODO: use KeyguardStateController#isOccluded to remove this dependency
mCentralSurfaces = centralSurfaces; mCentralSurfaces = centralSurfaces;
mPresenter = presenter; mPresenter = presenter;
mNotificationPanel = panel; mShadeViewController = shadeViewController;
mActivityLaunchAnimator = activityLaunchAnimator; mActivityLaunchAnimator = activityLaunchAnimator;
mNotificationAnimationProvider = notificationAnimationProvider; mNotificationAnimationProvider = notificationAnimationProvider;
mUserTracker = userTracker; mUserTracker = userTracker;
@@ -237,7 +237,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte
&& mActivityIntentHelper.wouldPendingLaunchResolverActivity(intent, && mActivityIntentHelper.wouldPendingLaunchResolverActivity(intent,
mLockscreenUserManager.getCurrentUserId()); mLockscreenUserManager.getCurrentUserId());
final boolean animate = !willLaunchResolverActivity final boolean animate = !willLaunchResolverActivity
&& mCentralSurfaces.shouldAnimateLaunch(isActivityIntent); && mActivityStarter.shouldAnimateLaunch(isActivityIntent);
boolean showOverLockscreen = mKeyguardStateController.isShowing() && intent != null boolean showOverLockscreen = mKeyguardStateController.isShowing() && intent != null
&& mActivityIntentHelper.wouldPendingShowOverLockscreen(intent, && mActivityIntentHelper.wouldPendingShowOverLockscreen(intent,
mLockscreenUserManager.getCurrentUserId()); mLockscreenUserManager.getCurrentUserId());
@@ -288,7 +288,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte
} }
// Always defer the keyguard dismiss when animating. // Always defer the keyguard dismiss when animating.
return animate || !mNotificationPanel.isFullyCollapsed(); return animate || !mShadeViewController.isFullyCollapsed();
} }
private void handleNotificationClickAfterPanelCollapsed( private void handleNotificationClickAfterPanelCollapsed(
@@ -323,7 +323,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte
removeHunAfterClick(row); removeHunAfterClick(row);
// Show work challenge, do not run PendingIntent and // Show work challenge, do not run PendingIntent and
// remove notification // remove notification
collapseOnMainThread(); mShadeController.collapseOnMainThread();
return; return;
} }
} }
@@ -440,7 +440,8 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte
ActivityLaunchAnimator.Controller animationController = ActivityLaunchAnimator.Controller animationController =
new StatusBarLaunchAnimatorController( new StatusBarLaunchAnimatorController(
mNotificationAnimationProvider.getAnimatorController(row, null), mNotificationAnimationProvider.getAnimatorController(row, null),
mCentralSurfaces, mShadeViewController,
mShadeController,
mNotificationShadeWindowController, mNotificationShadeWindowController,
isActivityIntent); isActivityIntent);
mActivityLaunchAnimator.startPendingIntentWithAnimation( mActivityLaunchAnimator.startPendingIntentWithAnimation(
@@ -472,7 +473,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte
@Override @Override
public void startNotificationGutsIntent(final Intent intent, final int appUid, public void startNotificationGutsIntent(final Intent intent, final int appUid,
ExpandableNotificationRow row) { ExpandableNotificationRow row) {
boolean animate = mCentralSurfaces.shouldAnimateLaunch(true /* isActivityIntent */); boolean animate = mActivityStarter.shouldAnimateLaunch(true /* isActivityIntent */);
ActivityStarter.OnDismissAction onDismissAction = new ActivityStarter.OnDismissAction() { ActivityStarter.OnDismissAction onDismissAction = new ActivityStarter.OnDismissAction() {
@Override @Override
public boolean onDismiss() { public boolean onDismiss() {
@@ -480,7 +481,8 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte
ActivityLaunchAnimator.Controller animationController = ActivityLaunchAnimator.Controller animationController =
new StatusBarLaunchAnimatorController( new StatusBarLaunchAnimatorController(
mNotificationAnimationProvider.getAnimatorController(row), mNotificationAnimationProvider.getAnimatorController(row),
mCentralSurfaces, mShadeViewController,
mShadeController,
mNotificationShadeWindowController, mNotificationShadeWindowController,
true /* isActivityIntent */); true /* isActivityIntent */);
@@ -507,7 +509,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte
@Override @Override
public void startHistoryIntent(View view, boolean showHistory) { public void startHistoryIntent(View view, boolean showHistory) {
boolean animate = mCentralSurfaces.shouldAnimateLaunch(true /* isActivityIntent */); boolean animate = mActivityStarter.shouldAnimateLaunch(true /* isActivityIntent */);
ActivityStarter.OnDismissAction onDismissAction = new ActivityStarter.OnDismissAction() { ActivityStarter.OnDismissAction onDismissAction = new ActivityStarter.OnDismissAction() {
@Override @Override
public boolean onDismiss() { public boolean onDismiss() {
@@ -529,7 +531,8 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte
viewController == null ? null viewController == null ? null
: new StatusBarLaunchAnimatorController( : new StatusBarLaunchAnimatorController(
viewController, viewController,
mCentralSurfaces, mShadeViewController,
mShadeController,
mNotificationShadeWindowController, mNotificationShadeWindowController,
true /* isActivityIntent */); true /* isActivityIntent */);
@@ -630,11 +633,4 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte
return true; return true;
} }
private void collapseOnMainThread() {
if (Looper.getMainLooper().isCurrentThread()) {
mShadeController.collapseShade();
} else {
mMainThreadHandler.post(mShadeController::collapseShade);
}
}
} }

View File

@@ -67,6 +67,7 @@ import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.plugins.GlobalActions; import com.android.systemui.plugins.GlobalActions;
import com.android.systemui.settings.UserContextProvider; import com.android.systemui.settings.UserContextProvider;
import com.android.systemui.settings.UserTracker; import com.android.systemui.settings.UserTracker;
import com.android.systemui.shade.ShadeController;
import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.VibratorHelper; import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.CentralSurfaces;
@@ -128,6 +129,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase {
@Mock private UserContextProvider mUserContextProvider; @Mock private UserContextProvider mUserContextProvider;
@Mock private VibratorHelper mVibratorHelper; @Mock private VibratorHelper mVibratorHelper;
@Mock private CentralSurfaces mCentralSurfaces; @Mock private CentralSurfaces mCentralSurfaces;
@Mock private ShadeController mShadeController;
@Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor; @Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@Mock private DialogLaunchAnimator mDialogLaunchAnimator; @Mock private DialogLaunchAnimator mDialogLaunchAnimator;
@Mock private OnBackInvokedDispatcher mOnBackInvokedDispatcher; @Mock private OnBackInvokedDispatcher mOnBackInvokedDispatcher;
@@ -177,6 +179,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase {
mHandler, mHandler,
mPackageManager, mPackageManager,
Optional.of(mCentralSurfaces), Optional.of(mCentralSurfaces),
mShadeController,
mKeyguardUpdateMonitor, mKeyguardUpdateMonitor,
mDialogLaunchAnimator); mDialogLaunchAnimator);
mGlobalActionsDialogLite.setZeroDialogPressDelayForTesting(); mGlobalActionsDialogLite.setZeroDialogPressDelayForTesting();
@@ -317,7 +320,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase {
MotionEvent end = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 500, 0); MotionEvent end = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 500, 0);
gestureListener.onFling(start, end, 0, 1000); gestureListener.onFling(start, end, 0, 1000);
verifyLogPosted(GlobalActionsDialogLite.GlobalActionsEvent.GA_CLOSE_TAP_OUTSIDE); verifyLogPosted(GlobalActionsDialogLite.GlobalActionsEvent.GA_CLOSE_TAP_OUTSIDE);
verify(mCentralSurfaces).animateExpandSettingsPanel(null); verify(mShadeController).animateExpandQs();
} }
@Test @Test
@@ -341,7 +344,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase {
MotionEvent end = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 500, 0); MotionEvent end = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 500, 0);
gestureListener.onFling(start, end, 0, 1000); gestureListener.onFling(start, end, 0, 1000);
verifyLogPosted(GlobalActionsDialogLite.GlobalActionsEvent.GA_CLOSE_TAP_OUTSIDE); verifyLogPosted(GlobalActionsDialogLite.GlobalActionsEvent.GA_CLOSE_TAP_OUTSIDE);
verify(mCentralSurfaces).animateExpandNotificationsPanel(); verify(mShadeController).animateExpandShade();
} }
@Test @Test

View File

@@ -67,8 +67,8 @@ import com.android.systemui.qs.logging.QSLogger;
import com.android.systemui.qs.tileimpl.QSTileImpl; import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.settings.UserFileManager; import com.android.systemui.settings.UserFileManager;
import com.android.systemui.settings.UserTracker; import com.android.systemui.settings.UserTracker;
import com.android.systemui.shade.ShadeController;
import com.android.systemui.statusbar.phone.AutoTileManager; import com.android.systemui.statusbar.phone.AutoTileManager;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.tuner.TunerService; import com.android.systemui.tuner.TunerService;
import com.android.systemui.util.FakeSharedPreferences; import com.android.systemui.util.FakeSharedPreferences;
import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.concurrency.FakeExecutor;
@@ -86,7 +86,6 @@ import org.mockito.stubbing.Answer;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import javax.inject.Provider; import javax.inject.Provider;
@@ -110,7 +109,7 @@ public class QSTileHostTest extends SysuiTestCase {
@Mock @Mock
private Provider<AutoTileManager> mAutoTiles; private Provider<AutoTileManager> mAutoTiles;
@Mock @Mock
private CentralSurfaces mCentralSurfaces; private ShadeController mShadeController;
@Mock @Mock
private QSLogger mQSLogger; private QSLogger mQSLogger;
@Mock @Mock
@@ -161,7 +160,7 @@ public class QSTileHostTest extends SysuiTestCase {
mSecureSettings = new FakeSettings(); mSecureSettings = new FakeSettings();
saveSetting(""); saveSetting("");
mQSTileHost = new TestQSTileHost(mContext, mDefaultFactory, mMainExecutor, mQSTileHost = new TestQSTileHost(mContext, mDefaultFactory, mMainExecutor,
mPluginManager, mTunerService, mAutoTiles, mCentralSurfaces, mPluginManager, mTunerService, mAutoTiles, mShadeController,
mQSLogger, mUserTracker, mSecureSettings, mCustomTileStatePersister, mQSLogger, mUserTracker, mSecureSettings, mCustomTileStatePersister,
mTileLifecycleManagerFactory, mUserFileManager, mFeatureFlags); mTileLifecycleManagerFactory, mUserFileManager, mFeatureFlags);
@@ -682,13 +681,13 @@ public class QSTileHostTest extends SysuiTestCase {
QSFactory defaultFactory, Executor mainExecutor, QSFactory defaultFactory, Executor mainExecutor,
PluginManager pluginManager, TunerService tunerService, PluginManager pluginManager, TunerService tunerService,
Provider<AutoTileManager> autoTiles, Provider<AutoTileManager> autoTiles,
CentralSurfaces centralSurfaces, QSLogger qsLogger, ShadeController shadeController, QSLogger qsLogger,
UserTracker userTracker, SecureSettings secureSettings, UserTracker userTracker, SecureSettings secureSettings,
CustomTileStatePersister customTileStatePersister, CustomTileStatePersister customTileStatePersister,
TileLifecycleManager.Factory tileLifecycleManagerFactory, TileLifecycleManager.Factory tileLifecycleManagerFactory,
UserFileManager userFileManager, FeatureFlags featureFlags) { UserFileManager userFileManager, FeatureFlags featureFlags) {
super(context, defaultFactory, mainExecutor, pluginManager, super(context, defaultFactory, mainExecutor, pluginManager,
tunerService, autoTiles, Optional.of(centralSurfaces), qsLogger, tunerService, autoTiles, shadeController, qsLogger,
userTracker, secureSettings, customTileStatePersister, userTracker, secureSettings, customTileStatePersister,
tileLifecycleManagerFactory, userFileManager, featureFlags); tileLifecycleManagerFactory, userFileManager, featureFlags);
} }

View File

@@ -18,8 +18,7 @@ package com.android.systemui.qs.pipeline.domain.interactor
import android.testing.AndroidTestingRunner import android.testing.AndroidTestingRunner
import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase
import com.android.systemui.statusbar.phone.CentralSurfaces import com.android.systemui.shade.ShadeController
import java.util.Optional
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@@ -31,7 +30,7 @@ import org.mockito.MockitoAnnotations
@SmallTest @SmallTest
class PanelInteractorImplTest : SysuiTestCase() { class PanelInteractorImplTest : SysuiTestCase() {
@Mock private lateinit var centralSurfaces: CentralSurfaces @Mock private lateinit var shadeController: ShadeController
@Before @Before
fun setup() { fun setup() {
@@ -40,37 +39,28 @@ class PanelInteractorImplTest : SysuiTestCase() {
@Test @Test
fun openPanels_callsCentralSurfaces() { fun openPanels_callsCentralSurfaces() {
val underTest = PanelInteractorImpl(Optional.of(centralSurfaces)) val underTest = PanelInteractorImpl(shadeController)
underTest.openPanels() underTest.openPanels()
verify(centralSurfaces).postAnimateOpenPanels() verify(shadeController).postAnimateExpandQs()
} }
@Test @Test
fun collapsePanels_callsCentralSurfaces() { fun collapsePanels_callsCentralSurfaces() {
val underTest = PanelInteractorImpl(Optional.of(centralSurfaces)) val underTest = PanelInteractorImpl(shadeController)
underTest.collapsePanels() underTest.collapsePanels()
verify(centralSurfaces).postAnimateCollapsePanels() verify(shadeController).postAnimateCollapseShade()
} }
@Test @Test
fun forceCollapsePanels_callsCentralSurfaces() { fun forceCollapsePanels_callsCentralSurfaces() {
val underTest = PanelInteractorImpl(Optional.of(centralSurfaces)) val underTest = PanelInteractorImpl(shadeController)
underTest.forceCollapsePanels() underTest.forceCollapsePanels()
verify(centralSurfaces).postAnimateForceCollapsePanels() verify(shadeController).postAnimateForceCollapseShade()
}
@Test
fun whenOptionalEmpty_doesnThrow() {
val underTest = PanelInteractorImpl(Optional.empty())
underTest.openPanels()
underTest.collapsePanels()
underTest.forceCollapsePanels()
} }
} }

View File

@@ -0,0 +1,107 @@
/*
* Copyright (C) 2023 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.shade
import android.testing.AndroidTestingRunner
import android.view.Display
import android.view.WindowManager
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.assist.AssistManager
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.statusbar.CommandQueue
import com.android.systemui.statusbar.NotificationShadeWindowController
import com.android.systemui.statusbar.notification.row.NotificationGutsManager
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager
import com.android.systemui.statusbar.policy.DeviceProvisionedController
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.statusbar.window.StatusBarWindowController
import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.mockito.whenever
import com.android.systemui.util.time.FakeSystemClock
import dagger.Lazy
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers
import org.mockito.Mock
import org.mockito.Mockito.never
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations
@RunWith(AndroidTestingRunner::class)
@SmallTest
class ShadeControllerImplTest : SysuiTestCase() {
@Mock private lateinit var commandQueue: CommandQueue
@Mock private lateinit var keyguardStateController: KeyguardStateController
@Mock private lateinit var statusBarStateController: StatusBarStateController
@Mock private lateinit var statusBarKeyguardViewManager: StatusBarKeyguardViewManager
@Mock private lateinit var statusBarWindowController: StatusBarWindowController
@Mock private lateinit var deviceProvisionedController: DeviceProvisionedController
@Mock private lateinit var notificationShadeWindowController: NotificationShadeWindowController
@Mock private lateinit var windowManager: WindowManager
@Mock private lateinit var assistManager: AssistManager
@Mock private lateinit var gutsManager: NotificationGutsManager
@Mock private lateinit var notificationPanelViewController: NotificationPanelViewController
@Mock private lateinit var display: Display
private lateinit var shadeController: ShadeControllerImpl
@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
whenever(windowManager.defaultDisplay).thenReturn(display)
whenever(deviceProvisionedController.isCurrentUserSetup).thenReturn(true)
shadeController =
ShadeControllerImpl(
commandQueue,
FakeExecutor(FakeSystemClock()),
keyguardStateController,
statusBarStateController,
statusBarKeyguardViewManager,
statusBarWindowController,
deviceProvisionedController,
notificationShadeWindowController,
windowManager,
Lazy { assistManager },
Lazy { gutsManager },
)
shadeController.setNotificationPanelViewController(notificationPanelViewController)
}
@Test
fun testDisableNotificationShade() {
whenever(commandQueue.panelsEnabled()).thenReturn(false)
// Trying to open it does nothing.
shadeController.animateExpandShade()
verify(notificationPanelViewController, never()).expandToNotifications()
shadeController.animateExpandQs()
verify(notificationPanelViewController, never()).expand(ArgumentMatchers.anyBoolean())
}
@Test
fun testEnableNotificationShade() {
whenever(commandQueue.panelsEnabled()).thenReturn(true)
// Can now be opened.
shadeController.animateExpandShade()
verify(notificationPanelViewController).expandToNotifications()
shadeController.animateExpandQs()
verify(notificationPanelViewController).expandToQs()
}
}

View File

@@ -108,7 +108,7 @@ public class ExpandableNotificationRowDragControllerTest extends SysuiTestCase {
mRow.doDragCallback(0, 0); mRow.doDragCallback(0, 0);
verify(controller).startDragAndDrop(mRow); verify(controller).startDragAndDrop(mRow);
verify(mShadeController).animateCollapsePanels(eq(0), eq(true), verify(mShadeController).animateCollapseShade(eq(0), eq(true),
eq(false), anyFloat()); eq(false), anyFloat());
verify(mNotificationPanelLogger, times(1)).logNotificationDrag(any()); verify(mNotificationPanelLogger, times(1)).logNotificationDrag(any());
} }

View File

@@ -18,7 +18,6 @@ package com.android.systemui.statusbar.phone;
import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.DEFAULT_DISPLAY;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@@ -153,12 +152,6 @@ public class CentralSurfacesCommandQueueCallbacksTest extends SysuiTestCase {
verify(mCentralSurfaces).updateQsExpansionEnabled(); verify(mCentralSurfaces).updateQsExpansionEnabled();
verify(mShadeController).animateCollapseShade(); verify(mShadeController).animateCollapseShade();
// Trying to open it does nothing.
mSbcqCallbacks.animateExpandNotificationsPanel();
verify(mShadeViewController, never()).expandToNotifications();
mSbcqCallbacks.animateExpandSettingsPanel(null);
verify(mShadeViewController, never()).expand(anyBoolean());
} }
@Test @Test
@@ -171,12 +164,6 @@ public class CentralSurfacesCommandQueueCallbacksTest extends SysuiTestCase {
StatusBarManager.DISABLE2_NONE, false); StatusBarManager.DISABLE2_NONE, false);
verify(mCentralSurfaces).updateQsExpansionEnabled(); verify(mCentralSurfaces).updateQsExpansionEnabled();
verify(mShadeController, never()).animateCollapseShade(); verify(mShadeController, never()).animateCollapseShade();
// Can now be opened.
mSbcqCallbacks.animateExpandNotificationsPanel();
verify(mShadeViewController).expandToNotifications();
mSbcqCallbacks.animateExpandSettingsPanel(null);
verify(mShadeViewController).expandToQs();
} }
@Test @Test

View File

@@ -431,10 +431,12 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
mShadeController = spy(new ShadeControllerImpl( mShadeController = spy(new ShadeControllerImpl(
mCommandQueue, mCommandQueue,
mMainExecutor,
mKeyguardStateController, mKeyguardStateController,
mStatusBarStateController, mStatusBarStateController,
mStatusBarKeyguardViewManager, mStatusBarKeyguardViewManager,
mStatusBarWindowController, mStatusBarWindowController,
mDeviceProvisionedController,
mNotificationShadeWindowController, mNotificationShadeWindowController,
mContext.getSystemService(WindowManager.class), mContext.getSystemService(WindowManager.class),
() -> mAssistManager, () -> mAssistManager,