summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vladimir Komsiyski <vladokom@google.com> 2024-02-14 10:17:14 +0100
committer Vladimir Komsiyski <vladokom@google.com> 2024-02-14 13:32:57 +0100
commitc49e68994b84775d3985b3a3fb243293c513878b (patch)
tree3f2a9bff75ddeebc01c11c42a1eb77e1138e4837
parentb47b88de9a55bf09d7964bfe904e7c212a128abb (diff)
Always look for display-specific IME.
Even if the current displayId or deviceId doesn't change, always lookup and validate the relevant IME. Otherwise subsequent calls to startInputUncheckedLocked will have the wrong behavior if the VDM IME is not available for some reason because we do not persist the display IME policy in that case. Fix: 325018800 Test: atest VirtualDeviceImeTest --iterations=100 Change-Id: I7ce274662774a7c5756303a5254ae1213c84fc40
-rw-r--r--services/core/java/com/android/server/inputmethod/InputMethodManagerService.java21
1 files changed, 9 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index 4bb8e1913199..ab683530d1f7 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -2421,20 +2421,17 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
return InputBindResult.NOT_IME_TARGET_WINDOW;
}
final int csDisplayId = cs.mSelfReportedDisplayId;
- final int oldDisplayIdToShowIme = mDisplayIdToShowIme;
mDisplayIdToShowIme = mVisibilityStateComputer.computeImeDisplayId(winState, csDisplayId);
// Potentially override the selected input method if the new display belongs to a virtual
// device with a custom IME.
String selectedMethodId = getSelectedMethodIdLocked();
- if (oldDisplayIdToShowIme != mDisplayIdToShowIme) {
- final String deviceMethodId = computeCurrentDeviceMethodIdLocked(selectedMethodId);
- if (deviceMethodId == null) {
- mVisibilityStateComputer.getImePolicy().setImeHiddenByDisplayPolicy(true);
- } else if (!Objects.equals(deviceMethodId, selectedMethodId)) {
- setInputMethodLocked(deviceMethodId, NOT_A_SUBTYPE_ID, mDeviceIdToShowIme);
- selectedMethodId = deviceMethodId;
- }
+ final String deviceMethodId = computeCurrentDeviceMethodIdLocked(selectedMethodId);
+ if (deviceMethodId == null) {
+ mVisibilityStateComputer.getImePolicy().setImeHiddenByDisplayPolicy(true);
+ } else if (!Objects.equals(deviceMethodId, selectedMethodId)) {
+ setInputMethodLocked(deviceMethodId, NOT_A_SUBTYPE_ID, mDeviceIdToShowIme);
+ selectedMethodId = deviceMethodId;
}
if (mVisibilityStateComputer.getImePolicy().isImeHiddenByDisplayPolicy()) {
@@ -2534,10 +2531,10 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
final int oldDeviceId = mDeviceIdToShowIme;
mDeviceIdToShowIme = mVdmInternal.getDeviceIdForDisplayId(mDisplayIdToShowIme);
- if (mDeviceIdToShowIme == oldDeviceId) {
- return currentMethodId;
- }
if (mDeviceIdToShowIme == DEVICE_ID_DEFAULT) {
+ if (oldDeviceId == DEVICE_ID_DEFAULT) {
+ return currentMethodId;
+ }
final String defaultDeviceMethodId = mSettings.getSelectedDefaultDeviceInputMethod();
if (DEBUG) {
Slog.v(TAG, "Restoring default device input method: " + defaultDeviceMethodId);