From 853d666fc8d4ebc3e3404ac5df411b53c67cf2f8 Mon Sep 17 00:00:00 2001 From: Dave Mankoff Date: Tue, 22 Mar 2022 16:37:15 +0000 Subject: [PATCH] Ignore ACTION_OUTSIDE in FalsingManager Multipe outside motion events can be fired for a single tap. This throws off the falsing manager, causing it to improperly increase its belief in false touches. Ignore them. A few other small cleanups in the interaction between the WalletActivity and the FalsingManager are also included. There was one touch interaction with the wallet carousel that was not being analyzed by the FalsingManager. The WalletActivity was also making some redundant checks that the FalsingManager is already performaing internally. Fixes: 215558965 Test: manual & atest SystemUITests Change-Id: I51139fdaaa0214b7a9ddfb9b730a1c8b114c721d --- .../systemui/classifier/FalsingCollectorImpl.java | 4 ++++ .../android/systemui/wallet/ui/WalletActivity.java | 3 +-- .../systemui/wallet/ui/WalletCardCarousel.java | 8 +++++++- .../systemui/wallet/ui/WalletScreenController.java | 11 +++++++++-- .../classifier/FalsingCollectorImplTest.java | 14 ++++++++++++++ 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/classifier/FalsingCollectorImpl.java b/packages/SystemUI/src/com/android/systemui/classifier/FalsingCollectorImpl.java index b325700954c20..56dd1e18f2454 100644 --- a/packages/SystemUI/src/com/android/systemui/classifier/FalsingCollectorImpl.java +++ b/packages/SystemUI/src/com/android/systemui/classifier/FalsingCollectorImpl.java @@ -309,6 +309,10 @@ class FalsingCollectorImpl implements FalsingCollector { avoidGesture(); return; } + if (ev.getActionMasked() == MotionEvent.ACTION_OUTSIDE) { + return; + } + // We delay processing down events to see if another component wants to process them. // If #avoidGesture is called after a MotionEvent.ACTION_DOWN, all following motion events // will be ignored by the collector until another MotionEvent.ACTION_DOWN is passed in. diff --git a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletActivity.java b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletActivity.java index 89c31009a58ec..e3cd98996a41b 100644 --- a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletActivity.java +++ b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletActivity.java @@ -152,8 +152,7 @@ public class WalletActivity extends LifecycleActivity implements Log.w(TAG, "Unable to create wallet app intent."); return; } - if (!mKeyguardStateController.isUnlocked() - && mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) { + if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) { return; } diff --git a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletCardCarousel.java b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletCardCarousel.java index 77fd2e8308736..b7c8b4900e874 100644 --- a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletCardCarousel.java +++ b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletCardCarousel.java @@ -81,6 +81,12 @@ public class WalletCardCarousel extends RecyclerView { private float mCardCenterToScreenCenterDistancePx = Float.MAX_VALUE; interface OnSelectionListener { + /** + * A non-centered card was clicked. + * @param position + */ + void onUncenteredClick(int position); + /** * The card was moved to the center, thus selecting it. */ @@ -403,7 +409,7 @@ public class WalletCardCarousel extends RecyclerView { viewHolder.mCardView.setOnClickListener( v -> { if (position != mCenteredAdapterPosition) { - smoothScrollToPosition(position); + mSelectionListener.onUncenteredClick(position); } else { mSelectionListener.onCardClicked(cardViewInfo); } diff --git a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java index ba9b638fac99b..a062e7b2db502 100644 --- a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java +++ b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java @@ -180,6 +180,14 @@ public class WalletScreenController implements queryWalletCards(); } + @Override + public void onUncenteredClick(int position) { + if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) { + return; + } + mCardCarousel.smoothScrollToPosition(position); + } + @Override public void onCardSelected(@NonNull WalletCardViewInfo card) { if (mIsDismissed) { @@ -208,8 +216,7 @@ public class WalletScreenController implements @Override public void onCardClicked(@NonNull WalletCardViewInfo cardInfo) { - if (!mKeyguardStateController.isUnlocked() - && mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) { + if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) { return; } if (!(cardInfo instanceof QAWalletCardViewInfo) diff --git a/packages/SystemUI/tests/src/com/android/systemui/classifier/FalsingCollectorImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/classifier/FalsingCollectorImplTest.java index d99a5531d353b..acb5622c9790e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/classifier/FalsingCollectorImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/classifier/FalsingCollectorImplTest.java @@ -198,6 +198,20 @@ public class FalsingCollectorImplTest extends SysuiTestCase { verify(mFalsingDataProvider, never()).onMotionEvent(any(MotionEvent.class)); } + @Test + public void testIgnoreActionOutside() { + MotionEvent outside = MotionEvent.obtain(0, 0, MotionEvent.ACTION_OUTSIDE, 0, 0, 0); + MotionEvent up = MotionEvent.obtain(0, 0, MotionEvent.ACTION_UP, 0, 0, 0); + + // Nothing passed initially. The outside event will be completely ignored. + mFalsingCollector.onTouchEvent(outside); + verify(mFalsingDataProvider, never()).onMotionEvent(any(MotionEvent.class)); + + // Up event flushes, and the outside event isn't passed through. + mFalsingCollector.onTouchEvent(up); + verify(mFalsingDataProvider).onMotionEvent(up); + } + @Test public void testAvoidUnlocked() { MotionEvent down = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 0, 0);