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

Commit 6d40ac31 authored by Dave Mankoff's avatar Dave Mankoff Committed by Android (Google) Code Review
Browse files

Merge "Incorporate Falsing Belief sooner." into sc-dev

parents e3143763 c5755b29
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -143,10 +143,10 @@ are ready to act on the owner's action, and then query the `FalsingManager`. The
will update its belief in pocket dialing based only on the last call made, so multiple calls per
gesture are not well defined.

The `FalsingManager` does not update its belief in pocket-dialing until a new
gesture starts. That is to say, if the owner makes a bad tap on your feature,
the belief in pocket dialing will not incorporate this new data until the
following gesture begins.
The `FalsingManager` does not update its belief in pocket-dialing until after a gesture completes.
That is to say, if the owner makes a bad tap on your feature, the "belief" in pocket dialing will
not incorporate this new data after processing on the final `ACTION_UP` or `ACTION_CANCEL` event
occurs.

If you expect a mix of taps, double taps, and swipes on your feature, segment them
accordingly. Figure out which `FalsingManager` method you need to call first, rather than relying
+13 −1
Original line number Diff line number Diff line
@@ -112,9 +112,21 @@ public interface FalsingCollector {
    /** */
    void onBouncerHidden();

    /** */
    /**
     * Call this to record a MotionEvent in the {@link com.android.systemui.plugins.FalsingManager}.
     *
     * Be sure to call {@link #onMotionEventComplete()} after the rest of SystemUI is done with the
     * MotionEvent.
     */
    void onTouchEvent(MotionEvent ev);

    /**
     * Call this once SystemUI has completed all processing of a given MotionEvent.
     *
     * See {@link #onTouchEvent(MotionEvent)}.
     */
    void onMotionEventComplete();

    /** */
    void avoidGesture();

+4 −0
Original line number Diff line number Diff line
@@ -146,6 +146,10 @@ public class FalsingCollectorFake implements FalsingCollector {
    public void onTouchEvent(MotionEvent ev) {
    }

    @Override
    public void onMotionEventComplete() {
    }

    @Override
    public void avoidGesture() {
    }
+5 −0
Original line number Diff line number Diff line
@@ -274,6 +274,11 @@ class FalsingCollectorImpl implements FalsingCollector {
        }
    }

    @Override
    public void onMotionEventComplete() {
        mFalsingDataProvider.onMotionEventComplete();
    }

    @Override
    public void avoidGesture() {
        mAvoidGesture = true;
+12 −1
Original line number Diff line number Diff line
@@ -81,8 +81,8 @@ public class FalsingDataProvider {
        }

        if (motionEvent.getActionMasked() == MotionEvent.ACTION_DOWN) {
            // Ensure prior gesture was completed. May be a no-op.
            completePriorGesture();
            mRecentMotionEvents = new TimeLimitedMotionEventBuffer(MOTION_EVENT_AGE_MS);
        }
        mRecentMotionEvents.addAll(motionEvents);

@@ -100,12 +100,23 @@ public class FalsingDataProvider {
        mDirty = true;
    }

    void onMotionEventComplete() {
        if (mRecentMotionEvents.isEmpty()) {
            return;
        }
        int action = mRecentMotionEvents.get(mRecentMotionEvents.size() - 1).getActionMasked();
        if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
            completePriorGesture();
        }
    }

    private void completePriorGesture() {
        if (!mRecentMotionEvents.isEmpty()) {
            mGestureFinalizedListeners.forEach(listener -> listener.onGestureFinalized(
                    mRecentMotionEvents.get(mRecentMotionEvents.size() - 1).getEventTime()));

            mPriorMotionEvents = mRecentMotionEvents;
            mRecentMotionEvents = new TimeLimitedMotionEventBuffer(MOTION_EVENT_AGE_MS);
        }
    }

Loading