Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +25 −1 Original line number Original line Diff line number Diff line Loading @@ -4690,9 +4690,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub private int handleShellCommandEnableDisableInputMethod( private int handleShellCommandEnableDisableInputMethod( @NonNull ShellCommand shellCommand, boolean enabled) { @NonNull ShellCommand shellCommand, boolean enabled) { final String id = shellCommand.getNextArgRequired(); final String id = shellCommand.getNextArgRequired(); final boolean previouslyEnabled; final boolean previouslyEnabled; synchronized (mMethodMap) { synchronized (mMethodMap) { if (!userHasDebugPriv(mSettings.getCurrentUserId(), shellCommand)) { return ShellCommandResult.SUCCESS; } previouslyEnabled = setInputMethodEnabledLocked(id, enabled); previouslyEnabled = setInputMethodEnabledLocked(id, enabled); } } final PrintWriter pr = shellCommand.getOutPrintWriter(); final PrintWriter pr = shellCommand.getOutPrintWriter(); Loading @@ -4714,6 +4716,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub private int handleShellCommandSetInputMethod(@NonNull ShellCommand shellCommand) { private int handleShellCommandSetInputMethod(@NonNull ShellCommand shellCommand) { final String id = shellCommand.getNextArgRequired(); final String id = shellCommand.getNextArgRequired(); synchronized (mMethodMap) { synchronized (mMethodMap) { if (!userHasDebugPriv(mSettings.getCurrentUserId(), shellCommand)) { return ShellCommandResult.SUCCESS; } setInputMethodLocked(id, NOT_A_SUBTYPE_ID); setInputMethodLocked(id, NOT_A_SUBTYPE_ID); } } final PrintWriter pr = shellCommand.getOutPrintWriter(); final PrintWriter pr = shellCommand.getOutPrintWriter(); Loading @@ -4732,6 +4737,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub @ShellCommandResult @ShellCommandResult private int handleShellCommandResetInputMethod(@NonNull ShellCommand shellCommand) { private int handleShellCommandResetInputMethod(@NonNull ShellCommand shellCommand) { synchronized (mMethodMap) { synchronized (mMethodMap) { if (!userHasDebugPriv(mSettings.getCurrentUserId(), shellCommand)) { return ShellCommandResult.SUCCESS; } final String nextIme; final String nextIme; final List<InputMethodInfo> nextEnabledImes; final List<InputMethodInfo> nextEnabledImes; hideCurrentInputLocked(0, null); hideCurrentInputLocked(0, null); Loading Loading @@ -4769,6 +4777,22 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } /** * @param userId the actual user handle obtained by {@link UserHandle#getIdentifier()} * and *not* pseudo ids like {@link UserHandle#USER_ALL etc}. * @return {@code true} if userId has debugging privileges. * i.e. {@link UserManager#DISALLOW_DEBUGGING_FEATURES} is {@code false}. */ private boolean userHasDebugPriv(int userId, final ShellCommand shellCommand) { if (mUserManager.hasUserRestriction( UserManager.DISALLOW_DEBUGGING_FEATURES, UserHandle.of(userId))) { shellCommand.getErrPrintWriter().println("User #" + userId + " is restricted with DISALLOW_DEBUGGING_FEATURES."); return false; } return true; } private static final class InputMethodPrivilegedOperationsImpl private static final class InputMethodPrivilegedOperationsImpl extends IInputMethodPrivilegedOperations.Stub { extends IInputMethodPrivilegedOperations.Stub { private final InputMethodManagerService mImms; private final InputMethodManagerService mImms; Loading Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +25 −1 Original line number Original line Diff line number Diff line Loading @@ -4690,9 +4690,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub private int handleShellCommandEnableDisableInputMethod( private int handleShellCommandEnableDisableInputMethod( @NonNull ShellCommand shellCommand, boolean enabled) { @NonNull ShellCommand shellCommand, boolean enabled) { final String id = shellCommand.getNextArgRequired(); final String id = shellCommand.getNextArgRequired(); final boolean previouslyEnabled; final boolean previouslyEnabled; synchronized (mMethodMap) { synchronized (mMethodMap) { if (!userHasDebugPriv(mSettings.getCurrentUserId(), shellCommand)) { return ShellCommandResult.SUCCESS; } previouslyEnabled = setInputMethodEnabledLocked(id, enabled); previouslyEnabled = setInputMethodEnabledLocked(id, enabled); } } final PrintWriter pr = shellCommand.getOutPrintWriter(); final PrintWriter pr = shellCommand.getOutPrintWriter(); Loading @@ -4714,6 +4716,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub private int handleShellCommandSetInputMethod(@NonNull ShellCommand shellCommand) { private int handleShellCommandSetInputMethod(@NonNull ShellCommand shellCommand) { final String id = shellCommand.getNextArgRequired(); final String id = shellCommand.getNextArgRequired(); synchronized (mMethodMap) { synchronized (mMethodMap) { if (!userHasDebugPriv(mSettings.getCurrentUserId(), shellCommand)) { return ShellCommandResult.SUCCESS; } setInputMethodLocked(id, NOT_A_SUBTYPE_ID); setInputMethodLocked(id, NOT_A_SUBTYPE_ID); } } final PrintWriter pr = shellCommand.getOutPrintWriter(); final PrintWriter pr = shellCommand.getOutPrintWriter(); Loading @@ -4732,6 +4737,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub @ShellCommandResult @ShellCommandResult private int handleShellCommandResetInputMethod(@NonNull ShellCommand shellCommand) { private int handleShellCommandResetInputMethod(@NonNull ShellCommand shellCommand) { synchronized (mMethodMap) { synchronized (mMethodMap) { if (!userHasDebugPriv(mSettings.getCurrentUserId(), shellCommand)) { return ShellCommandResult.SUCCESS; } final String nextIme; final String nextIme; final List<InputMethodInfo> nextEnabledImes; final List<InputMethodInfo> nextEnabledImes; hideCurrentInputLocked(0, null); hideCurrentInputLocked(0, null); Loading Loading @@ -4769,6 +4777,22 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } } } /** * @param userId the actual user handle obtained by {@link UserHandle#getIdentifier()} * and *not* pseudo ids like {@link UserHandle#USER_ALL etc}. * @return {@code true} if userId has debugging privileges. * i.e. {@link UserManager#DISALLOW_DEBUGGING_FEATURES} is {@code false}. */ private boolean userHasDebugPriv(int userId, final ShellCommand shellCommand) { if (mUserManager.hasUserRestriction( UserManager.DISALLOW_DEBUGGING_FEATURES, UserHandle.of(userId))) { shellCommand.getErrPrintWriter().println("User #" + userId + " is restricted with DISALLOW_DEBUGGING_FEATURES."); return false; } return true; } private static final class InputMethodPrivilegedOperationsImpl private static final class InputMethodPrivilegedOperationsImpl extends IInputMethodPrivilegedOperations.Stub { extends IInputMethodPrivilegedOperations.Stub { private final InputMethodManagerService mImms; private final InputMethodManagerService mImms; Loading