From ce1a4f3fe5bb23f9c399fcc731bd7b1016c9688e Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Tue, 19 Jul 2022 01:37:26 +0800 Subject: [PATCH] Add willShowImeOnTarget in RemoteAnimationTarget(Compat) ..used for signaling the launcher to crop the remote animation target bounds when task animating on the taskbar. If the task will show IME on the top means the animation taget would not need to be cropped according to the taskBar insets, since visually the taskbar is hidden when IME is visible. Bug: 219981732 Test: manual as steps 0) enable taskbar with Settings > Developer options > Smallest width as 600dp. 1) launch an app from all apps and show the IME by tapping the editor. 2) swipe out to home and launch it again by pressing the shortcut. 3) Verify the animating task preview with IME shown without being cropped. Change-Id: Iab526e78614c68626bd5424e0e3219044f671f4d --- .../android/view/RemoteAnimationTarget.java | 18 ++++++++++++++++++ core/java/android/window/TransitionInfo.java | 6 +++++- .../system/RemoteAnimationTargetCompat.java | 9 +++++++-- .../com/android/server/wm/ActivityRecord.java | 1 + .../server/wm/RecentsAnimationController.java | 6 ++++++ .../java/com/android/server/wm/Transition.java | 8 ++++++++ 6 files changed, 45 insertions(+), 3 deletions(-) diff --git a/core/java/android/view/RemoteAnimationTarget.java b/core/java/android/view/RemoteAnimationTarget.java index a468951c50205..44f419a8097de 100644 --- a/core/java/android/view/RemoteAnimationTarget.java +++ b/core/java/android/view/RemoteAnimationTarget.java @@ -45,6 +45,7 @@ import android.os.Build; import android.os.Parcel; import android.os.Parcelable; import android.util.proto.ProtoOutputStream; +import android.window.TaskSnapshot; import java.io.PrintWriter; import java.lang.annotation.Retention; @@ -234,6 +235,12 @@ public class RemoteAnimationTarget implements Parcelable { */ public @ColorInt int backgroundColor; + /** + * Whether the activity is going to show IME on the target window after the app transition. + * @see TaskSnapshot#hasImeSurface() that used the task snapshot during animating task. + */ + public boolean willShowImeOnTarget; + public RemoteAnimationTarget(int taskId, int mode, SurfaceControl leash, boolean isTranslucent, Rect clipRect, Rect contentInsets, int prefixOrderIndex, Point position, Rect localBounds, Rect screenSpaceBounds, @@ -294,12 +301,21 @@ public class RemoteAnimationTarget implements Parcelable { hasAnimatingParent = in.readBoolean(); backgroundColor = in.readInt(); showBackdrop = in.readBoolean(); + willShowImeOnTarget = in.readBoolean(); } public void setShowBackdrop(boolean shouldShowBackdrop) { showBackdrop = shouldShowBackdrop; } + public void setWillShowImeOnTarget(boolean showImeOnTarget) { + willShowImeOnTarget = showImeOnTarget; + } + + public boolean willShowImeOnTarget() { + return willShowImeOnTarget; + } + @Override public int describeContents() { return 0; @@ -328,6 +344,7 @@ public class RemoteAnimationTarget implements Parcelable { dest.writeBoolean(hasAnimatingParent); dest.writeInt(backgroundColor); dest.writeBoolean(showBackdrop); + dest.writeBoolean(willShowImeOnTarget); } public void dump(PrintWriter pw, String prefix) { @@ -350,6 +367,7 @@ public class RemoteAnimationTarget implements Parcelable { pw.print(prefix); pw.print("hasAnimatingParent="); pw.print(hasAnimatingParent); pw.print(prefix); pw.print("backgroundColor="); pw.print(backgroundColor); pw.print(prefix); pw.print("showBackdrop="); pw.print(showBackdrop); + pw.print(prefix); pw.print("willShowImeOnTarget="); pw.print(willShowImeOnTarget); } public void dumpDebug(ProtoOutputStream proto, long fieldId) { diff --git a/core/java/android/window/TransitionInfo.java b/core/java/android/window/TransitionInfo.java index 1f3841ad8b58b..b263b08d6abcd 100644 --- a/core/java/android/window/TransitionInfo.java +++ b/core/java/android/window/TransitionInfo.java @@ -116,6 +116,9 @@ public final class TransitionInfo implements Parcelable { /** 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 << 10; + /** The container is going to show IME on its task after the transition. */ + public static final int FLAG_WILL_IME_SHOWN = 1 << 11; + /** @hide */ @IntDef(prefix = { "FLAG_" }, value = { FLAG_NONE, @@ -129,7 +132,8 @@ public final class TransitionInfo implements Parcelable { FLAG_DISPLAY_HAS_ALERT_WINDOWS, FLAG_IS_INPUT_METHOD, FLAG_IS_EMBEDDED, - FLAG_FIRST_CUSTOM + FLAG_FIRST_CUSTOM, + FLAG_WILL_IME_SHOWN }) public @interface ChangeFlags {} diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java index 249133a9a63bd..3b1c9874806ba 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java @@ -79,6 +79,8 @@ public class RemoteAnimationTargetCompat { // Fields used only to unrap into RemoteAnimationTarget private final Rect startBounds; + public final boolean willShowImeOnTarget; + public RemoteAnimationTargetCompat(RemoteAnimationTarget app) { taskId = app.taskId; mode = app.mode; @@ -102,6 +104,7 @@ public class RemoteAnimationTargetCompat { windowType = app.windowType; windowConfiguration = app.windowConfiguration; startBounds = app.startBounds; + willShowImeOnTarget = app.willShowImeOnTarget; } private static int newModeToLegacyMode(int newMode) { @@ -118,14 +121,15 @@ public class RemoteAnimationTargetCompat { } public RemoteAnimationTarget unwrap() { - return new RemoteAnimationTarget( + final RemoteAnimationTarget target = new RemoteAnimationTarget( taskId, mode, leash, isTranslucent, clipRect, contentInsets, prefixOrderIndex, position, localBounds, screenSpaceBounds, windowConfiguration, isNotInRecents, mStartLeash, startBounds, taskInfo, allowEnterPip, windowType ); + target.setWillShowImeOnTarget(willShowImeOnTarget); + return target; } - /** * Almost a copy of Transitions#setupStartState. * TODO: remove when there is proper cross-process transaction sync. @@ -235,6 +239,7 @@ public class RemoteAnimationTargetCompat { ? change.getTaskInfo().configuration.windowConfiguration : new WindowConfiguration(); startBounds = change.getStartAbsBounds(); + willShowImeOnTarget = (change.getFlags() & TransitionInfo.FLAG_WILL_IME_SHOWN) != 0; } public static RemoteAnimationTargetCompat[] wrap(RemoteAnimationTarget[] apps) { diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index ed32a7d7f778e..cfaad54cf9ea0 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -9755,6 +9755,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A record.mThumbnailAdapter != null ? record.mThumbnailAdapter.mCapturedLeash : null, record.mStartBounds, task.getTaskInfo(), checkEnterPictureInPictureAppOpsState()); target.setShowBackdrop(record.mShowBackdrop); + target.setWillShowImeOnTarget(mStartingData != null && mStartingData.hasImeSurface()); target.hasAnimatingParent = record.hasAnimatingParent(); return target; } diff --git a/services/core/java/com/android/server/wm/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java index 53f1fe6abec5f..23609969204a6 100644 --- a/services/core/java/com/android/server/wm/RecentsAnimationController.java +++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java @@ -1236,6 +1236,12 @@ public class RecentsAnimationController implements DeathRecipient { mLocalBounds, mBounds, mTask.getWindowConfiguration(), mIsRecentTaskInvisible, null, null, mTask.getTaskInfo(), topApp.checkEnterPictureInPictureAppOpsState()); + + final ActivityRecord topActivity = mTask.getTopNonFinishingActivity(); + if (topActivity != null && topActivity.mStartingData != null + && topActivity.mStartingData.hasImeSurface()) { + mTarget.setWillShowImeOnTarget(true); + } return mTarget; } diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java index 31d8eb8eea170..bbc95a1dd70f6 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -54,6 +54,7 @@ import static android.window.TransitionInfo.FLAG_OCCLUDES_KEYGUARD; import static android.window.TransitionInfo.FLAG_SHOW_WALLPAPER; import static android.window.TransitionInfo.FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT; import static android.window.TransitionInfo.FLAG_TRANSLUCENT; +import static android.window.TransitionInfo.FLAG_WILL_IME_SHOWN; import static com.android.server.wm.ActivityRecord.State.RESUMED; import static com.android.server.wm.ActivityTaskManagerInternal.APP_TRANSITION_RECENTS_ANIM; @@ -1728,6 +1729,13 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe if (task != null && task.voiceSession != null) { flags |= FLAG_IS_VOICE_INTERACTION; } + if (task != null) { + final ActivityRecord topActivity = task.getTopNonFinishingActivity(); + if (topActivity != null && topActivity.mStartingData != null + && topActivity.mStartingData.hasImeSurface()) { + flags |= FLAG_WILL_IME_SHOWN; + } + } final ActivityRecord record = wc.asActivityRecord(); if (record != null) { if (record.mUseTransferredAnimation) {