Merge "Add logs to MotionPauseDetector" into sc-v2-dev

This commit is contained in:
TreeHugger Robot
2021-08-09 17:13:26 +00:00
committed by Android (Google) Code Review
2 changed files with 17 additions and 3 deletions
@@ -17,6 +17,7 @@ package com.android.quickstep.util;
import android.content.Context;
import android.content.res.Resources;
import android.util.Log;
import android.view.MotionEvent;
import android.view.VelocityTracker;
@@ -85,7 +86,12 @@ public class MotionPauseDetector {
mSpeedSomewhatFast = res.getDimension(R.dimen.motion_pause_detector_speed_somewhat_fast);
mSpeedFast = res.getDimension(R.dimen.motion_pause_detector_speed_fast);
mForcePauseTimeout = new Alarm();
mForcePauseTimeout.setOnAlarmListener(alarm -> updatePaused(true /* isPaused */));
mForcePauseTimeout.setOnAlarmListener(alarm -> {
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.MOTION_PAUSE_TIMEOUT, "onAlarm");
}
updatePaused(true /* isPaused */);
});
mMakePauseHarderToTrigger = makePauseHarderToTrigger;
mVelocityProvider = new SystemVelocityProvider(axis);
}
@@ -119,9 +125,13 @@ public class MotionPauseDetector {
* @param pointerIndex Index for the pointer being tracked in the motion event
*/
public void addPosition(MotionEvent ev, int pointerIndex) {
mForcePauseTimeout.setAlarm(TestProtocol.sForcePauseTimeout != null
long timeoutMs = TestProtocol.sForcePauseTimeout != null
? TestProtocol.sForcePauseTimeout
: mMakePauseHarderToTrigger ? HARDER_TRIGGER_TIMEOUT : FORCE_PAUSE_TIMEOUT);
: mMakePauseHarderToTrigger ? HARDER_TRIGGER_TIMEOUT : FORCE_PAUSE_TIMEOUT;
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.MOTION_PAUSE_TIMEOUT, "setAlarm: " + timeoutMs);
}
mForcePauseTimeout.setAlarm(timeoutMs);
float newVelocity = mVelocityProvider.addMotionEvent(ev, ev.getPointerId(pointerIndex));
if (mPreviousVelocity != null) {
checkMotionPaused(newVelocity, mPreviousVelocity, ev.getEventTime());
@@ -162,6 +172,9 @@ public class MotionPauseDetector {
}
}
}
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.MOTION_PAUSE_TIMEOUT, "checkMotionPaused: " + isPaused);
}
updatePaused(isPaused);
}
@@ -117,4 +117,5 @@ public final class TestProtocol {
public static final String WORK_PROFILE_REMOVED = "b/159671700";
public static final String FALLBACK_ACTIVITY_NO_SET = "b/181019015";
public static final String THIRD_PARTY_LAUNCHER_NOT_SET = "b/187080582";
public static final String MOTION_PAUSE_TIMEOUT = "b/194114179";
}