Keyguard: use transition state for syncing occlude [RESTRICT AUTOMERGE]

Previously keyguard occlude state was passed in onAnimationCancelled
which was not reliable for two reasons:

 (1) onAnimationCancelled is not called if the animation immediately
 finishes itself due to unhappiness at the contents of the transition
 it's been asked to play (eg. empty app list)

 (2) Clients have inconsistent handling of that paramter - some ignore
 it, some respect it, one may get passed wrong information by a local
 caller in mergeAnimation.

Instead note the Keyguard flags at the start of every app transition
and queue up a call to setKeyguardOccluded if the transition may cause a
change. This should be sent after the animation is already finished.

This is ideally similar to 140a05907d
(Run keyguard occlusion update after transitions) which was done for
WmShell transitions.

Test: atest KeyguardTests
Test: atest ActivityLifecycleKeyguardTests
Test: atest MultiDisplayKeyguardTests
Test: atest MultiDisplayLockedKeyguardTests
Bug: 286099078
Change-Id: Ifcdac241bfe33f44f5f03f1a6db682c57f0cd388
This commit is contained in:
Robin Lee
2023-06-12 21:00:20 +02:00
parent d73ad15bf9
commit 831787c50d
2 changed files with 19 additions and 18 deletions

View File

@@ -963,14 +963,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
mOccludeByDreamAnimator.cancel(); mOccludeByDreamAnimator.cancel();
} }
}); });
// The value of isKeyguardOccluded here may come from mergeAnimation, which Log.d(TAG, "Occlude by Dream animation cancelled.");
// isn't reliable. In all cases, after running or cancelling this animation,
// keyguard should be occluded.
setOccluded(true /* isOccluded */, false /* animate */);
if (DEBUG) {
Log.d(TAG, "Occlude by Dream animation cancelled. Occluded state is now: "
+ mOccluded);
}
} }
@Override @Override
@@ -1076,10 +1069,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
} }
}); });
setOccluded(isKeyguardOccluded /* isOccluded */, false /* animate */); Log.d(TAG, "Unocclude animation cancelled.");
Log.d(TAG, "Unocclude animation cancelled. Occluded state is now: "
+ mOccluded);
mInteractionJankMonitor.cancel(CUJ_LOCKSCREEN_OCCLUSION); mInteractionJankMonitor.cancel(CUJ_LOCKSCREEN_OCCLUSION);
} }
@@ -3446,10 +3436,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
public void onAnimationCancelled(boolean isKeyguardOccluded) throws RemoteException { public void onAnimationCancelled(boolean isKeyguardOccluded) throws RemoteException {
super.onAnimationCancelled(isKeyguardOccluded); super.onAnimationCancelled(isKeyguardOccluded);
Log.d(TAG, "Occlude animation cancelled by WM. " Log.d(TAG, "Occlude animation cancelled by WM.");
+ "Setting occluded state to: " + isKeyguardOccluded);
setOccluded(isKeyguardOccluded /* occluded */, false /* animate */);
mInteractionJankMonitor.cancel(CUJ_LOCKSCREEN_OCCLUSION); mInteractionJankMonitor.cancel(CUJ_LOCKSCREEN_OCCLUSION);
} }
} }

View File

@@ -2134,10 +2134,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} }
mWindowManagerInternal.registerAppTransitionListener(new AppTransitionListener() { mWindowManagerInternal.registerAppTransitionListener(new AppTransitionListener() {
private boolean mOccludeChangingInTransition = false;
@Override @Override
public int onAppTransitionStartingLocked(boolean keyguardGoingAway, public int onAppTransitionStartingLocked(boolean keyguardGoingAway,
boolean keyguardOccluding, long duration, long statusBarAnimationStartTime, boolean keyguardOccluding, long duration, long statusBarAnimationStartTime,
long statusBarAnimationDuration) { long statusBarAnimationDuration) {
mOccludeChangingInTransition = keyguardGoingAway || keyguardOccluding;
// When remote animation is enabled for KEYGUARD_GOING_AWAY transition, SysUI // When remote animation is enabled for KEYGUARD_GOING_AWAY transition, SysUI
// receives IRemoteAnimationRunner#onAnimationStart to start animation, so we don't // receives IRemoteAnimationRunner#onAnimationStart to start animation, so we don't
// need to call IKeyguardService#keyguardGoingAway here. // need to call IKeyguardService#keyguardGoingAway here.
@@ -2153,6 +2157,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
0 /* duration */); 0 /* duration */);
synchronized (mLock) { synchronized (mLock) {
if (mOccludeChangingInTransition) {
mKeyguardOccludedChanged = true;
mOccludeChangingInTransition = false;
}
applyKeyguardOcclusionChange(false);
mLockAfterAppTransitionFinished = false; mLockAfterAppTransitionFinished = false;
} }
} }
@@ -2160,12 +2169,16 @@ public class PhoneWindowManager implements WindowManagerPolicy {
@Override @Override
public void onAppTransitionFinishedLocked(IBinder token) { public void onAppTransitionFinishedLocked(IBinder token) {
synchronized (mLock) { synchronized (mLock) {
if (mOccludeChangingInTransition) {
mKeyguardOccludedChanged = true;
mOccludeChangingInTransition = false;
}
applyKeyguardOcclusionChange(false /* transitionStarted */);
if (!mLockAfterAppTransitionFinished) { if (!mLockAfterAppTransitionFinished) {
return; return;
} }
mLockAfterAppTransitionFinished = false; mLockAfterAppTransitionFinished = false;
} }
lockNow(null); lockNow(null);
} }
}); });
@@ -3355,7 +3368,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (mKeyguardOccludedChanged) { if (mKeyguardOccludedChanged) {
if (DEBUG_KEYGUARD) Slog.d(TAG, "transition/occluded changed occluded=" if (DEBUG_KEYGUARD) Slog.d(TAG, "transition/occluded changed occluded="
+ mPendingKeyguardOccluded); + mPendingKeyguardOccluded);
if (setKeyguardOccludedLw(mPendingKeyguardOccluded, false /* force */, if (setKeyguardOccludedLw(mPendingKeyguardOccluded, true /* force */,
transitionStarted)) { transitionStarted)) {
return FINISH_LAYOUT_REDO_LAYOUT | FINISH_LAYOUT_REDO_WALLPAPER; return FINISH_LAYOUT_REDO_LAYOUT | FINISH_LAYOUT_REDO_WALLPAPER;
} }
@@ -3616,6 +3629,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private boolean setKeyguardOccludedLw(boolean isOccluded, boolean force, private boolean setKeyguardOccludedLw(boolean isOccluded, boolean force,
boolean transitionStarted) { boolean transitionStarted) {
if (DEBUG_KEYGUARD) Slog.d(TAG, "setKeyguardOccluded occluded=" + isOccluded); if (DEBUG_KEYGUARD) Slog.d(TAG, "setKeyguardOccluded occluded=" + isOccluded);
mPendingKeyguardOccluded = isOccluded;
mKeyguardOccludedChanged = false; mKeyguardOccludedChanged = false;
if (isKeyguardOccluded() == isOccluded && !force) { if (isKeyguardOccluded() == isOccluded && !force) {
return false; return false;