A new power button mode to hide the IME when shown
As discussed in Bug 33038203 on certain platforms there is a demand that the power button can change the behavior depending on whether an IME window is shown on the screen or not. The behavior requested here can be summarized into two parts: * Hide the IME window if it is shown [1] * Go to the home screen if no IME window is shown This CL implements the above request by introducing a new config mode for config_shortPressOnPowerBehavior. Note the definition of when an IME is shown is often tricky than people would expect. The way this CL is implemented is to propagate IME window state from InputMethodManagerService (IMMS) to PhoneWindowManager via WindowManagerService regarding when the back button on the NavBar for phones/tablets should be shown as an IME dismiss key [2]. [1]: Even with this CL the IME still is allowed to ignore the request to hide the software keyboard. Currently there is no official protocol to forcefully hide the software keyboard. How to deal with such a situation is a long standing TODO task. [2]: Internally this is controlled by the following IMMS fields: - InputMethodManagerService#mImeWindowVis - InputMethodManagerService#mBackDisposition Note that those fields rely on self-report from the IME. To be precise, the base implementation of InputMethodService is responsible for report back its internal state to IMMS when necessary. The important point is that, although this could allow a malicious IME to confuse the system UI to some extent, supporting malicious IMEs is not clearly a goal of Android. Anyway, the definition of when an IME is shown is a kind of hot topic in several system services recently. Hopefully we can come up with better definition and reliable mechanism in a future release. Fixes: 33824860 Test: Manually verified as follows 1. Change config_shortPressOnPowerBehavior to "5" 2. Rebuilt the OS image and flash it to the device 3. Make sure that the power button works like a home button if software keyboard is not shown. 4. Open dialer and focus in to the text field shown on top 5. Make sure that the AOSP keyboard is shown. 6. Run 'adb shell dumpsys input_method' to observe the following line: mImeWindowVis=Active|Visible 7. Tap the power button to make sure that the AOSP keyboard gets dismissed. 8. Tap the power button again to make sure that it works as if a home button. Test: Manually tested as follows 1. Open dialer and focus in to the text field to show an IME 2. Run 'adb shell dumpsys window policy' to make sure mDismissImeOnBackKeyPressed=true 3. Tap the back button to dismiss the IME 4. Run 'adb shell dumpsys window policy' to make sure mDismissImeOnBackKeyPressed=false Change-Id: I20721547c73360a70b5fc5cbe06824d577d1768a
Loading
Please register or sign in to comment