From 2dbc53242927a796117a0b70d856021c0d4918a5 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Sun, 3 Apr 2016 22:50:18 -0700 Subject: Fix a regression in SHOW_IME_WITH_HARD_KEYBOARD handling. This is a follow up CL to my previous CL [1], which caused a regression that LatinIME does not correctly initialize its UI when: 1. Make sure SHOW_IME_WITH_HARD_KEYBOARD is off. 2. Pair a hardware keyboard. 3. Reboot. 4. Make sure the hardware keyboard is paird. 5. Focus in a text box. 6. Make sure that LatinIME does not show software keyboard. 7. Tap the IME switcher and turn of "Show Input Method" toggle. Previously IMS had called many methods from IMS#onConfigurationChanged(), which was just replaced with IMS#restartInput() by my CL [1] then broke some assumptions in LatinIME. This could also break other IMEs' assumptions as well. To avoid unexpected regressions between M and N like this, this CL ensures that those methods are called as we have done until [1]. [1]: Id4d332e3909590c68345e10e1f2e18650efb2eb7 7b739a802cb7d97460a0bf8a1e9774efe96fa552 Bug: 26985193 Change-Id: Iebd98f26d388b64cb318ac202b3bcdd956bd3a27 --- core/java/android/inputmethodservice/InputMethodService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'core/java/android/inputmethodservice/InputMethodService.java') diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 9d53a0001a84..cc201bc78bb5 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -717,7 +717,11 @@ public class InputMethodService extends AbstractInputMethodService { mShowImeWithHardKeyboard = Settings.Secure.getInt(mService.getContentResolver(), Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD, 0) != 0 ? ShowImeWithHardKeyboardType.TRUE : ShowImeWithHardKeyboardType.FALSE; - mService.updateInputViewShown(); + // In Android M and prior, state change of + // Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD has triggered + // #onConfigurationChanged(). For compatibility reasons, we reset the internal + // state as if configuration was changed. + mService.resetStateForNewConfiguration(); } } @@ -884,7 +888,10 @@ public class InputMethodService extends AbstractInputMethodService { */ @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); + resetStateForNewConfiguration(); + } + private void resetStateForNewConfiguration() { boolean visible = mWindowVisible; int showFlags = mShowInputFlags; boolean showingInput = mShowInputRequested; -- cgit v1.2.3