Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +16 −3 Original line number Original line Diff line number Diff line Loading @@ -276,7 +276,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub final Context mContext; final Context mContext; final Resources mRes; final Resources mRes; private final Handler mHandler; private final Handler mHandler; final InputMethodSettings mSettings; private final InputMethodSettings mSettings; final SettingsObserver mSettingsObserver; final SettingsObserver mSettingsObserver; private final SparseBooleanArray mLoggedDeniedGetInputMethodWindowVisibleHeightForUid = private final SparseBooleanArray mLoggedDeniedGetInputMethodWindowVisibleHeightForUid = new SparseBooleanArray(0); new SparseBooleanArray(0); Loading Loading @@ -316,7 +316,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub // Mapping from deviceId to the device-specific imeId for that device. // Mapping from deviceId to the device-specific imeId for that device. private final SparseArray<String> mVirtualDeviceMethodMap = new SparseArray<>(); private final SparseArray<String> mVirtualDeviceMethodMap = new SparseArray<>(); final InputMethodSubtypeSwitchingController mSwitchingController; private final InputMethodSubtypeSwitchingController mSwitchingController; final HardwareKeyboardShortcutController mHardwareKeyboardShortcutController = final HardwareKeyboardShortcutController mHardwareKeyboardShortcutController = new HardwareKeyboardShortcutController(); new HardwareKeyboardShortcutController(); Loading Loading @@ -4812,7 +4812,20 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub Slog.e(TAG, "Unknown subtype picker mode = " + msg.arg1); Slog.e(TAG, "Unknown subtype picker mode = " + msg.arg1); return false; return false; } } mMenuController.showInputMethodMenu(showAuxSubtypes, displayId); synchronized (ImfLock.class) { final boolean isScreenLocked = mWindowManagerInternal.isKeyguardLocked() && mWindowManagerInternal.isKeyguardSecure( mSettings.getCurrentUserId()); final String lastInputMethodId = mSettings.getSelectedInputMethod(); int lastInputMethodSubtypeId = mSettings.getSelectedInputMethodSubtypeId(lastInputMethodId); final List<ImeSubtypeListItem> imList = mSwitchingController .getSortedInputMethodAndSubtypeListForImeMenuLocked( showAuxSubtypes, isScreenLocked); mMenuController.showInputMethodMenuLocked(showAuxSubtypes, displayId, lastInputMethodId, lastInputMethodSubtypeId, imList); } return true; return true; // --------------------------------------------------------- // --------------------------------------------------------- Loading services/core/java/com/android/server/inputmethod/InputMethodMenuController.java +116 −124 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.inputmethod; import static com.android.server.inputmethod.InputMethodManagerService.DEBUG; import static com.android.server.inputmethod.InputMethodManagerService.DEBUG; import static com.android.server.inputmethod.InputMethodUtils.NOT_A_SUBTYPE_ID; import static com.android.server.inputmethod.InputMethodUtils.NOT_A_SUBTYPE_ID; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.app.AlertDialog; import android.app.AlertDialog; import android.content.Context; import android.content.Context; Loading Loading @@ -52,8 +53,6 @@ final class InputMethodMenuController { private static final String TAG = InputMethodMenuController.class.getSimpleName(); private static final String TAG = InputMethodMenuController.class.getSimpleName(); private final InputMethodManagerService mService; private final InputMethodManagerService mService; private final InputMethodUtils.InputMethodSettings mSettings; private final InputMethodSubtypeSwitchingController mSwitchingController; private final WindowManagerInternal mWindowManagerInternal; private final WindowManagerInternal mWindowManagerInternal; private AlertDialog.Builder mDialogBuilder; private AlertDialog.Builder mDialogBuilder; Loading @@ -70,44 +69,36 @@ final class InputMethodMenuController { InputMethodMenuController(InputMethodManagerService service) { InputMethodMenuController(InputMethodManagerService service) { mService = service; mService = service; mSettings = mService.mSettings; mSwitchingController = mService.mSwitchingController; mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class); mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class); } } void showInputMethodMenu(boolean showAuxSubtypes, int displayId) { @GuardedBy("ImfLock.class") void showInputMethodMenuLocked(boolean showAuxSubtypes, int displayId, String preferredInputMethodId, int preferredInputMethodSubtypeId, @NonNull List<ImeSubtypeListItem> imList) { if (DEBUG) Slog.v(TAG, "Show switching menu. showAuxSubtypes=" + showAuxSubtypes); if (DEBUG) Slog.v(TAG, "Show switching menu. showAuxSubtypes=" + showAuxSubtypes); synchronized (ImfLock.class) { final int userId = mService.getCurrentImeUserIdLocked(); final int userId = mService.getCurrentImeUserIdLocked(); final boolean isScreenLocked = mWindowManagerInternal.isKeyguardLocked() && mWindowManagerInternal.isKeyguardSecure(userId); final String lastInputMethodId = mSettings.getSelectedInputMethod(); int lastInputMethodSubtypeId = mSettings.getSelectedInputMethodSubtypeId(lastInputMethodId); if (DEBUG) Slog.v(TAG, "Current IME: " + lastInputMethodId); final List<ImeSubtypeListItem> imList = mSwitchingController .getSortedInputMethodAndSubtypeListForImeMenuLocked( showAuxSubtypes, isScreenLocked); if (imList.isEmpty()) { if (imList.isEmpty()) { return; return; } } hideInputMethodMenuLocked(); hideInputMethodMenuLocked(); if (lastInputMethodSubtypeId == NOT_A_SUBTYPE_ID) { if (preferredInputMethodSubtypeId == NOT_A_SUBTYPE_ID) { final InputMethodSubtype currentSubtype = final InputMethodSubtype currentSubtype = mService.getCurrentInputMethodSubtypeLocked(); mService.getCurrentInputMethodSubtypeLocked(); if (currentSubtype != null) { if (currentSubtype != null) { final String curMethodId = mService.getSelectedMethodIdLocked(); final String curMethodId = mService.getSelectedMethodIdLocked(); final InputMethodInfo currentImi = final InputMethodInfo currentImi = mService.queryInputMethodForCurrentUserLocked(curMethodId); mService.queryInputMethodForCurrentUserLocked(curMethodId); lastInputMethodSubtypeId = SubtypeUtils.getSubtypeIdFromHashCode( preferredInputMethodSubtypeId = SubtypeUtils.getSubtypeIdFromHashCode( currentImi, currentSubtype.hashCode()); currentImi, currentSubtype.hashCode()); } } } } // Find out which item should be checked by default. final int size = imList.size(); final int size = imList.size(); mIms = new InputMethodInfo[size]; mIms = new InputMethodInfo[size]; mSubtypeIds = new int[size]; mSubtypeIds = new int[size]; Loading @@ -116,11 +107,11 @@ final class InputMethodMenuController { final ImeSubtypeListItem item = imList.get(i); final ImeSubtypeListItem item = imList.get(i); mIms[i] = item.mImi; mIms[i] = item.mImi; mSubtypeIds[i] = item.mSubtypeId; mSubtypeIds[i] = item.mSubtypeId; if (mIms[i].getId().equals(lastInputMethodId)) { if (mIms[i].getId().equals(preferredInputMethodId)) { int subtypeId = mSubtypeIds[i]; int subtypeId = mSubtypeIds[i]; if ((subtypeId == NOT_A_SUBTYPE_ID) if ((subtypeId == NOT_A_SUBTYPE_ID) || (lastInputMethodSubtypeId == NOT_A_SUBTYPE_ID && subtypeId == 0) || (preferredInputMethodSubtypeId == NOT_A_SUBTYPE_ID && subtypeId == 0) || (subtypeId == lastInputMethodSubtypeId)) { || (subtypeId == preferredInputMethodSubtypeId)) { checkedItem = i; checkedItem = i; } } } } Loading Loading @@ -165,6 +156,8 @@ final class InputMethodMenuController { hideInputMethodMenu(); hideInputMethodMenu(); }); }); // Fill the list items with onClick listener, which takes care of IME (and subtype) // switching when clicked. final ImeSubtypeListAdapter adapter = new ImeSubtypeListAdapter(dialogContext, final ImeSubtypeListAdapter adapter = new ImeSubtypeListAdapter(dialogContext, com.android.internal.R.layout.input_method_switch_item, imList, checkedItem); com.android.internal.R.layout.input_method_switch_item, imList, checkedItem); final DialogInterface.OnClickListener choiceListener = (dialog, which) -> { final DialogInterface.OnClickListener choiceListener = (dialog, which) -> { Loading @@ -188,6 +181,7 @@ final class InputMethodMenuController { }; }; mDialogBuilder.setSingleChoiceItems(adapter, checkedItem, choiceListener); mDialogBuilder.setSingleChoiceItems(adapter, checkedItem, choiceListener); // Final steps to instantiate a dialog to show it up. mSwitchingDialog = mDialogBuilder.create(); mSwitchingDialog = mDialogBuilder.create(); mSwitchingDialog.setCanceledOnTouchOutside(true); mSwitchingDialog.setCanceledOnTouchOutside(true); final Window w = mSwitchingDialog.getWindow(); final Window w = mSwitchingDialog.getWindow(); Loading @@ -204,8 +198,6 @@ final class InputMethodMenuController { mService.updateSystemUiLocked(); mService.updateSystemUiLocked(); mService.sendOnNavButtonFlagsChangedLocked(); mService.sendOnNavButtonFlagsChangedLocked(); mSwitchingDialog.show(); mSwitchingDialog.show(); } } } void updateKeyboardFromSettingsLocked() { void updateKeyboardFromSettingsLocked() { Loading Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +16 −3 Original line number Original line Diff line number Diff line Loading @@ -276,7 +276,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub final Context mContext; final Context mContext; final Resources mRes; final Resources mRes; private final Handler mHandler; private final Handler mHandler; final InputMethodSettings mSettings; private final InputMethodSettings mSettings; final SettingsObserver mSettingsObserver; final SettingsObserver mSettingsObserver; private final SparseBooleanArray mLoggedDeniedGetInputMethodWindowVisibleHeightForUid = private final SparseBooleanArray mLoggedDeniedGetInputMethodWindowVisibleHeightForUid = new SparseBooleanArray(0); new SparseBooleanArray(0); Loading Loading @@ -316,7 +316,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub // Mapping from deviceId to the device-specific imeId for that device. // Mapping from deviceId to the device-specific imeId for that device. private final SparseArray<String> mVirtualDeviceMethodMap = new SparseArray<>(); private final SparseArray<String> mVirtualDeviceMethodMap = new SparseArray<>(); final InputMethodSubtypeSwitchingController mSwitchingController; private final InputMethodSubtypeSwitchingController mSwitchingController; final HardwareKeyboardShortcutController mHardwareKeyboardShortcutController = final HardwareKeyboardShortcutController mHardwareKeyboardShortcutController = new HardwareKeyboardShortcutController(); new HardwareKeyboardShortcutController(); Loading Loading @@ -4812,7 +4812,20 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub Slog.e(TAG, "Unknown subtype picker mode = " + msg.arg1); Slog.e(TAG, "Unknown subtype picker mode = " + msg.arg1); return false; return false; } } mMenuController.showInputMethodMenu(showAuxSubtypes, displayId); synchronized (ImfLock.class) { final boolean isScreenLocked = mWindowManagerInternal.isKeyguardLocked() && mWindowManagerInternal.isKeyguardSecure( mSettings.getCurrentUserId()); final String lastInputMethodId = mSettings.getSelectedInputMethod(); int lastInputMethodSubtypeId = mSettings.getSelectedInputMethodSubtypeId(lastInputMethodId); final List<ImeSubtypeListItem> imList = mSwitchingController .getSortedInputMethodAndSubtypeListForImeMenuLocked( showAuxSubtypes, isScreenLocked); mMenuController.showInputMethodMenuLocked(showAuxSubtypes, displayId, lastInputMethodId, lastInputMethodSubtypeId, imList); } return true; return true; // --------------------------------------------------------- // --------------------------------------------------------- Loading
services/core/java/com/android/server/inputmethod/InputMethodMenuController.java +116 −124 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.inputmethod; import static com.android.server.inputmethod.InputMethodManagerService.DEBUG; import static com.android.server.inputmethod.InputMethodManagerService.DEBUG; import static com.android.server.inputmethod.InputMethodUtils.NOT_A_SUBTYPE_ID; import static com.android.server.inputmethod.InputMethodUtils.NOT_A_SUBTYPE_ID; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.app.AlertDialog; import android.app.AlertDialog; import android.content.Context; import android.content.Context; Loading Loading @@ -52,8 +53,6 @@ final class InputMethodMenuController { private static final String TAG = InputMethodMenuController.class.getSimpleName(); private static final String TAG = InputMethodMenuController.class.getSimpleName(); private final InputMethodManagerService mService; private final InputMethodManagerService mService; private final InputMethodUtils.InputMethodSettings mSettings; private final InputMethodSubtypeSwitchingController mSwitchingController; private final WindowManagerInternal mWindowManagerInternal; private final WindowManagerInternal mWindowManagerInternal; private AlertDialog.Builder mDialogBuilder; private AlertDialog.Builder mDialogBuilder; Loading @@ -70,44 +69,36 @@ final class InputMethodMenuController { InputMethodMenuController(InputMethodManagerService service) { InputMethodMenuController(InputMethodManagerService service) { mService = service; mService = service; mSettings = mService.mSettings; mSwitchingController = mService.mSwitchingController; mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class); mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class); } } void showInputMethodMenu(boolean showAuxSubtypes, int displayId) { @GuardedBy("ImfLock.class") void showInputMethodMenuLocked(boolean showAuxSubtypes, int displayId, String preferredInputMethodId, int preferredInputMethodSubtypeId, @NonNull List<ImeSubtypeListItem> imList) { if (DEBUG) Slog.v(TAG, "Show switching menu. showAuxSubtypes=" + showAuxSubtypes); if (DEBUG) Slog.v(TAG, "Show switching menu. showAuxSubtypes=" + showAuxSubtypes); synchronized (ImfLock.class) { final int userId = mService.getCurrentImeUserIdLocked(); final int userId = mService.getCurrentImeUserIdLocked(); final boolean isScreenLocked = mWindowManagerInternal.isKeyguardLocked() && mWindowManagerInternal.isKeyguardSecure(userId); final String lastInputMethodId = mSettings.getSelectedInputMethod(); int lastInputMethodSubtypeId = mSettings.getSelectedInputMethodSubtypeId(lastInputMethodId); if (DEBUG) Slog.v(TAG, "Current IME: " + lastInputMethodId); final List<ImeSubtypeListItem> imList = mSwitchingController .getSortedInputMethodAndSubtypeListForImeMenuLocked( showAuxSubtypes, isScreenLocked); if (imList.isEmpty()) { if (imList.isEmpty()) { return; return; } } hideInputMethodMenuLocked(); hideInputMethodMenuLocked(); if (lastInputMethodSubtypeId == NOT_A_SUBTYPE_ID) { if (preferredInputMethodSubtypeId == NOT_A_SUBTYPE_ID) { final InputMethodSubtype currentSubtype = final InputMethodSubtype currentSubtype = mService.getCurrentInputMethodSubtypeLocked(); mService.getCurrentInputMethodSubtypeLocked(); if (currentSubtype != null) { if (currentSubtype != null) { final String curMethodId = mService.getSelectedMethodIdLocked(); final String curMethodId = mService.getSelectedMethodIdLocked(); final InputMethodInfo currentImi = final InputMethodInfo currentImi = mService.queryInputMethodForCurrentUserLocked(curMethodId); mService.queryInputMethodForCurrentUserLocked(curMethodId); lastInputMethodSubtypeId = SubtypeUtils.getSubtypeIdFromHashCode( preferredInputMethodSubtypeId = SubtypeUtils.getSubtypeIdFromHashCode( currentImi, currentSubtype.hashCode()); currentImi, currentSubtype.hashCode()); } } } } // Find out which item should be checked by default. final int size = imList.size(); final int size = imList.size(); mIms = new InputMethodInfo[size]; mIms = new InputMethodInfo[size]; mSubtypeIds = new int[size]; mSubtypeIds = new int[size]; Loading @@ -116,11 +107,11 @@ final class InputMethodMenuController { final ImeSubtypeListItem item = imList.get(i); final ImeSubtypeListItem item = imList.get(i); mIms[i] = item.mImi; mIms[i] = item.mImi; mSubtypeIds[i] = item.mSubtypeId; mSubtypeIds[i] = item.mSubtypeId; if (mIms[i].getId().equals(lastInputMethodId)) { if (mIms[i].getId().equals(preferredInputMethodId)) { int subtypeId = mSubtypeIds[i]; int subtypeId = mSubtypeIds[i]; if ((subtypeId == NOT_A_SUBTYPE_ID) if ((subtypeId == NOT_A_SUBTYPE_ID) || (lastInputMethodSubtypeId == NOT_A_SUBTYPE_ID && subtypeId == 0) || (preferredInputMethodSubtypeId == NOT_A_SUBTYPE_ID && subtypeId == 0) || (subtypeId == lastInputMethodSubtypeId)) { || (subtypeId == preferredInputMethodSubtypeId)) { checkedItem = i; checkedItem = i; } } } } Loading Loading @@ -165,6 +156,8 @@ final class InputMethodMenuController { hideInputMethodMenu(); hideInputMethodMenu(); }); }); // Fill the list items with onClick listener, which takes care of IME (and subtype) // switching when clicked. final ImeSubtypeListAdapter adapter = new ImeSubtypeListAdapter(dialogContext, final ImeSubtypeListAdapter adapter = new ImeSubtypeListAdapter(dialogContext, com.android.internal.R.layout.input_method_switch_item, imList, checkedItem); com.android.internal.R.layout.input_method_switch_item, imList, checkedItem); final DialogInterface.OnClickListener choiceListener = (dialog, which) -> { final DialogInterface.OnClickListener choiceListener = (dialog, which) -> { Loading @@ -188,6 +181,7 @@ final class InputMethodMenuController { }; }; mDialogBuilder.setSingleChoiceItems(adapter, checkedItem, choiceListener); mDialogBuilder.setSingleChoiceItems(adapter, checkedItem, choiceListener); // Final steps to instantiate a dialog to show it up. mSwitchingDialog = mDialogBuilder.create(); mSwitchingDialog = mDialogBuilder.create(); mSwitchingDialog.setCanceledOnTouchOutside(true); mSwitchingDialog.setCanceledOnTouchOutside(true); final Window w = mSwitchingDialog.getWindow(); final Window w = mSwitchingDialog.getWindow(); Loading @@ -204,8 +198,6 @@ final class InputMethodMenuController { mService.updateSystemUiLocked(); mService.updateSystemUiLocked(); mService.sendOnNavButtonFlagsChangedLocked(); mService.sendOnNavButtonFlagsChangedLocked(); mSwitchingDialog.show(); mSwitchingDialog.show(); } } } void updateKeyboardFromSettingsLocked() { void updateKeyboardFromSettingsLocked() { Loading