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

Commit 284aecda authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move dumpViewInfo from InputMethodManager to InputMethodDebug"

parents 8eb254ef 9f3c04e5
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -181,7 +181,8 @@ public final class ImeFocusController {
        if (!view.hasImeFocus() || !view.hasWindowFocus()) {
            return;
        }
        if (DEBUG) Log.d(TAG, "onViewFocusChanged, view=" + view + ", mServedView=" + mServedView);
        if (DEBUG) Log.d(TAG, "onViewFocusChanged, view=" + InputMethodDebug.dumpViewInfo(view)
                + ", mServedView=" + InputMethodDebug.dumpViewInfo(mServedView));

        // We don't need to track the next served view when the view lost focus here because:
        // 1) The current view focus may be cleared temporary when in touch mode, closing input
+7 −24
Original line number Diff line number Diff line
@@ -1771,7 +1771,7 @@ public final class InputMethodManager {
        if (getServedViewLocked() != null) {
            if (DEBUG) {
                Log.v(TAG, "FINISH INPUT: mServedView="
                        + dumpViewInfo(getServedViewLocked()));
                        + InputMethodDebug.dumpViewInfo(getServedViewLocked()));
            }
            setServedViewLocked(null);
            mCompletions = null;
@@ -2304,7 +2304,7 @@ public final class InputMethodManager {

            // Make sure we have a window token for the served view.
            if (DEBUG) {
                Log.v(TAG, "Starting input: view=" + dumpViewInfo(view) +
                Log.v(TAG, "Starting input: view=" + InputMethodDebug.dumpViewInfo(view) +
                        " reason=" + InputMethodDebug.startInputReasonToString(startInputReason));
            }
            if (view == null) {
@@ -2375,9 +2375,9 @@ public final class InputMethodManager {
            final View servedView = getServedViewLocked();
            if (servedView != view || !mServedConnecting) {
                // Something else happened, so abort.
                if (DEBUG) Log.v(TAG,
                        "Starting input: finished by someone else. view=" + dumpViewInfo(view)
                        + " servedView=" + dumpViewInfo(servedView)
                if (DEBUG) Log.v(TAG, "Starting input: finished by someone else."
                        + " view=" + InputMethodDebug.dumpViewInfo(view)
                        + " servedView=" + InputMethodDebug.dumpViewInfo(servedView)
                        + " mServedConnecting=" + mServedConnecting);
                if (mServedInputConnection != null && startInputReason == BOUND_TO_IMMS) {
                    // This is not an error. Once IME binds (MSG_BIND), InputConnection is fully
@@ -2437,8 +2437,8 @@ public final class InputMethodManager {
            mServedInputConnection = servedInputConnection;

            if (DEBUG) {
                Log.v(TAG, "START INPUT: view=" + dumpViewInfo(view) + " ic="
                        + ic + " editorInfo=" + editorInfo + " startInputFlags="
                Log.v(TAG, "START INPUT: view=" + InputMethodDebug.dumpViewInfo(view)
                        + " ic=" + ic + " editorInfo=" + editorInfo + " startInputFlags="
                        + InputMethodDebug.startInputFlagsToString(startInputFlags));
            }

@@ -3774,23 +3774,6 @@ public final class InputMethodManager {
        return mCurBindState != null ? mCurBindState.mBindSequence : -1;
    }

    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(",autofillUiShowing=" + isAutofillUIShowing(view));
        sb.append(",window=" + view.getWindowToken());
        sb.append(",displayId=" + view.getContext().getDisplayId());
        sb.append(",temporaryDetach=" + view.isTemporarilyDetached());
        sb.append(",hasImeFocus=" + view.hasImeFocus());

        return sb.toString();
    }

    /**
     * Checks the args to see if a proto-based ime dump was requested and writes the client side
     * ime dump to the given {@link FileDescriptor}.
+15 −13
Original line number Diff line number Diff line
@@ -16,10 +16,11 @@

package com.android.internal.inputmethod;

import android.annotation.AnyThread;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams.SoftInputModeFlags;
import android.view.autofill.AutofillManager;
import android.view.inputmethod.HandwritingGesture;

import java.util.StringJoiner;
@@ -281,20 +282,21 @@ public final class InputMethodDebug {
    }

    /**
     * Return a fixed size string of the object.
     * TODO(b/151575861): Take & return with StringBuilder to make more memory efficient.
     * Dumps the given {@link View} related to input method focus state for debugging.
     */
    @NonNull
    @AnyThread
    public static String objToString(Object obj) {
        if (obj == null) {
    public static String dumpViewInfo(@Nullable View view) {
        if (view == null) {
            return "null";
        }
        StringBuilder sb = new StringBuilder(64);
        sb.setLength(0);
        sb.append(obj.getClass().getName());
        sb.append("@");
        sb.append(Integer.toHexString(obj.hashCode()));
        final StringBuilder sb = new StringBuilder();
        sb.append(view);
        sb.append(",focus=" + view.hasFocus());
        sb.append(",windowFocus=" + view.hasWindowFocus());
        sb.append(",window=" + view.getWindowToken());
        sb.append(",displayId=" + view.getContext().getDisplayId());
        sb.append(",temporaryDetach=" + view.isTemporarilyDetached());
        sb.append(",hasImeFocus=" + view.hasImeFocus());

        return sb.toString();
    }
}