Narrow down the condition of wallpaper target for occluded keyguard
Previously, keyguard will be selected as the backup wallpaper target
if there keyguard is locked and there is an active transition. That
is to avoid wallpaper from being show/hide in a short time when
running recents transition to close app on keyguard.
The condition was a bit broad so the regular transition will also
keep wallpaper target on keyguard. Which could make the transition
change mode of wallpaper become CHANGE rather than TO_BACK when
launching an occlude-keyguard app and then display rotates. Which
could make the condition of seamless rotation rejects the seamless
effect because it found wallpaper is a changing operation.
To avoid such case, only enable the condition if there is a transient
(recents) transition.
Bug: 333557024
Test: Enable auto rotation. Set a secured lock. Turn off screen.
Double click power key to launch camera when holding the
device in landscape. There should not have a rotation animation.
Test: On a secured keyguard. Double click power key to launch camera.
Swipe from bottom to dismiss camera. The wallpaper target
should only change to notification shade once.
Test: atest WallpaperControllerTests#testShowWhenLockedWallpaperTarge
Merged-In: I43a29e828798f36f39d38af130f98de7c5859ec6
Change-Id: I43a29e828798f36f39d38af130f98de7c5859ec6
(cherry picked from commit 275e2758aa0b6739f0e92972fd66a3627cf75685)
diff --git a/services/core/java/com/android/server/wm/TransitionController.java b/services/core/java/com/android/server/wm/TransitionController.java
index 503f925..1e34ad9 100644
--- a/services/core/java/com/android/server/wm/TransitionController.java
+++ b/services/core/java/com/android/server/wm/TransitionController.java
@@ -493,6 +493,27 @@
return false;
}
+ /** Returns {@code true} if the display contains a transient-launch transition. */
+ boolean hasTransientLaunch(@NonNull DisplayContent dc) {
+ if (mCollectingTransition != null && mCollectingTransition.hasTransientLaunch()
+ && mCollectingTransition.isOnDisplay(dc)) {
+ return true;
+ }
+ for (int i = mWaitingTransitions.size() - 1; i >= 0; --i) {
+ final Transition transition = mWaitingTransitions.get(i);
+ if (transition.hasTransientLaunch() && transition.isOnDisplay(dc)) {
+ return true;
+ }
+ }
+ for (int i = mPlayingTransitions.size() - 1; i >= 0; --i) {
+ final Transition transition = mPlayingTransitions.get(i);
+ if (transition.hasTransientLaunch() && transition.isOnDisplay(dc)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
boolean isTransientHide(@NonNull Task task) {
if (mCollectingTransition != null && mCollectingTransition.isInTransientHide(task)) {
return true;
diff --git a/services/core/java/com/android/server/wm/WallpaperController.java b/services/core/java/com/android/server/wm/WallpaperController.java
index c2b847c..1ac46ef 100644
--- a/services/core/java/com/android/server/wm/WallpaperController.java
+++ b/services/core/java/com/android/server/wm/WallpaperController.java
@@ -166,7 +166,7 @@
|| (w.mActivityRecord != null && !w.mActivityRecord.fillsParent());
}
} else if (w.hasWallpaper() && mService.mPolicy.isKeyguardHostWindow(w.mAttrs)
- && w.mTransitionController.isTransitionOnDisplay(mDisplayContent)) {
+ && w.mTransitionController.hasTransientLaunch(mDisplayContent)) {
// If we have no candidates at all, notification shade is allowed to be the target
// of last resort even if it has not been made visible yet.
if (DEBUG_WALLPAPER) Slog.v(TAG, "Found keyguard as wallpaper target: " + w);
diff --git a/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java
index 72bedf2..69f33d4 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java
@@ -314,6 +314,18 @@
// Wallpaper is invisible because the lowest show-when-locked activity is opaque.
assertNull(wallpaperController.getWallpaperTarget());
+ // Only transient-launch transition will make notification shade as last resort target.
+ // This verifies that regular transition won't choose invisible keyguard as the target.
+ final WindowState keyguard = createWindow(null /* parent */,
+ WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE, "keyguard");
+ keyguard.mAttrs.flags |= FLAG_SHOW_WALLPAPER;
+ registerTestTransitionPlayer();
+ final Transition transition = wallpaperWindow.mTransitionController.createTransition(
+ WindowManager.TRANSIT_CHANGE);
+ transition.collect(keyguard);
+ wallpaperController.adjustWallpaperWindows();
+ assertNull(wallpaperController.getWallpaperTarget());
+
// A show-when-locked wallpaper is used for lockscreen. So the top wallpaper should
// be the one that is not show-when-locked.
final WindowState wallpaperWindow2 = createWallpaperWindow(mDisplayContent);