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

Commit 5c1e6751 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Dump more info for View when IMM#DEBUG is true.

This is a preparation CL to fix Bug 27858665.  In order to debug issues
like this, we want to record following information about View.
 - Whether the View is focused or not.
 - Whether the Window to which the View belongs is focused or not.
 - Whether the View belongs to a Window or not.

This CL has no impact on production build where IMM#DEBUG is false.

Bug: 18920212
Change-Id: I06bcd5e42d55f96a9e916eb34ed7785cfe14c96f
parent 9194f344
Loading
Loading
Loading
Loading
+26 −15
Original line number Original line Diff line number Diff line
@@ -832,7 +832,7 @@ public final class InputMethodManager {
    void finishInputLocked() {
    void finishInputLocked() {
        mNextServedView = null;
        mNextServedView = null;
        if (mServedView != null) {
        if (mServedView != null) {
            if (DEBUG) Log.v(TAG, "FINISH INPUT: " + mServedView);
            if (DEBUG) Log.v(TAG, "FINISH INPUT: mServedView=" + dumpViewInfo(mServedView));
            if (mCurrentTextBoxAttribute != null) {
            if (mCurrentTextBoxAttribute != null) {
                try {
                try {
                    mService.finishInput(mClient);
                    mService.finishInput(mClient);
@@ -1144,7 +1144,7 @@ public final class InputMethodManager {


            // Make sure we have a window token for the served view.
            // Make sure we have a window token for the served view.
            if (DEBUG) {
            if (DEBUG) {
                Log.v(TAG, "Starting input: view=" + view +
                Log.v(TAG, "Starting input: view=" + dumpViewInfo(view) +
                        " reason=" + InputMethodClient.getStartInputReason(startInputReason));
                        " reason=" + InputMethodClient.getStartInputReason(startInputReason));
            }
            }
            if (view == null) {
            if (view == null) {
@@ -1198,8 +1198,9 @@ public final class InputMethodManager {
            if (mServedView != view || !mServedConnecting) {
            if (mServedView != view || !mServedConnecting) {
                // Something else happened, so abort.
                // Something else happened, so abort.
                if (DEBUG) Log.v(TAG,
                if (DEBUG) Log.v(TAG,
                        "Starting input: finished by someone else (view="
                        "Starting input: finished by someone else. view=" + dumpViewInfo(view)
                        + mServedView + " conn=" + mServedConnecting + ")");
                        + " mServedView=" + dumpViewInfo(mServedView)
                        + " mServedConnecting=" + mServedConnecting);
                return false;
                return false;
            }
            }


@@ -1243,7 +1244,7 @@ public final class InputMethodManager {
            mServedInputConnectionWrapper = servedContext;
            mServedInputConnectionWrapper = servedContext;


            try {
            try {
                if (DEBUG) Log.v(TAG, "START INPUT: " + view + " ic="
                if (DEBUG) Log.v(TAG, "START INPUT: view=" + dumpViewInfo(view) + " ic="
                        + ic + " tba=" + tba + " controlFlags=#"
                        + ic + " tba=" + tba + " controlFlags=#"
                        + Integer.toHexString(controlFlags));
                        + Integer.toHexString(controlFlags));
                final InputBindResult res = mService.startInputOrWindowGainedFocus(
                final InputBindResult res = mService.startInputOrWindowGainedFocus(
@@ -1309,7 +1310,7 @@ public final class InputMethodManager {
    }
    }


    void focusInLocked(View view) {
    void focusInLocked(View view) {
        if (DEBUG) Log.v(TAG, "focusIn: " + view);
        if (DEBUG) Log.v(TAG, "focusIn: " + dumpViewInfo(view));


        if (mCurRootView != view.getRootView()) {
        if (mCurRootView != view.getRootView()) {
            // This is a request from a window that isn't in the window with
            // This is a request from a window that isn't in the window with
@@ -1328,9 +1329,8 @@ public final class InputMethodManager {
     */
     */
    public void focusOut(View view) {
    public void focusOut(View view) {
        synchronized (mH) {
        synchronized (mH) {
            if (DEBUG) Log.v(TAG, "focusOut: " + view
            if (DEBUG) Log.v(TAG, "focusOut: view=" + dumpViewInfo(view)
                    + " mServedView=" + mServedView
                    + " mServedView=" + dumpViewInfo(mServedView));
                    + " winFocus=" + view.hasWindowFocus());
            if (mServedView != view) {
            if (mServedView != view) {
                // The following code would auto-hide the IME if we end up
                // The following code would auto-hide the IME if we end up
                // with no more views with focus.  This can happen, however,
                // with no more views with focus.  This can happen, however,
@@ -1351,9 +1351,8 @@ public final class InputMethodManager {
     */
     */
    public void onViewDetachedFromWindow(View view) {
    public void onViewDetachedFromWindow(View view) {
        synchronized (mH) {
        synchronized (mH) {
            if (DEBUG) Log.v(TAG, "onViewDetachedFromWindow: " + view
            if (DEBUG) Log.v(TAG, "onViewDetachedFromWindow: view=" + dumpViewInfo(view)
                    + " mServedView=" + mServedView
                    + " mServedView=" + dumpViewInfo(mServedView));
                    + " hasWindowFocus=" + view.hasWindowFocus());
            if (mServedView == view && view.hasWindowFocus()) {
            if (mServedView == view && view.hasWindowFocus()) {
                mNextServedView = null;
                mNextServedView = null;
                scheduleCheckFocusLocked(view);
                scheduleCheckFocusLocked(view);
@@ -2311,4 +2310,16 @@ public final class InputMethodManager {
            }
            }
        }
        }
    }
    }

    private static String dumpViewInfo(@Nullable final View view) {
        if (view == null) {
            return "null";
        }
        final StringBuilder sb = new StringBuilder();
        sb.append(view);
        sb.append(",focus=" + view.hasFocus());
        sb.append(",windowFocus=" + view.hasWindowFocus());
        sb.append(",window=" + view.getWindowToken());
        return sb.toString();
    }
}
}