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

Commit eb778956 authored by Ioana Stefan's avatar Ioana Stefan Committed by Android (Google) Code Review
Browse files

Merge "Expose public interface to starting and stopping IME tracing"

parents eeef7c82 e92ea72e
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
@@ -121,7 +121,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;
@@ -4110,6 +4109,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) {
@@ -5772,9 +5809,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
@@ -1817,5 +1817,15 @@ public final class MultiClientInputMethodManagerService {
        public boolean isImeTraceEnabled() {
            return false;
        }

        @BinderThread
        @Override
        public void startImeTrace() {
        }

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