From bbb10e8ec05956c7dc84091e6d9c2a6f44e1480a Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Fri, 17 Feb 2017 20:13:52 -0800 Subject: [PATCH] Really fix regressions in IMMS#setImeWindowStatus My previous CL [1] that aimed to fix Bug 35395372 was imperfect. It just converted InvalidParameterException into NullPointerException due to a silly mistake in a new error check. [1]: Ib9448c551d9a30776a999c27a5ff20f1a095633a ee2a7ed3d971f83134a2b28258dd2e56f9634f94 Test: Made sure Bug 35395372 and Bug 35479942 are no longer reproducible, that is, 1. Flash a new image and complete the setup wizard on a direct-boot unaware device. 2. Set a device password and require it upon each device boot. 3. adb reboot 4. Observe the default IME does not crash because of NullPointerException/InvalidParameterException thrown by IMMS. Test: Made sure IMM#showSoftInputFromInputMethod(IBinder, int) does not throw an NullPointerException even in an extreme case. 1. Rebuild LatinIME with the following code in LatinIME.java @Override public AbstractInputMethodImpl onCreateInputMethodInterface() { return new InputMethodService.InputMethodImpl() { @Override public void attachToken(IBinder token) { super.attachToken(token); final InputMethodManager imm = getSystemService(InputMethodManager.class); final IBinder imeToken = getWindow().getWindow().getAttributes().token; imm.showSoftInputFromInputMethod(imeToken, 0); } }; } 2. adb install -r LatinIME.apk 3. adb shell ime enable com.android.inputmethod.latin/.LatinIME 4. adb shell ime set com.android.inputmethod.latin/.LatinIME 5. Tap any text field. 4. Observe LatinIME does not crash because of NullPointerException/InvalidParameterException thrown by IMMS. Bug: 34628091 Bug: 35079353 Fixes: 35395372 Fixes: 35479942 Change-Id: Id8e34ecb28480755e8141b6e46820b37fe3dc92b --- .../core/java/com/android/server/InputMethodManagerService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java index 8442c111edd42..fe5b3a24dcc77 100644 --- a/services/core/java/com/android/server/InputMethodManagerService.java +++ b/services/core/java/com/android/server/InputMethodManagerService.java @@ -2046,7 +2046,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } mWindowManagerInternal.updateInputMethodWindowStatus(token, (vis & InputMethodService.IME_VISIBLE) != 0, - token != null ? info.mTargetWindow : null); + info != null ? info.mTargetWindow : null); } private void updateSystemUi(IBinder token, int vis, int backDisposition) {