From d44d48523b4f2f1e632f5f517903cb258956ac53 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Mon, 7 Jun 2021 00:42:53 +0800 Subject: [PATCH] Calling updateImeParent when the layering target is staled Fix "Invisible keyboard" issue that when SystemUI dynamically remove FLAG_ALT_FOCUSABLE_IM window flag to make NotificationShade be IME focusable window after it focused. The above use case happens when a direct-reply notification with shown IME, SystemUI side will let NotificationShade be IME focusable and then tapping the notification to show another message activity with IME shown, then if go back to focus on the direct-reply notification again, there is a timing issue that the new IME layering target may updated after NotificationShade laid out but the system keeps using the previous IME layering target as IME surface parent, this caused the IME surface will behind the IME control target window. To fix this issue, we should modify DC#updateImeControlTarget to invoke updateImeParent when the IME layering target is staled. Fix: 190057993 Test: manual as the steps 1. Make and install EditTextVariations 2. Launch EditTextVariations -> select "Direct Reply" menu item 3. Received HUP direct-reply notification 4 Press "Direct Reply Test" on notification > expect keyboard shown 5. Tap the notification to launch an Editor Activity to show keyboard 6. Again back to direct-reply notification Perform step 4 ~ 6 7. Observe if any "invisible keyboard" issue happened Change-Id: Id3f5a82089c9d75c8536ada6a128de32ce5299e8 --- .../java/com/android/server/wm/DisplayContent.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index e0bae9d8de32c..3eae556969b6f 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -3814,7 +3814,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp // 4. Update the IME control target to apply any inset change and animation. // 5. Reparent the IME container surface to either the input target app, or the IME window // parent. - updateImeControlTarget(); + updateImeControlTarget(true /* forceUpdateImeParent */); } @VisibleForTesting @@ -3946,12 +3946,17 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp } void updateImeControlTarget() { + updateImeControlTarget(false /* forceUpdateImeParent */); + } + + void updateImeControlTarget(boolean forceUpdateImeParent) { InsetsControlTarget prevImeControlTarget = mImeControlTarget; mImeControlTarget = computeImeControlTarget(); mInsetsStateController.onImeControlTargetChanged(mImeControlTarget); - // Update Ime parent when IME insets leash created, which is the best time that default - // IME visibility has been settled down after IME control target changed. - if (prevImeControlTarget != mImeControlTarget) { + // Update Ime parent when IME insets leash created or the new IME layering target might + // updated from setImeLayeringTarget, which is the best time that default IME visibility + // has been settled down after IME control target changed. + if (prevImeControlTarget != mImeControlTarget || forceUpdateImeParent) { updateImeParent(); }