From 9cd0c8a6c62af2c8badbfd482b2944616dfc3c69 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Mon, 4 Feb 2019 22:25:24 -0800 Subject: [PATCH] Fix possible incorrect output from 'adb shell ime reset' This is a follow up CL to my previous CL [1], which enabled InputMethodManager#getEnabledInputMethodList() to return the result based on the caller's user ID, not based on the current IME user, which is mSettings.getCurrentUserId(). Since InputMethodManagerService#handleShellCommandSetInputMethod() always runs as user 0, we cannot actually simply call IMMS#getEnabledInputMethodList() any more from that method. Instead, we should use mSettings.getEnabledInputMethodListLocked() so that the right user's result should be shown on the console. This is a minor fix for the output message of a debug command. There should be no visible behavior change for production use cases. [1]: I192a0f5a1375170d17a4c08af94f23966dbaea8b 7f8ee4b9ddd31ad36a12c5278b27990dc76011cc Bug: 122164939 Fix: 123906510 Test: Manually verified as follows. 1. Build aosp_taimen-userdebug and flash it. 2. make -j SoftKeyboard 3. adb install -r $OUT/system/app/SoftKeyboard/SoftKeyboard.apk 4. adb shell ime enable com.example.android.softkeyboard/.SoftKeyboard 5. adb shell pm create-user test_user 6. adb shell am switch-user 10 7. adb shell ime reset -> Confirm that the output is Reset current and enabled IMEs Newly selected IME: com.android.inputmethod.latin/.LatinIME Newly enabled IMEs: com.android.inputmethod.latin/.LatinIME Change-Id: I4c29ade9373b0fa5ab77f5a349017389ff1fb827 --- .../android/server/inputmethod/InputMethodManagerService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index d20508a5e7049..9d9721d5d4025 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -4697,7 +4697,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mSettings.getCurrentUserId(), mContext.getBasePackageName()); nextIme = mSettings.getSelectedInputMethod(); - nextEnabledImes = getEnabledInputMethodList(); + nextEnabledImes = mSettings.getEnabledInputMethodListLocked(); final PrintWriter pr = shellCommand.getOutPrintWriter(); pr.println("Reset current and enabled IMEs"); pr.println("Newly selected IME:");