From 0984d32e69cb72cf892e21e6c605a390b25228c3 Mon Sep 17 00:00:00 2001 From: Beverly Date: Wed, 28 Jun 2023 21:55:13 +0000 Subject: [PATCH] Add falsing to QSTile long click All touches are analyzed by the falsing manager. By checking falsing for the QS tile long click gesture, we make sure the gesture doesn't add a large penalty to the falsing algorithm by getting counted as an accidental touch. Test: atest QSTileImplTest Bug: 288235975 Change-Id: Icee87c61488dd6b5f0b93a1d51d59d4d782817e0 --- .../systemui/qs/tileimpl/QSTileImpl.java | 4 +++- .../systemui/qs/tileimpl/QSTileImplTest.java | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java index 2a9e7d05c187b..1ca2a961744bb 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java @@ -330,7 +330,9 @@ public abstract class QSTileImpl implements QSTile, Lifecy final int eventId = mClickEventId++; mQSLogger.logTileLongClick(mTileSpec, mStatusBarStateController.getState(), mState.state, eventId); - mHandler.obtainMessage(H.LONG_CLICK, eventId, 0, view).sendToTarget(); + if (!mFalsingManager.isFalseLongTap(FalsingManager.LOW_PENALTY)) { + mHandler.obtainMessage(H.LONG_CLICK, eventId, 0, view).sendToTarget(); + } } public LogMaker populate(LogMaker logMaker) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java index 962b537372746..22b1c7b58ab35 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java @@ -203,6 +203,19 @@ public class QSTileImplTest extends SysuiTestCase { assertThat(mTile.mClicked).isTrue(); } + @Test + public void testLongClick_falsing() { + mFalsingManager.setFalseLongTap(true); + mTile.longClick(null /* view */); + mTestableLooper.processAllMessages(); + assertThat(mTile.mLongClicked).isFalse(); + + mFalsingManager.setFalseLongTap(false); + mTile.longClick(null /* view */); + mTestableLooper.processAllMessages(); + assertThat(mTile.mLongClicked).isTrue(); + } + @Test public void testSecondaryClick_Metrics() { mTile.secondaryClick(null /* view */); @@ -518,6 +531,7 @@ public class QSTileImplTest extends SysuiTestCase { } private static class TileImpl extends QSTileImpl { boolean mClicked; + boolean mLongClicked; int mRefreshes = 0; protected TileImpl( @@ -550,6 +564,11 @@ public class QSTileImplTest extends SysuiTestCase { mClicked = true; } + @Override + protected void handleLongClick(@Nullable View view) { + mLongClicked = true; + } + @Override protected void handleUpdateState(BooleanState state, Object arg) { mRefreshes++;