Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 45457033 authored by Taran Singh's avatar Taran Singh
Browse files

Deliver hideInsets when target is removed

hideInsets(IME) may not be delivered to the control target if
the window requesting hide is no longer available in WindowManager's
window map. However, it is still nicer to deliver it to the default
display's control target rather than not delivering it at all.
Fix: 159623277
Test: Manually using steps in bug.

Change-Id: I22cdf20627da2183d30af444f6dd9d0375d417c1
parent bba5d59a
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -757,6 +757,12 @@
      "group": "WM_DEBUG_BOOT",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-547111355": {
      "message": "hideIme Control target: %s ",
      "level": "DEBUG",
      "group": "WM_DEBUG_IME",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-545190927": {
      "message": "<<< CLOSE TRANSACTION animate",
      "level": "INFO",
@@ -1087,6 +1093,12 @@
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "95216706": {
      "message": "hideIme target: %s ",
      "level": "DEBUG",
      "group": "WM_DEBUG_IME",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "95281111": {
      "message": "Attempted to get IME flag of a display that does not exist: %d",
      "level": "WARN",
+3 −1
Original line number Diff line number Diff line
@@ -4047,7 +4047,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                    // Send it to window manager to hide IME from IME target window.
                    // TODO(b/139861270): send to mCurClient.client once IMMS is aware of
                    // actual IME target.
                    mWindowManagerInternal.hideIme(mHideRequestWindowMap.get(windowToken));
                    mWindowManagerInternal.hideIme(
                            mHideRequestWindowMap.get(windowToken),
                            mCurClient.selfReportedDisplayId);
                }
            } else {
                // Send to window manager to show IME after IME layout finishes.
+2 −1
Original line number Diff line number Diff line
@@ -528,8 +528,9 @@ public abstract class WindowManagerInternal {
     * Hide IME using imeTargetWindow when requested.
     *
     * @param imeTargetWindowToken token of the (IME target) window on which IME should be hidden.
     * @param displayId the id of the display the IME is on.
     */
    public abstract void hideIme(IBinder imeTargetWindowToken);
    public abstract void hideIme(IBinder imeTargetWindowToken, int displayId);

    /**
     * Tell window manager about a package that should not be running with high refresh rate
+17 −14
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_BOOT;
import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_FOCUS;
import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_FOCUS_LIGHT;
import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_IME;
import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_KEEP_SCREEN_ON;
import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ORIENTATION;
import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_SCREEN_ON;
@@ -7616,26 +7617,28 @@ public class WindowManagerService extends IWindowManager.Stub
        }

        @Override
        public void hideIme(IBinder imeTargetWindowToken) {
        public void hideIme(IBinder imeTargetWindowToken, int displayId) {
            synchronized (mGlobalLock) {
                WindowState imeTarget = mWindowMap.get(imeTargetWindowToken);
                if (imeTarget == null) {
                    // The target window no longer exists.
                    return;
                }
                ProtoLog.d(WM_DEBUG_IME, "hideIme target: %s ", imeTarget);
                DisplayContent dc = mRoot.getDisplayContent(displayId);
                if (imeTarget != null) {
                    imeTarget = imeTarget.getImeControlTarget().getWindow();
                final DisplayContent dc = imeTarget != null
                        ? imeTarget.getDisplayContent() : getDefaultDisplayContentLocked();
                    if (imeTarget != null) {
                        dc = imeTarget.getDisplayContent();
                    }
                    // If there was a pending IME show(), reset it as IME has been
                    // requested to be hidden.
                    dc.getInsetsStateController().getImeSourceProvider().abortShowImePostLayout();
                if (dc.mInputMethodControlTarget == null) {
                    return;
                }
                if (dc != null && dc.mInputMethodControlTarget != null) {
                    ProtoLog.d(WM_DEBUG_IME, "hideIme Control target: %s ",
                            dc.mInputMethodControlTarget);
                    dc.mInputMethodControlTarget.hideInsets(
                            WindowInsets.Type.ime(), true /* fromIme */);
                }
            }
        }

        @Override
        public boolean isUidAllowedOnDisplay(int displayId, int uid) {