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

Commit 0984d32e authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

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
parent ffa5a849
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -330,8 +330,10 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy
        final int eventId = mClickEventId++;
        mQSLogger.logTileLongClick(mTileSpec, mStatusBarStateController.getState(), mState.state,
                eventId);
        if (!mFalsingManager.isFalseLongTap(FalsingManager.LOW_PENALTY)) {
            mHandler.obtainMessage(H.LONG_CLICK, eventId, 0, view).sendToTarget();
        }
    }

    public LogMaker populate(LogMaker logMaker) {
        if (mState instanceof BooleanState) {
+19 −0
Original line number Diff line number Diff line
@@ -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<QSTile.BooleanState> {
        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++;