Loading quickstep/src/com/android/quickstep/util/ActiveGestureLog.java +44 −20 Original line number Original line Diff line number Diff line Loading @@ -67,15 +67,15 @@ public class ActiveGestureLog { /** /** * Adds a log to be printed at log-dump-time. * Adds a log to be printed at log-dump-time. */ */ public void addLog(String event) { public void addLog(@NonNull String event) { addLog(event, null); addLog(event, null); } } public void addLog(String event, int extras) { public void addLog(@NonNull String event, int extras) { addLog(event, extras, null); addLog(event, extras, null); } } public void addLog(String event, boolean extras) { public void addLog(@NonNull String event, boolean extras) { addLog(event, extras, null); addLog(event, extras, null); } } Loading @@ -85,30 +85,30 @@ public class ActiveGestureLog { * @param gestureEvent GestureEvent representing the event being logged. * @param gestureEvent GestureEvent representing the event being logged. */ */ public void addLog( public void addLog( String event, @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { @NonNull String event, @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { addLog(new CompoundString(event), gestureEvent); addLog(new CompoundString(event), gestureEvent); } } public void addLog( public void addLog( String event, @NonNull String event, int extras, int extras, @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { addLog(new CompoundString(event).append(": ").append(extras), gestureEvent); addLog(new CompoundString(event).append(": ").append(extras), gestureEvent); } } public void addLog( public void addLog( String event, @NonNull String event, boolean extras, boolean extras, @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { addLog(new CompoundString(event).append(": ").append(extras), gestureEvent); addLog(new CompoundString(event).append(": ").append(extras), gestureEvent); } } public void addLog(CompoundString compoundString) { public void addLog(@NonNull CompoundString compoundString) { addLog(compoundString, null); addLog(compoundString, null); } } public void addLog( public void addLog( CompoundString compoundString, @NonNull CompoundString compoundString, @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { EventLog lastEventLog = logs[(nextIndex + logs.length - 1) % logs.length]; EventLog lastEventLog = logs[(nextIndex + logs.length - 1) % logs.length]; if (lastEventLog == null || mCurrentLogId != lastEventLog.logId) { if (lastEventLog == null || mCurrentLogId != lastEventLog.logId) { Loading Loading @@ -259,21 +259,20 @@ public class ActiveGestureLog { public CompoundString(String substring) { public CompoundString(String substring) { mIsNoOp = substring == null; mIsNoOp = substring == null; if (mIsNoOp) { mSubstrings = mIsNoOp ? null : new ArrayList<>(); mSubstrings = null; mArgs = mIsNoOp ? null : new ArrayList<>(); mArgs = null; return; if (!mIsNoOp) { } mSubstrings = new ArrayList<>(); mSubstrings.add(substring); mSubstrings.add(substring); mArgs = new ArrayList<>(); } } } public CompoundString append(CompoundString substring) { public CompoundString append(CompoundString substring) { if (mIsNoOp) { if (mIsNoOp || substring.mIsNoOp) { return this; return this; } } mSubstrings.addAll(substring.mSubstrings); mSubstrings.addAll(substring.mSubstrings); mArgs.addAll(substring.mArgs); return this; return this; } } Loading @@ -288,30 +287,53 @@ public class ActiveGestureLog { } } public CompoundString append(int num) { public CompoundString append(int num) { if (mIsNoOp) { return this; } mArgs.add(num); return append("%d"); } public CompoundString append(long num) { if (mIsNoOp) { return this; } mArgs.add(num); mArgs.add(num); return append("%d"); return append("%d"); } } public CompoundString append(float num) { public CompoundString append(float num) { if (mIsNoOp) { return this; } mArgs.add(num); mArgs.add(num); return append("%.2f"); return append("%.2f"); } } public CompoundString append(double num) { public CompoundString append(double num) { if (mIsNoOp) { return this; } mArgs.add(num); mArgs.add(num); return append("%.2f"); return append("%.2f"); } } public CompoundString append(boolean bool) { public CompoundString append(boolean bool) { if (mIsNoOp) { return this; } mArgs.add(bool); mArgs.add(bool); return append("%b"); return append("%b"); } } public Object[] getArgs() { private Object[] getArgs() { Preconditions.assertTrue(!mIsNoOp); return mArgs.toArray(); return mArgs.toArray(); } } Loading @@ -320,7 +342,7 @@ public class ActiveGestureLog { return String.format(toUnformattedString(), getArgs()); return String.format(toUnformattedString(), getArgs()); } } public String toUnformattedString() { private String toUnformattedString() { Preconditions.assertTrue(!mIsNoOp); Preconditions.assertTrue(!mIsNoOp); StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder(); Loading @@ -333,7 +355,7 @@ public class ActiveGestureLog { @Override @Override public int hashCode() { public int hashCode() { return Objects.hash(mIsNoOp, mSubstrings); return Objects.hash(mIsNoOp, mSubstrings, mArgs); } } @Override @Override Loading @@ -342,7 +364,9 @@ public class ActiveGestureLog { return false; return false; } } CompoundString other = (CompoundString) obj; CompoundString other = (CompoundString) obj; return (mIsNoOp == other.mIsNoOp) && Objects.equals(mSubstrings, other.mSubstrings); return (mIsNoOp == other.mIsNoOp) && Objects.equals(mSubstrings, other.mSubstrings) && Objects.equals(mArgs, other.mArgs); } } } } } } quickstep/src/com/android/quickstep/util/MotionPauseDetector.java +49 −19 Original line number Original line Diff line number Diff line Loading @@ -96,8 +96,14 @@ public class MotionPauseDetector { mSpeedSomewhatFast = res.getDimension(R.dimen.motion_pause_detector_speed_somewhat_fast); mSpeedSomewhatFast = res.getDimension(R.dimen.motion_pause_detector_speed_somewhat_fast); mSpeedFast = res.getDimension(R.dimen.motion_pause_detector_speed_fast); mSpeedFast = res.getDimension(R.dimen.motion_pause_detector_speed_fast); mForcePauseTimeout = new Alarm(); mForcePauseTimeout = new Alarm(); mForcePauseTimeout.setOnAlarmListener(alarm -> updatePaused(true /* isPaused */, mForcePauseTimeout.setOnAlarmListener(alarm -> { "Force pause timeout after " + alarm.getLastSetTimeout() + "ms" /* reason */)); ActiveGestureLog.CompoundString log = new ActiveGestureLog.CompoundString("Force pause timeout after ") .append(alarm.getLastSetTimeout()) .append("ms"); addLogs(log); updatePaused(true /* isPaused */, log); }); mMakePauseHarderToTrigger = makePauseHarderToTrigger; mMakePauseHarderToTrigger = makePauseHarderToTrigger; mVelocityProvider = new SystemVelocityProvider(axis); mVelocityProvider = new SystemVelocityProvider(axis); } } Loading @@ -113,8 +119,14 @@ public class MotionPauseDetector { * @param disallowPause If true, we will not detect any pauses until this is set to false again. * @param disallowPause If true, we will not detect any pauses until this is set to false again. */ */ public void setDisallowPause(boolean disallowPause) { public void setDisallowPause(boolean disallowPause) { ActiveGestureLog.CompoundString log = new ActiveGestureLog.CompoundString("Set disallowPause=") .append(disallowPause); if (mDisallowPause != disallowPause) { addLogs(log); } mDisallowPause = disallowPause; mDisallowPause = disallowPause; updatePaused(mIsPaused, "Set disallowPause=" + disallowPause); updatePaused(mIsPaused, log); } } /** /** Loading Loading @@ -148,27 +160,30 @@ public class MotionPauseDetector { float speed = Math.abs(velocity); float speed = Math.abs(velocity); float previousSpeed = Math.abs(prevVelocity); float previousSpeed = Math.abs(prevVelocity); boolean isPaused; boolean isPaused; String isPausedReason = ""; ActiveGestureLog.CompoundString isPausedReason; if (mIsPaused) { if (mIsPaused) { // Continue to be paused until moving at a fast speed. // Continue to be paused until moving at a fast speed. isPaused = speed < mSpeedFast || previousSpeed < mSpeedFast; isPaused = speed < mSpeedFast || previousSpeed < mSpeedFast; isPausedReason = "Was paused, but started moving at a fast speed"; isPausedReason = new ActiveGestureLog.CompoundString( "Was paused, but started moving at a fast speed"); } else { } else { if (velocity < 0 != prevVelocity < 0) { if (velocity < 0 != prevVelocity < 0) { // We're just changing directions, not necessarily stopping. // We're just changing directions, not necessarily stopping. isPaused = false; isPaused = false; isPausedReason = "Velocity changed directions"; isPausedReason = new ActiveGestureLog.CompoundString("Velocity changed directions"); } else { } else { isPaused = speed < mSpeedVerySlow && previousSpeed < mSpeedVerySlow; isPaused = speed < mSpeedVerySlow && previousSpeed < mSpeedVerySlow; isPausedReason = "Pause requires back to back slow speeds"; isPausedReason = new ActiveGestureLog.CompoundString( "Pause requires back to back slow speeds"); if (!isPaused && !mHasEverBeenPaused) { if (!isPaused && !mHasEverBeenPaused) { // We want to be more aggressive about detecting the first pause to ensure it // We want to be more aggressive about detecting the first pause to ensure it // feels as responsive as possible; getting two very slow speeds back to back // feels as responsive as possible; getting two very slow speeds back to back // takes too long, so also check for a rapid deceleration. // takes too long, so also check for a rapid deceleration. boolean isRapidDeceleration = speed < previousSpeed * RAPID_DECELERATION_FACTOR; boolean isRapidDeceleration = speed < previousSpeed * RAPID_DECELERATION_FACTOR; isPaused = isRapidDeceleration && speed < mSpeedSomewhatFast; isPaused = isRapidDeceleration && speed < mSpeedSomewhatFast; isPausedReason = "Didn't have back to back slow speeds, checking for rapid" isPausedReason = new ActiveGestureLog.CompoundString( + " deceleration on first pause only"; "Didn't have back to back slow speeds, checking for rapid ") .append(" deceleration on first pause only"); } } if (mMakePauseHarderToTrigger) { if (mMakePauseHarderToTrigger) { if (speed < mSpeedSlow) { if (speed < mSpeedSlow) { Loading @@ -176,12 +191,14 @@ public class MotionPauseDetector { mSlowStartTime = time; mSlowStartTime = time; } } isPaused = time - mSlowStartTime >= HARDER_TRIGGER_TIMEOUT; isPaused = time - mSlowStartTime >= HARDER_TRIGGER_TIMEOUT; isPausedReason = "Maintained slow speed for sufficient duration when making" isPausedReason = new ActiveGestureLog.CompoundString( + " pause harder to trigger"; "Maintained slow speed for sufficient duration when making") .append(" pause harder to trigger"); } else { } else { mSlowStartTime = 0; mSlowStartTime = 0; isPaused = false; isPaused = false; isPausedReason = "Intentionally making pause harder to trigger"; isPausedReason = new ActiveGestureLog.CompoundString( "Intentionally making pause harder to trigger"); } } } } } } Loading @@ -189,18 +206,21 @@ public class MotionPauseDetector { updatePaused(isPaused, isPausedReason); updatePaused(isPaused, isPausedReason); } } private void updatePaused(boolean isPaused, String reason) { private void updatePaused(boolean isPaused, ActiveGestureLog.CompoundString reason) { if (mDisallowPause) { if (mDisallowPause) { reason = "Disallow pause; otherwise, would have been " + isPaused + " due to " + reason; reason = new ActiveGestureLog.CompoundString( "Disallow pause; otherwise, would have been ") .append(isPaused) .append(" due to reason:") .append(reason); isPaused = false; isPaused = false; } } if (mIsPaused != isPaused) { if (mIsPaused != isPaused) { mIsPaused = isPaused; mIsPaused = isPaused; String logString = "onMotionPauseChanged, paused=" + mIsPaused + " reason=" + reason; addLogs(new ActiveGestureLog.CompoundString("onMotionPauseChanged triggered; paused=") if (Utilities.isRunningInTestHarness()) { .append(mIsPaused) Log.d(TAG, logString); .append(", reason=") } .append(reason)); ActiveGestureLog.INSTANCE.addLog(logString); boolean isFirstDetectedPause = !mHasEverBeenPaused && mIsPaused; boolean isFirstDetectedPause = !mHasEverBeenPaused && mIsPaused; if (mIsPaused) { if (mIsPaused) { AccessibilityManagerCompat.sendTestProtocolEventToTest(mContext, AccessibilityManagerCompat.sendTestProtocolEventToTest(mContext, Loading @@ -219,6 +239,16 @@ public class MotionPauseDetector { } } } } private void addLogs(ActiveGestureLog.CompoundString compoundString) { ActiveGestureLog.CompoundString logString = new ActiveGestureLog.CompoundString("MotionPauseDetector: ") .append(compoundString); if (Utilities.isRunningInTestHarness()) { Log.d(TAG, logString.toString()); } ActiveGestureLog.INSTANCE.addLog(logString); } public void clear() { public void clear() { mVelocityProvider.clear(); mVelocityProvider.clear(); mPreviousVelocity = null; mPreviousVelocity = null; Loading Loading
quickstep/src/com/android/quickstep/util/ActiveGestureLog.java +44 −20 Original line number Original line Diff line number Diff line Loading @@ -67,15 +67,15 @@ public class ActiveGestureLog { /** /** * Adds a log to be printed at log-dump-time. * Adds a log to be printed at log-dump-time. */ */ public void addLog(String event) { public void addLog(@NonNull String event) { addLog(event, null); addLog(event, null); } } public void addLog(String event, int extras) { public void addLog(@NonNull String event, int extras) { addLog(event, extras, null); addLog(event, extras, null); } } public void addLog(String event, boolean extras) { public void addLog(@NonNull String event, boolean extras) { addLog(event, extras, null); addLog(event, extras, null); } } Loading @@ -85,30 +85,30 @@ public class ActiveGestureLog { * @param gestureEvent GestureEvent representing the event being logged. * @param gestureEvent GestureEvent representing the event being logged. */ */ public void addLog( public void addLog( String event, @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { @NonNull String event, @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { addLog(new CompoundString(event), gestureEvent); addLog(new CompoundString(event), gestureEvent); } } public void addLog( public void addLog( String event, @NonNull String event, int extras, int extras, @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { addLog(new CompoundString(event).append(": ").append(extras), gestureEvent); addLog(new CompoundString(event).append(": ").append(extras), gestureEvent); } } public void addLog( public void addLog( String event, @NonNull String event, boolean extras, boolean extras, @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { addLog(new CompoundString(event).append(": ").append(extras), gestureEvent); addLog(new CompoundString(event).append(": ").append(extras), gestureEvent); } } public void addLog(CompoundString compoundString) { public void addLog(@NonNull CompoundString compoundString) { addLog(compoundString, null); addLog(compoundString, null); } } public void addLog( public void addLog( CompoundString compoundString, @NonNull CompoundString compoundString, @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { EventLog lastEventLog = logs[(nextIndex + logs.length - 1) % logs.length]; EventLog lastEventLog = logs[(nextIndex + logs.length - 1) % logs.length]; if (lastEventLog == null || mCurrentLogId != lastEventLog.logId) { if (lastEventLog == null || mCurrentLogId != lastEventLog.logId) { Loading Loading @@ -259,21 +259,20 @@ public class ActiveGestureLog { public CompoundString(String substring) { public CompoundString(String substring) { mIsNoOp = substring == null; mIsNoOp = substring == null; if (mIsNoOp) { mSubstrings = mIsNoOp ? null : new ArrayList<>(); mSubstrings = null; mArgs = mIsNoOp ? null : new ArrayList<>(); mArgs = null; return; if (!mIsNoOp) { } mSubstrings = new ArrayList<>(); mSubstrings.add(substring); mSubstrings.add(substring); mArgs = new ArrayList<>(); } } } public CompoundString append(CompoundString substring) { public CompoundString append(CompoundString substring) { if (mIsNoOp) { if (mIsNoOp || substring.mIsNoOp) { return this; return this; } } mSubstrings.addAll(substring.mSubstrings); mSubstrings.addAll(substring.mSubstrings); mArgs.addAll(substring.mArgs); return this; return this; } } Loading @@ -288,30 +287,53 @@ public class ActiveGestureLog { } } public CompoundString append(int num) { public CompoundString append(int num) { if (mIsNoOp) { return this; } mArgs.add(num); return append("%d"); } public CompoundString append(long num) { if (mIsNoOp) { return this; } mArgs.add(num); mArgs.add(num); return append("%d"); return append("%d"); } } public CompoundString append(float num) { public CompoundString append(float num) { if (mIsNoOp) { return this; } mArgs.add(num); mArgs.add(num); return append("%.2f"); return append("%.2f"); } } public CompoundString append(double num) { public CompoundString append(double num) { if (mIsNoOp) { return this; } mArgs.add(num); mArgs.add(num); return append("%.2f"); return append("%.2f"); } } public CompoundString append(boolean bool) { public CompoundString append(boolean bool) { if (mIsNoOp) { return this; } mArgs.add(bool); mArgs.add(bool); return append("%b"); return append("%b"); } } public Object[] getArgs() { private Object[] getArgs() { Preconditions.assertTrue(!mIsNoOp); return mArgs.toArray(); return mArgs.toArray(); } } Loading @@ -320,7 +342,7 @@ public class ActiveGestureLog { return String.format(toUnformattedString(), getArgs()); return String.format(toUnformattedString(), getArgs()); } } public String toUnformattedString() { private String toUnformattedString() { Preconditions.assertTrue(!mIsNoOp); Preconditions.assertTrue(!mIsNoOp); StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder(); Loading @@ -333,7 +355,7 @@ public class ActiveGestureLog { @Override @Override public int hashCode() { public int hashCode() { return Objects.hash(mIsNoOp, mSubstrings); return Objects.hash(mIsNoOp, mSubstrings, mArgs); } } @Override @Override Loading @@ -342,7 +364,9 @@ public class ActiveGestureLog { return false; return false; } } CompoundString other = (CompoundString) obj; CompoundString other = (CompoundString) obj; return (mIsNoOp == other.mIsNoOp) && Objects.equals(mSubstrings, other.mSubstrings); return (mIsNoOp == other.mIsNoOp) && Objects.equals(mSubstrings, other.mSubstrings) && Objects.equals(mArgs, other.mArgs); } } } } } }
quickstep/src/com/android/quickstep/util/MotionPauseDetector.java +49 −19 Original line number Original line Diff line number Diff line Loading @@ -96,8 +96,14 @@ public class MotionPauseDetector { mSpeedSomewhatFast = res.getDimension(R.dimen.motion_pause_detector_speed_somewhat_fast); mSpeedSomewhatFast = res.getDimension(R.dimen.motion_pause_detector_speed_somewhat_fast); mSpeedFast = res.getDimension(R.dimen.motion_pause_detector_speed_fast); mSpeedFast = res.getDimension(R.dimen.motion_pause_detector_speed_fast); mForcePauseTimeout = new Alarm(); mForcePauseTimeout = new Alarm(); mForcePauseTimeout.setOnAlarmListener(alarm -> updatePaused(true /* isPaused */, mForcePauseTimeout.setOnAlarmListener(alarm -> { "Force pause timeout after " + alarm.getLastSetTimeout() + "ms" /* reason */)); ActiveGestureLog.CompoundString log = new ActiveGestureLog.CompoundString("Force pause timeout after ") .append(alarm.getLastSetTimeout()) .append("ms"); addLogs(log); updatePaused(true /* isPaused */, log); }); mMakePauseHarderToTrigger = makePauseHarderToTrigger; mMakePauseHarderToTrigger = makePauseHarderToTrigger; mVelocityProvider = new SystemVelocityProvider(axis); mVelocityProvider = new SystemVelocityProvider(axis); } } Loading @@ -113,8 +119,14 @@ public class MotionPauseDetector { * @param disallowPause If true, we will not detect any pauses until this is set to false again. * @param disallowPause If true, we will not detect any pauses until this is set to false again. */ */ public void setDisallowPause(boolean disallowPause) { public void setDisallowPause(boolean disallowPause) { ActiveGestureLog.CompoundString log = new ActiveGestureLog.CompoundString("Set disallowPause=") .append(disallowPause); if (mDisallowPause != disallowPause) { addLogs(log); } mDisallowPause = disallowPause; mDisallowPause = disallowPause; updatePaused(mIsPaused, "Set disallowPause=" + disallowPause); updatePaused(mIsPaused, log); } } /** /** Loading Loading @@ -148,27 +160,30 @@ public class MotionPauseDetector { float speed = Math.abs(velocity); float speed = Math.abs(velocity); float previousSpeed = Math.abs(prevVelocity); float previousSpeed = Math.abs(prevVelocity); boolean isPaused; boolean isPaused; String isPausedReason = ""; ActiveGestureLog.CompoundString isPausedReason; if (mIsPaused) { if (mIsPaused) { // Continue to be paused until moving at a fast speed. // Continue to be paused until moving at a fast speed. isPaused = speed < mSpeedFast || previousSpeed < mSpeedFast; isPaused = speed < mSpeedFast || previousSpeed < mSpeedFast; isPausedReason = "Was paused, but started moving at a fast speed"; isPausedReason = new ActiveGestureLog.CompoundString( "Was paused, but started moving at a fast speed"); } else { } else { if (velocity < 0 != prevVelocity < 0) { if (velocity < 0 != prevVelocity < 0) { // We're just changing directions, not necessarily stopping. // We're just changing directions, not necessarily stopping. isPaused = false; isPaused = false; isPausedReason = "Velocity changed directions"; isPausedReason = new ActiveGestureLog.CompoundString("Velocity changed directions"); } else { } else { isPaused = speed < mSpeedVerySlow && previousSpeed < mSpeedVerySlow; isPaused = speed < mSpeedVerySlow && previousSpeed < mSpeedVerySlow; isPausedReason = "Pause requires back to back slow speeds"; isPausedReason = new ActiveGestureLog.CompoundString( "Pause requires back to back slow speeds"); if (!isPaused && !mHasEverBeenPaused) { if (!isPaused && !mHasEverBeenPaused) { // We want to be more aggressive about detecting the first pause to ensure it // We want to be more aggressive about detecting the first pause to ensure it // feels as responsive as possible; getting two very slow speeds back to back // feels as responsive as possible; getting two very slow speeds back to back // takes too long, so also check for a rapid deceleration. // takes too long, so also check for a rapid deceleration. boolean isRapidDeceleration = speed < previousSpeed * RAPID_DECELERATION_FACTOR; boolean isRapidDeceleration = speed < previousSpeed * RAPID_DECELERATION_FACTOR; isPaused = isRapidDeceleration && speed < mSpeedSomewhatFast; isPaused = isRapidDeceleration && speed < mSpeedSomewhatFast; isPausedReason = "Didn't have back to back slow speeds, checking for rapid" isPausedReason = new ActiveGestureLog.CompoundString( + " deceleration on first pause only"; "Didn't have back to back slow speeds, checking for rapid ") .append(" deceleration on first pause only"); } } if (mMakePauseHarderToTrigger) { if (mMakePauseHarderToTrigger) { if (speed < mSpeedSlow) { if (speed < mSpeedSlow) { Loading @@ -176,12 +191,14 @@ public class MotionPauseDetector { mSlowStartTime = time; mSlowStartTime = time; } } isPaused = time - mSlowStartTime >= HARDER_TRIGGER_TIMEOUT; isPaused = time - mSlowStartTime >= HARDER_TRIGGER_TIMEOUT; isPausedReason = "Maintained slow speed for sufficient duration when making" isPausedReason = new ActiveGestureLog.CompoundString( + " pause harder to trigger"; "Maintained slow speed for sufficient duration when making") .append(" pause harder to trigger"); } else { } else { mSlowStartTime = 0; mSlowStartTime = 0; isPaused = false; isPaused = false; isPausedReason = "Intentionally making pause harder to trigger"; isPausedReason = new ActiveGestureLog.CompoundString( "Intentionally making pause harder to trigger"); } } } } } } Loading @@ -189,18 +206,21 @@ public class MotionPauseDetector { updatePaused(isPaused, isPausedReason); updatePaused(isPaused, isPausedReason); } } private void updatePaused(boolean isPaused, String reason) { private void updatePaused(boolean isPaused, ActiveGestureLog.CompoundString reason) { if (mDisallowPause) { if (mDisallowPause) { reason = "Disallow pause; otherwise, would have been " + isPaused + " due to " + reason; reason = new ActiveGestureLog.CompoundString( "Disallow pause; otherwise, would have been ") .append(isPaused) .append(" due to reason:") .append(reason); isPaused = false; isPaused = false; } } if (mIsPaused != isPaused) { if (mIsPaused != isPaused) { mIsPaused = isPaused; mIsPaused = isPaused; String logString = "onMotionPauseChanged, paused=" + mIsPaused + " reason=" + reason; addLogs(new ActiveGestureLog.CompoundString("onMotionPauseChanged triggered; paused=") if (Utilities.isRunningInTestHarness()) { .append(mIsPaused) Log.d(TAG, logString); .append(", reason=") } .append(reason)); ActiveGestureLog.INSTANCE.addLog(logString); boolean isFirstDetectedPause = !mHasEverBeenPaused && mIsPaused; boolean isFirstDetectedPause = !mHasEverBeenPaused && mIsPaused; if (mIsPaused) { if (mIsPaused) { AccessibilityManagerCompat.sendTestProtocolEventToTest(mContext, AccessibilityManagerCompat.sendTestProtocolEventToTest(mContext, Loading @@ -219,6 +239,16 @@ public class MotionPauseDetector { } } } } private void addLogs(ActiveGestureLog.CompoundString compoundString) { ActiveGestureLog.CompoundString logString = new ActiveGestureLog.CompoundString("MotionPauseDetector: ") .append(compoundString); if (Utilities.isRunningInTestHarness()) { Log.d(TAG, logString.toString()); } ActiveGestureLog.INSTANCE.addLog(logString); } public void clear() { public void clear() { mVelocityProvider.clear(); mVelocityProvider.clear(); mPreviousVelocity = null; mPreviousVelocity = null; Loading