Merge "Remove flag for keyguard remote animations in SysUI."

This commit is contained in:
Issei Suzuki
2022-08-26 08:13:02 +00:00
committed by Android (Google) Code Review
5 changed files with 85 additions and 150 deletions

View File

@@ -53,7 +53,6 @@ import android.os.IBinder;
import android.os.PowerManager;
import android.os.Process;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.Trace;
import android.util.ArrayMap;
import android.util.Log;
@@ -89,34 +88,6 @@ public class KeyguardService extends Service {
static final String TAG = "KeyguardService";
static final String PERMISSION = android.Manifest.permission.CONTROL_KEYGUARD;
/**
* Run Keyguard animation as remote animation in System UI instead of local animation in
* 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.
*/
private static final String ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY =
"persist.wm.enable_remote_keyguard_animation";
private static final int sEnableRemoteKeyguardAnimation =
SystemProperties.getInt(ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY, 2);
/**
* @see #ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY
*/
public static boolean sEnableRemoteKeyguardGoingAwayAnimation =
sEnableRemoteKeyguardAnimation >= 1;
/**
* @see #ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY
*/
public static boolean sEnableRemoteKeyguardOccludeAnimation =
sEnableRemoteKeyguardAnimation >= 2;
private final KeyguardViewMediator mKeyguardViewMediator;
private final KeyguardLifecyclesDispatcher mKeyguardLifecyclesDispatcher;
private final ShellTransitions mShellTransitions;
@@ -288,97 +259,90 @@ public class KeyguardService extends Service {
if (mShellTransitions == null || !Transitions.ENABLE_SHELL_TRANSITIONS) {
RemoteAnimationDefinition definition = new RemoteAnimationDefinition();
if (sEnableRemoteKeyguardGoingAwayAnimation) {
final RemoteAnimationAdapter exitAnimationAdapter =
new RemoteAnimationAdapter(mExitAnimationRunner, 0, 0);
definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_GOING_AWAY,
exitAnimationAdapter);
definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER,
exitAnimationAdapter);
}
if (sEnableRemoteKeyguardOccludeAnimation) {
final RemoteAnimationAdapter occludeAnimationAdapter =
new RemoteAnimationAdapter(
mKeyguardViewMediator.getOccludeAnimationRunner(), 0, 0);
definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_OCCLUDE,
occludeAnimationAdapter);
final RemoteAnimationAdapter exitAnimationAdapter =
new RemoteAnimationAdapter(mExitAnimationRunner, 0, 0);
definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_GOING_AWAY,
exitAnimationAdapter);
definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER,
exitAnimationAdapter);
final RemoteAnimationAdapter occludeAnimationAdapter =
new RemoteAnimationAdapter(
mKeyguardViewMediator.getOccludeAnimationRunner(), 0, 0);
definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_OCCLUDE,
occludeAnimationAdapter);
final RemoteAnimationAdapter unoccludeAnimationAdapter =
new RemoteAnimationAdapter(
mKeyguardViewMediator.getUnoccludeAnimationRunner(), 0, 0);
definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_UNOCCLUDE,
unoccludeAnimationAdapter);
}
final RemoteAnimationAdapter unoccludeAnimationAdapter =
new RemoteAnimationAdapter(
mKeyguardViewMediator.getUnoccludeAnimationRunner(), 0, 0);
definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_UNOCCLUDE,
unoccludeAnimationAdapter);
ActivityTaskManager.getInstance().registerRemoteAnimationsForDisplay(
DEFAULT_DISPLAY, definition);
return;
}
if (sEnableRemoteKeyguardGoingAwayAnimation) {
Slog.d(TAG, "KeyguardService registerRemote: TRANSIT_KEYGUARD_GOING_AWAY");
TransitionFilter f = new TransitionFilter();
f.mFlags = TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
mShellTransitions.registerRemote(f,
new RemoteTransition(wrap(mExitAnimationRunner), getIApplicationThread()));
}
if (sEnableRemoteKeyguardOccludeAnimation) {
Slog.d(TAG, "KeyguardService registerRemote: TRANSIT_KEYGUARD_(UN)OCCLUDE");
// Register for occluding
final RemoteTransition occludeTransition = new RemoteTransition(
mOccludeAnimation, getIApplicationThread());
TransitionFilter f = new TransitionFilter();
f.mFlags = TRANSIT_FLAG_KEYGUARD_LOCKED;
f.mRequirements = new TransitionFilter.Requirement[]{
new TransitionFilter.Requirement(), new TransitionFilter.Requirement()};
// First require at-least one app showing that occludes.
f.mRequirements[0].mMustBeIndependent = false;
f.mRequirements[0].mFlags = FLAG_OCCLUDES_KEYGUARD;
f.mRequirements[0].mModes = new int[]{TRANSIT_OPEN, TRANSIT_TO_FRONT};
// Then require that we aren't closing any occludes (because this would mean a
// regular task->task or activity->activity animation not involving keyguard).
f.mRequirements[1].mNot = true;
f.mRequirements[1].mMustBeIndependent = false;
f.mRequirements[1].mFlags = FLAG_OCCLUDES_KEYGUARD;
f.mRequirements[1].mModes = new int[]{TRANSIT_CLOSE, TRANSIT_TO_BACK};
mShellTransitions.registerRemote(f, occludeTransition);
Slog.d(TAG, "KeyguardService registerRemote: TRANSIT_KEYGUARD_GOING_AWAY");
TransitionFilter f = new TransitionFilter();
f.mFlags = TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
mShellTransitions.registerRemote(f,
new RemoteTransition(wrap(mExitAnimationRunner), getIApplicationThread()));
// Now register for un-occlude.
final RemoteTransition unoccludeTransition = new RemoteTransition(
mUnoccludeAnimation, getIApplicationThread());
f = new TransitionFilter();
f.mFlags = TRANSIT_FLAG_KEYGUARD_LOCKED;
f.mRequirements = new TransitionFilter.Requirement[]{
new TransitionFilter.Requirement(), new TransitionFilter.Requirement()};
// First require at-least one app going-away (doesn't need occlude flag
// as that is implicit by it having been visible and we don't want to exclude
// cases where we are un-occluding because the app removed its showWhenLocked
// capability at runtime).
f.mRequirements[1].mMustBeIndependent = false;
f.mRequirements[1].mModes = new int[]{TRANSIT_CLOSE, TRANSIT_TO_BACK};
f.mRequirements[1].mMustBeTask = true;
// Then require that we aren't opening any occludes (otherwise we'd remain
// occluded).
f.mRequirements[0].mNot = true;
f.mRequirements[0].mMustBeIndependent = false;
f.mRequirements[0].mFlags = FLAG_OCCLUDES_KEYGUARD;
f.mRequirements[0].mModes = new int[]{TRANSIT_OPEN, TRANSIT_TO_FRONT};
mShellTransitions.registerRemote(f, unoccludeTransition);
Slog.d(TAG, "KeyguardService registerRemote: TRANSIT_KEYGUARD_(UN)OCCLUDE");
// Register for occluding
final RemoteTransition occludeTransition = new RemoteTransition(
mOccludeAnimation, getIApplicationThread());
f = new TransitionFilter();
f.mFlags = TRANSIT_FLAG_KEYGUARD_LOCKED;
f.mRequirements = new TransitionFilter.Requirement[]{
new TransitionFilter.Requirement(), new TransitionFilter.Requirement()};
// First require at-least one app showing that occludes.
f.mRequirements[0].mMustBeIndependent = false;
f.mRequirements[0].mFlags = FLAG_OCCLUDES_KEYGUARD;
f.mRequirements[0].mModes = new int[]{TRANSIT_OPEN, TRANSIT_TO_FRONT};
// Then require that we aren't closing any occludes (because this would mean a
// regular task->task or activity->activity animation not involving keyguard).
f.mRequirements[1].mNot = true;
f.mRequirements[1].mMustBeIndependent = false;
f.mRequirements[1].mFlags = FLAG_OCCLUDES_KEYGUARD;
f.mRequirements[1].mModes = new int[]{TRANSIT_CLOSE, TRANSIT_TO_BACK};
mShellTransitions.registerRemote(f, occludeTransition);
// Register for specific transition type.
// Above filter cannot fulfill all conditions.
// E.g. close top activity while screen off but next activity is occluded, this should
// an occluded transition, but since the activity is invisible, the condition would
// match unoccluded transition.
// But on the contrary, if we add above condition in occluded transition, then when user
// trying to dismiss occluded activity when unlock keyguard, the condition would match
// occluded transition.
f = new TransitionFilter();
f.mTypeSet = new int[]{TRANSIT_KEYGUARD_OCCLUDE};
mShellTransitions.registerRemote(f, occludeTransition);
// Now register for un-occlude.
final RemoteTransition unoccludeTransition = new RemoteTransition(
mUnoccludeAnimation, getIApplicationThread());
f = new TransitionFilter();
f.mFlags = TRANSIT_FLAG_KEYGUARD_LOCKED;
f.mRequirements = new TransitionFilter.Requirement[]{
new TransitionFilter.Requirement(), new TransitionFilter.Requirement()};
// First require at-least one app going-away (doesn't need occlude flag
// as that is implicit by it having been visible and we don't want to exclude
// cases where we are un-occluding because the app removed its showWhenLocked
// capability at runtime).
f.mRequirements[1].mMustBeIndependent = false;
f.mRequirements[1].mModes = new int[]{TRANSIT_CLOSE, TRANSIT_TO_BACK};
f.mRequirements[1].mMustBeTask = true;
// Then require that we aren't opening any occludes (otherwise we'd remain
// occluded).
f.mRequirements[0].mNot = true;
f.mRequirements[0].mMustBeIndependent = false;
f.mRequirements[0].mFlags = FLAG_OCCLUDES_KEYGUARD;
f.mRequirements[0].mModes = new int[]{TRANSIT_OPEN, TRANSIT_TO_FRONT};
mShellTransitions.registerRemote(f, unoccludeTransition);
f = new TransitionFilter();
f.mTypeSet = new int[]{TRANSIT_KEYGUARD_UNOCCLUDE};
mShellTransitions.registerRemote(f, unoccludeTransition);
}
// Register for specific transition type.
// Above filter cannot fulfill all conditions.
// E.g. close top activity while screen off but next activity is occluded, this should
// an occluded transition, but since the activity is invisible, the condition would
// match unoccluded transition.
// But on the contrary, if we add above condition in occluded transition, then when user
// trying to dismiss occluded activity when unlock keyguard, the condition would match
// occluded transition.
f = new TransitionFilter();
f.mTypeSet = new int[]{TRANSIT_KEYGUARD_OCCLUDE};
mShellTransitions.registerRemote(f, occludeTransition);
f = new TransitionFilter();
f.mTypeSet = new int[]{TRANSIT_KEYGUARD_UNOCCLUDE};
mShellTransitions.registerRemote(f, unoccludeTransition);
}
@Override

View File

@@ -484,8 +484,8 @@ class KeyguardUnlockAnimationController @Inject constructor(
// surface behind the keyguard to finish unlocking.
if (keyguardStateController.isFlingingToDismissKeyguard) {
playCannedUnlockAnimation()
} else if (keyguardStateController.isDismissingFromSwipe
&& willUnlockWithInWindowLauncherAnimations) {
} else if (keyguardStateController.isDismissingFromSwipe &&
willUnlockWithInWindowLauncherAnimations) {
// If we're swiping to unlock to the Launcher, and can play in-window animations,
// make the launcher surface fully visible and play the in-window unlock animation
// on the launcher icons. System UI will remain locked, using the swipe-to-unlock
@@ -622,10 +622,6 @@ class KeyguardUnlockAnimationController @Inject constructor(
}
override fun onKeyguardDismissAmountChanged() {
if (!willHandleUnlockAnimation()) {
return
}
if (keyguardViewController.isShowing && !playingCannedUnlockAnimation) {
showOrHideSurfaceIfDismissAmountThresholdsReached()
@@ -685,8 +681,7 @@ class KeyguardUnlockAnimationController @Inject constructor(
*/
private fun finishKeyguardExitRemoteAnimationIfReachThreshold() {
// no-op if keyguard is not showing or animation is not enabled.
if (!KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation ||
!keyguardViewController.isShowing) {
if (!keyguardViewController.isShowing) {
return
}
@@ -727,8 +722,8 @@ class KeyguardUnlockAnimationController @Inject constructor(
// If we're dismissing via swipe to the Launcher, we'll play in-window scale animations, so
// don't also scale the window.
if (keyguardStateController.isDismissingFromSwipe
&& willUnlockWithInWindowLauncherAnimations) {
if (keyguardStateController.isDismissingFromSwipe &&
willUnlockWithInWindowLauncherAnimations) {
scaleFactor = 1f
}
@@ -919,17 +914,6 @@ class KeyguardUnlockAnimationController @Inject constructor(
return willUnlockWithSmartspaceTransition
}
/**
* Whether this animation controller will be handling the unlock. We require remote animations
* to be enabled to do this.
*
* If this is not true, nothing in this class is relevant, and the unlock will be handled in
* [KeyguardViewMediator].
*/
fun willHandleUnlockAnimation(): Boolean {
return KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation
}
/**
* Whether the RemoteAnimation on the app/launcher surface behind the keyguard is 'running'.
*/

View File

@@ -2427,7 +2427,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
LatencyTracker.getInstance(mContext)
.onActionEnd(LatencyTracker.ACTION_LOCKSCREEN_UNLOCK);
if (KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation && runner != null
if (runner != null
&& finishedCallback != null) {
// Wrap finishedCallback to clean up the keyguard state once the animation is done.
IRemoteAnimationFinishedCallback callback =
@@ -2461,8 +2461,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
// When remaining on the shade, there's no need to do a fancy remote animation,
// it will dismiss the panel in that case.
} else if (KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation
&& !mStatusBarStateController.leaveOpenOnKeyguardHide()
} else if (!mStatusBarStateController.leaveOpenOnKeyguardHide()
&& apps != null && apps.length > 0) {
mSurfaceBehindRemoteAnimationFinishedCallback = finishedCallback;
mSurfaceBehindRemoteAnimationRunning = true;

View File

@@ -477,15 +477,6 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
if (!wasDeviceInteractive) {
mPendingShowBouncer = true;
} else {
// If the keyguard unlock controller is going to handle the unlock animation, it
// will fling the panel collapsed when it's ready.
if (!mKeyguardUnlockAnimationController.willHandleUnlockAnimation()) {
mShadeController.animateCollapsePanels(
CommandQueue.FLAG_EXCLUDE_NONE,
true /* force */,
false /* delayed */,
BIOMETRIC_COLLAPSE_SPEEDUP_FACTOR);
}
mPendingShowBouncer = false;
mKeyguardViewController.notifyKeyguardAuthenticated(
false /* strongAuth */);

View File

@@ -152,7 +152,6 @@ import com.android.systemui.flags.Flags;
import com.android.systemui.fragments.ExtensionFragmentListener;
import com.android.systemui.fragments.FragmentHostManager;
import com.android.systemui.fragments.FragmentService;
import com.android.systemui.keyguard.KeyguardService;
import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.keyguard.ScreenLifecycle;
@@ -1875,11 +1874,9 @@ public class CentralSurfacesImpl extends CoreStartable implements
return true;
}
// If we are locked and have to dismiss the keyguard, only animate if remote unlock
// animations are enabled. We also don't animate non-activity launches as they can break the
// animation.
// 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 && KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation;
return isActivityIntent;
}
/** Whether we should animate an activity launch. */