From dbb7725436562079dd1f44d58805a45119f3ee37 Mon Sep 17 00:00:00 2001 From: Jason Chang Date: Fri, 20 May 2022 17:55:21 +0800 Subject: [PATCH] Fix toggle QS tiles don't respond when One-handed mode triggered Previous ag/17896369 missed the OHM edge case, when OHM activated, the ev.getX(), ev.getY() has been count in OHM offset, using ev.getRawX() & ev.getRawY() would mis-leading the QQS tile location while OHM translate down DisplayArea. 1. Set x and y offset for mQsHeaderBound when OHM activated 2. Fix broken NotificationStackScrollLayoutTest Bug: 233033336 Bug: 232901446 Test: manually check notificaiton panel when entering One-handed mode Test: manually test the QS/QQS functionality works in landscape Test: atest SystemUITests Test: atest NotificationStackScrollLayoutTest Change-Id: I8be7ba86fee52f19bac2733661c8616528a705be --- .../stack/NotificationStackScrollLayout.java | 12 ++++++++++++ .../stack/NotificationStackScrollLayoutTest.java | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index ba57d57d0fd31..936e005ca17ed 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -3642,6 +3642,18 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable @ShadeViewRefactor(RefactorComponent.INPUT) protected boolean isInsideQsHeader(MotionEvent ev) { mQsHeader.getBoundsOnScreen(mQsHeaderBound); + /** + * One-handed mode defines a feature FEATURE_ONE_HANDED of DisplayArea {@link DisplayArea} + * that will translate down the Y-coordinate whole window screen type except for + * TYPE_NAVIGATION_BAR and TYPE_NAVIGATION_BAR_PANEL .{@link DisplayAreaPolicy}. + * + * So, to consider triggered One-handed mode would translate down the absolute Y-coordinate + * of DisplayArea into relative coordinates for all windows, we need to correct the + * QS Head bounds here. + */ + final int xOffset = Math.round(ev.getRawX() - ev.getX()); + final int yOffset = Math.round(ev.getRawY() - ev.getY()); + mQsHeaderBound.offsetTo(xOffset, yOffset); return mQsHeaderBound.contains((int) ev.getRawX(), (int) ev.getRawY()); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index 63e0f53e093d4..9961aaee4224e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -608,10 +608,10 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { assertFalse(mStackScroller.isInsideQsHeader(event1)); MotionEvent event2 = transformEventForView(createMotionEvent(150f, 150f), mStackScroller); - assertTrue(mStackScroller.isInsideQsHeader(event2)); + assertFalse(mStackScroller.isInsideQsHeader(event2)); MotionEvent event3 = transformEventForView(createMotionEvent(250f, 250f), mStackScroller); - assertTrue(mStackScroller.isInsideQsHeader(event2)); + assertTrue(mStackScroller.isInsideQsHeader(event3)); } @Test