Check IME info nullability before switching
This moves the nullability check of the input method info outside of the
InputMethodSubtypeSwitchingController, to maintain consistency with
other methods.
Flag: EXEMPT refactor
Bug: 347693610
Test: presubmit
Change-Id: I4141d1c909b8d96fd6ee7bf72cd82a0f2e0ef6d0
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index 3654283..f34b4e9 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -4233,6 +4233,9 @@
@NonNull UserData userData) {
final var bindingController = userData.mBindingController;
final var currentImi = bindingController.getSelectedMethod();
+ if (currentImi == null) {
+ return false;
+ }
final ImeSubtypeListItem nextSubtype = userData.mSwitchingController
.getNextInputMethodLocked(onlyCurrentIme, currentImi,
bindingController.getCurrentSubtype(),
@@ -4250,6 +4253,9 @@
private boolean shouldOfferSwitchingToNextInputMethodLocked(@NonNull UserData userData) {
final var bindingController = userData.mBindingController;
final var currentImi = bindingController.getSelectedMethod();
+ if (currentImi == null) {
+ return false;
+ }
final ImeSubtypeListItem nextSubtype = userData.mSwitchingController
.getNextInputMethodLocked(false /* onlyCurrentIme */, currentImi,
bindingController.getCurrentSubtype(),
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java b/services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java
index 202543c..96b3e08 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java
@@ -686,11 +686,8 @@
*/
@Nullable
public ImeSubtypeListItem getNextInputMethodLocked(boolean onlyCurrentIme,
- @Nullable InputMethodInfo imi, @Nullable InputMethodSubtype subtype,
+ @NonNull InputMethodInfo imi, @Nullable InputMethodSubtype subtype,
@SwitchMode int mode, boolean forward) {
- if (imi == null) {
- return null;
- }
if (Flags.imeSwitcherRevamp()) {
return mRotationList.next(imi, subtype, onlyCurrentIme,
isRecency(mode, forward), forward);