Fix IME shrunk by WindowTokenClient mis-detach
As CL[1] introduced WindowTokenClient for WindowProviderService (aka the parent class of InputMethodService starts from CL[2]) as a token that IME context can associate with the windowContainer of the InputMethod window in server side. Like the activity context, IME context can adopt configuration/resources update when the IME window changed by display/window changes. And, the IME context caller can also create another type of context with wrapping IME context (i.e. calling createDisplayContext to create a display context), that makes this context can be mixed the window token of WindowProviderService since it's the base context. However, the finalization of the context mixed WindowTokenClient will detach the token when the attached context type is non-window context, this action will mis-detach the token when it managed by WindowProviderService. So like SoftKeyboard previously using createDisplayContext in CL[3] to workaround context resources issues, will in-directly expose this mis-detach token issue as the above. Beside, the handling of WindowTokenClient#{onConfigurationChange, onWindowTokenRemoved} does not thread-safe since this is called from IPC. As the result, the fix is to ignore the check in ContextImpl#finalize to not detach the token when it managed by WindowProviderService, also make sure to post to the main handler when received onConfigurationChanged/onWindowTokenRemoved in WindowTokenClient. Note that this fix could help to resolve "The Window Context should have been attached to a DisplayArea." exception if the token has been detached as the above case that happens before the next WindowProviderService#attachToWindowToken invoked. [1]: I64a1614f32d097785915f6105b1813a929e0fe32 [2]: Ie565e30ed5dd3f2cfe27355a6dded76dc3adc14b [3]: Ic592a1d2fb2da149220c8b503b522b3e864bcc77 Bug: 213118079 Bug: 211062619 Test: manual as steps: 1) adb install -r EditTextVariations.apk 2) adb install -r SoftKeyboard.apk 3) adb shell ime enable com.example.android.softkeyboard/.SoftKeyboard 4) adb shell ime set com.example.android.softkeyboard/.SoftKeyboard5 5) Enable screen auto-rotation 6) Launch EditTextVariations from launcher's shortcut 7) Tap the first EditText field to show IME 8) Rotate the device to the landscape mode 9) Expect the IME should not be shrunk Change-Id: I7beb7a122af93e596239a36db62073233cea0726
Loading
Please register or sign in to comment