From b54270fbf94aff7205b372eb02c33f8cfbc53550 Mon Sep 17 00:00:00 2001 From: Evan Rosky Date: Tue, 10 May 2022 17:53:19 -0700 Subject: [PATCH] Don't hide IME windows in transition player IME windows, like wallpaper windows, have their visibilities managed outside of the transition system. This means that altering their visibilities can get us stuck in situations that can't be undone. So, like wallpaper, just check and skip explicit visibility changes on IME windows. Bug: 230733128 Test: messages in portrait, open ime, swipe to home, open messages in landscape, swipe home, open messages in portrait again (ime should be visible). Change-Id: I0df284cce19f367003570a4e882dd6ffbc8dbef6 --- core/java/android/window/TransitionInfo.java | 9 ++++++++- .../android/wm/shell/transition/Transitions.java | 15 +++++++++------ .../java/com/android/server/wm/Transition.java | 9 +++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/core/java/android/window/TransitionInfo.java b/core/java/android/window/TransitionInfo.java index 51da61ffb9c98..c81184fb23830 100644 --- a/core/java/android/window/TransitionInfo.java +++ b/core/java/android/window/TransitionInfo.java @@ -107,8 +107,11 @@ public final class TransitionInfo implements Parcelable { */ public static final int FLAG_DISPLAY_HAS_ALERT_WINDOWS = 1 << 7; + /** The container is an input-method window. */ + public static final int FLAG_IS_INPUT_METHOD = 1 << 8; + /** The first unused bit. This can be used by remotes to attach custom flags to this change. */ - public static final int FLAG_FIRST_CUSTOM = 1 << 8; + public static final int FLAG_FIRST_CUSTOM = 1 << 9; /** @hide */ @IntDef(prefix = { "FLAG_" }, value = { @@ -121,6 +124,7 @@ public final class TransitionInfo implements Parcelable { FLAG_IS_DISPLAY, FLAG_OCCLUDES_KEYGUARD, FLAG_DISPLAY_HAS_ALERT_WINDOWS, + FLAG_IS_INPUT_METHOD, FLAG_FIRST_CUSTOM }) public @interface ChangeFlags {} @@ -300,6 +304,9 @@ public final class TransitionInfo implements Parcelable { if ((flags & FLAG_IS_WALLPAPER) != 0) { sb.append("IS_WALLPAPER"); } + if ((flags & FLAG_IS_INPUT_METHOD) != 0) { + sb.append("IS_INPUT_METHOD"); + } if ((flags & FLAG_TRANSLUCENT) != 0) { sb.append((sb.length() == 0 ? "" : "|") + "TRANSLUCENT"); } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java index 98eee7ba33a0e..903dfc20eaf7c 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java @@ -23,6 +23,7 @@ import static android.view.WindowManager.TRANSIT_KEYGUARD_GOING_AWAY; import static android.view.WindowManager.TRANSIT_OPEN; import static android.view.WindowManager.TRANSIT_TO_BACK; import static android.view.WindowManager.TRANSIT_TO_FRONT; +import static android.window.TransitionInfo.FLAG_IS_INPUT_METHOD; import static android.window.TransitionInfo.FLAG_IS_WALLPAPER; import static android.window.TransitionInfo.FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT; @@ -287,12 +288,14 @@ public class Transitions implements RemoteCallable { finishT.setAlpha(leash, 1.f); } } else if (mode == TRANSIT_CLOSE || mode == TRANSIT_TO_BACK) { - // Wallpaper is a bit of an anomaly: it's visibility is tied to other WindowStates. - // As a result, we actually can't hide it's WindowToken because there may not be a - // transition associated with it becoming visible again. Fortunately, since it is - // always z-ordered to the back, we don't have to worry about it flickering to the - // front during reparenting, so the hide here isn't necessary for it. - if ((change.getFlags() & FLAG_IS_WALLPAPER) == 0) { + // Wallpaper/IME are anomalies: their visibility is tied to other WindowStates. + // As a result, we actually can't hide their WindowTokens because there may not be a + // transition associated with them becoming visible again. Fortunately, since + // wallpapers are always z-ordered to the back, we don't have to worry about it + // flickering to the front during reparenting. Similarly, the IME is reparented to + // the associated app, so its visibility is coupled. So, an explicit hide is not + // needed visually anyways. + if ((change.getFlags() & (FLAG_IS_WALLPAPER | FLAG_IS_INPUT_METHOD)) == 0) { finishT.hide(leash); } } diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java index dfbeb55a9bf0d..d5acf4fed330b 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -27,6 +27,7 @@ import static android.view.WindowManager.INPUT_CONSUMER_RECENTS_ANIMATION; import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS; import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_UNSPECIFIED; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; +import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManager.TRANSIT_CHANGE; import static android.view.WindowManager.TRANSIT_CLOSE; import static android.view.WindowManager.TRANSIT_FLAG_IS_RECENTS; @@ -45,6 +46,7 @@ import static android.view.WindowManager.TransitionType; import static android.view.WindowManager.transitTypeToString; import static android.window.TransitionInfo.FLAG_DISPLAY_HAS_ALERT_WINDOWS; import static android.window.TransitionInfo.FLAG_IS_DISPLAY; +import static android.window.TransitionInfo.FLAG_IS_INPUT_METHOD; import static android.window.TransitionInfo.FLAG_IS_VOICE_INTERACTION; import static android.window.TransitionInfo.FLAG_IS_WALLPAPER; import static android.window.TransitionInfo.FLAG_OCCLUDES_KEYGUARD; @@ -1025,6 +1027,10 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe return wc.asWallpaperToken() != null; } + private static boolean isInputMethod(WindowContainer wc) { + return wc.getWindowType() == TYPE_INPUT_METHOD; + } + private static boolean occludesKeyguard(WindowContainer wc) { final ActivityRecord ar = wc.asActivityRecord(); if (ar != null) { @@ -1614,6 +1620,9 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe if (isWallpaper(wc)) { flags |= FLAG_IS_WALLPAPER; } + if (isInputMethod(wc)) { + flags |= FLAG_IS_INPUT_METHOD; + } if (occludesKeyguard(wc)) { flags |= FLAG_OCCLUDES_KEYGUARD; }