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

Commit 9e77f25d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Adding tracing for non-detection of Pause" into ub-launcher3-rvc-dev

parents 75999598 09179467
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -19,11 +19,13 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_LSQ_VELOCITY_PROV

import android.content.Context;
import android.content.res.Resources;
import android.util.Log;
import android.view.MotionEvent;

import com.android.launcher3.Alarm;
import com.android.launcher3.R;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.testing.TestProtocol;

/**
 * Given positions along x- or y-axis, tracks velocity and acceleration and determines when there is
@@ -84,6 +86,9 @@ public class MotionPauseDetector {
        mSpeedSlow = res.getDimension(R.dimen.motion_pause_detector_speed_slow);
        mSpeedSomewhatFast = res.getDimension(R.dimen.motion_pause_detector_speed_somewhat_fast);
        mSpeedFast = res.getDimension(R.dimen.motion_pause_detector_speed_fast);
        if (TestProtocol.sDebugTracing) {
            Log.d(TestProtocol.PAUSE_NOT_DETECTED, "creating alarm");
        }
        mForcePauseTimeout = new Alarm();
        mForcePauseTimeout.setOnAlarmListener(alarm -> updatePaused(true /* isPaused */));
        mMakePauseHarderToTrigger = makePauseHarderToTrigger;
@@ -120,6 +125,9 @@ public class MotionPauseDetector {
     * @param pointerIndex Index for the pointer being tracked in the motion event
     */
    public void addPosition(MotionEvent ev, int pointerIndex) {
        if (TestProtocol.sDebugTracing) {
            Log.d(TestProtocol.PAUSE_NOT_DETECTED, "setting alarm");
        }
        mForcePauseTimeout.setAlarm(mMakePauseHarderToTrigger
                ? HARDER_TRIGGER_TIMEOUT
                : FORCE_PAUSE_TIMEOUT);
@@ -167,6 +175,9 @@ public class MotionPauseDetector {
    }

    private void updatePaused(boolean isPaused) {
        if (TestProtocol.sDebugTracing) {
            Log.d(TestProtocol.PAUSE_NOT_DETECTED, "updatePaused: " + isPaused);
        }
        if (mDisallowPause) {
            isPaused = false;
        }
@@ -188,6 +199,9 @@ public class MotionPauseDetector {
        setOnMotionPauseListener(null);
        mIsPaused = mHasEverBeenPaused = false;
        mSlowStartTime = 0;
        if (TestProtocol.sDebugTracing) {
            Log.d(TestProtocol.PAUSE_NOT_DETECTED, "canceling alarm");
        }
        mForcePauseTimeout.cancelAlarm();
    }

+1 −0
Original line number Diff line number Diff line
@@ -99,4 +99,5 @@ public final class TestProtocol {
    public static final String REQUEST_MOCK_SENSOR_ROTATION = "mock-sensor-rotation";

    public static final String PERMANENT_DIAG_TAG = "TaplTarget";
    public static final String PAUSE_NOT_DETECTED = "b/139891609";
}