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

Commit d0bc1712 authored by Ming-Shin Lu's avatar Ming-Shin Lu
Browse files

Add IME {insets control, IME-WM} target to History

From new WindowInsets API, showing IME visiblity will not only rely on
IME focusable window focus and knowing who calls {show, hide}SoftInput request
from client, but also the client can call getInsetsControler().{show, hide}(ime()).

Since the true IME visiblity depends on which IME InsetsControlTarget that can
show / hide IME window, we need to track when it changes for more easily debug.

And, we also need to track the z-order information such the window which
behind the soft-keyboard.

Add those targets information into SoftInputShowHideHistory for
tracking.

Fix: 156198073
Test: adb shell dumpsys input_method, check SoftInputShowHideHistory.
Change-Id: I7f0b927afcf7b19102689b680bcf07de2380bba5
parent 1bf40c21
Loading
Loading
Loading
Loading
+24 −3
Original line number Original line Diff line number Diff line
@@ -820,10 +820,15 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            final EditorInfo mEditorInfo;
            final EditorInfo mEditorInfo;
            @NonNull
            @NonNull
            final String mRequestWindowName;
            final String mRequestWindowName;
            @Nullable
            final String mImeControlTargetName;
            @Nullable
            final String mImeTargetNameFromWm;


            Entry(ClientState client, EditorInfo editorInfo, String focusedWindowName,
            Entry(ClientState client, EditorInfo editorInfo, String focusedWindowName,
                    @SoftInputModeFlags int softInputMode, @SoftInputShowHideReason int reason,
                    @SoftInputModeFlags int softInputMode, @SoftInputShowHideReason int reason,
                    boolean inFullscreenMode, String requestWindowName) {
                    boolean inFullscreenMode, String requestWindowName,
                    @Nullable String imeControlTargetName, @Nullable String imeTargetName) {
                mClientState = client;
                mClientState = client;
                mEditorInfo = editorInfo;
                mEditorInfo = editorInfo;
                mFocusedWindowName = focusedWindowName;
                mFocusedWindowName = focusedWindowName;
@@ -833,6 +838,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                mWallTime = System.currentTimeMillis();
                mWallTime = System.currentTimeMillis();
                mInFullscreenMode = inFullscreenMode;
                mInFullscreenMode = inFullscreenMode;
                mRequestWindowName = requestWindowName;
                mRequestWindowName = requestWindowName;
                mImeControlTargetName = imeControlTargetName;
                mImeTargetNameFromWm = imeTargetName;
            }
            }
        }
        }


@@ -872,6 +879,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                pw.print(prefix);
                pw.print(prefix);
                pw.println(" requestWindowName=" + entry.mRequestWindowName);
                pw.println(" requestWindowName=" + entry.mRequestWindowName);


                pw.print(prefix);
                pw.println(" imeControlTargetName=" + entry.mImeControlTargetName);

                pw.print(prefix);
                pw.println(" imeTargetNameFromWm=" + entry.mImeTargetNameFromWm);

                pw.print(prefix);
                pw.print(prefix);
                pw.print(" editorInfo: ");
                pw.print(" editorInfo: ");
                pw.print(" inputType=" + entry.mEditorInfo.inputType);
                pw.print(" inputType=" + entry.mEditorInfo.inputType);
@@ -4123,7 +4136,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                            mWindowManagerInternal.getWindowName(mCurFocusedWindow),
                            mWindowManagerInternal.getWindowName(mCurFocusedWindow),
                            mCurFocusedWindowSoftInputMode, reason, mInFullscreenMode,
                            mCurFocusedWindowSoftInputMode, reason, mInFullscreenMode,
                            mWindowManagerInternal.getWindowName(
                            mWindowManagerInternal.getWindowName(
                                    mShowRequestWindowMap.get(args.arg3))));
                                    mShowRequestWindowMap.get(args.arg3)),
                            mWindowManagerInternal.getImeControlTargetNameForLogging(
                                    mCurTokenDisplayId),
                            mWindowManagerInternal.getImeTargetNameForLogging(
                                    mCurTokenDisplayId)));
                } catch (RemoteException e) {
                } catch (RemoteException e) {
                }
                }
                args.recycle();
                args.recycle();
@@ -4142,7 +4159,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                            mWindowManagerInternal.getWindowName(mCurFocusedWindow),
                            mWindowManagerInternal.getWindowName(mCurFocusedWindow),
                            mCurFocusedWindowSoftInputMode, reason, mInFullscreenMode,
                            mCurFocusedWindowSoftInputMode, reason, mInFullscreenMode,
                            mWindowManagerInternal.getWindowName(
                            mWindowManagerInternal.getWindowName(
                                    mHideRequestWindowMap.get(args.arg3))));
                                    mHideRequestWindowMap.get(args.arg3)),
                            mWindowManagerInternal.getImeControlTargetNameForLogging(
                                    mCurTokenDisplayId),
                            mWindowManagerInternal.getImeTargetNameForLogging(
                                    mCurTokenDisplayId)));
                } catch (RemoteException e) {
                } catch (RemoteException e) {
                }
                }
                args.recycle();
                args.recycle();
+20 −0
Original line number Original line Diff line number Diff line
@@ -576,4 +576,24 @@ public abstract class WindowManagerInternal {
     * @return The corresponding {@link WindowState#getName()}
     * @return The corresponding {@link WindowState#getName()}
     */
     */
    public abstract String getWindowName(@NonNull IBinder binder);
    public abstract String getWindowName(@NonNull IBinder binder);

    /**
     * Return the window name of IME Insets control target.
     *
     * @param displayId The ID of the display which input method is currently focused.
     * @return The corresponding {@link WindowState#getName()}
     */
    public abstract @Nullable String getImeControlTargetNameForLogging(int displayId);

    /**
     * Return the current window name of the input method is on top of.
     *
     * Note that the concept of this window is only reparent the target window behind the input
     * method window, it may different with the window which reported by
     * {@code InputMethodManagerService#reportStartInput} which has input connection.
     *
     * @param displayId The ID of the display which input method is currently focused.
     * @return The corresponding {@link WindowState#getName()}
     */
    public abstract @Nullable String getImeTargetNameForLogging(int displayId);
}
}
+27 −0
Original line number Original line Diff line number Diff line
@@ -7750,6 +7750,33 @@ public class WindowManagerService extends IWindowManager.Stub
                return w != null ? w.getName() : null;
                return w != null ? w.getName() : null;
            }
            }
        }
        }

        @Override
        public String getImeControlTargetNameForLogging(int displayId) {
            synchronized (mGlobalLock) {
                final DisplayContent dc = mRoot.getDisplayContent(displayId);
                if (dc == null) {
                    return null;
                }
                final InsetsControlTarget target = dc.mInputMethodControlTarget;
                if (target == null) {
                    return null;
                }
                final WindowState win = target.getWindow();
                return win != null ? win.getName() : target.toString();
            }
        }

        @Override
        public String getImeTargetNameForLogging(int displayId) {
            synchronized (mGlobalLock) {
                final DisplayContent dc = mRoot.getDisplayContent(displayId);
                if (dc == null) {
                    return null;
                }
                return dc.mInputMethodTarget != null ? dc.mInputMethodTarget.getName() : null;
            }
        }
    }
    }


    void registerAppFreezeListener(AppFreezeListener listener) {
    void registerAppFreezeListener(AppFreezeListener listener) {