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

Commit c59ba280 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Simplify IMMS#onCommandWithSystemIdentity()

This is mechanical refacotring.  There should be no
developer-observable behavior change.

This is a preparation to fix Bug 180765389.

Bug: 180765389
Test: "adb shell ime" still shows help.
Test: "adb shell ime help" still works.
Test: "adb shell ime list" still works.
Test: "adb shell cmd input_method" still shows help.
Test: "adb shell cmd input_method dump" still works.
Test: "adb shell cmd input_method help" still works.
Test: "adb shell cmd input_method ime list" still works.
Change-Id: I2fb5d9d84d9e51890e432e996ca294778d507362
parent be7698d6
Loading
Loading
Loading
Loading
+32 −30
Original line number Diff line number Diff line
@@ -5412,18 +5412,16 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        @BinderThread
        @ShellCommandResult
        private int onCommandWithSystemIdentity(@Nullable String cmd) {
            if ("get-last-switch-user-id".equals(cmd)) {
            switch (TextUtils.emptyIfNull(cmd)) {
                case "get-last-switch-user-id":
                    return mService.getLastSwitchUserId(this);
            }

            // 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;
                }
                case "ime": {  // For "adb shell ime <command>".
                    final String imeCommand = TextUtils.emptyIfNull(getNextArg());
                    switch (imeCommand) {
                        case "":
                        case "-h":
                        case "help":
                            return onImeCommandHelp();
                        case "list":
                            return mService.handleShellCommandListInputMethods(this);
                        case "enable":
@@ -5441,9 +5439,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                            return ShellCommandResult.FAILURE;
                    }
                }

                default:
                    return handleDefaultCommands(cmd);
            }
        }

        @BinderThread
        @Override
@@ -5459,7 +5458,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            }
        }

        private void onImeCommandHelp() {
        @BinderThread
        @ShellCommandResult
        private int onImeCommandHelp() {
            try (IndentingPrintWriter pw =
                         new IndentingPrintWriter(getOutPrintWriter(), "  ", 100)) {
                pw.println("ime <command>:");
@@ -5514,6 +5515,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub

                pw.decreaseIndent();
            }
            return ShellCommandResult.SUCCESS;
        }
    }