Merge changes I4dae426c,I3e45ca52,I46879ef8,I81cf31fe into sc-dev

* changes:
  Enable remote animation for keyguard going away transition.
  Continue to dismiss keyguard when the remote animation is cancelled.
  Stop animating wallpaper and non-app windows in WM
  Extend property to enable remote animation for keyguard.
This commit is contained in:
Issei Suzuki
2021-06-14 06:43:39 +00:00
committed by Android (Google) Code Review
9 changed files with 84 additions and 34 deletions

View File

@@ -51,6 +51,7 @@ import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardService; import com.android.internal.policy.IKeyguardService;
import com.android.internal.policy.IKeyguardStateCallback; import com.android.internal.policy.IKeyguardStateCallback;
import com.android.systemui.SystemUIApplication; import com.android.systemui.SystemUIApplication;
import com.android.wm.shell.transition.Transitions;
import javax.inject.Inject; import javax.inject.Inject;
@@ -62,16 +63,29 @@ public class KeyguardService extends Service {
* Run Keyguard animation as remote animation in System UI instead of local animation in * Run Keyguard animation as remote animation in System UI instead of local animation in
* the server process. * the server process.
* *
* 0: Runs all keyguard animation as local animation
* 1: Only runs keyguard going away animation as remote animation
* 2: Runs all keyguard animation as remote animation
*
* Note: Must be consistent with WindowManagerService. * Note: Must be consistent with WindowManagerService.
*/ */
private static final String ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY = private static final String ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY =
"persist.wm.enable_remote_keyguard_animation"; "persist.wm.enable_remote_keyguard_animation";
private static final int sEnableRemoteKeyguardAnimation =
SystemProperties.getInt(ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY, 1);
/** /**
* @see #ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY * @see #ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY
*/ */
public static boolean sEnableRemoteKeyguardAnimation = public static boolean sEnableRemoteKeyguardGoingAwayAnimation =
SystemProperties.getBoolean(ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY, false); !Transitions.ENABLE_SHELL_TRANSITIONS && sEnableRemoteKeyguardAnimation >= 1;
/**
* @see #ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY
*/
public static boolean sEnableRemoteKeyguardOccludeAnimation =
!Transitions.ENABLE_SHELL_TRANSITIONS && sEnableRemoteKeyguardAnimation >= 2;
private final KeyguardViewMediator mKeyguardViewMediator; private final KeyguardViewMediator mKeyguardViewMediator;
private final KeyguardLifecyclesDispatcher mKeyguardLifecyclesDispatcher; private final KeyguardLifecyclesDispatcher mKeyguardLifecyclesDispatcher;
@@ -83,20 +97,22 @@ public class KeyguardService extends Service {
mKeyguardViewMediator = keyguardViewMediator; mKeyguardViewMediator = keyguardViewMediator;
mKeyguardLifecyclesDispatcher = keyguardLifecyclesDispatcher; mKeyguardLifecyclesDispatcher = keyguardLifecyclesDispatcher;
if (sEnableRemoteKeyguardAnimation) { RemoteAnimationDefinition definition = new RemoteAnimationDefinition();
RemoteAnimationDefinition definition = new RemoteAnimationDefinition(); if (sEnableRemoteKeyguardGoingAwayAnimation) {
final RemoteAnimationAdapter exitAnimationAdapter = final RemoteAnimationAdapter exitAnimationAdapter =
new RemoteAnimationAdapter(mExitAnimationRunner, 0, 0); new RemoteAnimationAdapter(mExitAnimationRunner, 0, 0);
definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_GOING_AWAY, exitAnimationAdapter); definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_GOING_AWAY, exitAnimationAdapter);
definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER, definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER,
exitAnimationAdapter); exitAnimationAdapter);
}
if (sEnableRemoteKeyguardOccludeAnimation) {
final RemoteAnimationAdapter occludeAnimationAdapter = final RemoteAnimationAdapter occludeAnimationAdapter =
new RemoteAnimationAdapter(mOccludeAnimationRunner, 0, 0); new RemoteAnimationAdapter(mOccludeAnimationRunner, 0, 0);
definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_OCCLUDE, occludeAnimationAdapter); definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_OCCLUDE, occludeAnimationAdapter);
definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_UNOCCLUDE, occludeAnimationAdapter); definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_UNOCCLUDE, occludeAnimationAdapter);
ActivityTaskManager.getInstance().registerRemoteAnimationsForDisplay(
DEFAULT_DISPLAY, definition);
} }
ActivityTaskManager.getInstance().registerRemoteAnimationsForDisplay(
DEFAULT_DISPLAY, definition);
} }
@Override @Override

View File

@@ -162,7 +162,8 @@ class KeyguardUnlockAnimationController @Inject constructor(
// If the surface alpha is 0f, it's no longer visible so we can safely be done with // If the surface alpha is 0f, it's no longer visible so we can safely be done with
// the animation. // the animation.
if (surfaceBehindAlpha == 0f) { if (surfaceBehindAlpha == 0f) {
keyguardViewMediator.get().finishSurfaceBehindRemoteAnimation() keyguardViewMediator.get().finishSurfaceBehindRemoteAnimation(
false /* cancelled */)
} }
} }
}) })
@@ -175,7 +176,8 @@ class KeyguardUnlockAnimationController @Inject constructor(
} }
surfaceBehindEntryAnimator.addListener(object : AnimatorListenerAdapter() { surfaceBehindEntryAnimator.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) { override fun onAnimationEnd(animation: Animator) {
keyguardViewMediator.get().onKeyguardExitRemoteAnimationFinished() keyguardViewMediator.get().onKeyguardExitRemoteAnimationFinished(
false /* cancelled */)
} }
}) })
@@ -317,7 +319,7 @@ class KeyguardUnlockAnimationController @Inject constructor(
} }
override fun onKeyguardDismissAmountChanged() { override fun onKeyguardDismissAmountChanged() {
if (!KeyguardService.sEnableRemoteKeyguardAnimation) { if (!KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation) {
return return
} }
@@ -370,7 +372,7 @@ class KeyguardUnlockAnimationController @Inject constructor(
} else if (keyguardViewMediator.get() } else if (keyguardViewMediator.get()
.isAnimatingBetweenKeyguardAndSurfaceBehindOrWillBe && .isAnimatingBetweenKeyguardAndSurfaceBehindOrWillBe &&
reachedHideKeyguardThreshold) { reachedHideKeyguardThreshold) {
keyguardViewMediator.get().onKeyguardExitRemoteAnimationFinished() keyguardViewMediator.get().onKeyguardExitRemoteAnimationFinished(false /* cancelled */)
} }
} }

View File

@@ -2180,7 +2180,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
IRemoteAnimationRunner runner = mKeyguardExitAnimationRunner; IRemoteAnimationRunner runner = mKeyguardExitAnimationRunner;
mKeyguardExitAnimationRunner = null; mKeyguardExitAnimationRunner = null;
if (KeyguardService.sEnableRemoteKeyguardAnimation && runner != null if (KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation && runner != null
&& finishedCallback != null) { && finishedCallback != null) {
// Wrap finishedCallback to clean up the keyguard state once the animation is done. // Wrap finishedCallback to clean up the keyguard state once the animation is done.
IRemoteAnimationFinishedCallback callback = IRemoteAnimationFinishedCallback callback =
@@ -2211,7 +2211,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
// When remaining on the shade, there's no need to do a fancy remote animation, // When remaining on the shade, there's no need to do a fancy remote animation,
// it will dismiss the panel in that case. // it will dismiss the panel in that case.
} else if (KeyguardService.sEnableRemoteKeyguardAnimation } else if (KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation
&& !mStatusBarStateController.leaveOpenOnKeyguardHide() && !mStatusBarStateController.leaveOpenOnKeyguardHide()
&& apps != null && apps.length > 0) { && apps != null && apps.length > 0) {
mSurfaceBehindRemoteAnimationFinishedCallback = finishedCallback; mSurfaceBehindRemoteAnimationFinishedCallback = finishedCallback;
@@ -2315,15 +2315,15 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
} }
/** /**
* Called if the keyguard exit animation has been cancelled and we should return to the * Called if the keyguard exit animation has been cancelled and we should dismiss to the
* keyguard. * keyguard.
* *
* This can happen due to the system cancelling the RemoteAnimation (due to a timeout), or the * This can happen due to the system cancelling the RemoteAnimation (due to a timeout, a new
* user cancelling the unlock swipe gesture. * app transition before finishing the current RemoteAnimation).
*/ */
private void handleCancelKeyguardExitAnimation() { private void handleCancelKeyguardExitAnimation() {
hideSurfaceBehindKeyguard(); showSurfaceBehindKeyguard();
mKeyguardUnlockAnimationControllerLazy.get().notifyCancelKeyguardExitAnimation(); onKeyguardExitRemoteAnimationFinished(true /* cancelled */);
} }
/** /**
@@ -2332,8 +2332,10 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
* This will call {@link #mSurfaceBehindRemoteAnimationFinishedCallback} to let WM know that * This will call {@link #mSurfaceBehindRemoteAnimationFinishedCallback} to let WM know that
* we're done with the RemoteAnimation, actually hide the keyguard, and clean up state related * we're done with the RemoteAnimation, actually hide the keyguard, and clean up state related
* to the keyguard exit animation. * to the keyguard exit animation.
*
* @param cancelled {@code true} if the animation was cancelled before it finishes.
*/ */
public void onKeyguardExitRemoteAnimationFinished() { public void onKeyguardExitRemoteAnimationFinished(boolean cancelled) {
if (!mSurfaceBehindRemoteAnimationRunning && !mSurfaceBehindRemoteAnimationRequested) { if (!mSurfaceBehindRemoteAnimationRunning && !mSurfaceBehindRemoteAnimationRequested) {
return; return;
} }
@@ -2347,7 +2349,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
mKeyguardUnlockAnimationControllerLazy.get().hideKeyguardViewAfterRemoteAnimation(); mKeyguardUnlockAnimationControllerLazy.get().hideKeyguardViewAfterRemoteAnimation();
} }
finishSurfaceBehindRemoteAnimation(); finishSurfaceBehindRemoteAnimation(cancelled);
mSurfaceBehindRemoteAnimationRequested = false; mSurfaceBehindRemoteAnimationRequested = false;
mKeyguardUnlockAnimationControllerLazy.get().notifyFinishedKeyguardExitAnimation(); mKeyguardUnlockAnimationControllerLazy.get().notifyFinishedKeyguardExitAnimation();
InteractionJankMonitor.getInstance().end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION); InteractionJankMonitor.getInstance().end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
@@ -2389,12 +2391,14 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
} }
/** If it's running, finishes the RemoteAnimation on the surface behind the keyguard. */ /** If it's running, finishes the RemoteAnimation on the surface behind the keyguard. */
public void finishSurfaceBehindRemoteAnimation() { public void finishSurfaceBehindRemoteAnimation(boolean cancelled) {
mSurfaceBehindRemoteAnimationRunning = false; mSurfaceBehindRemoteAnimationRunning = false;
if (mSurfaceBehindRemoteAnimationFinishedCallback != null) { if (mSurfaceBehindRemoteAnimationFinishedCallback != null) {
try { try {
mSurfaceBehindRemoteAnimationFinishedCallback.onAnimationFinished(); if (!cancelled) {
mSurfaceBehindRemoteAnimationFinishedCallback.onAnimationFinished();
}
mSurfaceBehindRemoteAnimationFinishedCallback = null; mSurfaceBehindRemoteAnimationFinishedCallback = null;
} catch (RemoteException e) { } catch (RemoteException e) {
e.printStackTrace(); e.printStackTrace();
@@ -2638,10 +2642,10 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
} }
/** /**
* Cancel the keyguard exit animation, usually because we were swiping to unlock and the swipe * Cancel the keyguard exit animation, usually because we were swiping to unlock but WM starts
* gesture was cancelled. * a new remote animation before finishing the keyguard exit animation.
* *
* This will re-show the keyguard and animate out the app/launcher surface behind the keyguard. * This will dismiss the keyguard.
*/ */
public void cancelKeyguardExitAnimation() { public void cancelKeyguardExitAnimation() {
Trace.beginSection("KeyguardViewMediator#cancelKeyguardExitAnimation"); Trace.beginSection("KeyguardViewMediator#cancelKeyguardExitAnimation");

View File

@@ -2101,7 +2101,7 @@ public class StatusBar extends SystemUI implements DemoMode,
// launches as they can break the animation. // launches as they can break the animation.
// TODO(b/184121838): Support non activity launches on the lockscreen. // TODO(b/184121838): Support non activity launches on the lockscreen.
return isActivityIntent return isActivityIntent
&& KeyguardService.sEnableRemoteKeyguardAnimation && KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation
&& mKeyguardStateController.canDismissLockScreen(); && mKeyguardStateController.canDismissLockScreen();
} }

View File

@@ -3051,7 +3051,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private int handleStartTransitionForKeyguardLw(boolean keyguardGoingAway, long duration) { private int handleStartTransitionForKeyguardLw(boolean keyguardGoingAway, long duration) {
final int res = applyKeyguardOcclusionChange(); final int res = applyKeyguardOcclusionChange();
if (res != 0) return res; if (res != 0) return res;
if (!WindowManagerService.sEnableRemoteKeyguardAnimation && keyguardGoingAway) { if (!WindowManagerService.sEnableRemoteKeyguardGoingAwayAnimation && keyguardGoingAway) {
if (DEBUG_KEYGUARD) Slog.d(TAG, "Starting keyguard exit animation"); if (DEBUG_KEYGUARD) Slog.d(TAG, "Starting keyguard exit animation");
startKeyguardExitAnimation(SystemClock.uptimeMillis(), duration); startKeyguardExitAnimation(SystemClock.uptimeMillis(), duration);
} }

View File

@@ -264,7 +264,8 @@ public class KeyguardServiceDelegate {
*/ */
@Deprecated @Deprecated
public void setOccluded(boolean isOccluded, boolean animate) { public void setOccluded(boolean isOccluded, boolean animate) {
if (!WindowManagerService.sEnableRemoteKeyguardAnimation && mKeyguardService != null) { if (!WindowManagerService.sEnableRemoteKeyguardOccludeAnimation
&& mKeyguardService != null) {
if (DEBUG) Log.v(TAG, "setOccluded(" + isOccluded + ") animate=" + animate); if (DEBUG) Log.v(TAG, "setOccluded(" + isOccluded + ") animate=" + animate);
mKeyguardService.setOccluded(isOccluded, animate); mKeyguardService.setOccluded(isOccluded, animate);
} }
@@ -405,7 +406,8 @@ public class KeyguardServiceDelegate {
} }
public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) { public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) {
if (!WindowManagerService.sEnableRemoteKeyguardAnimation && mKeyguardService != null) { if (!WindowManagerService.sEnableRemoteKeyguardGoingAwayAnimation
&& mKeyguardService != null) {
mKeyguardService.startKeyguardExitAnimation(startTime, fadeoutDuration); mKeyguardService.startKeyguardExitAnimation(startTime, fadeoutDuration);
} }
} }

View File

@@ -800,7 +800,8 @@ public class AppTransitionController {
} }
private void handleNonAppWindowsInTransition(@TransitionOldType int transit, int flags) { private void handleNonAppWindowsInTransition(@TransitionOldType int transit, int flags) {
if (transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY) { if (transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY
&& !WindowManagerService.sEnableRemoteKeyguardGoingAwayAnimation) {
if ((flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER) != 0 if ((flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER) != 0
&& (flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION) == 0 && (flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION) == 0
&& (flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION) == 0) { && (flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION) == 0) {
@@ -812,8 +813,9 @@ public class AppTransitionController {
} }
} }
} }
if (transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY if ((transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY
|| transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER) { || transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER)
&& !WindowManagerService.sEnableRemoteKeyguardGoingAwayAnimation) {
mDisplayContent.startKeyguardExitOnNonAppWindows( mDisplayContent.startKeyguardExitOnNonAppWindows(
transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER, transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER,
(flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE) != 0, (flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE) != 0,

View File

@@ -401,7 +401,8 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
if (dc == null) { if (dc == null) {
return; return;
} }
if (transit == TRANSIT_KEYGUARD_GOING_AWAY) { if (transit == TRANSIT_KEYGUARD_GOING_AWAY
&& !WindowManagerService.sEnableRemoteKeyguardGoingAwayAnimation) {
if ((flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER) != 0 if ((flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER) != 0
&& (flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION) == 0 && (flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION) == 0
&& (flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION) == 0) { && (flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION) == 0) {

View File

@@ -421,19 +421,42 @@ public class WindowManagerService extends IWindowManager.Stub
static boolean sDisableCustomTaskAnimationProperty = static boolean sDisableCustomTaskAnimationProperty =
SystemProperties.getBoolean(DISABLE_CUSTOM_TASK_ANIMATION_PROPERTY, true); SystemProperties.getBoolean(DISABLE_CUSTOM_TASK_ANIMATION_PROPERTY, true);
/**
* Use WMShell for app transition.
*/
public static final String ENABLE_SHELL_TRANSITIONS = "persist.debug.shell_transit";
/**
* @see #ENABLE_SHELL_TRANSITIONS
*/
public static final boolean sEnableShellTransitions =
SystemProperties.getBoolean(ENABLE_SHELL_TRANSITIONS, false);
/** /**
* Run Keyguard animation as remote animation in System UI instead of local animation in * Run Keyguard animation as remote animation in System UI instead of local animation in
* the server process. * the server process.
*
* 0: Runs all keyguard animation as local animation
* 1: Only runs keyguard going away animation as remote animation
* 2: Runs all keyguard animation as remote animation
*/ */
private static final String ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY = private static final String ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY =
"persist.wm.enable_remote_keyguard_animation"; "persist.wm.enable_remote_keyguard_animation";
private static final int sEnableRemoteKeyguardAnimation =
SystemProperties.getInt(ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY, 1);
/** /**
* @see #ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY * @see #ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY
*/ */
public static boolean sEnableRemoteKeyguardAnimation = public static final boolean sEnableRemoteKeyguardGoingAwayAnimation = !sEnableShellTransitions
SystemProperties.getBoolean(ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY, false); && sEnableRemoteKeyguardAnimation >= 1;
/**
* @see #ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY
*/
public static final boolean sEnableRemoteKeyguardOccludeAnimation = !sEnableShellTransitions
&& sEnableRemoteKeyguardAnimation >= 2;
/** /**
* Allows a fullscreen windowing mode activity to launch in its desired orientation directly * Allows a fullscreen windowing mode activity to launch in its desired orientation directly