Refresh visible IME proc boost upon onBindingDied
When an active IME is force-stopped, service connections from InputMethodManagerService (IMMS) to that IME have died and ServiceConnection#onServiceConnected() will never happen (again) even if Context.BIND_AUTO_CREATE is specified hence IMMS needs to re-establish connections from scratch. Previously IMMS did not handle this scenario and InputMethodManagerService#mVisibleConnection can remain to be true even after the current IME is updated, force-stopped, or whatever permanent death happened to it. As a result, IMMS fails to give process priority boost to the IME process when it shows up until it becomes hidden then shown again. Even though this is one-time anomaly, not giving priority boost to a visible IME is not intentional and should be fixed. Luckily we can rely on a recently introduced callback ServiceConnection#onBindingDied() [1][2] to clean up InputMethodManagerService#mVisibleBound for such a scenario, and this CL does it. [1]: I526cc00816c384fa9eb1312b92406f38085cbff9 9484603c [2]: Ic21f7ef66d43fb6db9f7ebbc833f28c09474ea59 ac265349 Fix: 80625728 Test: Manually verified as follows. 1. Build and flash aosp_taimen-userdebug 2. Run adb shell dumpsys input_method | grep mVisibleBound to make sure that mVisibleBound is true when and only when AOSP Keyboard is shown. 3. Run adb shell dumpsys activity services com.android.inputmethod.latin to make sure that there are two connections to "com.android.inputmethod.latin/.LatinIME" when AOSP Keyboard is shown and is only one connection when AOSP Keyboard is hidden. 4. Run adb shell dumpsys activity processes com.android.inputmethod.latin | grep curProcState to make sure that curProcState is PROCESS_STATE_BOUND_FOREGROUND_SERVICE (==4) when AOSP Keyboard is shown and curProcState is PROCESS_STATE_IMPORTANT_BACKGROUND (==6) when AOSP Keyboard is hidden. 5. Run adb shell cat /proc/`adb shell pidof com.android.inputmethod.latin`/cgroup to make sure that cpuset is foreground when and only when AOSP Keyboard is shown. 6. Run the following command while AOSP Keyboard is visible adb shell am force-stop com.android.inputmethod.latin 7. Run adb shell dumpsys input_method | grep mVisibleBound to make sure that mVisibleBound is reset to false. 8. Tap any EditText field 9. Make sure mVisibleBound becomes true again 10. Make sure curProcState becomes PROCESS_STATE_BOUND_FOREGROUND_SERVICE again 11. Make sure cpuset for AOSP Keyboard is foreground Change-Id: I983d95ffc0c2edab687117f6c6fa5a0d002ef6ad
Loading
Please register or sign in to comment