Merge "Fix the media launch animation on lockscreen" into sc-dev am: f0b8563020

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

Change-Id: I535abc9f9854807b4f0b80f47cd4ce683eca0891
This commit is contained in:
Jordan Demeulenaere
2021-06-14 07:40:07 +00:00
committed by Automerger Merge Worker
2 changed files with 28 additions and 16 deletions

View File

@@ -2846,12 +2846,13 @@ public class StatusBar extends SystemUI implements DemoMode,
@Nullable ActivityLaunchAnimator.Controller animationController) { @Nullable ActivityLaunchAnimator.Controller animationController) {
if (onlyProvisioned && !mDeviceProvisionedController.isDeviceProvisioned()) return; if (onlyProvisioned && !mDeviceProvisionedController.isDeviceProvisioned()) return;
final boolean afterKeyguardGone = mActivityIntentHelper.wouldLaunchResolverActivity( final boolean willLaunchResolverActivity =
intent, mLockscreenUserManager.getCurrentUserId()); mActivityIntentHelper.wouldLaunchResolverActivity(intent,
mLockscreenUserManager.getCurrentUserId());
ActivityLaunchAnimator.Controller animController = ActivityLaunchAnimator.Controller animController =
shouldAnimateLaunch(true /* isActivityIntent */) ? wrapAnimationController( !willLaunchResolverActivity && shouldAnimateLaunch(true /* isActivityIntent */)
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.
@@ -2915,7 +2916,7 @@ public class StatusBar extends SystemUI implements DemoMode,
} }
}; };
executeRunnableDismissingKeyguard(runnable, cancelRunnable, dismissShadeDirectly, executeRunnableDismissingKeyguard(runnable, cancelRunnable, dismissShadeDirectly,
afterKeyguardGone, true /* deferred */); willLaunchResolverActivity, true /* deferred */);
} }
@Nullable @Nullable
@@ -4617,9 +4618,11 @@ 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
* instance to run animations on the keyguard before hiding it.
*/ */
private void executeActionDismissingKeyguard(Runnable action, boolean afterKeyguardGone, private void executeActionDismissingKeyguard(Runnable action, boolean afterKeyguardGone,
boolean collapsePanel) { boolean collapsePanel, boolean deferKeyguardDismiss) {
if (!mDeviceProvisionedController.isDeviceProvisioned()) return; if (!mDeviceProvisionedController.isDeviceProvisioned()) return;
dismissKeyguardThenExecute(() -> { dismissKeyguardThenExecute(() -> {
@@ -4635,8 +4638,7 @@ public class StatusBar extends SystemUI implements DemoMode,
action.run(); action.run();
}).start(); }).start();
boolean deferred = collapsePanel ? mShadeController.collapsePanel() : false; return collapsePanel ? mShadeController.collapsePanel() : deferKeyguardDismiss;
return deferred;
}, afterKeyguardGone); }, afterKeyguardGone);
} }
@@ -4669,12 +4671,19 @@ public class StatusBar extends SystemUI implements DemoMode,
public void startPendingIntentDismissingKeyguard( public void startPendingIntentDismissingKeyguard(
final PendingIntent intent, @Nullable final Runnable intentSentUiThreadCallback, final PendingIntent intent, @Nullable final Runnable intentSentUiThreadCallback,
@Nullable ActivityLaunchAnimator.Controller animationController) { @Nullable ActivityLaunchAnimator.Controller animationController) {
final boolean afterKeyguardGone = intent.isActivity() final boolean willLaunchResolverActivity = intent.isActivity()
&& mActivityIntentHelper.wouldLaunchResolverActivity(intent.getIntent(), && mActivityIntentHelper.wouldLaunchResolverActivity(intent.getIntent(),
mLockscreenUserManager.getCurrentUserId()); mLockscreenUserManager.getCurrentUserId());
boolean collapse = animationController == null; boolean animate = !willLaunchResolverActivity
boolean animate = shouldAnimateLaunch(intent.isActivity()); && animationController != null
&& shouldAnimateLaunch(intent.isActivity());
// 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) collapsing
// the shade and hiding the keyguard once it is done.
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 +4712,7 @@ public class StatusBar extends SystemUI implements DemoMode,
if (intentSentUiThreadCallback != null) { if (intentSentUiThreadCallback != null) {
postOnUiThread(intentSentUiThreadCallback); postOnUiThread(intentSentUiThreadCallback);
} }
}, afterKeyguardGone, collapse); }, willLaunchResolverActivity, collapse, deferKeyguardDismiss);
} }
private void postOnUiThread(Runnable runnable) { private void postOnUiThread(Runnable runnable) {

View File

@@ -252,10 +252,11 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit
} }
boolean isActivityIntent = intent != null && intent.isActivity() && !isBubble; boolean isActivityIntent = intent != null && intent.isActivity() && !isBubble;
final boolean afterKeyguardGone = isActivityIntent final boolean willLaunchResolverActivity = isActivityIntent
&& mActivityIntentHelper.wouldLaunchResolverActivity(intent.getIntent(), && mActivityIntentHelper.wouldLaunchResolverActivity(intent.getIntent(),
mLockscreenUserManager.getCurrentUserId()); mLockscreenUserManager.getCurrentUserId());
final boolean animate = mStatusBar.shouldAnimateLaunch(isActivityIntent); final boolean animate = !willLaunchResolverActivity
&& mStatusBar.shouldAnimateLaunch(isActivityIntent);
boolean showOverLockscreen = mKeyguardStateController.isShowing() && intent != null boolean showOverLockscreen = mKeyguardStateController.isShowing() && intent != null
&& mActivityIntentHelper.wouldShowOverLockscreen(intent.getIntent(), && mActivityIntentHelper.wouldShowOverLockscreen(intent.getIntent(),
mLockscreenUserManager.getCurrentUserId()); mLockscreenUserManager.getCurrentUserId());
@@ -268,7 +269,7 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit
postKeyguardAction.onDismiss(); postKeyguardAction.onDismiss();
} else { } else {
mActivityStarter.dismissKeyguardThenExecute( mActivityStarter.dismissKeyguardThenExecute(
postKeyguardAction, null /* cancel */, afterKeyguardGone); postKeyguardAction, null /* cancel */, willLaunchResolverActivity);
} }
} }
@@ -296,7 +297,9 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit
} else { } else {
runnable.run(); runnable.run();
} }
return !mNotificationPanel.isFullyCollapsed();
// Always defer the keyguard dismiss when animating.
return animate || !mNotificationPanel.isFullyCollapsed();
} }
private void handleNotificationClickAfterPanelCollapsed( private void handleNotificationClickAfterPanelCollapsed(