summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Riddle Hsu <riddlehsu@google.com> 2024-04-23 10:08:57 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-04-23 10:08:57 +0000
commit2f7b477159fa569519936ce4f7fe438f65752e8d (patch)
tree29db4951f47123e465c73e9aaa506a1d5e99af9f
parent04db05f4e991f42a2fa01569088d04e9ef5476df (diff)
parentec1eac9a06deebb4d97c6c8d63a1fd98e81adbe7 (diff)
Merge "Detach stale IME leash for orientation change with gesture navigation" into main
-rw-r--r--services/core/java/com/android/server/wm/Transition.java37
1 files changed, 30 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java
index 664019a125b5..989888ee3ac3 100644
--- a/services/core/java/com/android/server/wm/Transition.java
+++ b/services/core/java/com/android/server/wm/Transition.java
@@ -1429,20 +1429,17 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
}
}
if (mTransientLaunches != null) {
- InsetsControlTarget prevImeTarget = dc.getImeTarget(
- DisplayContent.IME_TARGET_CONTROL);
- InsetsControlTarget newImeTarget = null;
TaskDisplayArea transientTDA = null;
- // Transient-launch activities cannot be IME target (WindowState#canBeImeTarget),
- // so re-compute in case the IME target is changed after transition.
for (int t = 0; t < mTransientLaunches.size(); ++t) {
if (mTransientLaunches.keyAt(t).getDisplayContent() == dc) {
- newImeTarget = dc.computeImeTarget(true /* updateImeTarget */);
+ if (hasVisibleTransientLaunch) {
+ updateImeForVisibleTransientLaunch(dc);
+ }
transientTDA = mTransientLaunches.keyAt(i).getTaskDisplayArea();
break;
}
}
- if (mRecentsDisplayId != INVALID_DISPLAY && prevImeTarget == newImeTarget) {
+ if (!hasVisibleTransientLaunch && mRecentsDisplayId == dc.mDisplayId) {
// Restore IME icon only when moving the original app task to front from
// recents, in case IME icon may missing if the moving task has already been
// the current focused task.
@@ -1540,6 +1537,32 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
return null;
}
+ /**
+ * Transient-launch activities cannot be IME target (see {@link WindowState#canBeImeTarget}),
+ * so re-compute in case the IME target is changed after transition.
+ */
+ private void updateImeForVisibleTransientLaunch(@NonNull DisplayContent dc) {
+ final WindowState imeTarget = dc.computeImeTarget(true /* updateImeTarget */);
+ final WindowState imeWindow = dc.mInputMethodWindow;
+ if (imeWindow == null || imeTarget == null
+ || !mController.hasCollectingRotationChange(dc, dc.getRotation())) {
+ return;
+ }
+ // Drop the insets leash if it is still controlled by previous (invisible) app. This avoids
+ // showing IME with old rotation on an app with new rotation if IME parent is updated
+ // but insets leash hasn't been refreshed, i.e. DisplayContent#updateImeParent is called
+ // but InsetsStateController#notifyControlTargetChanged still waits for IME to redraw.
+ final InsetsSourceProvider sourceProvider = imeWindow.getControllableInsetProvider();
+ if (sourceProvider == null || sourceProvider.mControl == null
+ || imeTarget == sourceProvider.getControlTarget()) {
+ return;
+ }
+ final SurfaceControl imeInsetsLeash = sourceProvider.mControl.getLeash();
+ if (imeInsetsLeash != null) {
+ dc.getSyncTransaction().reparent(imeInsetsLeash, null);
+ }
+ }
+
void abort() {
// This calls back into itself via controller.abort, so just early return here.
if (mState == STATE_ABORT) return;