From 472a79e4d7e46999936b6ed7c981149d611318a8 Mon Sep 17 00:00:00 2001 From: Mariia Sandrikova Date: Mon, 20 Sep 2021 12:45:21 +0100 Subject: [PATCH] Fix RuntimeException in GestureDetector for Letterbox. RuntimeException in GestureDetector happened because GestureDetector constructor may only be used from android.os.Looper thread which wasn't always true. Fixing by explicitly providing the UI thread handler in GestureDetector constructor. Also, fix tests that were incorrectly changed in ag/15731742 due to this exception. Fix: 199596390 Test: manual - double tap now works for all apps. Change-Id: I622474bf2635d7d183b9e04994d0b6f25b1b1e94 --- services/core/java/com/android/server/wm/Letterbox.java | 3 ++- .../wmtests/src/com/android/server/wm/SizeCompatTests.java | 4 ---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/wm/Letterbox.java b/services/core/java/com/android/server/wm/Letterbox.java index c18c94d8242e8..45411a946f55e 100644 --- a/services/core/java/com/android/server/wm/Letterbox.java +++ b/services/core/java/com/android/server/wm/Letterbox.java @@ -247,7 +247,8 @@ public class Letterbox { TapEventReceiver(InputChannel inputChannel, Context context) { super(inputChannel, UiThread.getHandler().getLooper()); mDoubleTapListener = new DoubleTapListener(); - mDoubleTapDetector = new GestureDetector(context, mDoubleTapListener); + mDoubleTapDetector = new GestureDetector( + context, mDoubleTapListener, UiThread.getHandler()); } @Override diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java index 348472a931497..6407c92ee2aa8 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -1171,7 +1171,6 @@ public class SizeCompatTests extends WindowTestsBase { final WindowState w = addWindowToActivity(mActivity); // Compute the frames of the window and invoke {@link ActivityRecord#layoutLetterbox}. mActivity.mRootWindowContainer.performSurfacePlacement(); - mActivity.layoutLetterbox(null); // The letterbox insets should be [450, 0 - 250, 0]. assertEquals(new Rect(mActivity.getBounds().left, 0, dh - mActivity.getBounds().right, 0), mActivity.getLetterboxInsets()); @@ -1833,9 +1832,6 @@ public class SizeCompatTests extends WindowTestsBase { } private void assertLetterboxSurfacesDrawnBetweenActivityAndParentBounds(Rect parentBounds) { - // Ensure Letterbox is updated. - mActivity.layoutLetterbox(null); - // Letterbox should fill the gap between the parent bounds and the letterboxed activity. final Rect letterboxedBounds = new Rect(mActivity.getBounds()); assertTrue(parentBounds.contains(letterboxedBounds));