Commit Graph

534 Commits

Author SHA1 Message Date
Taran Singh
4cff41a3f2 Merge "Finish handwriting session for recents gesture" into tm-dev 2022-03-21 20:54:31 +00:00
Yohei Yukawa
13b27571c9 Merge TODO(b/217397817) to TODO(b/215443343)
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
2022-03-16 14:57:10 -07:00
Taran Singh
d98f037ab2 Finish handwriting session for recents gesture
Finish stylus handwriting session when user swipes to recent.
Bug: 223748964
Test: Manually:
     1. Open an app with editor
     2. swipe on editor with stylus [or emulated stylus]
     3. Observe ink trail drawn on screen
     4. quickly sipe to recents, ink should go away.
     5. repeat steps 1-3 for swipe to home

Change-Id: Id750ff55cb447247c3eca75daf37cb5aeb1d0cfa
2022-03-15 20:44:30 +00:00
Taran Singh
6e3f7a9847 Merge "Introduce new IMS method for Stylus events and dispatch" into tm-dev 2022-03-10 15:24:29 +00:00
Taran Singh
2cb5152f97 Merge "Remove ImsConfigTracker#onBindInput precondition" into tm-dev 2022-03-09 20:35:22 +00:00
Taran Singh
467fd168d5 Introduce new IMS method for Stylus events and dispatch
As of today we show the InkWindow and dispatch Stylus events without
waiting. At the time of dispatch, InkWindow is not added and first stylus gesture
is skipped. In order to deliver the first gesture to IME, we should wait until
InkWindow is added and IME's Inking View is attached.

However, waiting for it will introduce latency in the system. To counter
that, we introduce a new API method to listen for Stylus MotionEvent.
IME can override the API method to listen to MotionEvents sooner.

By default, the stylus MotionEvents are buffered until Ink view is visible.

Change-Id: I3a18067da45fd15bf0f6e377da0a82cdd6df1d41
Fix: 222081673
Test: atest StylusHandwriting
2022-03-09 18:35:21 +00:00
Taran Singh
5c53f0ca67 Remove ImsConfigTracker#onBindInput precondition
It is expected the onIntialize() is called before onBindInput(), however
it's not precisely known why onBindInput() is being called prior to onIntialize().
Once possibility is it could be that onDestory() is being called
and init was skipped and call made it to onBindInput().

Replacing precondition with an early return should be safe here.

Fix: 223083664
Bug: 223443508
Test: atest CtsInputMethodTestCases

Change-Id: I8312d98b0349fbc661b6eb0f4c47bea25ffbb2a9
2022-03-09 18:25:38 +00:00
Yohei Yukawa
63fc97c8d0 Fix remaining lint erros under a.i.navigationbar
This is a mechanical cleanup CL.  There should be no behavior change.

Bug: 215443343
Test: prebuilts/checkstyle/checkstyle.py -f \
  frameworks/base/core/java/android/inputmethodservice/navigationbar/ \
  | grep ".java:"
Change-Id: Ib9dcddc675bdd540ae93a1eb5b1db00d1dccecb1
2022-03-08 20:23:30 -08:00
Yohei Yukawa
0b1522bce4 Fix camel-case-related lint erros under a.i.navigationbar
This is a mechanical cleanup CL.  There should be no behavior change.

Bug: 215443343
Test: prebuilts/checkstyle/checkstyle.py -f \
  frameworks/base/core/java/android/inputmethodservice/navigationbar/ \
  | grep "camel-case"
Change-Id: I05b25b11c6b571407bc4a707161fb993960603f9
2022-03-08 20:23:26 -08:00
Yohei Yukawa
76adda5ef3 Fix whitespace-related lint erros under a.i.navigationbar
This is a mechanical cleanup CL.  There should be no behavior change.

Bug: 215443343
Test: prebuilts/checkstyle/checkstyle.py -f \
  frameworks/base/core/java/android/inputmethodservice/navigationbar/ \
  | grep "whitespace"
Change-Id: I342af73d675f6432b16acd2604d2e43a5055b701
2022-03-08 20:23:22 -08:00
Yohei Yukawa
dc4679a818 Fix modifier-related lint erros under a.i.navigationbar
This is a mechanical cleanup CL.  There should be no behavior change.

Bug: 215443343
Test: prebuilts/checkstyle/checkstyle.py -f \
  frameworks/base/core/java/android/inputmethodservice/navigationbar/ \
  | grep "modifier"
Change-Id: Idf3c8d13c63770397e895bc05ba2374c10fb3bd1
2022-03-08 20:23:17 -08:00
Yohei Yukawa
f1b6f5c09d Fix Javadoc-related lint erros under a.i.navigationbar
This is a mechanical cleanup CL.  There should be no behavior change.

Bug: 215443343
Test: prebuilts/checkstyle/checkstyle.py -f \
  frameworks/base/core/java/android/inputmethodservice/navigationbar/ \
  | grep "Missing a Javadoc comment"
Change-Id: I5cb365b69864a145e7eaf7ff4454c261324ab845
2022-03-08 20:23:10 -08:00
Yohei Yukawa
c0e93388ff Enable IMS#canImeRenderGesturalNavButtons() by default (3rd try)
This is the third attempt to enable

  IMS#canImeRenderGesturalNavButtons()

by default.  The first attempt [1] was reverted due to Bug 217668258.
The second attempt [2] was reverted due to Bug 219604375 and
Bug 218322263.

With this CL, the back button and IME switcher button on the
navigation bar are rendered by the IME when gestural navigation mode
is enabled.

The new behavior can still be manually disabled as follows

  adb root
  adb shell setprop  \
        persist.sys.ime.can_render_gestural_nav_buttons false
  adb reboot

The only observable behavior change we are aware of is that now those
buttons are included in the task screenshot in Recents.

Other than that, there should be no observable behavior change.

 [1]: I45e511f5cfec93cdd002d23c091b4fe735b28227
      793e152713
 [2]: I39f454a2d41d7d5255b8cc4f7d9a3f7a7642b2f3
      f21d211559

Fix: 215545985
Test: Manually tested with ThemedNavBarKeyboard sample
  1. Build aosp_coral-userdebug and flash it
  2. Enable gesture navigation mode.
  3. make -j ThemedNavBarKeyboard
  4. adb install -r \
      $OUT/system/app/ThemedNavBarKeyboard/ThemedNavBarKeyboard.apk
  5. adb shell ime enable \
      com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard
  6. adb shell ime set \
      com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard
  7. Open the Dialer app
  8. Tap "EXTENDED LIGHT NAVIGARION BAR" mode
  9. Make sure that the navigation button color is optimized for light
     navigation bar.
 10. Tap "STANDARD LIGHT NAVIGARION BAR" mode
 11. Make sure that the navigation button color is optimized for light
     navigation bar.
 12. Tap "FLOATING MODE" mode
 13. Make sure that the navigation buttons are visible.
Test: Manually verified as follows.
  1. Build coral-userdebug and flash it
  2. Make sure that the back button is shown on the setup wizard
     no matter whether the IME is shown or not.
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: Iec55ce12e8198e243cdd716ab7c52d0f3939c279
2022-03-08 08:15:03 -08:00
Yohei Yukawa
f93769b1ae Use parentUserId when reading config_imeDrawsImeNavBar
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
      ff7b453ca8
 [2]: Id0cfa44cce5de515dc5d28254e1d41bdfc01e201
      177e4aafdb

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
2022-03-07 11:13:58 -08:00
Yohei Yukawa
5f9f1ca560 Introduce InputMethodNavButtonFlags
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
      75b935a12b

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
2022-03-07 10:47:47 -08:00
TreeHugger Robot
33a2b4bacd Merge "Incorporate API feedback: CAI requestCursorUpdates()" into tm-dev 2022-03-03 13:27:04 +00:00
Prabir Pradhan
f1a82ef0ef Configure handwriting window with the IME's pid and uid for ANRs
When starting a handwriting session, update the handwriting input window
so that it is configured with the IME's pid and uid. This means any ANRs
that occur due to the handwriting input window will be directed to the
IME process.

Since oneway binder calls do not have pid information, we cannot use
Binder.getCallingPid() to get the pid of the IME. Instead, we report the
pid from IMS when starting handwriting.

Bug: 210978621
Test: manual with custom IME, verify ANR is directed to IME.
Change-Id: Ia6963eb02cad22c7f604896e6c78ed31c84e32f6
Merged-In: Ia6963eb02cad22c7f604896e6c78ed31c84e32f6
(cherry picked from commit 58df52232a)
2022-03-02 11:57:51 +00:00
Taran Singh
472e5c3825 Incorporate API feedback: CAI requestCursorUpdates()
1. Use intDef for CurosrUpdateFilter
2. overload requestCursorUpdates(mode, filter)
3. additional details in javadoc

Fix: 218314883
Bug: 210039666
Test: atest CtsInputMethodTestCases

Change-Id: I1dc5acac4f968b2a2d1780f2ee6c0145c7dcbbaa
2022-03-01 19:05:50 +00:00
TreeHugger Robot
b6e868e01d Merge "Revert "Enable IMS#canImeRenderGesturalNavButtons() by default (2nd try)"" 2022-02-15 23:02:09 +00:00
Yohei Yukawa
7522e42738 Revert "Enable IMS#canImeRenderGesturalNavButtons() by default (2nd try)"
This reverts commit f21d211559 [1].

Reason for revert:
IME Nav buttons are unexpectedly invisible in the following cases.
 * work profile apps (Bug 219604375)
 * setup wizard (Bug 218322263)

 [1]: I39f454a2d41d7d5255b8cc4f7d9a3f7a7642b2f3

Bug: 215545985
Fix: 219604375
Test: Manually verified as follows.
 1. Build aosp_coral-userdebug and flash it.
 2. adb install -r TestDPC-normalv8001.apk
 3. Set up work-profile
 4. Enable gestural navigation mode
 5. adb shell am start --user 10 -n \
     com.android.documentsui/com.android.documentsui.files.FilesActivity
 6. Tap the magnifier icon to show the AOSP Keyboard
 7. Confirm that the back button is shown on the nav bar
 8. adb shell dumpsys input_method | grep mNavigationBarController
    -> "No-op implementation"
Change-Id: If3da8dbad0b8bd204cc4ec04f882e9248439c456
2022-02-15 16:44:26 +00:00
Yohei Yukawa
e559812ca7 Merge "Remove unused InputMethod#setCurrentShowInputToken()" 2022-02-15 16:29:23 +00:00
Yohei Yukawa
99a34dabf4 Merge "Remove unused InputMethod#setCurrentHideInputToken()" 2022-02-15 16:19:42 +00:00
TreeHugger Robot
5128d9d808 Merge "Use config_imeDrawsImeNavBar" 2022-02-15 02:50:22 +00:00
Yohei Yukawa
7d2f3d98ad Remove unused InputMethod#setCurrentShowInputToken()
This is a clean up CL to our previous CL [1], which introduced an
unused @hide method

  InputMethod#setCurrentShowInputToken().

Since that method has never been called, there should be no behavior
change in this CL.

 [1]: Ia49e23dd077d264a58d28a7b8acffde54b7db187
      bb0e2f753b

Bug: 111084606
Bug: 192412909
Test: presubmit
Change-Id: Idd607ef62c91a92006da4bf26a86338ea7224ce8
2022-02-14 12:19:09 -08:00
Yohei Yukawa
10c406e461 Remove unused InputMethod#setCurrentHideInputToken()
This is a clean up CL to our previous CL [1], which introduced an
unused @hide method

  InputMethod#setCurrentHideInputToken().

Since that method has never been called, there should be no behavior
change in this CL.

 [1]: Ia596a392eb73ae46debd097151c8c9a7edd59833
      44e2ae4afc30b6a873e1536e31619db258f6cf00

Bug: 133381284
Bug: 149870112
Bug: 192412909
Test: presubmit
Change-Id: I8906360dc51ad3468b9ce4c97d477ae9bcdb2e91
2022-02-14 12:14:57 -08:00
TreeHugger Robot
708216ab8c Merge "Recycle obtained TypedArrays" 2022-02-10 18:34:36 +00:00
Nikolas Havrikov
0ebfffb897 Recycle obtained TypedArrays
Bug: 218835043
Test: make
Change-Id: I2c19ca3b6e4773de533cceac6b5341ae964b4fd4
2022-02-10 14:50:42 +01:00
Taran Singh
ded74d352f Merge changes I53808ec2,I6f1b8a93
* changes:
  Minimal test IME with Stylus HW support
  Fix IMS#onPrepareStylusHandwriting call
2022-02-10 12:57:03 +00:00
Taran Singh
070f7b67e8 Fix IMS#onPrepareStylusHandwriting call
Ensure onPrepareStylusHandwriting() is always called before
onStartStylusHandwriting().

Test: manually using HandwritingIme
Bug: 217957587
Change-Id: I6f1b8a93a76dbb34d3323439253a3394c05d98a8
2022-02-10 04:55:49 +00:00
Yohei Yukawa
442bc2b28d Use config_imeDrawsImeNavBar
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
2022-02-09 08:29:57 -08:00
yingleiw
fb17e5ae7a Allow a11y services to enter text via the path IMEs use
InputMethodService is the primary and a11y is the secondary.
InputMethodService is not
affected by a11y status. When the session from input method is
established, app can start input (pass input context to input method).
When an a11y session comes back, it will be passed to the app. When
InputMethodManagerService binds to/start input with
InputMethodService, it does the same to a11y services which
requested IME functionalities.

It is possible that input method can edit text before ally sessios are
established. So the EditorInfo passed to a11y could be stale.
So when an a11y session is passed to client, client will send
a notification (input method doesn't have this extra notification) for
the current selection. I think since the time for a11y session establish
shouldn't be long, and we get the current state later, it should be fine
for a11y services.

When input method is disconnected from app (client) (even for input
method switching), we cleared a11y and sessions too. When
input method request sessions, we must rerequest sessions for a11y. This
is mainly because when we unbindCurrentClientLocked(SWITCH_IME), we set
active to false for the current client. Suppose we don't want to
change the current structure of input method, an inactive client
probably should clear accessibility sessions too.

When we switch to a client which already has a session with input
method, there might be some a11y sessions with this client, and
some a11y services might be disabled or enabled while the client was
switched out. We pass unchanged a11y
sessions to client, and request sessions for newly enabled a11y services.
When an a11y service is disabled, it removes its session
from all clients in InputMethodManagerService.

Test: type word through modified "switchToInputMethod". Tested session
notification through logs. Tested client switching, input method
switching, a11y service enabled/disable, multiple a11y services,
a11y service enabled before device reboot.
Also tested work profile.

Bug: 187453053

Change-Id: Ia651a811093a939d00c081be1961e24ed3ad0356
2022-02-08 22:14:19 -08:00
Adrian Roos
ad5bd08354 Merge "Fix IMS window visibility" 2022-02-07 17:14:39 +00:00
Robin Lee
a246b947d4 Add null check for mNavigationBarFrame
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
2022-02-07 11:41:05 +00:00
Yohei Yukawa
f21d211559 Enable IMS#canImeRenderGesturalNavButtons() by default (2nd try)
This is the second attempt to enable

  IMS#canImeRenderGesturalNavButtons()

by default.  The first attempt [1] was reverted due to Bug 217668258.

With this CL, the back button and IME switcher button on the
navigation bar are rendered by the IME when gestural navigation mode
is enabled.

The new behavior can still be manually disabled as follows

  adb root
  adb shell setprop  \
        persist.sys.ime.can_render_gestural_nav_buttons false
  adb reboot

The only observable behavior change we are aware of is that now those
buttons are included in the task screenshot in Recents.

Other than that, there should be no observable behavior change.

 [1]: I45e511f5cfec93cdd002d23c091b4fe735b28227
      793e152713

Fix: 215545985
Test: Manually tested with ThemedNavBarKeyboard sample
  1. Build aosp_coral-userdebug and flash it
  2. Enable gesture navigation mode.
  3. make -j ThemedNavBarKeyboard
  4. adb install -r \
      $OUT/system/app/ThemedNavBarKeyboard/ThemedNavBarKeyboard.apk
  5. adb shell ime enable \
      com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard
  6. adb shell ime set \
      com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard
  7. Open the Dialer app
  8. Tap "EXTENDED LIGHT NAVIGARION BAR" mode
  9. Make sure that the navigation button color is optimized for light
     navigation bar.
 10. Tap "STANDARD LIGHT NAVIGARION BAR" mode
 11. Make sure that the navigation button color is optimized for light
     navigation bar.
 12. Tap "FLOATING MODE" mode
 13. Make sure that the navigation buttons are visible.
Test: Manually verified as follows.
  1. Build coral-userdebug and flash it
  2. Make sure that the back button is shown on the setup wizard.
Change-Id: I39f454a2d41d7d5255b8cc4f7d9a3f7a7642b2f3
2022-02-04 12:50:07 -08:00
Yohei Yukawa
bf122b9f94 Have both NAVIGATION_HINT_IME{,_SWITCHER}_SHOWN
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
2022-02-04 12:49:21 -08:00
Yohei Yukawa
8b70de55fa Merge "Revert "Enable IMS#canImeRenderGesturalNavButtons() by default"" 2022-02-04 00:01:55 +00:00
Yohei Yukawa
4d3ddb067c Add a missing "=" in dumpsys input_method
My previous CL [1] lacked "=" when dumping

  NavigationBarController#mShouldShowImeSwitcherWhenImeIsShown

into dumpsys.  This CL fixes that typo.

 [1]: I5de9ac0dc8670842edf66306bb4c281c77cea376
      75b935a12b

Bug: 215551357
Test: adb shell dumpsys input_method | grep NavigationBarController
Change-Id: Ifa2f5d2abcbe982b0afa5a6dad1573a86123485e
2022-02-03 11:59:37 -08:00
Yohei Yukawa
c35df2f1ec Revert "Enable IMS#canImeRenderGesturalNavButtons() by default"
This reverts commit 793e152713 [1].

Reason for revert:
No back button on the setup wizard.

 [1]: I45e511f5cfec93cdd002d23c091b4fe735b28227

Bug: 215545985
Fix: 217668258
Change-Id: Iac77c5bfafc5d208a1d3f3b56f0f7ee81d51031b
2022-02-03 16:07:54 +00:00
Adrian Roos
92fbace14b Fix IMS window visibility
Fixes an issue with IMS window visibility, where an unfortunate timing
of removeImeSurface() and showWindow() could result in the window being
hidden without resetting mDecorViewVisible.

Root cause is the scheduled removeImeSurface() not being cancelled in
all code paths that end up calling showWindow().

To avoid this we
- consolidate calls to cancelImeSurfaceRemoval
  and applyVisibilityInInsetsConsumerIfNecessary into showWindow()
- inline the now unnecessary doHideWindow
- unconditionally call mWindow.show() in showWindow, since View.java
  already avoids unnecessary work if the decor visibility won't change

Fixes: 203137087
Test: manual
Change-Id: Iaef9efd4f1a89fe6da27fc6396b62ff3b4ca11f4
2022-02-03 14:08:56 +00:00
Yohei Yukawa
793e152713 Enable IMS#canImeRenderGesturalNavButtons() by default
With this CL, the back button and IME switcher button on the
navigation bar are rendered by the IME when gestural navigation mode
is enabled.

The new behavior can still be manually disabled as follows

  adb root
  adb shell setprop  \
        persist.sys.ime.can_render_gestural_nav_buttons false
  adb reboot

The only observable behavior change we are aware of is that now those
buttons are included in the task screenshot in Recents.

Other than that, there should be no observable behavior change.

Fix: 215545985
Test: Manually tested with ThemedNavBarKeyboard sample
  1. Build aosp_coral-userdebug and flash it
  2. Enable gesture navigation mode.
  3. make -j ThemedNavBarKeyboard
  4. adb install -r \
      $OUT/system/app/ThemedNavBarKeyboard/ThemedNavBarKeyboard.apk
  5. adb shell ime enable \
      com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard
  6. adb shell ime set \
      com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard
  7. Open the Dialer app
  8. Tap "EXTENDED LIGHT NAVIGARION BAR" mode
  9. Make sure that the navigation button color is optimized for light
     navigation bar.
 10. Tap "STANDARD LIGHT NAVIGARION BAR" mode
 11. Make sure that the navigation button color is optimized for light
     navigation bar.
 12. Tap "FLOATING MODE" mode
 13. Make sure that the navigation buttons are visible.
Change-Id: I45e511f5cfec93cdd002d23c091b4fe735b28227
2022-02-01 11:25:32 -08:00
Yohei Yukawa
c98b9c8f40 Support floating IMEs even when IMEs render the nav buttons
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
2022-01-31 18:56:59 -08:00
Yohei Yukawa
af1695a78a Introduce Window.DecorCallback
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
      678ddce11c

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
2022-01-31 18:56:50 -08:00
Yohei Yukawa
75b935a12b Support IME switcher icon visibility update
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
2022-01-28 10:04:32 -08:00
Yohei Yukawa
dec2c21955 Support nav button color transitions
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
2022-01-28 09:15:24 -08:00
Jared Duke
5ff99b87c5 Merge "Avoid reflection with ObjectAnimator" 2022-01-27 22:45:47 +00:00
TreeHugger Robot
b8319503a2 Merge "Make IME extract text fields public" 2022-01-27 21:56:20 +00:00
Jared Duke
912b87abee Avoid reflection with ObjectAnimator
Use explicit FloatProperty proxies for routing ObjectAnimator updates.
This prevents issues with Proguard-related shrinking/optimization for
custom class types.

Test: atest SystemUITests + manual validation of error logs
Bug: 203472868
Change-Id: Ie0889101f1063a929d2052756b1f4008f2b84a92
2022-01-27 19:29:23 +00:00
Yohei Yukawa
678ddce11c Support light navigation bar
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
2022-01-27 10:29:33 -08:00
TreeHugger Robot
4c4cd6f670 Merge changes from topics "CAI-filters", "onPrepareStylusHandwriting"
* changes:
  Scribe in IMF: Introduce filters in CursoAnchorInfo API 7/N
  Scribe in IMF: Early InkWindow preparation 6/N
2022-01-27 10:32:06 +00:00
TreeHugger Robot
cc016b3496 Merge "Scribe in IMF: Stylus Spy windows Impl 5/N" 2022-01-27 08:33:08 +00:00