From 5e6c273cdf57cc43d1833977d81920443e62cdc9 Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Fri, 15 Oct 2021 10:57:48 +0800 Subject: [PATCH] Prevent the occlusion state mismatch between WM and SystemUI. The mismatch condition could happen due to the race condition from keyguard unlock animation and the execute of AppTransition. Pre-condition: keyguard is locked and showing a showWhenLocked activity on top of device, while starting another activity B without showWhenLocked. The issue sequence is: 1. Start Activity B and it is no occluded, update PWM#onKeyguardOccludedChangedLw(occluded = false), because keyguard is showing so set mKeyguardOccludedChanged to true. 2. Because device was occluded, there will attach showWhenLocked flag to the starting window of Activity B, when this starting window added to WM, the occluded state chage to true and overwrite the mPendingKeyguardOccluded again. 3. Keyguard unlock animation finish, WM receive keyguard showing become false. 4. Starting window removed so occluded state change to false, because the keyguard is hidden, PWM will update the occluded value to SystemUI directly. 5. App Transition start, PWM#applyKeyguardOcclusionChange with the mPendingKeyguardOccluded value, which was true, thus the occluded state become mismatch. If the timing between 3, 4, 5 has slightly change, then this issue won't happen. Anyway, an easy fix is to ensure the updated value on PWM should always be the latest value from KeyguardController. Bug: 201328381 Test: atest KeyguardTests KeyguardTransitionTests KeyguardLockedTests Change-Id: I69e9cbb6238a19cf75ac0c9cb16adb2310399876 --- .../core/java/com/android/server/policy/PhoneWindowManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 6a9a2827dad06..cda7407dc98c0 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -3060,7 +3060,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (mKeyguardOccludedChanged) { if (DEBUG_KEYGUARD) Slog.d(TAG, "transition/occluded changed occluded=" + mPendingKeyguardOccluded); - mKeyguardOccludedChanged = false; if (setKeyguardOccludedLw(mPendingKeyguardOccluded, false /* force */, transitionStarted)) { return FINISH_LAYOUT_REDO_LAYOUT | FINISH_LAYOUT_REDO_WALLPAPER; @@ -3282,6 +3281,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { private boolean setKeyguardOccludedLw(boolean isOccluded, boolean force, boolean transitionStarted) { if (DEBUG_KEYGUARD) Slog.d(TAG, "setKeyguardOccluded occluded=" + isOccluded); + mKeyguardOccludedChanged = false; if (isKeyguardOccluded() == isOccluded && !force) { return false; }