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

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

Merge "Map "shell ime" to "shell cmd input_method ime""

parents 7221ed9a cac97720
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
#!/system/bin/sh
exec cmd input_method "$@"
exec cmd input_method ime "$@"
+67 −29
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import com.android.internal.os.SomeArgs;
import com.android.internal.os.TransferPipe;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.view.IInputContext;
import com.android.internal.view.IInputMethod;
import com.android.internal.view.IInputMethodClient;
@@ -4663,10 +4664,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        @ShellCommandResult
        @Override
        public int onCommand(@Nullable String cmd) {
            if (cmd == null) {
                return handleDefaultCommands(cmd);
            // For existing "adb shell ime <command>".
            if ("ime".equals(cmd)) {
                final String imeCommand = getNextArg();
                if (imeCommand == null || "help".equals(imeCommand) || "-h".equals(imeCommand)) {
                    onImeCommandHelp();
                    return ShellCommandResult.SUCCESS;
                }
            switch (cmd) {
                switch (imeCommand) {
                    case "list":
                        return mService.handleShellCommandListInputMethods(this);
                    case "enable":
@@ -4675,13 +4680,17 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                        return mService.handleShellCommandEnableDisableInputMethod(this, false);
                    case "set":
                        return mService.handleShellCommandSetInputMethod(this);
                case "reset-ime":
                    case "reset":
                        return mService.handleShellCommandResetInputMethod(this);
                    default:
                    return handleDefaultCommands(cmd);
                        getOutPrintWriter().println("Unknown command: " + imeCommand);
                        return ShellCommandResult.FAILURE;
                }
            }

            return handleDefaultCommands(cmd);
        }

        @BinderThread
        @Override
        public void onHelp() {
@@ -4691,19 +4700,48 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                pw.println("    Prints this help text.");
                pw.println("  dump [options]");
                pw.println("    Synonym of dumpsys.");
                pw.println("  ime <command> [options]");
                pw.println("    Manipulate IMEs.  Run \"ime help\" for details.");
            }
        }

        private void onImeCommandHelp() {
            try (IndentingPrintWriter pw =
                         new IndentingPrintWriter(getOutPrintWriter(), "  ", 100)) {
                pw.println("ime <command>:");
                pw.increaseIndent();

                pw.println("list [-a] [-s]");
                pw.increaseIndent();
                pw.println("prints all enabled input methods.");
                pw.increaseIndent();
                pw.println("-a: see all input methods");
                pw.println("-s: only a single summary line of each");
                pw.decreaseIndent();
                pw.decreaseIndent();

                pw.println("enable <ID>");
                pw.increaseIndent();
                pw.println("allows the given input method ID to be used.");
                pw.decreaseIndent();

                pw.println("disable <ID>");
                pw.increaseIndent();
                pw.println("disallows the given input method ID to be used.");
                pw.decreaseIndent();

                pw.println("set <ID>");
                pw.increaseIndent();
                pw.println("switches to the given input method ID.");
                pw.println("  reset-ime");
                pw.println("    reset currently selected/enabled IMEs to the default ones as if");
                pw.println("    the device is initially booted with the current locale.");
                pw.decreaseIndent();

                pw.println("reset");
                pw.increaseIndent();
                pw.println("reset currently selected/enabled IMEs to the default ones as if "
                        + "the device is initially booted with the current locale.");
                pw.decreaseIndent();

                pw.decreaseIndent();
            }
        }
    }