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

Commit 62c5a29e authored by Yohei Yukawa's avatar Yohei Yukawa Committed by Android (Google) Code Review
Browse files

Merge "Simplify IMMS#onCommandWithSystemIdentity()" into sc-dev

parents 0e35769c c59ba280
Loading
Loading
Loading
Loading
+32 −30
Original line number Diff line number Diff line
@@ -5414,18 +5414,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":
@@ -5443,9 +5441,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                            return ShellCommandResult.FAILURE;
                    }
                }

                default:
                    return handleDefaultCommands(cmd);
            }
        }

        @BinderThread
        @Override
@@ -5461,7 +5460,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>:");
@@ -5516,6 +5517,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub

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