From cf3bbffa899437f028a0da5092f20a93b9a3b96a Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Tue, 20 Nov 2018 17:24:20 -0800 Subject: [PATCH] Simplify IMMS#showInputMethodMenu() a bit SwitchingController#getSortedInputMethodAndSubtypeListLocked() is anyway called to determine what items should be shown on the IME switcher dialog, whether there is no item to show or not should also be determined by the same method. There is no need to call getExplicitlyOrImplicitlyEnabledInputMethodsAndSubtypeListLocked() just to check whether its result is empty or not. Bug: 119837138 Test: Locally verified as follows: 1. Build and flash aosp_taimen-userdebug into taimen. 2. adb shell "settings put secure enabled_input_methods 'com.android.inputmethod.latin/.LatinIME;-921088104;-1337596075'" 3. Open the Dialer app and tap the top edit field. 4. Long tap the space key on AOSP Keyboard. 5. Make sure that IME switcher dialog is shown. 6. make -j SoftKeyboard 7. adb install -r $OUT/system/app/SoftKeyboard/SoftKeyboard.apk 8. adb shell ime enable com.example.android.softkeyboard/.SoftKeyboard 9. Tap the keyboard icon on the navigation bar. 10. Make sure that IME switcher dialog is shown. Change-Id: Ie166bbd86179db1dae9e31f25d45e76c5e1b15ad --- .../inputmethod/InputMethodManagerService.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 9d5d65d870624..b44207205d317 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -3824,19 +3824,15 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (DEBUG) Slog.v(TAG, "Current IME: " + lastInputMethodId); synchronized (mMethodMap) { - final HashMap> immis = - mSettings.getExplicitlyOrImplicitlyEnabledInputMethodsAndSubtypeListLocked( - mContext); - if (immis == null || immis.size() == 0) { + final List imList = + mSwitchingController.getSortedInputMethodAndSubtypeListLocked( + showAuxSubtypes, isScreenLocked); + if (imList.isEmpty()) { return; } hideInputMethodMenuLocked(); - final List imList = - mSwitchingController.getSortedInputMethodAndSubtypeListLocked( - showAuxSubtypes, isScreenLocked); - if (lastInputMethodSubtypeId == NOT_A_SUBTYPE_ID) { final InputMethodSubtype currentSubtype = getCurrentInputMethodSubtypeLocked(); if (currentSubtype != null) {