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

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

Expose public interface to starting and stopping IME tracing

The added interface makes it possible to start or stop IME tracing from
another process. This will be used together with the DevelopmentTiles to
ghather IME tracing data when the WinscopeTrace tile is used.

Bug: 154348613
Test: flash a device together with the other change in this topic
      enable the WinscopeTrace tile and do some actions
      disable the WinscopeTrace tile
      do a bugreport and visualise contents in Winscope
      or just check contents of /data/misc/wmtrace/ through adb
Change-Id: Id03ede35f71c3d513dea50ef69e4ed4ce05a8d53
parent 6b534458
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -79,4 +79,9 @@ interface IInputMethodManager {
    void removeImeSurfaceFromWindow(in IBinder windowToken);
    void startProtoDump(in byte[] protoDump, int source, String where);
    boolean isImeTraceEnabled();

    // Starts an ime trace.
    void startImeTrace();
    // Stops an ime trace.
    void stopImeTrace();
}
+40 −4
Original line number Diff line number Diff line
@@ -118,7 +118,6 @@ import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.EventLog;
import android.util.IndentingPrintWriter;
import android.util.Log;
import android.util.LruCache;
import android.util.Pair;
import android.util.PrintWriterPrinter;
@@ -4077,6 +4076,44 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        return ImeTracing.getInstance().isEnabled();
    }

    @BinderThread
    @Override
    public void startImeTrace() {
        ImeTracing.getInstance().startTrace(null /* printwriter */);
        ArrayMap<IBinder, ClientState> clients;
        synchronized (mMethodMap) {
            clients = new ArrayMap<>(mClients);
        }
        for (ClientState state : clients.values()) {
            if (state != null) {
                try {
                    state.client.setImeTraceEnabled(true /* enabled */);
                } catch (RemoteException e) {
                    Slog.e(TAG, "Error while trying to enable ime trace on client window", e);
                }
            }
        }
    }

    @BinderThread
    @Override
    public void stopImeTrace() {
        ImeTracing.getInstance().stopTrace(null /* printwriter */);
        ArrayMap<IBinder, ClientState> clients;
        synchronized (mMethodMap) {
            clients = new ArrayMap<>(mClients);
        }
        for (ClientState state : clients.values()) {
            if (state != null) {
                try {
                    state.client.setImeTraceEnabled(false /* enabled */);
                } catch (RemoteException e) {
                    Slog.e(TAG, "Error while trying to disable ime trace on client window", e);
                }
            }
        }
    }

    @GuardedBy("mMethodMap")
    private void dumpDebug(ProtoOutputStream proto, long fieldId) {
        synchronized (mMethodMap) {
@@ -5722,9 +5759,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                try {
                    state.client.setImeTraceEnabled(isImeTraceEnabled);
                } catch (RemoteException e) {
                    Log.e(TAG,
                            "Error while trying to enable/disable ime "
                            + "trace on client window", e);
                    Slog.e(TAG, "Error while trying to enable/disable ime trace on client window",
                            e);
                }
            }
        }
+10 −0
Original line number Diff line number Diff line
@@ -1816,5 +1816,15 @@ public final class MultiClientInputMethodManagerService {
        public boolean isImeTraceEnabled() {
            return false;
        }

        @BinderThread
        @Override
        public void startImeTrace() {
        }

        @BinderThread
        @Override
        public void stopImeTrace() {
        }
    }
}