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

Commit 45296595 authored by Ioana Stefan's avatar Ioana Stefan
Browse files

Log only current client data in IME tracing

This change moves from dumping information of all Input Method client
instances to dumping only the current client, which is the one in which
the triggering event happened.

Bug: 154348613
Test: flash a device
      start IME tracing by calling "adb shell ime tracing start"
      end IME tracing by calling "adb shell ime tracing stop"
      pull generated trace files and visualize in Winscope
      or start tracing directly through ADB Connect and visualize traces
Change-Id: I46460d3d08947c7d37a8969a2fed6539f35aaf91
parent d7daa0bd
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.os.ServiceManager.ServiceNotFoundException;
import android.os.ShellCommand;
import android.util.Log;
import android.util.proto.ProtoOutputStream;
import android.view.inputmethod.InputMethodManager;

import com.android.internal.view.IInputMethodManager;

@@ -105,8 +106,9 @@ public abstract class ImeTracing {
     * Starts a proto dump of the client side information.
     *
     * @param where Place where the trace was triggered.
     * @param immInstance The {@link InputMethodManager} instance to dump.
     */
    public abstract void triggerClientDump(String where);
    public abstract void triggerClientDump(String where, InputMethodManager immInstance);

    /**
     * Starts a proto dump of the currently connected InputMethodService information.
+4 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.util.imetracing;

import android.annotation.NonNull;
import android.inputmethodservice.AbstractInputMethodService;
import android.os.RemoteException;
import android.os.ServiceManager.ServiceNotFoundException;
@@ -42,7 +43,7 @@ class ImeTracingClientImpl extends ImeTracing {
    }

    @Override
    public void triggerClientDump(String where) {
    public void triggerClientDump(String where, @NonNull InputMethodManager immInstance) {
        if (!isEnabled() || !isAvailable()) {
            return;
        }
@@ -56,7 +57,7 @@ class ImeTracingClientImpl extends ImeTracing {

        try {
            ProtoOutputStream proto = new ProtoOutputStream();
            InputMethodManager.dumpProto(proto);
            immInstance.dumpDebug(proto);
            sendToService(proto.getBytes(), IME_TRACING_FROM_CLIENT, where);
        } catch (RemoteException e) {
            Log.e(TAG, "Exception while sending ime-related client dump to server", e);
@@ -66,7 +67,7 @@ class ImeTracingClientImpl extends ImeTracing {
    }

    @Override
    public void triggerServiceDump(String where, AbstractInputMethodService service) {
    public void triggerServiceDump(String where, @NonNull AbstractInputMethodService service) {
        if (!isEnabled() || !isAvailable()) {
            return;
        }
+2 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.util.proto.ProtoOutputStream;
import android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceFileProto;
import android.view.inputmethod.InputMethodEditorTraceProto.InputMethodManagerServiceTraceFileProto;
import android.view.inputmethod.InputMethodEditorTraceProto.InputMethodServiceTraceFileProto;
import android.view.inputmethod.InputMethodManager;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.TraceBuffer;
@@ -131,7 +132,7 @@ class ImeTracingServerImpl extends ImeTracing {
    }

    @Override
    public void triggerClientDump(String where) {
    public void triggerClientDump(String where, InputMethodManager immInstance) {
        // Intentionally left empty, this is implemented in ImeTracingClientImpl
    }

+0 −5
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ import android.util.Log;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.util.SparseSetArray;
import android.util.imetracing.ImeTracing;
import android.util.proto.ProtoOutputStream;
import android.view.InsetsState.InternalInsetsSide;
import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams;
@@ -136,10 +135,6 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
        mTranslator = translator;
        mController.startAnimation(this, listener, types, mAnimation,
                new Bounds(mHiddenInsets, mShownInsets));

        if ((mTypes & WindowInsets.Type.ime()) != 0) {
            ImeTracing.getInstance().triggerClientDump("InsetsAnimationControlImpl");
        }
    }

    private boolean calculatePerceptible(Insets currentInsets, float currentAlpha) {
+19 −10
Original line number Diff line number Diff line
@@ -312,11 +312,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation

        @Override
        public void onReady(WindowInsetsAnimationController controller, int types) {
            if ((types & ime()) != 0) {
                ImeTracing.getInstance().triggerClientDump(
                        "InsetsController.InternalAnimationControlListener#onReady");
            }

            mController = controller;
            if (DEBUG) Log.d(TAG, "default animation onReady types: " + types);

@@ -833,7 +828,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            Log.d(TAG, "show(ime(), fromIme=" + fromIme + ")");
        }
        if (fromIme) {
            ImeTracing.getInstance().triggerClientDump("InsetsController#show");
            ImeTracing.getInstance().triggerClientDump("InsetsController#show",
                    mHost.getInputMethodManager());
            Trace.asyncTraceEnd(TRACE_TAG_VIEW, "IC.showRequestFromApiToImeReady", 0);
            Trace.asyncTraceBegin(TRACE_TAG_VIEW, "IC.showRequestFromIme", 0);
        } else {
@@ -889,7 +885,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation

    void hide(@InsetsType int types, boolean fromIme) {
        if (fromIme) {
            ImeTracing.getInstance().triggerClientDump("InsetsController#hide");
            ImeTracing.getInstance().triggerClientDump("InsetsController#hide",
                    mHost.getInputMethodManager());
            Trace.asyncTraceBegin(TRACE_TAG_VIEW, "IC.hideRequestFromIme", 0);
        } else {
            Trace.asyncTraceBegin(TRACE_TAG_VIEW, "IC.hideRequestFromApi", 0);
@@ -930,7 +927,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
        }
        if (fromIme) {
            ImeTracing.getInstance().triggerClientDump(
                    "InsetsController#controlWindowInsetsAnimation");
                    "InsetsController#controlWindowInsetsAnimation",
                    mHost.getInputMethodManager());
        }

        controlAnimationUnchecked(types, cancellationSignal, listener, mFrame, fromIme, durationMs,
@@ -1022,6 +1020,10 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
                : new InsetsAnimationControlImpl(controls,
                        frame, mState, listener, typesReady, this, durationMs, interpolator,
                        animationType, mHost.getTranslator());
        if ((typesReady & WindowInsets.Type.ime()) != 0) {
            ImeTracing.getInstance().triggerClientDump("InsetsAnimationControlImpl",
                    mHost.getInputMethodManager());
        }
        mRunningAnimations.add(new RunningAnimation(runner, animationType));
        if (DEBUG) Log.d(TAG, "Animation added to runner. useInsetsAnimationThread: "
                + useInsetsAnimationThread);
@@ -1195,6 +1197,11 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
                mRunningAnimations.remove(i);
                ArraySet<Integer> types = toInternalType(control.getTypes());
                for (int j = types.size() - 1; j >= 0; j--) {
                    if (types.valueAt(j) == ITYPE_IME) {
                        ImeTracing.getInstance().triggerClientDump(
                                "InsetsSourceConsumer#notifyAnimationFinished",
                                mHost.getInputMethodManager());
                    }
                    stateChanged |= getSourceConsumer(types.valueAt(j)).notifyAnimationFinished();
                }
                if (invokeCallback && runningAnimation.startDispatched) {
@@ -1337,7 +1344,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            @InsetsType int types, boolean animationFinished, @AnimationType int animationType,
            boolean fromIme) {
        if ((types & ime()) != 0) {
            ImeTracing.getInstance().triggerClientDump("InsetsController#hideDirectly");
            ImeTracing.getInstance().triggerClientDump("InsetsController#hideDirectly",
                    mHost.getInputMethodManager());
        }
        final ArraySet<Integer> internalTypes = InsetsState.toInternalType(types);
        for (int i = internalTypes.size() - 1; i >= 0; i--) {
@@ -1352,7 +1360,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation

    private void showDirectly(@InsetsType int types, boolean fromIme) {
        if ((types & ime()) != 0) {
            ImeTracing.getInstance().triggerClientDump("InsetsController#showDirectly");
            ImeTracing.getInstance().triggerClientDump("InsetsController#showDirectly",
                    mHost.getInputMethodManager());
        }
        final ArraySet<Integer> internalTypes = InsetsState.toInternalType(types);
        for (int i = internalTypes.size() - 1; i >= 0; i--) {
Loading