From 81e1ffd4064ec2714bafe424670d3388d2497d35 Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Fri, 4 May 2018 16:08:22 -0700 Subject: [PATCH] Add full unlock gesture to FalsingManager When FalsingManager.onBouncerShown() is called, this will cause the MotionEvents to no longer be added to the HumanInteractionClassifier, which means that the classifier will have to work with only partial gesture, and will not be able to make a proper decision on unlock. This would cause many valid unlock gestures to fail. Instead, record the state of the bouncer visibility at the beginning of each MotionEvent (on ACTION_DOWN). Then, if the bouncer was not visible, add the full gesture to the HumanInteractionClassifier. Test: recorded a valid unlock event with inputstudio, then replayed it with and without the change. Consistently succeeded with unlock with this patch, and failed many times (but not always) before the change. Bug: 71762354 Change-Id: Ib93f21bff19c36aa296ddf6ed9a0a3e879eeb69c --- .../systemui/classifier/FalsingManager.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/classifier/FalsingManager.java b/packages/SystemUI/src/com/android/systemui/classifier/FalsingManager.java index a265a5e1d5a78..0ca0a117f6e6e 100644 --- a/packages/SystemUI/src/com/android/systemui/classifier/FalsingManager.java +++ b/packages/SystemUI/src/com/android/systemui/classifier/FalsingManager.java @@ -74,6 +74,7 @@ public class FalsingManager implements SensorEventListener { private boolean mEnforceBouncer = false; private boolean mBouncerOn = false; + private boolean mBouncerOffOnDown = false; private boolean mSessionActive = false; private boolean mIsTouchScreen = true; private int mState = StatusBarState.SHADE; @@ -459,10 +460,19 @@ public class FalsingManager implements SensorEventListener { public void onTouchEvent(MotionEvent event, int width, int height) { if (event.getAction() == MotionEvent.ACTION_DOWN) { mIsTouchScreen = event.isFromSource(InputDevice.SOURCE_TOUCHSCREEN); + // If the bouncer was not shown during the down event, + // we want the entire gesture going to HumanInteractionClassifier + mBouncerOffOnDown = !mBouncerOn; } - if (mSessionActive && !mBouncerOn) { - mDataCollector.onTouchEvent(event, width, height); - mHumanInteractionClassifier.onTouchEvent(event); + if (mSessionActive) { + if (!mBouncerOn) { + // In case bouncer is "visible", but onFullyShown has not yet been called, + // avoid adding the event to DataCollector + mDataCollector.onTouchEvent(event, width, height); + } + if (mBouncerOffOnDown) { + mHumanInteractionClassifier.onTouchEvent(event); + } } }