Loading quickstep/src/com/android/quickstep/util/MotionPauseDetector.java +4 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.view.MotionEvent; import com.android.launcher3.Alarm; import com.android.launcher3.R; import com.android.launcher3.compat.AccessibilityManagerCompat; /** * Given positions along x- or y-axis, tracks velocity and acceleration and determines when there is Loading @@ -47,6 +48,7 @@ public class MotionPauseDetector { private final float mSpeedFast; private final Alarm mForcePauseTimeout; private final boolean mMakePauseHarderToTrigger; private final Context mContext; private Long mPreviousTime = null; private Float mPreviousPosition = null; Loading @@ -71,6 +73,7 @@ public class MotionPauseDetector { * @param makePauseHarderToTrigger Used for gestures that require a more explicit pause. */ public MotionPauseDetector(Context context, boolean makePauseHarderToTrigger) { mContext = context; Resources res = context.getResources(); mSpeedVerySlow = res.getDimension(R.dimen.motion_pause_detector_speed_very_slow); mSpeedSlow = res.getDimension(R.dimen.motion_pause_detector_speed_slow); Loading Loading @@ -165,6 +168,7 @@ public class MotionPauseDetector { if (mIsPaused != isPaused) { mIsPaused = isPaused; if (mIsPaused) { AccessibilityManagerCompat.sendPauseDetectedEventToTest(mContext); mHasEverBeenPaused = true; } if (mOnMotionPauseListener != null) { Loading src/com/android/launcher3/allapps/AllAppsRecyclerView.java +1 −1 Original line number Diff line number Diff line Loading @@ -425,7 +425,7 @@ public class AllAppsRecyclerView extends BaseRecyclerView implements LogContaine public void onScrollStateChanged(int state) { super.onScrollStateChanged(state); if (state == SCROLL_STATE_IDLE && Utilities.IS_RUNNING_IN_TEST_HARNESS) { if (state == SCROLL_STATE_IDLE) { AccessibilityManagerCompat.sendScrollFinishedEventToTest(getContext()); } } Loading src/com/android/launcher3/compat/AccessibilityManagerCompat.java +7 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,13 @@ public class AccessibilityManagerCompat { sendEventToTest(accessibilityManager, TestProtocol.SCROLL_FINISHED_MESSAGE, null); } public static void sendPauseDetectedEventToTest(Context context) { final AccessibilityManager accessibilityManager = getAccessibilityManagerForTest(context); if (accessibilityManager == null) return; sendEventToTest(accessibilityManager, TestProtocol.PAUSE_DETECTED_MESSAGE, null); } private static void sendEventToTest( AccessibilityManager accessibilityManager, String eventTag, Bundle data) { final AccessibilityEvent e = AccessibilityEvent.obtain( Loading src/com/android/launcher3/testing/TestProtocol.java +1 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ public final class TestProtocol { public static final String STATE_FIELD = "state"; public static final String SWITCHED_TO_STATE_MESSAGE = "TAPL_SWITCHED_TO_STATE"; public static final String SCROLL_FINISHED_MESSAGE = "TAPL_SCROLL_FINISHED"; public static final String PAUSE_DETECTED_MESSAGE = "TAPL_PAUSE_DETECTED"; public static final String RESPONSE_MESSAGE_POSTFIX = "_RESPONSE"; public static final int NORMAL_STATE_ORDINAL = 0; public static final int SPRING_LOADED_STATE_ORDINAL = 1; Loading tests/tapl/com/android/launcher3/tapl/Background.java +9 −4 Original line number Diff line number Diff line Loading @@ -32,7 +32,6 @@ import com.android.launcher3.testing.TestProtocol; */ public class Background extends LauncherInstrumentation.VisibleContainer { private static final int ZERO_BUTTON_SWIPE_UP_GESTURE_DURATION = 500; private static final int ZERO_BUTTON_SWIPE_UP_HOLD_DURATION = 400; Background(LauncherInstrumentation launcher) { super(launcher); Loading Loading @@ -72,9 +71,15 @@ public class Background extends LauncherInstrumentation.VisibleContainer { final long downTime = SystemClock.uptimeMillis(); mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, start); mLauncher.movePointer( downTime, downTime, ZERO_BUTTON_SWIPE_UP_GESTURE_DURATION, start, end); LauncherInstrumentation.sleep(ZERO_BUTTON_SWIPE_UP_HOLD_DURATION); mLauncher.executeAndWaitForEvent( () -> mLauncher.movePointer( downTime, downTime, ZERO_BUTTON_SWIPE_UP_GESTURE_DURATION, start, end), event -> TestProtocol.PAUSE_DETECTED_MESSAGE.equals(event.getClassName()), "Pause wasn't detected"); mLauncher.sendPointer( downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, end); break; Loading Loading
quickstep/src/com/android/quickstep/util/MotionPauseDetector.java +4 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.view.MotionEvent; import com.android.launcher3.Alarm; import com.android.launcher3.R; import com.android.launcher3.compat.AccessibilityManagerCompat; /** * Given positions along x- or y-axis, tracks velocity and acceleration and determines when there is Loading @@ -47,6 +48,7 @@ public class MotionPauseDetector { private final float mSpeedFast; private final Alarm mForcePauseTimeout; private final boolean mMakePauseHarderToTrigger; private final Context mContext; private Long mPreviousTime = null; private Float mPreviousPosition = null; Loading @@ -71,6 +73,7 @@ public class MotionPauseDetector { * @param makePauseHarderToTrigger Used for gestures that require a more explicit pause. */ public MotionPauseDetector(Context context, boolean makePauseHarderToTrigger) { mContext = context; Resources res = context.getResources(); mSpeedVerySlow = res.getDimension(R.dimen.motion_pause_detector_speed_very_slow); mSpeedSlow = res.getDimension(R.dimen.motion_pause_detector_speed_slow); Loading Loading @@ -165,6 +168,7 @@ public class MotionPauseDetector { if (mIsPaused != isPaused) { mIsPaused = isPaused; if (mIsPaused) { AccessibilityManagerCompat.sendPauseDetectedEventToTest(mContext); mHasEverBeenPaused = true; } if (mOnMotionPauseListener != null) { Loading
src/com/android/launcher3/allapps/AllAppsRecyclerView.java +1 −1 Original line number Diff line number Diff line Loading @@ -425,7 +425,7 @@ public class AllAppsRecyclerView extends BaseRecyclerView implements LogContaine public void onScrollStateChanged(int state) { super.onScrollStateChanged(state); if (state == SCROLL_STATE_IDLE && Utilities.IS_RUNNING_IN_TEST_HARNESS) { if (state == SCROLL_STATE_IDLE) { AccessibilityManagerCompat.sendScrollFinishedEventToTest(getContext()); } } Loading
src/com/android/launcher3/compat/AccessibilityManagerCompat.java +7 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,13 @@ public class AccessibilityManagerCompat { sendEventToTest(accessibilityManager, TestProtocol.SCROLL_FINISHED_MESSAGE, null); } public static void sendPauseDetectedEventToTest(Context context) { final AccessibilityManager accessibilityManager = getAccessibilityManagerForTest(context); if (accessibilityManager == null) return; sendEventToTest(accessibilityManager, TestProtocol.PAUSE_DETECTED_MESSAGE, null); } private static void sendEventToTest( AccessibilityManager accessibilityManager, String eventTag, Bundle data) { final AccessibilityEvent e = AccessibilityEvent.obtain( Loading
src/com/android/launcher3/testing/TestProtocol.java +1 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ public final class TestProtocol { public static final String STATE_FIELD = "state"; public static final String SWITCHED_TO_STATE_MESSAGE = "TAPL_SWITCHED_TO_STATE"; public static final String SCROLL_FINISHED_MESSAGE = "TAPL_SCROLL_FINISHED"; public static final String PAUSE_DETECTED_MESSAGE = "TAPL_PAUSE_DETECTED"; public static final String RESPONSE_MESSAGE_POSTFIX = "_RESPONSE"; public static final int NORMAL_STATE_ORDINAL = 0; public static final int SPRING_LOADED_STATE_ORDINAL = 1; Loading
tests/tapl/com/android/launcher3/tapl/Background.java +9 −4 Original line number Diff line number Diff line Loading @@ -32,7 +32,6 @@ import com.android.launcher3.testing.TestProtocol; */ public class Background extends LauncherInstrumentation.VisibleContainer { private static final int ZERO_BUTTON_SWIPE_UP_GESTURE_DURATION = 500; private static final int ZERO_BUTTON_SWIPE_UP_HOLD_DURATION = 400; Background(LauncherInstrumentation launcher) { super(launcher); Loading Loading @@ -72,9 +71,15 @@ public class Background extends LauncherInstrumentation.VisibleContainer { final long downTime = SystemClock.uptimeMillis(); mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, start); mLauncher.movePointer( downTime, downTime, ZERO_BUTTON_SWIPE_UP_GESTURE_DURATION, start, end); LauncherInstrumentation.sleep(ZERO_BUTTON_SWIPE_UP_HOLD_DURATION); mLauncher.executeAndWaitForEvent( () -> mLauncher.movePointer( downTime, downTime, ZERO_BUTTON_SWIPE_UP_GESTURE_DURATION, start, end), event -> TestProtocol.PAUSE_DETECTED_MESSAGE.equals(event.getClassName()), "Pause wasn't detected"); mLauncher.sendPointer( downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, end); break; Loading