Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +9 −9 Original line number Original line Diff line number Diff line Loading @@ -4028,9 +4028,9 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. if (currentImi == null) { if (currentImi == null) { return false; return false; } } final ImeSubtypeListItem nextSubtype = userData.mSwitchingController final ImeSubtypeListItem nextSubtype = userData.mSwitchingController.getNext(currentImi, .getNextInputMethod(currentImi, bindingController.getCurrentSubtype(), bindingController.getCurrentSubtype(), onlyCurrentIme, false /* forHardware */, onlyCurrentIme, MODE_AUTO, true /* forward */); MODE_AUTO, true /* forward */); if (nextSubtype == null) { if (nextSubtype == null) { return false; return false; } } Loading @@ -4047,9 +4047,9 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. if (currentImi == null) { if (currentImi == null) { return false; return false; } } final ImeSubtypeListItem nextSubtype = userData.mSwitchingController final ImeSubtypeListItem nextSubtype = userData.mSwitchingController.getNext(currentImi, .getNextInputMethod(currentImi, bindingController.getCurrentSubtype(), bindingController.getCurrentSubtype(), false /* onlyCurrentIme */, false /* onlyCurrentIme */, MODE_AUTO, true /* forward */); false /* forHardware */, MODE_AUTO, true /* forward */); return nextSubtype != null; return nextSubtype != null; } } Loading Loading @@ -4588,7 +4588,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. settings.getSelectedInputMethodSubtypeIndex(lastInputMethodId); settings.getSelectedInputMethodSubtypeIndex(lastInputMethodId); final List<ImeSubtypeListItem> items = userData.mSwitchingController final List<ImeSubtypeListItem> items = userData.mSwitchingController .getItemsForImeSwitcherMenu(includeAuxiliary); .getItems(true /* forMenu */, includeAuxiliary); if (items.isEmpty()) { if (items.isEmpty()) { Slog.w(TAG, "Show switching menu failed, items is empty," Slog.w(TAG, "Show switching menu failed, items is empty," + " showAuxSubtypes: " + showAuxSubtypes + " showAuxSubtypes: " + showAuxSubtypes Loading Loading @@ -5242,8 +5242,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. return; return; } } final var currentSubtype = bindingController.getCurrentSubtype(); final var currentSubtype = bindingController.getCurrentSubtype(); final var nextItem = userData.mSwitchingController.getNextInputMethodForHardware( final var nextItem = userData.mSwitchingController.getNext(currentImi, currentSubtype, currentImi, currentSubtype, false /* onlyCurrentIme */, MODE_AUTO, false /* onlyCurrentIme */, true /* forHardware */, MODE_AUTO, direction > 0 /* forward */); direction > 0 /* forward */); if (nextItem == null) { if (nextItem == null) { Slog.i(TAG, "Hardware keyboard switching shortcut," Slog.i(TAG, "Hardware keyboard switching shortcut," Loading services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java +26 −78 Original line number Original line Diff line number Diff line Loading @@ -242,42 +242,24 @@ final class InputMethodSubtypeSwitchingController { } } /** /** * Gets the list of enabled input methods and subtypes used for switching. * Gets the list of enabled input methods and subtypes. * * @param forHardware whether to filter by subtypes suitable for hardware keyboard only. */ @GuardedBy("ImfLock.class") @NonNull List<ImeSubtypeListItem> getItemsForSwitching(boolean forHardware) { final var res = new ArrayList<ImeSubtypeListItem>(); for (int i = 0; i < mEnabledItems.size(); i++) { final var item = mEnabledItems.get(i); final boolean valid = forHardware ? item.mSuitableForHardware : !item.mIsAuxiliary; if (valid) { res.add(item); } } return res; } /** * Gets the list of enabled input method and subtypes shown in the IME Switcher Menu. * * * @param forMenu whether to filter by items to be shown in the IME Switcher Menu. * @param includeAuxiliary whether to include auxiliary subtypes. * @param includeAuxiliary whether to include auxiliary subtypes. */ */ @GuardedBy("ImfLock.class") @GuardedBy("ImfLock.class") @NonNull @NonNull List<ImeSubtypeListItem> getItemsForImeSwitcherMenu(boolean includeAuxiliary) { List<ImeSubtypeListItem> getItems(boolean forMenu, boolean includeAuxiliary) { final var res = new ArrayList<ImeSubtypeListItem>(); final var res = new ArrayList<ImeSubtypeListItem>(); for (int i = 0; i < mEnabledItems.size(); i++) { for (int i = 0; i < mEnabledItems.size(); i++) { final var item = mEnabledItems.get(i); final var item = mEnabledItems.get(i); if (!item.mShowInImeSwitcherMenu) { if (forMenu && !item.mShowInImeSwitcherMenu) { continue; continue; } } if (!includeAuxiliary && item.mIsAuxiliary) { if (includeAuxiliary || !item.mIsAuxiliary) { continue; res.add(item); } } res.add(item); } } return res; return res; } } Loading Loading @@ -384,13 +366,14 @@ final class InputMethodSubtypeSwitchingController { * @param imi the input method to find the next value from. * @param imi the input method to find the next value from. * @param subtype the input method subtype to find the next value from, if any. * @param subtype the input method subtype to find the next value from, if any. * @param onlyCurrentIme whether to consider only subtypes of the current input method. * @param onlyCurrentIme whether to consider only subtypes of the current input method. * @param forHardware whether to consider only subtypes suitable for hardware keyboard. * @param useRecency whether to use the recency order, or the static order. * @param useRecency whether to use the recency order, or the static order. * @param forward whether to search forwards to backwards in the list. * @param forward whether to search forwards to backwards in the list. * @return the next input method and subtype if found, otherwise {@code null}. * @return the next input method and subtype if found, otherwise {@code null}. */ */ @Nullable @Nullable ImeSubtypeListItem next(@NonNull InputMethodInfo imi, @Nullable InputMethodSubtype subtype, ImeSubtypeListItem next(@NonNull InputMethodInfo imi, @Nullable InputMethodSubtype subtype, boolean onlyCurrentIme, boolean useRecency, boolean forward) { boolean onlyCurrentIme, boolean forHardware, boolean useRecency, boolean forward) { if (mItems.isEmpty()) { if (mItems.isEmpty()) { return null; return null; } } Loading @@ -409,9 +392,11 @@ final class InputMethodSubtypeSwitchingController { final int nextIndex = (index + i * incrementSign + size) % size; final int nextIndex = (index + i * incrementSign + size) % size; final int mappedIndex = useRecency ? mRecencyMap[nextIndex] : nextIndex; final int mappedIndex = useRecency ? mRecencyMap[nextIndex] : nextIndex; final var nextItem = mItems.get(mappedIndex); final var nextItem = mItems.get(mappedIndex); if (!onlyCurrentIme || nextItem.mImi.equals(imi)) { if ((onlyCurrentIme && !nextItem.mImi.equals(imi)) return nextItem; || (forHardware && !nextItem.mSuitableForHardware)) { continue; } } return nextItem; } } return null; return null; } } Loading Loading @@ -508,11 +493,6 @@ final class InputMethodSubtypeSwitchingController { @NonNull @NonNull private RotationList mRotationList = new RotationList(Collections.emptyList()); private RotationList mRotationList = new RotationList(Collections.emptyList()); /** List of input methods and subtypes suitable for hardware keyboards. */ @GuardedBy("ImfLock.class") @NonNull private RotationList mHardwareRotationList = new RotationList(Collections.emptyList()); /** /** * Whether there was a user action since the last input method and subtype switch. * Whether there was a user action since the last input method and subtype switch. * Used to determine the switching behaviour for {@link #MODE_AUTO}. * Used to determine the switching behaviour for {@link #MODE_AUTO}. Loading @@ -525,20 +505,13 @@ final class InputMethodSubtypeSwitchingController { * equal to the existing ones (regardless of recency order), the update is skipped and the * equal to the existing ones (regardless of recency order), the update is skipped and the * current recency order is kept. Otherwise, the recency order is reset. * current recency order is kept. Otherwise, the recency order is reset. * * * @param sortedEnabledItems the sorted list of enabled input methods and subtypes. * @param enabledItems the list of enabled input methods and subtypes. * @param hardwareKeyboardItems the unsorted list of enabled input method and subtypes * suitable for hardware keyboards. */ */ @GuardedBy("ImfLock.class") @GuardedBy("ImfLock.class") @VisibleForTesting @VisibleForTesting void update(@NonNull List<ImeSubtypeListItem> sortedEnabledItems, void update(@NonNull List<ImeSubtypeListItem> enabledItems) { @NonNull List<ImeSubtypeListItem> hardwareKeyboardItems) { if (!mRotationList.mItems.equals(enabledItems)) { if (!Objects.equals(mRotationList.mItems, sortedEnabledItems)) { mRotationList = new RotationList(enabledItems); mRotationList = new RotationList(sortedEnabledItems); } if (!Objects.equals(mHardwareRotationList.mItems, hardwareKeyboardItems)) { mHardwareRotationList = new RotationList(hardwareKeyboardItems); } } } } Loading @@ -551,39 +524,19 @@ final class InputMethodSubtypeSwitchingController { * @param imi the input method to find the next value from. * @param imi the input method to find the next value from. * @param subtype the input method subtype to find the next value from, if any. * @param subtype the input method subtype to find the next value from, if any. * @param onlyCurrentIme whether to consider only subtypes of the current input method. * @param onlyCurrentIme whether to consider only subtypes of the current input method. * @param forHardware whether to consider only subtypes * {@link InputMethodSubtype#isSuitableForPhysicalKeyboardLayoutMapping * suitable for hardware keyboard}. * @param mode the switching mode. * @param mode the switching mode. * @param forward whether to search search forwards or backwards in the list. * @param forward whether to search search forwards or backwards in the list. * @return the next input method and subtype if found, otherwise {@code null}. * @return the next input method and subtype if found, otherwise {@code null}. */ */ @GuardedBy("ImfLock.class") @GuardedBy("ImfLock.class") @Nullable @Nullable ImeSubtypeListItem getNextInputMethod(@NonNull InputMethodInfo imi, ImeSubtypeListItem getNext(@NonNull InputMethodInfo imi, @Nullable InputMethodSubtype subtype, @Nullable InputMethodSubtype subtype, boolean onlyCurrentIme, @SwitchMode int mode, boolean onlyCurrentIme, boolean forHardware, @SwitchMode int mode, boolean forward) { boolean forward) { return mRotationList.next(imi, subtype, onlyCurrentIme, forHardware, return mRotationList.next(imi, subtype, onlyCurrentIme, isRecency(mode, forward), forward); isRecency(mode, forward), forward); } /** * Gets the next input method and subtype suitable for hardware keyboards, starting from the * given ones, in the given direction. * * <p>If the given input method and subtype are not found, this returns the most recent * input method and subtype. * * @param imi the input method to find the next value from. * @param subtype the input method subtype to find the next value from, if any. * @param onlyCurrentIme whether to consider only subtypes of the current input method. * @param mode the switching mode * @param forward whether to search search forwards or backwards in the list. * @return the next input method and subtype if found, otherwise {@code null}. */ @GuardedBy("ImfLock.class") @Nullable ImeSubtypeListItem getNextInputMethodForHardware(@NonNull InputMethodInfo imi, @Nullable InputMethodSubtype subtype, boolean onlyCurrentIme, @SwitchMode int mode, boolean forward) { return mHardwareRotationList.next(imi, subtype, onlyCurrentIme, isRecency(mode, forward), forward); } } /** /** Loading @@ -597,9 +550,7 @@ final class InputMethodSubtypeSwitchingController { */ */ @GuardedBy("ImfLock.class") @GuardedBy("ImfLock.class") boolean onUserAction(@NonNull InputMethodInfo imi, @Nullable InputMethodSubtype subtype) { boolean onUserAction(@NonNull InputMethodInfo imi, @Nullable InputMethodSubtype subtype) { boolean recencyUpdated = false; final boolean recencyUpdated = mRotationList.setMostRecent(imi, subtype); recencyUpdated |= mRotationList.setMostRecent(imi, subtype); recencyUpdated |= mHardwareRotationList.setMostRecent(imi, subtype); if (recencyUpdated) { if (recencyUpdated) { mUserActionSinceSwitch = true; mUserActionSinceSwitch = true; } } Loading Loading @@ -631,8 +582,6 @@ final class InputMethodSubtypeSwitchingController { void dump(@NonNull Printer pw, @NonNull String prefix) { void dump(@NonNull Printer pw, @NonNull String prefix) { pw.println(prefix + "mRotationList:"); pw.println(prefix + "mRotationList:"); mRotationList.dump(pw, prefix + " "); mRotationList.dump(pw, prefix + " "); pw.println(prefix + "mHardwareRotationList:"); mHardwareRotationList.dump(pw, prefix + " "); pw.println(prefix + "mEnabledItems:"); pw.println(prefix + "mEnabledItems:"); for (int i = 0; i < mEnabledItems.size(); i++) { for (int i = 0; i < mEnabledItems.size(); i++) { final var item = mEnabledItems.get(i); final var item = mEnabledItems.get(i); Loading @@ -654,7 +603,6 @@ final class InputMethodSubtypeSwitchingController { @GuardedBy("ImfLock.class") @GuardedBy("ImfLock.class") void update(@NonNull Context context, @NonNull InputMethodSettings settings) { void update(@NonNull Context context, @NonNull InputMethodSettings settings) { mEnabledItems = getEnabledInputMethodsAndSubtypes(context, settings); mEnabledItems = getEnabledInputMethodsAndSubtypes(context, settings); update(getItemsForSwitching(false /* forHardware */), update(getItems(false /* forMenu */, false /* includeAuxiliary */)); getItemsForSwitching(true /* forHardware */)); } } } } Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +9 −9 Original line number Original line Diff line number Diff line Loading @@ -4028,9 +4028,9 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. if (currentImi == null) { if (currentImi == null) { return false; return false; } } final ImeSubtypeListItem nextSubtype = userData.mSwitchingController final ImeSubtypeListItem nextSubtype = userData.mSwitchingController.getNext(currentImi, .getNextInputMethod(currentImi, bindingController.getCurrentSubtype(), bindingController.getCurrentSubtype(), onlyCurrentIme, false /* forHardware */, onlyCurrentIme, MODE_AUTO, true /* forward */); MODE_AUTO, true /* forward */); if (nextSubtype == null) { if (nextSubtype == null) { return false; return false; } } Loading @@ -4047,9 +4047,9 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. if (currentImi == null) { if (currentImi == null) { return false; return false; } } final ImeSubtypeListItem nextSubtype = userData.mSwitchingController final ImeSubtypeListItem nextSubtype = userData.mSwitchingController.getNext(currentImi, .getNextInputMethod(currentImi, bindingController.getCurrentSubtype(), bindingController.getCurrentSubtype(), false /* onlyCurrentIme */, false /* onlyCurrentIme */, MODE_AUTO, true /* forward */); false /* forHardware */, MODE_AUTO, true /* forward */); return nextSubtype != null; return nextSubtype != null; } } Loading Loading @@ -4588,7 +4588,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. settings.getSelectedInputMethodSubtypeIndex(lastInputMethodId); settings.getSelectedInputMethodSubtypeIndex(lastInputMethodId); final List<ImeSubtypeListItem> items = userData.mSwitchingController final List<ImeSubtypeListItem> items = userData.mSwitchingController .getItemsForImeSwitcherMenu(includeAuxiliary); .getItems(true /* forMenu */, includeAuxiliary); if (items.isEmpty()) { if (items.isEmpty()) { Slog.w(TAG, "Show switching menu failed, items is empty," Slog.w(TAG, "Show switching menu failed, items is empty," + " showAuxSubtypes: " + showAuxSubtypes + " showAuxSubtypes: " + showAuxSubtypes Loading Loading @@ -5242,8 +5242,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. return; return; } } final var currentSubtype = bindingController.getCurrentSubtype(); final var currentSubtype = bindingController.getCurrentSubtype(); final var nextItem = userData.mSwitchingController.getNextInputMethodForHardware( final var nextItem = userData.mSwitchingController.getNext(currentImi, currentSubtype, currentImi, currentSubtype, false /* onlyCurrentIme */, MODE_AUTO, false /* onlyCurrentIme */, true /* forHardware */, MODE_AUTO, direction > 0 /* forward */); direction > 0 /* forward */); if (nextItem == null) { if (nextItem == null) { Slog.i(TAG, "Hardware keyboard switching shortcut," Slog.i(TAG, "Hardware keyboard switching shortcut," Loading
services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java +26 −78 Original line number Original line Diff line number Diff line Loading @@ -242,42 +242,24 @@ final class InputMethodSubtypeSwitchingController { } } /** /** * Gets the list of enabled input methods and subtypes used for switching. * Gets the list of enabled input methods and subtypes. * * @param forHardware whether to filter by subtypes suitable for hardware keyboard only. */ @GuardedBy("ImfLock.class") @NonNull List<ImeSubtypeListItem> getItemsForSwitching(boolean forHardware) { final var res = new ArrayList<ImeSubtypeListItem>(); for (int i = 0; i < mEnabledItems.size(); i++) { final var item = mEnabledItems.get(i); final boolean valid = forHardware ? item.mSuitableForHardware : !item.mIsAuxiliary; if (valid) { res.add(item); } } return res; } /** * Gets the list of enabled input method and subtypes shown in the IME Switcher Menu. * * * @param forMenu whether to filter by items to be shown in the IME Switcher Menu. * @param includeAuxiliary whether to include auxiliary subtypes. * @param includeAuxiliary whether to include auxiliary subtypes. */ */ @GuardedBy("ImfLock.class") @GuardedBy("ImfLock.class") @NonNull @NonNull List<ImeSubtypeListItem> getItemsForImeSwitcherMenu(boolean includeAuxiliary) { List<ImeSubtypeListItem> getItems(boolean forMenu, boolean includeAuxiliary) { final var res = new ArrayList<ImeSubtypeListItem>(); final var res = new ArrayList<ImeSubtypeListItem>(); for (int i = 0; i < mEnabledItems.size(); i++) { for (int i = 0; i < mEnabledItems.size(); i++) { final var item = mEnabledItems.get(i); final var item = mEnabledItems.get(i); if (!item.mShowInImeSwitcherMenu) { if (forMenu && !item.mShowInImeSwitcherMenu) { continue; continue; } } if (!includeAuxiliary && item.mIsAuxiliary) { if (includeAuxiliary || !item.mIsAuxiliary) { continue; res.add(item); } } res.add(item); } } return res; return res; } } Loading Loading @@ -384,13 +366,14 @@ final class InputMethodSubtypeSwitchingController { * @param imi the input method to find the next value from. * @param imi the input method to find the next value from. * @param subtype the input method subtype to find the next value from, if any. * @param subtype the input method subtype to find the next value from, if any. * @param onlyCurrentIme whether to consider only subtypes of the current input method. * @param onlyCurrentIme whether to consider only subtypes of the current input method. * @param forHardware whether to consider only subtypes suitable for hardware keyboard. * @param useRecency whether to use the recency order, or the static order. * @param useRecency whether to use the recency order, or the static order. * @param forward whether to search forwards to backwards in the list. * @param forward whether to search forwards to backwards in the list. * @return the next input method and subtype if found, otherwise {@code null}. * @return the next input method and subtype if found, otherwise {@code null}. */ */ @Nullable @Nullable ImeSubtypeListItem next(@NonNull InputMethodInfo imi, @Nullable InputMethodSubtype subtype, ImeSubtypeListItem next(@NonNull InputMethodInfo imi, @Nullable InputMethodSubtype subtype, boolean onlyCurrentIme, boolean useRecency, boolean forward) { boolean onlyCurrentIme, boolean forHardware, boolean useRecency, boolean forward) { if (mItems.isEmpty()) { if (mItems.isEmpty()) { return null; return null; } } Loading @@ -409,9 +392,11 @@ final class InputMethodSubtypeSwitchingController { final int nextIndex = (index + i * incrementSign + size) % size; final int nextIndex = (index + i * incrementSign + size) % size; final int mappedIndex = useRecency ? mRecencyMap[nextIndex] : nextIndex; final int mappedIndex = useRecency ? mRecencyMap[nextIndex] : nextIndex; final var nextItem = mItems.get(mappedIndex); final var nextItem = mItems.get(mappedIndex); if (!onlyCurrentIme || nextItem.mImi.equals(imi)) { if ((onlyCurrentIme && !nextItem.mImi.equals(imi)) return nextItem; || (forHardware && !nextItem.mSuitableForHardware)) { continue; } } return nextItem; } } return null; return null; } } Loading Loading @@ -508,11 +493,6 @@ final class InputMethodSubtypeSwitchingController { @NonNull @NonNull private RotationList mRotationList = new RotationList(Collections.emptyList()); private RotationList mRotationList = new RotationList(Collections.emptyList()); /** List of input methods and subtypes suitable for hardware keyboards. */ @GuardedBy("ImfLock.class") @NonNull private RotationList mHardwareRotationList = new RotationList(Collections.emptyList()); /** /** * Whether there was a user action since the last input method and subtype switch. * Whether there was a user action since the last input method and subtype switch. * Used to determine the switching behaviour for {@link #MODE_AUTO}. * Used to determine the switching behaviour for {@link #MODE_AUTO}. Loading @@ -525,20 +505,13 @@ final class InputMethodSubtypeSwitchingController { * equal to the existing ones (regardless of recency order), the update is skipped and the * equal to the existing ones (regardless of recency order), the update is skipped and the * current recency order is kept. Otherwise, the recency order is reset. * current recency order is kept. Otherwise, the recency order is reset. * * * @param sortedEnabledItems the sorted list of enabled input methods and subtypes. * @param enabledItems the list of enabled input methods and subtypes. * @param hardwareKeyboardItems the unsorted list of enabled input method and subtypes * suitable for hardware keyboards. */ */ @GuardedBy("ImfLock.class") @GuardedBy("ImfLock.class") @VisibleForTesting @VisibleForTesting void update(@NonNull List<ImeSubtypeListItem> sortedEnabledItems, void update(@NonNull List<ImeSubtypeListItem> enabledItems) { @NonNull List<ImeSubtypeListItem> hardwareKeyboardItems) { if (!mRotationList.mItems.equals(enabledItems)) { if (!Objects.equals(mRotationList.mItems, sortedEnabledItems)) { mRotationList = new RotationList(enabledItems); mRotationList = new RotationList(sortedEnabledItems); } if (!Objects.equals(mHardwareRotationList.mItems, hardwareKeyboardItems)) { mHardwareRotationList = new RotationList(hardwareKeyboardItems); } } } } Loading @@ -551,39 +524,19 @@ final class InputMethodSubtypeSwitchingController { * @param imi the input method to find the next value from. * @param imi the input method to find the next value from. * @param subtype the input method subtype to find the next value from, if any. * @param subtype the input method subtype to find the next value from, if any. * @param onlyCurrentIme whether to consider only subtypes of the current input method. * @param onlyCurrentIme whether to consider only subtypes of the current input method. * @param forHardware whether to consider only subtypes * {@link InputMethodSubtype#isSuitableForPhysicalKeyboardLayoutMapping * suitable for hardware keyboard}. * @param mode the switching mode. * @param mode the switching mode. * @param forward whether to search search forwards or backwards in the list. * @param forward whether to search search forwards or backwards in the list. * @return the next input method and subtype if found, otherwise {@code null}. * @return the next input method and subtype if found, otherwise {@code null}. */ */ @GuardedBy("ImfLock.class") @GuardedBy("ImfLock.class") @Nullable @Nullable ImeSubtypeListItem getNextInputMethod(@NonNull InputMethodInfo imi, ImeSubtypeListItem getNext(@NonNull InputMethodInfo imi, @Nullable InputMethodSubtype subtype, @Nullable InputMethodSubtype subtype, boolean onlyCurrentIme, @SwitchMode int mode, boolean onlyCurrentIme, boolean forHardware, @SwitchMode int mode, boolean forward) { boolean forward) { return mRotationList.next(imi, subtype, onlyCurrentIme, forHardware, return mRotationList.next(imi, subtype, onlyCurrentIme, isRecency(mode, forward), forward); isRecency(mode, forward), forward); } /** * Gets the next input method and subtype suitable for hardware keyboards, starting from the * given ones, in the given direction. * * <p>If the given input method and subtype are not found, this returns the most recent * input method and subtype. * * @param imi the input method to find the next value from. * @param subtype the input method subtype to find the next value from, if any. * @param onlyCurrentIme whether to consider only subtypes of the current input method. * @param mode the switching mode * @param forward whether to search search forwards or backwards in the list. * @return the next input method and subtype if found, otherwise {@code null}. */ @GuardedBy("ImfLock.class") @Nullable ImeSubtypeListItem getNextInputMethodForHardware(@NonNull InputMethodInfo imi, @Nullable InputMethodSubtype subtype, boolean onlyCurrentIme, @SwitchMode int mode, boolean forward) { return mHardwareRotationList.next(imi, subtype, onlyCurrentIme, isRecency(mode, forward), forward); } } /** /** Loading @@ -597,9 +550,7 @@ final class InputMethodSubtypeSwitchingController { */ */ @GuardedBy("ImfLock.class") @GuardedBy("ImfLock.class") boolean onUserAction(@NonNull InputMethodInfo imi, @Nullable InputMethodSubtype subtype) { boolean onUserAction(@NonNull InputMethodInfo imi, @Nullable InputMethodSubtype subtype) { boolean recencyUpdated = false; final boolean recencyUpdated = mRotationList.setMostRecent(imi, subtype); recencyUpdated |= mRotationList.setMostRecent(imi, subtype); recencyUpdated |= mHardwareRotationList.setMostRecent(imi, subtype); if (recencyUpdated) { if (recencyUpdated) { mUserActionSinceSwitch = true; mUserActionSinceSwitch = true; } } Loading Loading @@ -631,8 +582,6 @@ final class InputMethodSubtypeSwitchingController { void dump(@NonNull Printer pw, @NonNull String prefix) { void dump(@NonNull Printer pw, @NonNull String prefix) { pw.println(prefix + "mRotationList:"); pw.println(prefix + "mRotationList:"); mRotationList.dump(pw, prefix + " "); mRotationList.dump(pw, prefix + " "); pw.println(prefix + "mHardwareRotationList:"); mHardwareRotationList.dump(pw, prefix + " "); pw.println(prefix + "mEnabledItems:"); pw.println(prefix + "mEnabledItems:"); for (int i = 0; i < mEnabledItems.size(); i++) { for (int i = 0; i < mEnabledItems.size(); i++) { final var item = mEnabledItems.get(i); final var item = mEnabledItems.get(i); Loading @@ -654,7 +603,6 @@ final class InputMethodSubtypeSwitchingController { @GuardedBy("ImfLock.class") @GuardedBy("ImfLock.class") void update(@NonNull Context context, @NonNull InputMethodSettings settings) { void update(@NonNull Context context, @NonNull InputMethodSettings settings) { mEnabledItems = getEnabledInputMethodsAndSubtypes(context, settings); mEnabledItems = getEnabledInputMethodsAndSubtypes(context, settings); update(getItemsForSwitching(false /* forHardware */), update(getItems(false /* forMenu */, false /* includeAuxiliary */)); getItemsForSwitching(true /* forHardware */)); } } } }