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

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

Merge "Inline ImeTracing#onShellCommand()" into sc-dev

parents 13227f7a 11919f5d
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.inputmethodservice.AbstractInputMethodService;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager.ServiceNotFoundException;
import android.os.ShellCommand;
import android.util.Log;
import android.util.proto.ProtoOutputStream;
import android.view.inputmethod.InputMethodManager;
@@ -103,12 +102,6 @@ public abstract class ImeTracing {
     */
    public abstract void addToBuffer(ProtoOutputStream proto, int source);

    /**
     * @param shell The shell command to process
     * @return {@code 0} if the command was successfully processed, {@code -1} otherwise
     */
    public abstract int onShellCommand(ShellCommand shell);

    /**
     * Starts a proto dump of the client side information.
     *
+0 −6
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.annotation.NonNull;
import android.inputmethodservice.AbstractInputMethodService;
import android.os.RemoteException;
import android.os.ServiceManager.ServiceNotFoundException;
import android.os.ShellCommand;
import android.util.Log;
import android.util.proto.ProtoOutputStream;
import android.view.inputmethod.InputMethodManager;
@@ -44,11 +43,6 @@ class ImeTracingClientImpl extends ImeTracing {
    public void addToBuffer(ProtoOutputStream proto, int source) {
    }

    @Override
    public int onShellCommand(ShellCommand shell) {
        return -1;
    }

    @Override
    public void triggerClientDump(String where, @NonNull InputMethodManager immInstance,
            ProtoOutputStream icProto) {
+0 −27
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.annotation.Nullable;
import android.inputmethodservice.AbstractInputMethodService;
import android.os.RemoteException;
import android.os.ServiceManager.ServiceNotFoundException;
import android.os.ShellCommand;
import android.util.Log;
import android.util.proto.ProtoOutputStream;
import android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceFileProto;
@@ -106,32 +105,6 @@ class ImeTracingServerImpl extends ImeTracing {
        }
    }

    /**
     * Responds to a shell command of the format "adb shell cmd input_method ime tracing <command>"
     *
     * @param shell The shell command to process
     * @return {@code 0} if the command was valid and successfully processed, {@code -1} otherwise
     */
    @Override
    public int onShellCommand(ShellCommand shell) {
        PrintWriter pw = shell.getOutPrintWriter();
        String cmd = shell.getNextArgRequired();
        switch (cmd) {
            case "start":
                startTrace(pw);
                return 0;
            case "stop":
                stopTrace(pw);
                return 0;
            default:
                pw.println("Unknown command: " + cmd);
                pw.println("Input method trace options:");
                pw.println("  start: Start tracing");
                pw.println("  stop: Stop tracing");
                return -1;
        }
    }

    @Override
    public void triggerClientDump(String where, InputMethodManager immInstance,
            ProtoOutputStream icProto) {
+17 −2
Original line number Diff line number Diff line
@@ -5838,7 +5838,22 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    @BinderThread
    @ShellCommandResult
    private int handleShellCommandTraceInputMethod(@NonNull ShellCommand shellCommand) {
        int result = ImeTracing.getInstance().onShellCommand(shellCommand);
        final String cmd = shellCommand.getNextArgRequired();
        final PrintWriter pw = shellCommand.getOutPrintWriter();
        switch (cmd) {
            case "start":
                ImeTracing.getInstance().getInstance().startTrace(pw);
                break;
            case "stop":
                ImeTracing.getInstance().stopTrace(pw);
                break;
            default:
                pw.println("Unknown command: " + cmd);
                pw.println("Input method trace options:");
                pw.println("  start: Start tracing");
                pw.println("  stop: Stop tracing");
                return ShellCommandResult.FAILURE;
        }
        boolean isImeTraceEnabled = ImeTracing.getInstance().isEnabled();
        ArrayMap<IBinder, ClientState> clients;
        synchronized (mMethodMap) {
@@ -5854,7 +5869,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                }
            }
        }
        return result;
        return ShellCommandResult.SUCCESS;
    }

    /**