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
1 file changed