summaryrefslogtreecommitdiff
path: root/core/java/android/inputmethodservice/NavigationBarController.java
Commit message (Collapse)AuthorAgeFilesLines
* Fix touchable region calculation in NavigationBarController (2nd)Ming-Shin Lu2022-04-271-5/+13
| | | | | | | | | | | | | | | | | As ViewTreeObserver.InternelInsetsInfo.touchableRegion with setting TOUCHABLE_INSETS_REGION requires setting the region that relative the window position, but CL[1] uses the global screen position to calculate the touch region, which will affect the end result, To fix this, we should use getLocationInWindow to get the relative position of the window. [1]: I0fe54efac80dd0d55f4ba37cfa7d7188b642abb0 Fix: 229562319 Test: manually verified with the IME mentioned in the bug. Test: ensure Bug 226566506 is verified. Change-Id: I9e3fe45dccb263445d378b5ac17b0e450bdb1c24
* Fix touchable region calculation in NavigationBarControllerYohei Yukawa2022-04-061-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | This is a follow up CL to my previous CL [1], which aimed to automatically adjust InputMethodService.Insets so that the tap events on the navigation bar region can be sent to the IME. What I forgot was that View#get{Left,Top,Right,Bottom}() returns values in the window local coordinates, not in the screen coordinates. As a result, in some cases the keyboard area could become untouchable unless the IME specified ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION to InputMethodService.Insets#touchableInsets. With this CL, touchable region should be correctly calculated. [1]: I3e7e1f83554444131e2765dc159617bb9e2337c7 ff7b453ca8e23b4ef75ba2c3f5becaf511cb07d3 Fix: 226566506 Test: manually verified with the IME mentioned in the bug. Change-Id: I0fe54efac80dd0d55f4ba37cfa7d7188b642abb0
* Avoid Rect instantiation in NavigationBarController.ImplYohei Yukawa2022-04-061-4/+5
| | | | | | | | | | This is a preparation to fix Bug 226566506. There should be no behavior change in this CL. Bug: 226566506 Test: presubmit Change-Id: Ib4b8b1ce66bb64c0a710750af4ca95b5b2c9e9e8
* Merge TODO(b/217397817) to TODO(b/215443343)Yohei Yukawa2022-03-161-2/+2
| | | | | | | | | | | | | | | | Given the current schedule, it might be a bit unrealistic to clean up all the remaining TODO(b/217397817) in Android T time frame. Let's merge them into TODO(b/215443343), which is already punted to Android U. This CL is only about TODO comments. There should be no observable behavior change. Bug: 215443343 Fix: 217397817 Test: presubmit Change-Id: Ia9d4277d44e43a31f91d791a23ec894c33cc9d29
* Use parentUserId when reading config_imeDrawsImeNavBarYohei Yukawa2022-03-071-57/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL rewrites my previous CLs [1][2], which were written with an incorrect assumption that config_imeDrawsImeNavBar was overlaid for the entire profile group. While SysUI's navigation mode is dynamically configurable with Runtime Resource Overlay (RRO), it turns out that we currently configure RRO only for the profile parent user. This means that processes run under other profile users continue seeing the base resource value regardless of how RRO is configured for the profile parent user. This is the root cause of Bug 219604375. To work around this limitation, this CL uses InputMethodManagerService to monitor the value of config_imeDrawsImeNavBar for the profile parent user then to propagate it to the IME process. Luckily we have already been doing a similar thing for the IME switcher visibility. What this CL does is 1) adding a new flag to InputMethodNavButtonFlags then 2) just using the flag sent from IMMS instead of directly reading config_imeDrawsImeNavBar NavigationBarController. Alternative solutions considered: * Set RRO for profile users One of straightforward ways to address this problem is letting the Setting app apply the same RRO for other profile users. However, this could be tricky when 1) the user changes navigation mode then 2) sets up a new profile, because the Settings app is not an always-running process. While we might be able to rely on com.android.settings.SettingsInitialize#onReceive() to do so, the profile user's state could be left in a broken state if that method was somehow interrupted. To minimize the risk, we decided to not take this approach for T. * Make OverlayManager be aware of profile groups Given how RRO is used in SysUI, it's make more sense if OverlayManager natively supports resource overlay for the entire profile group. However, introducing such a new concept is too late for Android T. We have filed Bug 221443458 to see if we can do this in a future version of Android. [1]: I3e7e1f83554444131e2765dc159617bb9e2337c7 ff7b453ca8e23b4ef75ba2c3f5becaf511cb07d3 [2]: Id0cfa44cce5de515dc5d28254e1d41bdfc01e201 177e4aafdb33ec0e4b9172a16a07a34dc6420e36 Fix: 219820813 Test: Manually verified as follows 1. Build aosp_coral-userdebug then flash it. 2. adb root 3. adb shell setprop persist.sys.ime.can_render_gestural_nav_buttons true 4. adb reboot 5. adb install -r TestDPC-normalv8001.apk 6. adb shell am start -n com.afwsamples.testdpc/.SetupManagementLaunchActivity 7. Set up work-profile 8. make -j EditTextVariations 9. adb install -r \ $ANDROID_TARGET_OUT_TESTCASES/EditTextVariations/arm64/EditTextVariations.apk 10. adb shell am start --user 0 -n \ com.android.inputmethod.tools.edittextvariations/.EditTextVariations 11. adb shell dumpsys input_method | grep mNavigation -> "mNavigationBarController={mImeDrawsImeNavBar=false, ..." 12. Enable gesture navigation 13. adb shell dumpsys input_method | grep mNavigation -> "mNavigationBarController={mImeDrawsImeNavBar=true, ..." 14. adb shell am start --user 10 -n \ com.android.inputmethod.tools.edittextvariations/.EditTextVariations 15. adb shell dumpsys input_method | grep mNavigation -> "mNavigationBarController={mImeDrawsImeNavBar=true, ..." Change-Id: Id3d6a71d8ba1bfa49131350b68aa8d3424eca381
* Introduce InputMethodNavButtonFlagsYohei Yukawa2022-03-071-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | This CL reworks my previous CL [1], which let InputMethodManagerService report whether the IME switcher icon needs to be shown or not to the IME process by using IInputMethod IPCs. It turns out that we need to propagate one more boolean value in order to address Bug 219820813. It'd be much clearer if we use bit flags rather than adding a new boolean parameter to each IPC method. Thus this CL rewrites my previous CL by using a bit flag defined in a newly introduced InputMethodNavButtonFlags. This is a purely mechanical refactroing. There should be no behavior change. [1]: I5de9ac0dc8670842edf66306bb4c281c77cea376 75b935a12b37ffa97447b9acd80f94a4172bf3e6 Bug: 215551357 Bug: 219820813 Test: Manually verified with for the following scenarios: * Enabling/disabling multiple IMEs * Attaching/detaching a hardware keyboard * Showing/hinding the IME switcher * Showing an IME on the lock screen Change-Id: I81cb062a08d484ec8ce5d7b2fea64ce19028f82e
* Use config_imeDrawsImeNavBarYohei Yukawa2022-02-091-12/+10
| | | | | | | | | | | | | | | | | | | | | | | | | With this CL, IME and SysUI start checking config_imeDrawsImeNavBar [1] instead of config_navBarInteractionMode when determining whether the IME should render the back and IME switcher buttons or not. There should be no observable behavior change as long as config_navBarInteractionMode is set to true when the gestural navigation is enabled. [1]: I0651a99b6007a84be63b85b579a85af0f24bb6ec Fix: 216118048 Test: manual Change-Id: Ifdfd23612f6cb2bfe6ddf302e3caac1e342a8a1e
* Add null check for mNavigationBarFrameRobin Lee2022-02-071-5/+7
| | | | | | | | | This may not exist at this point (or at all depending on the device configuration) Change-Id: Ida9b5f4eadfd2620d7b74171268cf266f77f7b3d Test: manual - bring up the keyboard on a TV Fix: 218228687
* Have both NAVIGATION_HINT_IME{,_SWITCHER}_SHOWNYohei Yukawa2022-02-041-2/+2
| | | | | | | | | | | | | | | | | | | This is a mechanical renaming CL with no behavior change. Somehow NAVIGATION_HINT_IME_SHOWN was set when the IME switcher needs to be shown, not when the IME is shown. This CL aims to avoid future confusions by also introducing NAVIGATION_HINT_IME_SWITCHER_SHOWN then setting NAVIGATION_HINT_IME_SHOWN when the IME is actually shown. This CL also updates NavigationBarTest to verify those flags. Bug: 192412909 Bug: 217755059 Test: atest SystemUITests:NavigationBarTest Change-Id: I8bdd58d040689953072c7f384ece2bca677265e1
* Add a missing "=" in dumpsys input_methodYohei Yukawa2022-02-031-1/+2
| | | | | | | | | | | | | | | My previous CL [1] lacked "=" when dumping NavigationBarController#mShouldShowImeSwitcherWhenImeIsShown into dumpsys. This CL fixes that typo. [1]: I5de9ac0dc8670842edf66306bb4c281c77cea376 75b935a12b37ffa97447b9acd80f94a4172bf3e6 Bug: 215551357 Test: adb shell dumpsys input_method | grep NavigationBarController Change-Id: Ifa2f5d2abcbe982b0afa5a6dad1573a86123485e
* Support floating IMEs even when IMEs render the nav buttonsYohei Yukawa2022-01-311-5/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed in Bug 201375975, the nevigation bar handling for floating IMEs is a bit tricky. This CL tweaks DecorView behabior only when InputMethodService#canImeRenderGesturalNavButtons(), is true and the IME is floating in the gestural navigation mode. Fix: 215550296 Test: Manually tested with ThemedNavBarKeyboard sample 1. Build aosp_coral-userdebug and flash it 2. adb root 3. adb shell setprop \ persist.sys.ime.can_render_gestural_nav_buttons true 4. adb reboot 5. make -j ThemedNavBarKeyboard 6. adb install -r \ $OUT/system/app/ThemedNavBarKeyboard/ThemedNavBarKeyboard.apk 7. adb shell ime enable \ com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard 8. adb shell ime set \ com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard 9. Open the Dialer app 10. Focus in the top edit field. 11. Tap "FLOATING MODE" mode 12. Make sure that the navigation buttons are visible. Change-Id: Ia54499a3c2ac6e33e72f625eba3477fd81649d32
* Introduce Window.DecorCallbackYohei Yukawa2022-01-311-8/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a follow up CL to my previous CL [1], which introduced a hidden callback method into Window.Callback. This CL does not change any observable behavior but consolidate that hidden callback into a newly introduced Window.DecorCallback interface. In this approach, we no longer need to worry about accidental method name collision in Window.Callback implementations classes. Here is the new callback chain. ViewRootImpl#performTraversals() -> DecorView#onSystemBarAppearanceChanged() -> Window.dispatchOnSystemBarAppearanceChanged() -> NavigationBarController.Impl#onSystemBarAppearanceChanged() [1]: I08566034bebfafff6777ce0152cd6ca1f66f6cad 678ddce11c131a8e6746fe386c40ddc8d99d01c3 Bug: 215549533 Test: Manually tested with ThemedNavBarKeyboard sample 1. Build aosp_coral-userdebug and flash it 2. adb root 3. adb shell setprop \ persist.sys.ime.can_render_gestural_nav_buttons true 4. adb reboot 5. make -j ThemedNavBarKeyboard 6. adb install -r \ $OUT/system/app/ThemedNavBarKeyboard/ThemedNavBarKeyboard.apk 7. adb shell ime enable \ com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard 8. adb shell ime set \ com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard 9. Open the Dialer app 10. Focus in the top edit field. 11. Tap "EXTENDED LIGHT NAVIGARION BAR" mode 12. Make sure that the navigation button color is optimized for light navigation bar. 13. Tap "STANDARD LIGHT NAVIGARION BAR" mode 14. Make sure that the navigation button color is optimized for light navigation bar. Change-Id: I5168f76dfc9526e925c565dbfa87597b5543fcdc
* Support IME switcher icon visibility updateYohei Yukawa2022-01-281-1/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this CL, the IME switcher icon becomes visible only when necessary, even if InputMethodService renders the back button and the IME switcher button in the gestural navigation mode. Implementation idea: InputMethodManagerService#shouldShowImeSwitcherLocked() is the source of truth about whether the IME switcher visibility should be shown or not, and it internally depends on the following conditions: A. com.android.internal.R.bool.show_ongoing_ime_switcher B. Whether the IME switcher is already shown or not. C. Whether the IME is perceptible or not. D. Whether one or more hardware keyboards are attached or not. E. Keyguard state. F. What IMEs and their subtypes are enabled. Here are what those conditions would mean for this project. * A is considered to be a per-device constant value. * B, D, and F can happen at any time outside of the IME lifecycle events such as startInput(). * C is no longer relevant if those buttons are rendered by the IME. * E is considered to be constant throughout each startInput() cycle. This CL uses the following 3 IPCs to notify when the IME switcher visibility is changing. 1. IInputMethod#initializeInternal() 2. IInputMethod#startInput() 3. IInputMethod#onShouldShowImeSwitcherWhenImeIsShownChanged() 1 and 2 will be used to provide the "initial" value to avoid potential flickers. 3 is still necessary to take care of async changes triggered by B, D, and F. Fix: 215551357 Test: Manually verified with for the following scenarios: * Enabling/disabling multiple IMEs * Attaching/detaching a hardware keyboard * Showing/hinding the IME switcher * Showing an IME on the lock screen Change-Id: I5de9ac0dc8670842edf66306bb4c281c77cea376
* Support nav button color transitionsYohei Yukawa2022-01-281-1/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this CL, the back and IME switcher buttons on the navigation bar have the same color transition even when they are rendered by the IME. Note that the behavior is still behind a flag persist.sys.ime.can_render_gestural_nav_buttons, which is still off by default. There should be no observable changes no matter whether the flag is enabled or disabled though. Fix: 215549533 Test: Manually tested with ThemedNavBarKeyboard sample 1. Build aosp_coral-userdebug and flash it 2. adb root 3. adb shell setprop \ persist.sys.ime.can_render_gestural_nav_buttons true 4. adb reboot 5. make -j ThemedNavBarKeyboard 6. adb install -r \ $OUT/system/app/ThemedNavBarKeyboard/ThemedNavBarKeyboard.apk 7. adb shell ime enable \ com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard 8. adb shell ime set \ com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard 9. Open the Dialer app 10. Focus in the top edit field. 11. Tap "EXTENDED LIGHT NAVIGARION BAR" mode 12. Make sure that the navigation button color changes from light to dark with animation. 13. Tap "EXTENDED DARK NAVIGARION BAR" mode 12. Make sure that the navigation button color changes from dark to light with animation. Change-Id: I41a3478a97d67b238c4424d93acbcad646aee0d2
* Support light navigation barYohei Yukawa2022-01-271-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to propagate the information about whether the IME is using light navigation bar or not from android.view.ViewRootImpl to android.inputmethodservice.NavigationBarController within the same process, this CL adds a new @hide method to Window.Callback as follows. ViewRootImpl#performTraversals() -> DecorView#onSystemBarAppearanceChanged() -> Window.Callback#onSystemBarAppearanceChanged() -> SoftInputWindow#onSystemBarAppearanceChanged() -> NavigationBarController#onSystemBarAppearanceChanged() Button color transition will be implemented in a subsequent CL. Bug: 215549533 Test: Manually tested with ThemedNavBarKeyboard sample 1. Build aosp_coral-userdebug and flash it 2. adb root 3. adb shell setprop \ persist.sys.ime.can_render_gestural_nav_buttons true 4. adb reboot 5. make -j ThemedNavBarKeyboard 6. adb install -r \ $OUT/system/app/ThemedNavBarKeyboard/ThemedNavBarKeyboard.apk 7. adb shell ime enable \ com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard 8. adb shell ime set \ com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard 9. Open the Dialer app 10. Focus in the top edit field. 11. Tap "EXTENDED LIGHT NAVIGARION BAR" mode 12. Make sure that the navigation button color is optimized for light navigation bar. 13. Tap "STANDARD LIGHT NAVIGARION BAR" mode 14. Make sure that the navigation button color is optimized for light navigation bar. Change-Id: I08566034bebfafff6777ce0152cd6ca1f66f6cad
* Factor out to NavigationBarController#scheduleRelayout()Yohei Yukawa2022-01-251-24/+40
| | | | | | | | | This is a mechanical refactoring CL so that we can avoid code duplicate later. Bug: 215550296 Test: Manually verified that there is no behavior change Change-Id: I14d2c7609e156b9e627b26471d392cb47b14163b
* Update the IME nav UI when gesture navigation mode changesYohei Yukawa2022-01-241-1/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this CL, nav buttons rendered by InputMethodService can be dynamically enabled or disabled when the gesture navigation mode is updated. Note that the feature is still disabled by default behind the flag. Hence there should be no observable behavior changes unless the feature is explicitly enabled with setprop. Fix: 215552600 Test: Manually done as follows 1. Build aosp_coral-userdebug and flash it 2. adb root 3. adb shell setprop \ persist.sys.ime.can_render_gestural_nav_buttons true 4. adb reboot 5. Tap any edit field to show AOSP Keyboard. 6. adb shell dumpsys input_method | grep mNavigationBarController -> Confirm mRenderGesturalNavButtons is false. -> Confirm mNavigationBarFrame is null. 7. Switch to gestural navigation mode. 8. adb shell dumpsys input_method | grep mNavigationBarController -> Confirm mRenderGesturalNavButtons is true. -> Confirm mNavigationBarFrame is not null. 9. Switch to 3-button navigation mode again. 10. adb shell dumpsys input_method | grep mNavigationBarController -> Confirm mRenderGesturalNavButtons is false. -> Confirm mNavigationBarFrame is null. Change-Id: Id0cfa44cce5de515dc5d28254e1d41bdfc01e201
* Minimum impl of nav buttons rendered by IMEYohei Yukawa2022-01-201-0/+328
This is the minimum implementation of rendering the back button and the IME switcher button in the InputMethodService process. Note that the feature is still disabled by default behind the flag. Newly added UI logic should be running only when the feature flag is enabled. Bug 215545985: Enable canImeRenderGesturalNavButtons() by default Here is the list of known blockers before enabling the flag. * Bug 215552600: Subscribe gesture mode change. * Bug 215551357: Show IME swicher button only when necessary. * Bug 215549533: Support light navigation bar. * Bug 215550296: Support floating IME. * Bug 215554582: Set "input_method_rounded_corner_content_padding" for each devices. Also, after enabling the flag by default, we start cleaning up newly added code under android.inputmethodservice.navigationbar. at Bug 215443343. Bug: 205803355 Test: Manually done as follows 1. Build aosp_coral-userdebug and flash it 2. Switch to gestural navigation mode. 3. adb root 4. adb shell setprop \ persist.sys.ime.can_render_gestural_nav_buttons true 5. adb reboot 6. Tap any edit field to show AOSP Keyboard. 7. Confirm that the back button on the navbar works. 8. Confirm that the IME switcher button on the navbar works. Change-Id: I3e7e1f83554444131e2765dc159617bb9e2337c7