Merge "Fix bouncer to launcher/app animation" into sc-dev

This commit is contained in:
Jordan Demeulenaere
2021-06-16 12:13:43 +00:00
committed by Android (Google) Code Review
4 changed files with 167 additions and 96 deletions

View File

@@ -92,5 +92,12 @@ public interface ActivityStarter {
* *after* returning to start hiding the keyguard. * *after* returning to start hiding the keyguard.
*/ */
boolean onDismiss(); boolean onDismiss();
/**
* Whether running this action when we are locked will start an animation on the keyguard.
*/
default boolean willRunAnimationOnKeyguard() {
return false;
}
} }
} }

View File

@@ -2841,9 +2841,11 @@ public class StatusBar extends SystemUI implements DemoMode,
mActivityIntentHelper.wouldLaunchResolverActivity(intent, mActivityIntentHelper.wouldLaunchResolverActivity(intent,
mLockscreenUserManager.getCurrentUserId()); mLockscreenUserManager.getCurrentUserId());
boolean animate =
animationController != null && !willLaunchResolverActivity && shouldAnimateLaunch(
true /* isActivityIntent */);
ActivityLaunchAnimator.Controller animController = ActivityLaunchAnimator.Controller animController =
!willLaunchResolverActivity && shouldAnimateLaunch(true /* isActivityIntent */) animate ? wrapAnimationController(animationController, dismissShade) : null;
? wrapAnimationController(animationController, dismissShade) : null;
// If we animate, we will dismiss the shade only once the animation is done. This is taken // If we animate, we will dismiss the shade only once the animation is done. This is taken
// care of by the StatusBarLaunchAnimationController. // care of by the StatusBarLaunchAnimationController.
@@ -2857,7 +2859,7 @@ public class StatusBar extends SystemUI implements DemoMode,
int[] result = new int[]{ActivityManager.START_CANCELED}; int[] result = new int[]{ActivityManager.START_CANCELED};
mActivityLaunchAnimator.startIntentWithAnimation(animController, mActivityLaunchAnimator.startIntentWithAnimation(animController,
true /* animate */, intent.getPackage(), (adapter) -> { animate, intent.getPackage(), (adapter) -> {
ActivityOptions options = new ActivityOptions( ActivityOptions options = new ActivityOptions(
getActivityOptions(mDisplayId, adapter)); getActivityOptions(mDisplayId, adapter));
options.setDisallowEnterPictureInPictureWhileLaunching( options.setDisallowEnterPictureInPictureWhileLaunching(
@@ -2907,16 +2909,12 @@ public class StatusBar extends SystemUI implements DemoMode,
} }
}; };
executeRunnableDismissingKeyguard(runnable, cancelRunnable, dismissShadeDirectly, executeRunnableDismissingKeyguard(runnable, cancelRunnable, dismissShadeDirectly,
willLaunchResolverActivity, true /* deferred */); willLaunchResolverActivity, true /* deferred */, animate);
} }
@Nullable @Nullable
private ActivityLaunchAnimator.Controller wrapAnimationController( private ActivityLaunchAnimator.Controller wrapAnimationController(
@Nullable ActivityLaunchAnimator.Controller animationController, boolean dismissShade) { ActivityLaunchAnimator.Controller animationController, boolean dismissShade) {
if (animationController == null) {
return null;
}
View rootView = animationController.getLaunchContainer().getRootView(); View rootView = animationController.getLaunchContainer().getRootView();
if (rootView == mSuperStatusBarViewFactory.getStatusBarWindowView()) { if (rootView == mSuperStatusBarViewFactory.getStatusBarWindowView()) {
// We are animating a view in the status bar. We have to make sure that the status bar // We are animating a view in the status bar. We have to make sure that the status bar
@@ -2959,7 +2957,19 @@ public class StatusBar extends SystemUI implements DemoMode,
final boolean dismissShade, final boolean dismissShade,
final boolean afterKeyguardGone, final boolean afterKeyguardGone,
final boolean deferred) { final boolean deferred) {
dismissKeyguardThenExecute(() -> { executeRunnableDismissingKeyguard(runnable, cancelAction, dismissShade, afterKeyguardGone,
deferred, false /* willAnimateOnKeyguard */);
}
public void executeRunnableDismissingKeyguard(final Runnable runnable,
final Runnable cancelAction,
final boolean dismissShade,
final boolean afterKeyguardGone,
final boolean deferred,
final boolean willAnimateOnKeyguard) {
OnDismissAction onDismissAction = new OnDismissAction() {
@Override
public boolean onDismiss() {
if (runnable != null) { if (runnable != null) {
if (mStatusBarKeyguardViewManager.isShowing() if (mStatusBarKeyguardViewManager.isShowing()
&& mStatusBarKeyguardViewManager.isOccluded()) { && mStatusBarKeyguardViewManager.isOccluded()) {
@@ -2970,23 +2980,33 @@ public class StatusBar extends SystemUI implements DemoMode,
} }
if (dismissShade) { if (dismissShade) {
if (mExpandedVisible && !mBouncerShowing) { if (mExpandedVisible && !mBouncerShowing) {
mShadeController.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, mShadeController.animateCollapsePanels(
CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL,
true /* force */, true /* delayed*/); true /* force */, true /* delayed*/);
} else { } else {
// Do it after DismissAction has been processed to conserve the needed ordering. // Do it after DismissAction has been processed to conserve the needed
// ordering.
mHandler.post(mShadeController::runPostCollapseRunnables); mHandler.post(mShadeController::runPostCollapseRunnables);
} }
} else if (isInLaunchTransition() } else if (StatusBar.this.isInLaunchTransition()
&& mNotificationPanelViewController.isLaunchTransitionFinished()) { && mNotificationPanelViewController.isLaunchTransitionFinished()) {
// We are not dismissing the shade, but the launch transition is already finished, // We are not dismissing the shade, but the launch transition is already
// finished,
// so nobody will call readyForKeyguardDone anymore. Post it such that // so nobody will call readyForKeyguardDone anymore. Post it such that
// keyguardDonePending gets called first. // keyguardDonePending gets called first.
mHandler.post(mStatusBarKeyguardViewManager::readyForKeyguardDone); mHandler.post(mStatusBarKeyguardViewManager::readyForKeyguardDone);
} }
return deferred; return deferred;
}, cancelAction, afterKeyguardGone); }
@Override
public boolean willRunAnimationOnKeyguard() {
return willAnimateOnKeyguard;
}
};
dismissKeyguardThenExecute(onDismissAction, cancelAction, afterKeyguardGone);
} }
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@@ -4609,14 +4629,16 @@ public class StatusBar extends SystemUI implements DemoMode,
* *
* @param action The action to execute after dismissing the keyguard. * @param action The action to execute after dismissing the keyguard.
* @param collapsePanel Whether we should collapse the panel after dismissing the keyguard. * @param collapsePanel Whether we should collapse the panel after dismissing the keyguard.
* @param deferKeyguardDismiss Whether we should defer the keyguard actual dismissal, for * @param willAnimateOnKeyguard Whether {@param action} will run an animation on the keyguard if
* instance to run animations on the keyguard before hiding it. * we are locked.
*/ */
private void executeActionDismissingKeyguard(Runnable action, boolean afterKeyguardGone, private void executeActionDismissingKeyguard(Runnable action, boolean afterKeyguardGone,
boolean collapsePanel, boolean deferKeyguardDismiss) { boolean collapsePanel, boolean willAnimateOnKeyguard) {
if (!mDeviceProvisionedController.isDeviceProvisioned()) return; if (!mDeviceProvisionedController.isDeviceProvisioned()) return;
dismissKeyguardThenExecute(() -> { OnDismissAction onDismissAction = new OnDismissAction() {
@Override
public boolean onDismiss() {
new Thread(() -> { new Thread(() -> {
try { try {
// The intent we are sending is for the application, which // The intent we are sending is for the application, which
@@ -4629,8 +4651,15 @@ public class StatusBar extends SystemUI implements DemoMode,
action.run(); action.run();
}).start(); }).start();
return collapsePanel ? mShadeController.collapsePanel() : deferKeyguardDismiss; return collapsePanel ? mShadeController.collapsePanel() : willAnimateOnKeyguard;
}, afterKeyguardGone); }
@Override
public boolean willRunAnimationOnKeyguard() {
return willAnimateOnKeyguard;
}
};
dismissKeyguardThenExecute(onDismissAction, afterKeyguardGone);
} }
@Override @Override
@@ -4674,7 +4703,6 @@ public class StatusBar extends SystemUI implements DemoMode,
// the animation on the keyguard). The animation will take care of (instantly) collapsing // the animation on the keyguard). The animation will take care of (instantly) collapsing
// the shade and hiding the keyguard once it is done. // the shade and hiding the keyguard once it is done.
boolean collapse = !animate; boolean collapse = !animate;
boolean deferKeyguardDismiss = animate;
executeActionDismissingKeyguard(() -> { executeActionDismissingKeyguard(() -> {
try { try {
// We wrap animationCallback with a StatusBarLaunchAnimatorController so that the // We wrap animationCallback with a StatusBarLaunchAnimatorController so that the
@@ -4703,7 +4731,7 @@ public class StatusBar extends SystemUI implements DemoMode,
if (intentSentUiThreadCallback != null) { if (intentSentUiThreadCallback != null) {
postOnUiThread(intentSentUiThreadCallback); postOnUiThread(intentSentUiThreadCallback);
} }
}, willLaunchResolverActivity, collapse, deferKeyguardDismiss); }, willLaunchResolverActivity, collapse, animate);
} }
private void postOnUiThread(Runnable runnable) { private void postOnUiThread(Runnable runnable) {

View File

@@ -192,6 +192,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
private OnDismissAction mAfterKeyguardGoneAction; private OnDismissAction mAfterKeyguardGoneAction;
private Runnable mKeyguardGoneCancelAction; private Runnable mKeyguardGoneCancelAction;
private boolean mDismissActionWillAnimateOnKeyguard;
private final ArrayList<Runnable> mAfterKeyguardGoneRunnables = new ArrayList<>(); private final ArrayList<Runnable> mAfterKeyguardGoneRunnables = new ArrayList<>();
// Dismiss action to be launched when we stop dozing or the keyguard is gone. // Dismiss action to be launched when we stop dozing or the keyguard is gone.
@@ -447,6 +448,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
mAfterKeyguardGoneAction = r; mAfterKeyguardGoneAction = r;
mKeyguardGoneCancelAction = cancelAction; mKeyguardGoneCancelAction = cancelAction;
mDismissActionWillAnimateOnKeyguard = r != null && r.willRunAnimationOnKeyguard();
// If there is an an alternate auth interceptor (like the UDFPS), show that one instead // If there is an an alternate auth interceptor (like the UDFPS), show that one instead
// of the bouncer. // of the bouncer.
@@ -625,9 +627,12 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
mBouncer.startPreHideAnimation(finishRunnable); mBouncer.startPreHideAnimation(finishRunnable);
mStatusBar.onBouncerPreHideAnimation(); mStatusBar.onBouncerPreHideAnimation();
// startPreHideAnimation() will change the visibility of the bouncer, so we have to // We update the state (which will show the keyguard) only if an animation will run on
// make sure to update its state. // the keyguard. If there is no animation, we wait before updating the state so that we
// go directly from bouncer to launcher/app.
if (mDismissActionWillAnimateOnKeyguard) {
updateStates(); updateStates();
}
} else if (finishRunnable != null) { } else if (finishRunnable != null) {
finishRunnable.run(); finishRunnable.run();
} }
@@ -798,6 +803,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
mAfterKeyguardGoneAction = null; mAfterKeyguardGoneAction = null;
} }
mKeyguardGoneCancelAction = null; mKeyguardGoneCancelAction = null;
mDismissActionWillAnimateOnKeyguard = false;
for (int i = 0; i < mAfterKeyguardGoneRunnables.size(); i++) { for (int i = 0; i < mAfterKeyguardGoneRunnables.size(); i++) {
mAfterKeyguardGoneRunnables.get(i).run(); mAfterKeyguardGoneRunnables.get(i).run();
} }
@@ -866,6 +872,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
return; // allow bouncer to trigger saved actions return; // allow bouncer to trigger saved actions
} }
mAfterKeyguardGoneAction = null; mAfterKeyguardGoneAction = null;
mDismissActionWillAnimateOnKeyguard = false;
if (mKeyguardGoneCancelAction != null) { if (mKeyguardGoneCancelAction != null) {
mKeyguardGoneCancelAction.run(); mKeyguardGoneCancelAction.run();
mKeyguardGoneCancelAction = null; mKeyguardGoneCancelAction = null;

View File

@@ -260,10 +260,19 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit
boolean showOverLockscreen = mKeyguardStateController.isShowing() && intent != null boolean showOverLockscreen = mKeyguardStateController.isShowing() && intent != null
&& mActivityIntentHelper.wouldShowOverLockscreen(intent.getIntent(), && mActivityIntentHelper.wouldShowOverLockscreen(intent.getIntent(),
mLockscreenUserManager.getCurrentUserId()); mLockscreenUserManager.getCurrentUserId());
ActivityStarter.OnDismissAction postKeyguardAction = ActivityStarter.OnDismissAction postKeyguardAction = new ActivityStarter.OnDismissAction() {
() -> handleNotificationClickAfterKeyguardDismissed( @Override
public boolean onDismiss() {
return handleNotificationClickAfterKeyguardDismissed(
entry, row, controller, intent, entry, row, controller, intent,
isActivityIntent, animate, showOverLockscreen); isActivityIntent, animate, showOverLockscreen);
}
@Override
public boolean willRunAnimationOnKeyguard() {
return animate;
}
};
if (showOverLockscreen) { if (showOverLockscreen) {
mIsCollapsingToShowActivityOverLockscreen = true; mIsCollapsingToShowActivityOverLockscreen = true;
postKeyguardAction.onDismiss(); postKeyguardAction.onDismiss();
@@ -453,7 +462,9 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit
public void startNotificationGutsIntent(final Intent intent, final int appUid, public void startNotificationGutsIntent(final Intent intent, final int appUid,
ExpandableNotificationRow row) { ExpandableNotificationRow row) {
boolean animate = mStatusBar.shouldAnimateLaunch(true /* isActivityIntent */); boolean animate = mStatusBar.shouldAnimateLaunch(true /* isActivityIntent */);
mActivityStarter.dismissKeyguardThenExecute(() -> { ActivityStarter.OnDismissAction onDismissAction = new ActivityStarter.OnDismissAction() {
@Override
public boolean onDismiss() {
AsyncTask.execute(() -> { AsyncTask.execute(() -> {
ActivityLaunchAnimator.Controller animationController = ActivityLaunchAnimator.Controller animationController =
new StatusBarLaunchAnimatorController( new StatusBarLaunchAnimatorController(
@@ -470,13 +481,23 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit
new UserHandle(UserHandle.getUserId(appUid)))); new UserHandle(UserHandle.getUserId(appUid))));
}); });
return true; return true;
}, null, false /* afterKeyguardGone */); }
@Override
public boolean willRunAnimationOnKeyguard() {
return animate;
}
};
mActivityStarter.dismissKeyguardThenExecute(onDismissAction, null,
false /* afterKeyguardGone */);
} }
@Override @Override
public void startHistoryIntent(View view, boolean showHistory) { public void startHistoryIntent(View view, boolean showHistory) {
boolean animate = mStatusBar.shouldAnimateLaunch(true /* isActivityIntent */); boolean animate = mStatusBar.shouldAnimateLaunch(true /* isActivityIntent */);
mActivityStarter.dismissKeyguardThenExecute(() -> { ActivityStarter.OnDismissAction onDismissAction = new ActivityStarter.OnDismissAction() {
@Override
public boolean onDismiss() {
AsyncTask.execute(() -> { AsyncTask.execute(() -> {
Intent intent = showHistory ? new Intent( Intent intent = showHistory ? new Intent(
Settings.ACTION_NOTIFICATION_HISTORY) : new Intent( Settings.ACTION_NOTIFICATION_HISTORY) : new Intent(
@@ -499,7 +520,15 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit
UserHandle.CURRENT)); UserHandle.CURRENT));
}); });
return true; return true;
}, null, false /* afterKeyguardGone */); }
@Override
public boolean willRunAnimationOnKeyguard() {
return animate;
}
};
mActivityStarter.dismissKeyguardThenExecute(onDismissAction, null,
false /* afterKeyguardGone */);
} }
private void removeHunAfterClick(ExpandableNotificationRow row) { private void removeHunAfterClick(ExpandableNotificationRow row) {