Loading services/core/java/com/android/server/inputmethod/AdditionalSubtypeUtils.java +9 −5 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ import android.util.Xml; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; import libcore.io.IoUtils; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; Loading Loading @@ -172,11 +174,13 @@ final class AdditionalSubtypeUtils { out.endTag(null, NODE_SUBTYPES); out.endDocument(); subtypesFile.finishWrite(fos); } catch (java.io.IOException e) { } catch (IOException e) { Slog.w(TAG, "Error writing subtypes", e); if (fos != null) { subtypesFile.failWrite(fos); } } finally { IoUtils.closeQuietly(fos); } } Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +140 −133 Original line number Diff line number Diff line Loading @@ -3169,7 +3169,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } // TODO: Move this clearing calling identity block to setImeWindowStatus after making sure // all updateSystemUi happens on system previlege. // all updateSystemUi happens on system privilege. final long ident = Binder.clearCallingIdentity(); try { if (!mCurPerceptible) { Loading Loading @@ -4180,10 +4180,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub final ImeSubtypeListItem nextSubtype = mSwitchingController.getNextInputMethodLocked( false /* onlyCurrentIme */, mMethodMap.get(getSelectedMethodIdLocked()), mCurrentSubtype); if (nextSubtype == null) { return false; } return true; return nextSubtype != null; } } Loading Loading @@ -6110,9 +6107,9 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } } synchronized (ImfLock.class) { final PrintWriter pr = shellCommand.getOutPrintWriter(); final int[] userIds = InputMethodUtils.resolveUserId(userIdToBeResolved, mSettings.getCurrentUserId(), shellCommand.getErrPrintWriter()); try (PrintWriter pr = shellCommand.getOutPrintWriter()) { for (int userId : userIds) { final List<InputMethodInfo> methods = all ? getInputMethodListLocked(userId, DirectBootAwareness.AUTO) Loading @@ -6133,11 +6130,13 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } } } } return ShellCommandResult.SUCCESS; } /** * Handles {@code adb shell ime enable} and {@code adb shell ime disable}. * * @param shellCommand {@link ShellCommand} object that is handling this command. * @param enabled {@code true} if the command was {@code adb shell ime enable}. * @return Exit code of the command. Loading @@ -6148,9 +6147,9 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub @NonNull ShellCommand shellCommand, boolean enabled) { final int userIdToBeResolved = handleOptionsForCommandsThatOnlyHaveUserOption(shellCommand); final String imeId = shellCommand.getNextArgRequired(); final PrintWriter out = shellCommand.getOutPrintWriter(); final PrintWriter error = shellCommand.getErrPrintWriter(); boolean hasFailed = false; try (PrintWriter out = shellCommand.getOutPrintWriter(); PrintWriter error = shellCommand.getErrPrintWriter()) { synchronized (ImfLock.class) { final int[] userIds = InputMethodUtils.resolveUserId(userIdToBeResolved, mSettings.getCurrentUserId(), shellCommand.getErrPrintWriter()); Loading @@ -6162,6 +6161,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub userId, imeId, enabled, out, error); } } } return hasFailed ? ShellCommandResult.FAILURE : ShellCommandResult.SUCCESS; } Loading Loading @@ -6251,7 +6251,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub + " failed due to its unrecognized IME ID."); return false; } out.print("Input method "); out.print(imeId); out.print(": "); Loading @@ -6264,6 +6263,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub /** * Handles {@code adb shell ime set}. * * @param shellCommand {@link ShellCommand} object that is handling this command. * @return Exit code of the command. */ Loading @@ -6272,9 +6272,9 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub private int handleShellCommandSetInputMethod(@NonNull ShellCommand shellCommand) { final int userIdToBeResolved = handleOptionsForCommandsThatOnlyHaveUserOption(shellCommand); final String imeId = shellCommand.getNextArgRequired(); final PrintWriter out = shellCommand.getOutPrintWriter(); final PrintWriter error = shellCommand.getErrPrintWriter(); boolean hasFailed = false; try (PrintWriter out = shellCommand.getOutPrintWriter(); PrintWriter error = shellCommand.getErrPrintWriter()) { synchronized (ImfLock.class) { final int[] userIds = InputMethodUtils.resolveUserId(userIdToBeResolved, mSettings.getCurrentUserId(), shellCommand.getErrPrintWriter()); Loading @@ -6282,7 +6282,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub if (!userHasDebugPriv(userId, shellCommand)) { continue; } boolean failedToSelectUnknownIme = !switchToInputMethodLocked(imeId, userId); boolean failedToSelectUnknownIme = !switchToInputMethodLocked(imeId, userId); if (failedToSelectUnknownIme) { error.print("Unknown input method "); error.print(imeId); Loading @@ -6300,6 +6301,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub hasFailed |= failedToSelectUnknownIme; } } } return hasFailed ? ShellCommandResult.FAILURE : ShellCommandResult.SUCCESS; } Loading @@ -6311,9 +6313,9 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub @BinderThread @ShellCommandResult private int handleShellCommandResetInputMethod(@NonNull ShellCommand shellCommand) { final PrintWriter out = shellCommand.getOutPrintWriter(); final int userIdToBeResolved = handleOptionsForCommandsThatOnlyHaveUserOption(shellCommand); synchronized (ImfLock.class) { try (PrintWriter out = shellCommand.getOutPrintWriter()) { final int[] userIds = InputMethodUtils.resolveUserId(userIdToBeResolved, mSettings.getCurrentUserId(), shellCommand.getErrPrintWriter()); for (int userId : userIds) { Loading Loading @@ -6365,7 +6367,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub // Reset enabled IMEs. settings.putEnabledInputMethodsStr(""); nextEnabledImes.forEach(imi -> settings.appendAndPutEnabledInputMethodLocked( nextEnabledImes.forEach( imi -> settings.appendAndPutEnabledInputMethodLocked( imi.getId(), false)); // Reset selected IME. Loading @@ -6377,6 +6380,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub nextEnabledImes.forEach(ime -> out.println(" Enabled: " + ime.getId())); } } } return ShellCommandResult.SUCCESS; } Loading @@ -6389,7 +6393,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub @ShellCommandResult private int handleShellCommandTraceInputMethod(@NonNull ShellCommand shellCommand) { final String cmd = shellCommand.getNextArgRequired(); final PrintWriter pw = shellCommand.getOutPrintWriter(); try (PrintWriter pw = shellCommand.getOutPrintWriter()) { switch (cmd) { case "start": ImeTracing.getInstance().startTrace(pw); Loading @@ -6399,13 +6403,16 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub break; // proceed to the next step to update the IME client processes. case "save-for-bugreport": ImeTracing.getInstance().saveForBugreport(pw); return ShellCommandResult.SUCCESS; // no need to update the IME client processes. // no need to update the IME client processes. return ShellCommandResult.SUCCESS; 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; // no need to update the IME client processes. // no need to update the IME client processes. return ShellCommandResult.FAILURE; } } boolean isImeTraceEnabled = ImeTracing.getInstance().isEnabled(); ArrayMap<IBinder, ClientState> clients; Loading services/tests/servicestests/src/com/android/server/inputmethod/InputMethodUtilsTest.java +0 −6 Original line number Diff line number Diff line Loading @@ -199,9 +199,6 @@ public class InputMethodUtilsTest { final InputMethodSubtype nonAutoEnGB = createFakeInputMethodSubtype("en_GB", SUBTYPE_MODE_KEYBOARD, !IS_AUX, !IS_OVERRIDES_IMPLICITLY_ENABLED_SUBTYPE, IS_ASCII_CAPABLE, IS_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE); final InputMethodSubtype nonAutoEnIN = createFakeInputMethodSubtype("en_IN", SUBTYPE_MODE_KEYBOARD, !IS_AUX, !IS_OVERRIDES_IMPLICITLY_ENABLED_SUBTYPE, IS_ASCII_CAPABLE, IS_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE); final InputMethodSubtype nonAutoFrCA = createFakeInputMethodSubtype("fr_CA", SUBTYPE_MODE_KEYBOARD, !IS_AUX, !IS_OVERRIDES_IMPLICITLY_ENABLED_SUBTYPE, IS_ASCII_CAPABLE, IS_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE); Loading Loading @@ -656,9 +653,6 @@ public class InputMethodUtilsTest { final InputMethodSubtype nonAutoEnUS = createFakeInputMethodSubtype("en_US", SUBTYPE_MODE_KEYBOARD, !IS_AUX, !IS_OVERRIDES_IMPLICITLY_ENABLED_SUBTYPE, IS_ASCII_CAPABLE, !IS_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE); final InputMethodSubtype nonAutoEnGB = createFakeInputMethodSubtype("en_GB", SUBTYPE_MODE_KEYBOARD, !IS_AUX, !IS_OVERRIDES_IMPLICITLY_ENABLED_SUBTYPE, IS_ASCII_CAPABLE, IS_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE); final InputMethodSubtype nonAutoFil = createFakeInputMethodSubtype("fil", SUBTYPE_MODE_KEYBOARD, !IS_AUX, !IS_OVERRIDES_IMPLICITLY_ENABLED_SUBTYPE, IS_ASCII_CAPABLE, !IS_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE); Loading Loading
services/core/java/com/android/server/inputmethod/AdditionalSubtypeUtils.java +9 −5 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ import android.util.Xml; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; import libcore.io.IoUtils; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; Loading Loading @@ -172,11 +174,13 @@ final class AdditionalSubtypeUtils { out.endTag(null, NODE_SUBTYPES); out.endDocument(); subtypesFile.finishWrite(fos); } catch (java.io.IOException e) { } catch (IOException e) { Slog.w(TAG, "Error writing subtypes", e); if (fos != null) { subtypesFile.failWrite(fos); } } finally { IoUtils.closeQuietly(fos); } } Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +140 −133 Original line number Diff line number Diff line Loading @@ -3169,7 +3169,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } // TODO: Move this clearing calling identity block to setImeWindowStatus after making sure // all updateSystemUi happens on system previlege. // all updateSystemUi happens on system privilege. final long ident = Binder.clearCallingIdentity(); try { if (!mCurPerceptible) { Loading Loading @@ -4180,10 +4180,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub final ImeSubtypeListItem nextSubtype = mSwitchingController.getNextInputMethodLocked( false /* onlyCurrentIme */, mMethodMap.get(getSelectedMethodIdLocked()), mCurrentSubtype); if (nextSubtype == null) { return false; } return true; return nextSubtype != null; } } Loading Loading @@ -6110,9 +6107,9 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } } synchronized (ImfLock.class) { final PrintWriter pr = shellCommand.getOutPrintWriter(); final int[] userIds = InputMethodUtils.resolveUserId(userIdToBeResolved, mSettings.getCurrentUserId(), shellCommand.getErrPrintWriter()); try (PrintWriter pr = shellCommand.getOutPrintWriter()) { for (int userId : userIds) { final List<InputMethodInfo> methods = all ? getInputMethodListLocked(userId, DirectBootAwareness.AUTO) Loading @@ -6133,11 +6130,13 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub } } } } return ShellCommandResult.SUCCESS; } /** * Handles {@code adb shell ime enable} and {@code adb shell ime disable}. * * @param shellCommand {@link ShellCommand} object that is handling this command. * @param enabled {@code true} if the command was {@code adb shell ime enable}. * @return Exit code of the command. Loading @@ -6148,9 +6147,9 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub @NonNull ShellCommand shellCommand, boolean enabled) { final int userIdToBeResolved = handleOptionsForCommandsThatOnlyHaveUserOption(shellCommand); final String imeId = shellCommand.getNextArgRequired(); final PrintWriter out = shellCommand.getOutPrintWriter(); final PrintWriter error = shellCommand.getErrPrintWriter(); boolean hasFailed = false; try (PrintWriter out = shellCommand.getOutPrintWriter(); PrintWriter error = shellCommand.getErrPrintWriter()) { synchronized (ImfLock.class) { final int[] userIds = InputMethodUtils.resolveUserId(userIdToBeResolved, mSettings.getCurrentUserId(), shellCommand.getErrPrintWriter()); Loading @@ -6162,6 +6161,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub userId, imeId, enabled, out, error); } } } return hasFailed ? ShellCommandResult.FAILURE : ShellCommandResult.SUCCESS; } Loading Loading @@ -6251,7 +6251,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub + " failed due to its unrecognized IME ID."); return false; } out.print("Input method "); out.print(imeId); out.print(": "); Loading @@ -6264,6 +6263,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub /** * Handles {@code adb shell ime set}. * * @param shellCommand {@link ShellCommand} object that is handling this command. * @return Exit code of the command. */ Loading @@ -6272,9 +6272,9 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub private int handleShellCommandSetInputMethod(@NonNull ShellCommand shellCommand) { final int userIdToBeResolved = handleOptionsForCommandsThatOnlyHaveUserOption(shellCommand); final String imeId = shellCommand.getNextArgRequired(); final PrintWriter out = shellCommand.getOutPrintWriter(); final PrintWriter error = shellCommand.getErrPrintWriter(); boolean hasFailed = false; try (PrintWriter out = shellCommand.getOutPrintWriter(); PrintWriter error = shellCommand.getErrPrintWriter()) { synchronized (ImfLock.class) { final int[] userIds = InputMethodUtils.resolveUserId(userIdToBeResolved, mSettings.getCurrentUserId(), shellCommand.getErrPrintWriter()); Loading @@ -6282,7 +6282,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub if (!userHasDebugPriv(userId, shellCommand)) { continue; } boolean failedToSelectUnknownIme = !switchToInputMethodLocked(imeId, userId); boolean failedToSelectUnknownIme = !switchToInputMethodLocked(imeId, userId); if (failedToSelectUnknownIme) { error.print("Unknown input method "); error.print(imeId); Loading @@ -6300,6 +6301,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub hasFailed |= failedToSelectUnknownIme; } } } return hasFailed ? ShellCommandResult.FAILURE : ShellCommandResult.SUCCESS; } Loading @@ -6311,9 +6313,9 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub @BinderThread @ShellCommandResult private int handleShellCommandResetInputMethod(@NonNull ShellCommand shellCommand) { final PrintWriter out = shellCommand.getOutPrintWriter(); final int userIdToBeResolved = handleOptionsForCommandsThatOnlyHaveUserOption(shellCommand); synchronized (ImfLock.class) { try (PrintWriter out = shellCommand.getOutPrintWriter()) { final int[] userIds = InputMethodUtils.resolveUserId(userIdToBeResolved, mSettings.getCurrentUserId(), shellCommand.getErrPrintWriter()); for (int userId : userIds) { Loading Loading @@ -6365,7 +6367,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub // Reset enabled IMEs. settings.putEnabledInputMethodsStr(""); nextEnabledImes.forEach(imi -> settings.appendAndPutEnabledInputMethodLocked( nextEnabledImes.forEach( imi -> settings.appendAndPutEnabledInputMethodLocked( imi.getId(), false)); // Reset selected IME. Loading @@ -6377,6 +6380,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub nextEnabledImes.forEach(ime -> out.println(" Enabled: " + ime.getId())); } } } return ShellCommandResult.SUCCESS; } Loading @@ -6389,7 +6393,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub @ShellCommandResult private int handleShellCommandTraceInputMethod(@NonNull ShellCommand shellCommand) { final String cmd = shellCommand.getNextArgRequired(); final PrintWriter pw = shellCommand.getOutPrintWriter(); try (PrintWriter pw = shellCommand.getOutPrintWriter()) { switch (cmd) { case "start": ImeTracing.getInstance().startTrace(pw); Loading @@ -6399,13 +6403,16 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub break; // proceed to the next step to update the IME client processes. case "save-for-bugreport": ImeTracing.getInstance().saveForBugreport(pw); return ShellCommandResult.SUCCESS; // no need to update the IME client processes. // no need to update the IME client processes. return ShellCommandResult.SUCCESS; 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; // no need to update the IME client processes. // no need to update the IME client processes. return ShellCommandResult.FAILURE; } } boolean isImeTraceEnabled = ImeTracing.getInstance().isEnabled(); ArrayMap<IBinder, ClientState> clients; Loading
services/tests/servicestests/src/com/android/server/inputmethod/InputMethodUtilsTest.java +0 −6 Original line number Diff line number Diff line Loading @@ -199,9 +199,6 @@ public class InputMethodUtilsTest { final InputMethodSubtype nonAutoEnGB = createFakeInputMethodSubtype("en_GB", SUBTYPE_MODE_KEYBOARD, !IS_AUX, !IS_OVERRIDES_IMPLICITLY_ENABLED_SUBTYPE, IS_ASCII_CAPABLE, IS_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE); final InputMethodSubtype nonAutoEnIN = createFakeInputMethodSubtype("en_IN", SUBTYPE_MODE_KEYBOARD, !IS_AUX, !IS_OVERRIDES_IMPLICITLY_ENABLED_SUBTYPE, IS_ASCII_CAPABLE, IS_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE); final InputMethodSubtype nonAutoFrCA = createFakeInputMethodSubtype("fr_CA", SUBTYPE_MODE_KEYBOARD, !IS_AUX, !IS_OVERRIDES_IMPLICITLY_ENABLED_SUBTYPE, IS_ASCII_CAPABLE, IS_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE); Loading Loading @@ -656,9 +653,6 @@ public class InputMethodUtilsTest { final InputMethodSubtype nonAutoEnUS = createFakeInputMethodSubtype("en_US", SUBTYPE_MODE_KEYBOARD, !IS_AUX, !IS_OVERRIDES_IMPLICITLY_ENABLED_SUBTYPE, IS_ASCII_CAPABLE, !IS_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE); final InputMethodSubtype nonAutoEnGB = createFakeInputMethodSubtype("en_GB", SUBTYPE_MODE_KEYBOARD, !IS_AUX, !IS_OVERRIDES_IMPLICITLY_ENABLED_SUBTYPE, IS_ASCII_CAPABLE, IS_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE); final InputMethodSubtype nonAutoFil = createFakeInputMethodSubtype("fil", SUBTYPE_MODE_KEYBOARD, !IS_AUX, !IS_OVERRIDES_IMPLICITLY_ENABLED_SUBTYPE, IS_ASCII_CAPABLE, !IS_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE); Loading