Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 44fe4e47 authored by lumark's avatar lumark
Browse files

Fix ActivityViewTest#testInputMethod failed in freeform mode

Since IMM#reportActivityView() expects a matrix that transform coordinates
that maps (0, 0) in the ActivityView to the actual screen coordinates in
the host process.

So transform coordinates with getLocationInWindow which presents the location
that inside of ActivityView will be wrong when in freeform mode.

We should use getLocationOnScreen to fix this.

Fix: 137566626
Test: atest ActivityViewTest#testInputMethod in freeform / desktop mode
Test: manual as below steps:
      0) Make sure device connected HW keyboard & set Gboard launguages
         as Japanese input.
      1) Make and install ActivityViewTest.
      2) Launch any app and enter split screen mode.
      3) Launch "AV Main" with shortcut in split screen bottom stack.
      4) Press "Test Scroll ActiviyView" - > "launch"
      5) Scroll down ActivityView & tap EditText and then type words with
         HW keyboard.
      6) Check if candidate view shown on the right place that aligned
         with EditText.

Change-Id: Ia40b9aa94028592fd16e45c7226ec6e3cf07c9b1
parent 60bb23b1
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -386,9 +386,15 @@ public class ActivityView extends ViewGroup {


                // Also report this geometry information to InputMethodManagerService.
                // Also report this geometry information to InputMethodManagerService.
                // TODO(b/115693908): Unify this logic into the above WMS-based one.
                // TODO(b/115693908): Unify this logic into the above WMS-based one.
                // TODO(b/138175283): Address the location update when the host of this view is
                //  moving.
                final Matrix matrix = new Matrix();
                final Matrix matrix = new Matrix();
                final int[] locationOnScreen = new int[2];
                getLocationOnScreen(locationOnScreen);
                final int dx = locationOnScreen[0];
                final int dy = locationOnScreen[1];
                matrix.set(getMatrix());
                matrix.set(getMatrix());
                matrix.postTranslate(x, y);
                matrix.postTranslate(dx, dy);
                mContext.getSystemService(InputMethodManager.class)
                mContext.getSystemService(InputMethodManager.class)
                        .reportActivityView(displayId, matrix);
                        .reportActivityView(displayId, matrix);
            }
            }