Skip to content

Commit a7e27bc

Browse files
hex539Android Build Coastguard Worker
authored andcommitted
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 140a05907d905e38aa5690320d26c90ca29bf772 (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 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:831787c50d4d74913d5b12d344e25743760aa437) Merged-In: Ifcdac241bfe33f44f5f03f1a6db682c57f0cd388 Change-Id: Ifcdac241bfe33f44f5f03f1a6db682c57f0cd388
1 parent e6dfd1c commit a7e27bc

2 files changed

Lines changed: 19 additions & 18 deletions

File tree

packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -963,14 +963,7 @@ public void onAnimationCancelled(boolean isKeyguardOccluded) {
963963
mOccludeByDreamAnimator.cancel();
964964
}
965965
});
966-
// The value of isKeyguardOccluded here may come from mergeAnimation, which
967-
// isn't reliable. In all cases, after running or cancelling this animation,
968-
// keyguard should be occluded.
969-
setOccluded(true /* isOccluded */, false /* animate */);
970-
if (DEBUG) {
971-
Log.d(TAG, "Occlude by Dream animation cancelled. Occluded state is now: "
972-
+ mOccluded);
973-
}
966+
Log.d(TAG, "Occlude by Dream animation cancelled.");
974967
}
975968

976969
@Override
@@ -1076,10 +1069,7 @@ public void onAnimationCancelled(boolean isKeyguardOccluded) {
10761069
}
10771070
});
10781071

1079-
setOccluded(isKeyguardOccluded /* isOccluded */, false /* animate */);
1080-
Log.d(TAG, "Unocclude animation cancelled. Occluded state is now: "
1081-
+ mOccluded);
1082-
1072+
Log.d(TAG, "Unocclude animation cancelled.");
10831073
mInteractionJankMonitor.cancel(CUJ_LOCKSCREEN_OCCLUSION);
10841074
}
10851075

@@ -3446,10 +3436,7 @@ public void onAnimationStart(int transit, RemoteAnimationTarget[] apps,
34463436
public void onAnimationCancelled(boolean isKeyguardOccluded) throws RemoteException {
34473437
super.onAnimationCancelled(isKeyguardOccluded);
34483438

3449-
Log.d(TAG, "Occlude animation cancelled by WM. "
3450-
+ "Setting occluded state to: " + isKeyguardOccluded);
3451-
setOccluded(isKeyguardOccluded /* occluded */, false /* animate */);
3452-
3439+
Log.d(TAG, "Occlude animation cancelled by WM.");
34533440
mInteractionJankMonitor.cancel(CUJ_LOCKSCREEN_OCCLUSION);
34543441
}
34553442
}

services/core/java/com/android/server/policy/PhoneWindowManager.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,10 +2134,14 @@ public void init(Context context, WindowManagerFuncs windowManagerFuncs) {
21342134
}
21352135

21362136
mWindowManagerInternal.registerAppTransitionListener(new AppTransitionListener() {
2137+
private boolean mOccludeChangingInTransition = false;
2138+
21372139
@Override
21382140
public int onAppTransitionStartingLocked(boolean keyguardGoingAway,
21392141
boolean keyguardOccluding, long duration, long statusBarAnimationStartTime,
21402142
long statusBarAnimationDuration) {
2143+
mOccludeChangingInTransition = keyguardGoingAway || keyguardOccluding;
2144+
21412145
// When remote animation is enabled for KEYGUARD_GOING_AWAY transition, SysUI
21422146
// receives IRemoteAnimationRunner#onAnimationStart to start animation, so we don't
21432147
// need to call IKeyguardService#keyguardGoingAway here.
@@ -2153,19 +2157,28 @@ public void onAppTransitionCancelledLocked(boolean keyguardGoingAway) {
21532157
0 /* duration */);
21542158

21552159
synchronized (mLock) {
2160+
if (mOccludeChangingInTransition) {
2161+
mKeyguardOccludedChanged = true;
2162+
mOccludeChangingInTransition = false;
2163+
}
2164+
applyKeyguardOcclusionChange(false);
21562165
mLockAfterAppTransitionFinished = false;
21572166
}
21582167
}
21592168

21602169
@Override
21612170
public void onAppTransitionFinishedLocked(IBinder token) {
21622171
synchronized (mLock) {
2172+
if (mOccludeChangingInTransition) {
2173+
mKeyguardOccludedChanged = true;
2174+
mOccludeChangingInTransition = false;
2175+
}
2176+
applyKeyguardOcclusionChange(false /* transitionStarted */);
21632177
if (!mLockAfterAppTransitionFinished) {
21642178
return;
21652179
}
21662180
mLockAfterAppTransitionFinished = false;
21672181
}
2168-
21692182
lockNow(null);
21702183
}
21712184
});
@@ -3355,7 +3368,7 @@ public int applyKeyguardOcclusionChange(boolean transitionStarted) {
33553368
if (mKeyguardOccludedChanged) {
33563369
if (DEBUG_KEYGUARD) Slog.d(TAG, "transition/occluded changed occluded="
33573370
+ mPendingKeyguardOccluded);
3358-
if (setKeyguardOccludedLw(mPendingKeyguardOccluded, false /* force */,
3371+
if (setKeyguardOccludedLw(mPendingKeyguardOccluded, true /* force */,
33593372
transitionStarted)) {
33603373
return FINISH_LAYOUT_REDO_LAYOUT | FINISH_LAYOUT_REDO_WALLPAPER;
33613374
}
@@ -3616,6 +3629,7 @@ public void setNavBarVirtualKeyHapticFeedbackEnabledLw(boolean enabled) {
36163629
private boolean setKeyguardOccludedLw(boolean isOccluded, boolean force,
36173630
boolean transitionStarted) {
36183631
if (DEBUG_KEYGUARD) Slog.d(TAG, "setKeyguardOccluded occluded=" + isOccluded);
3632+
mPendingKeyguardOccluded = isOccluded;
36193633
mKeyguardOccludedChanged = false;
36203634
if (isKeyguardOccluded() == isOccluded && !force) {
36213635
return false;

0 commit comments

Comments
 (0)