Merge "Initialize mTouchInputMethod properly" into main
diff --git a/src/com/android/car/rotary/RotaryService.java b/src/com/android/car/rotary/RotaryService.java
index 828137f..c85e893 100644
--- a/src/com/android/car/rotary/RotaryService.java
+++ b/src/com/android/car/rotary/RotaryService.java
@@ -631,12 +631,13 @@
         validateImeConfiguration(mDefaultTouchInputMethod);
         mTouchInputMethod = mPrefs.getString(TOUCH_INPUT_METHOD_PREFIX
                 + mUserManager.getUserName(), mDefaultTouchInputMethod);
-        if (mTouchInputMethod.isEmpty()) {
+        // TODO(b/346437360): use a better way to initialize mTouchInputMethod.
+        if (mTouchInputMethod.isEmpty()
+                || !Utils.isInstalledIme(mTouchInputMethod, mInputMethodManager)) {
             // Workaround for b/323013736.
-            L.e("mTouchInputMethod shouldn't be empty!");
+            L.e("mTouchInputMethod is empty or not installed!");
             mTouchInputMethod = mDefaultTouchInputMethod;
         }
-        validateImeConfiguration(mTouchInputMethod);
 
         if (mRotaryInputMethod != null && mRotaryInputMethod.equals(getCurrentIme())) {
             // Switch from the rotary IME to the touch IME in case Android defaults to the rotary