Ensure that FalsingManager#isFalseTap handles delayed clicks.

Views, be default, don't immediately process touch events as clicks.
Instead, they post an internal runnable to the main thread that then
runs the click. This was tripping up the FalsingManager, as a recent
change meant that it no longer saw the motion events.

With this change, the FalsingManager will look at prior events if
the recent events are empty.

Fixes: 184635871
Test: manual
Change-Id: I69981b09837d8a1d94b3a033243bce7a2d31844c
This commit is contained in:
Dave Mankoff
2021-04-06 12:28:33 -04:00
parent 838d875bfe
commit 7a08f2b716
3 changed files with 18 additions and 5 deletions

View File

@@ -224,7 +224,9 @@ public class BrightLineFalsingManager implements FalsingManager {
}
FalsingClassifier.Result singleTapResult =
mSingleTapClassifier.isTap(mDataProvider.getRecentMotionEvents());
mSingleTapClassifier.isTap(mDataProvider.getRecentMotionEvents().isEmpty()
? mDataProvider.getPriorMotionEvents()
: mDataProvider.getRecentMotionEvents());
mPriorResults = Collections.singleton(singleTapResult);
if (!singleTapResult.isFalse() && robustCheck) {

View File

@@ -276,7 +276,9 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy
mUiEventLogger.logWithInstanceId(QSEvent.QS_ACTION_CLICK, 0, getMetricsSpec(),
getInstanceId());
mQSLogger.logTileClick(mTileSpec, mStatusBarStateController.getState(), mState.state);
mHandler.sendEmptyMessage(H.CLICK);
if (!mFalsingManager.isFalseTap(true, 0.1)) {
mHandler.sendEmptyMessage(H.CLICK);
}
}
public void secondaryClick() {
@@ -605,9 +607,7 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy
mContext, mEnforcedAdmin);
mActivityStarter.postStartActivityDismissingKeyguard(intent, 0);
} else {
if (!mFalsingManager.isFalseTap(true, 0.1)) {
handleClick();
}
handleClick();
}
} else if (msg.what == SECONDARY_CLICK) {
name = "handleSecondaryClick";

View File

@@ -179,6 +179,17 @@ public class BrightLineClassifierTest extends SysuiTestCase {
assertThat(mBrightLineFalsingManager.isFalseTap(false, 0)).isFalse();
}
@Test
public void testIsFalseTap_EmptyRecentEvents() {
// Ensure we look at prior events if recent events has already been emptied.
when(mFalsingDataProvider.getRecentMotionEvents()).thenReturn(new ArrayList<>());
when(mFalsingDataProvider.getPriorMotionEvents()).thenReturn(mMotionEventList);
mBrightLineFalsingManager.isFalseTap(false, 0);
verify(mSingleTapClassfier).isTap(mMotionEventList);
}
@Test
public void testIsFalseTap_RobustCheck_NoFaceAuth() {
when(mSingleTapClassfier.isTap(mMotionEventList)).thenReturn(mPassedResult);