From a9573379e273b36e3cb89da822d3e4e987c457fd Mon Sep 17 00:00:00 2001 From: Issei Suzuki Date: Wed, 20 Oct 2021 11:09:25 +0200 Subject: [PATCH 1/2] Remove keyguard candidate. Test: No-op refactoring, existing tests pass. Bug: 191438572 Change-Id: I187b5a5654bf7d10e63373fca8c40398838e655c --- .../com/android/server/policy/PhoneWindowManager.java | 9 --------- .../com/android/server/policy/WindowManagerPolicy.java | 7 ------- .../core/java/com/android/server/wm/DisplayPolicy.java | 6 ------ .../com/android/server/wm/TestWindowManagerPolicy.java | 4 ---- 4 files changed, 26 deletions(-) diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 83b7489dec85f..6a9a2827dad06 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -404,7 +404,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { private AccessibilityShortcutController mAccessibilityShortcutController; boolean mSafeMode; - private WindowState mKeyguardCandidate = null; // Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key. // This is for car dock and this is updated from resource. @@ -3271,14 +3270,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { mNavBarVirtualKeyHapticFeedbackEnabled = enabled; } - /** {@inheritDoc} */ - @Override - public void setKeyguardCandidateLw(WindowState win) { - mKeyguardCandidate = win; - setKeyguardOccludedLw(isKeyguardOccluded(), true /* force */, - false /* keyguardOccludingStarted */); - } - /** * Updates the occluded state of the Keyguard. * diff --git a/services/core/java/com/android/server/policy/WindowManagerPolicy.java b/services/core/java/com/android/server/policy/WindowManagerPolicy.java index c3ec6a4ab6b58..87465a4b2ffea 100644 --- a/services/core/java/com/android/server/policy/WindowManagerPolicy.java +++ b/services/core/java/com/android/server/policy/WindowManagerPolicy.java @@ -721,13 +721,6 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants { int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon, int logo, int windowFlags, Configuration overrideConfig, int displayId); - /** - * Set or clear a window which can behave as the keyguard. - * - * @param win The window which can behave as the keyguard. - */ - void setKeyguardCandidateLw(@Nullable WindowState win); - /** * Create and return an animation to re-display a window that was force hidden by Keyguard. */ diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 0c0d01c3db898..d1357c0899b80 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -1094,9 +1094,6 @@ public class DisplayPolicy { switch (attrs.type) { case TYPE_NOTIFICATION_SHADE: mNotificationShade = win; - if (mDisplayContent.isDefaultDisplay) { - mService.mPolicy.setKeyguardCandidateLw(win); - } break; case TYPE_STATUS_BAR: mStatusBar = win; @@ -1292,9 +1289,6 @@ public class DisplayPolicy { mDisplayContent.setInsetProvider(ITYPE_NAVIGATION_BAR, null, null); } else if (mNotificationShade == win) { mNotificationShade = null; - if (mDisplayContent.isDefaultDisplay) { - mService.mPolicy.setKeyguardCandidateLw(null); - } } else if (mClimateBarAlt == win) { mClimateBarAlt = null; mDisplayContent.setInsetProvider(ITYPE_CLIMATE_BAR, null, null); diff --git a/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java b/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java index 16d75ca884f1d..9001578cf37ae 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java +++ b/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java @@ -127,10 +127,6 @@ class TestWindowManagerPolicy implements WindowManagerPolicy { }; } - @Override - public void setKeyguardCandidateLw(WindowState win) { - } - @Override public Animation createHiddenByKeyguardExit(boolean onWallpaper, boolean goingToNotificationShade, boolean subtleAnimation) { From 5e6c273cdf57cc43d1833977d81920443e62cdc9 Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Fri, 15 Oct 2021 10:57:48 +0800 Subject: [PATCH 2/2] 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; }