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

Commit 557afbb6 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Log display IDs for both IME and IME-client in StartInputHistory

This is a follow up CL to a recent CL [1], which added a special
fallback mechanism for IMEs to be shown on the default display when
the target display doesn't have FLAG_CAN_SHOW_SYSTEM_DECORATIONS.

It turns out that this scenario will soon become more user-visible
once Bubble UI is enabled, because Bubble UI is built on top of
ActivityView, where the target Activity including any text input field
will be running on a virtual display, not on the default display,
while IMEs are expected to continue running on the default display.

To make it easier to diagnose this new scenario, this CL updates our
retrospective debugging mechanism called StartInputHistory [2].  With
this CL, InputMethodManagerService starts keeping track of both IME
display ID and IME client display ID for each StartInput so that we
can see them later into the StartInputHistory section of the
bugreport.

For Bubble UI scenario for instance, we would see a log like this:

  ... imeDisplayId=0 ... targetDisplayId=1 ...

There should be no user-visible behavior change.

 [1]: Iedd71e4ddf4983f90b02dd72e471e7fa8e838fbf
      ef1965bd
 [2]: Icb29c4ef0703553ead8654d3255a554de6d1a9b4
      357b2f60

Bug: 35079353
Bug: 114350902
Test: Manually verified with Bubble test app and run 'adb shell
      dumpsys input_method' to see that a virtual display ID is logged
      when typing on Bubble UI.
Change-Id: I6f40d86a03a7965d72af7e9a1b6466350b7dfab7
parent 1466e4a4
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -669,11 +669,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        final long mWallTime;
        @NonNull
        final IBinder mImeToken;
        final int mImeDisplayId;
        @NonNull
        final String mImeId;
        @StartInputReason
        final int mStartInputReason;
        final boolean mRestarting;
        final int mTargetDisplayId;
        @Nullable
        final IBinder mTargetWindow;
        @NonNull
@@ -682,17 +684,19 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        final int mTargetWindowSoftInputMode;
        final int mClientBindSequenceNumber;

        StartInputInfo(@NonNull IBinder imeToken, @NonNull String imeId,
                @StartInputReason int startInputReason, boolean restarting,
        StartInputInfo(@NonNull IBinder imeToken, int imeDisplayId, @NonNull String imeId,
                @StartInputReason int startInputReason, boolean restarting, int targetDisplayId,
                @Nullable IBinder targetWindow, @NonNull EditorInfo editorInfo,
                @SoftInputModeFlags int targetWindowSoftInputMode, int clientBindSequenceNumber) {
            mSequenceNumber = sSequenceNumber.getAndIncrement();
            mTimestamp = SystemClock.uptimeMillis();
            mWallTime = System.currentTimeMillis();
            mImeToken = imeToken;
            mImeDisplayId = imeDisplayId;
            mImeId = imeId;
            mStartInputReason = startInputReason;
            mRestarting = restarting;
            mTargetDisplayId = targetDisplayId;
            mTargetWindow = targetWindow;
            mEditorInfo = editorInfo;
            mTargetWindowSoftInputMode = targetWindowSoftInputMode;
@@ -751,11 +755,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            long mWallTime;
            @NonNull
            String mImeTokenString;
            int mImeDisplayId;
            @NonNull
            String mImeId;
            @StartInputReason
            int mStartInputReason;
            boolean mRestarting;
            int mTargetDisplayId;
            @NonNull
            String mTargetWindowString;
            @NonNull
@@ -775,9 +781,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                // Intentionally convert to String so as not to keep a strong reference to a Binder
                // object.
                mImeTokenString = String.valueOf(original.mImeToken);
                mImeDisplayId = original.mImeDisplayId;
                mImeId = original.mImeId;
                mStartInputReason = original.mStartInputReason;
                mRestarting = original.mRestarting;
                mTargetDisplayId = original.mTargetDisplayId;
                // Intentionally convert to String so as not to keep a strong reference to a Binder
                // object.
                mTargetWindowString = String.valueOf(original.mTargetWindow);
@@ -821,11 +829,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                        + " restarting=" + entry.mRestarting);

                pw.print(prefix);
                pw.println(" imeToken=" + entry.mImeTokenString + " [" + entry.mImeId + "]");
                pw.print(" imeToken=" + entry.mImeTokenString + " [" + entry.mImeId + "]");
                pw.println(" imeDisplayId=" + entry.mImeDisplayId);

                pw.print(prefix);
                pw.println(" targetWin=" + entry.mTargetWindowString
                        + " [" + entry.mEditorInfo.packageName + "]"
                        + " targetDisplayId=" + entry.mTargetDisplayId
                        + " clientBindSeq=" + entry.mClientBindSequenceNumber);

                pw.print(prefix);
@@ -1904,9 +1914,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        }

        final Binder startInputToken = new Binder();
        final StartInputInfo info = new StartInputInfo(mCurToken, mCurId, startInputReason,
                !initial, mCurFocusedWindow, mCurAttribute, mCurFocusedWindowSoftInputMode,
                mCurSeq);
        final StartInputInfo info = new StartInputInfo(mCurToken, mCurTokenDisplayId, mCurId,
                startInputReason, !initial, mCurClient.selfReportedDisplayId, mCurFocusedWindow,
                mCurAttribute, mCurFocusedWindowSoftInputMode, mCurSeq);
        mImeTargetWindowMap.put(startInputToken, mCurFocusedWindow);
        mStartInputHistory.addEntry(info);