Fix the media launch animation on lockscreen

This CL fixes the launch animation of the media player in the lockscreen
(when it is dismissable) and adds some additional checks by:
 - ensuring that we don't animate when the intent we start will launch
   a resolver activity.
 - deferring the keyguard dismissal when we animate so that the keyguard
   removal is driven by the animation.

Bug: 184726377
Test: Click the media player on lockscreen (with no security)
Change-Id: Id9c59adbf085bca9351fc6483ad81b4e68e16ee4
This commit is contained in:
Jordan Demeulenaere
2021-06-10 12:12:26 +02:00
parent 97be319829
commit 8ebdf0736f
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) {
if (onlyProvisioned && !mDeviceProvisionedController.isDeviceProvisioned()) return;
final boolean afterKeyguardGone = mActivityIntentHelper.wouldLaunchResolverActivity(
intent, mLockscreenUserManager.getCurrentUserId());
final boolean willLaunchResolverActivity =
mActivityIntentHelper.wouldLaunchResolverActivity(intent,
mLockscreenUserManager.getCurrentUserId());
ActivityLaunchAnimator.Controller animController =
shouldAnimateLaunch(true /* isActivityIntent */) ? wrapAnimationController(
animationController, dismissShade) : null;
!willLaunchResolverActivity && shouldAnimateLaunch(true /* isActivityIntent */)
? wrapAnimationController(animationController, dismissShade) : null;
// If we animate, we will dismiss the shade only once the animation is done. This is taken
// care of by the StatusBarLaunchAnimationController.
@@ -2915,7 +2916,7 @@ public class StatusBar extends SystemUI implements DemoMode,
}
};
executeRunnableDismissingKeyguard(runnable, cancelRunnable, dismissShadeDirectly,
afterKeyguardGone, true /* deferred */);
willLaunchResolverActivity, true /* deferred */);
}
@Nullable
@@ -4620,9 +4621,11 @@ public class StatusBar extends SystemUI implements DemoMode,
*
* @param action The action to execute 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,
boolean collapsePanel) {
boolean collapsePanel, boolean deferKeyguardDismiss) {
if (!mDeviceProvisionedController.isDeviceProvisioned()) return;
dismissKeyguardThenExecute(() -> {
@@ -4638,8 +4641,7 @@ public class StatusBar extends SystemUI implements DemoMode,
action.run();
}).start();
boolean deferred = collapsePanel ? mShadeController.collapsePanel() : false;
return deferred;
return collapsePanel ? mShadeController.collapsePanel() : deferKeyguardDismiss;
}, afterKeyguardGone);
}
@@ -4672,12 +4674,19 @@ public class StatusBar extends SystemUI implements DemoMode,
public void startPendingIntentDismissingKeyguard(
final PendingIntent intent, @Nullable final Runnable intentSentUiThreadCallback,
@Nullable ActivityLaunchAnimator.Controller animationController) {
final boolean afterKeyguardGone = intent.isActivity()
final boolean willLaunchResolverActivity = intent.isActivity()
&& mActivityIntentHelper.wouldLaunchResolverActivity(intent.getIntent(),
mLockscreenUserManager.getCurrentUserId());
boolean collapse = animationController == null;
boolean animate = shouldAnimateLaunch(intent.isActivity());
boolean animate = !willLaunchResolverActivity
&& 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(() -> {
try {
// We wrap animationCallback with a StatusBarLaunchAnimatorController so that the
@@ -4706,7 +4715,7 @@ public class StatusBar extends SystemUI implements DemoMode,
if (intentSentUiThreadCallback != null) {
postOnUiThread(intentSentUiThreadCallback);
}
}, afterKeyguardGone, collapse);
}, willLaunchResolverActivity, collapse, deferKeyguardDismiss);
}
private void postOnUiThread(Runnable runnable) {

View File

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