diff --git a/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java b/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java index 72b8d3fcae..dacd8a22ab 100644 --- a/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java +++ b/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java @@ -80,7 +80,7 @@ public class DebugTestInformationHandler extends TestInformationHandler { } @Override - public Bundle call(String method) { + public Bundle call(String method, String arg) { final Bundle response = new Bundle(); switch (method) { case TestProtocol.REQUEST_APP_LIST_FREEZE_FLAGS: { @@ -161,7 +161,7 @@ public class DebugTestInformationHandler extends TestInformationHandler { } default: - return super.call(method); + return super.call(method, arg); } } } diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java index 39af0db8ff..d531339f80 100644 --- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java +++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java @@ -21,7 +21,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { } @Override - public Bundle call(String method) { + public Bundle call(String method, String arg) { final Bundle response = new Bundle(); switch (method) { case TestProtocol.REQUEST_ALL_APPS_TO_OVERVIEW_SWIPE_HEIGHT: { @@ -66,7 +66,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { } } - return super.call(method); + return super.call(method, arg); } @Override diff --git a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java index 1ed2da3051..ac2534e081 100644 --- a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java +++ b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java @@ -23,6 +23,7 @@ import android.view.VelocityTracker; 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 @@ -118,9 +119,9 @@ public class MotionPauseDetector { * @param pointerIndex Index for the pointer being tracked in the motion event */ public void addPosition(MotionEvent ev, int pointerIndex) { - mForcePauseTimeout.setAlarm(mMakePauseHarderToTrigger - ? HARDER_TRIGGER_TIMEOUT - : FORCE_PAUSE_TIMEOUT); + mForcePauseTimeout.setAlarm(TestProtocol.sForcePauseTimeout != null + ? TestProtocol.sForcePauseTimeout + : mMakePauseHarderToTrigger ? HARDER_TRIGGER_TIMEOUT : FORCE_PAUSE_TIMEOUT); float newVelocity = mVelocityProvider.addMotionEvent(ev, ev.getPointerId(pointerIndex)); if (mPreviousVelocity != null) { checkMotionPaused(newVelocity, mPreviousVelocity, ev.getEventTime()); diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index 5106992dc7..bc5129d8cf 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -62,6 +62,10 @@ public class TestInformationHandler implements ResourceBasedOverride { } public Bundle call(String method) { + return call(method, /*arg=*/ null); + } + + public Bundle call(String method, String arg) { final Bundle response = new Bundle(); switch (method) { case TestProtocol.REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT: { @@ -129,6 +133,10 @@ public class TestInformationHandler implements ResourceBasedOverride { mDeviceProfile.isTwoPanels); return response; + case TestProtocol.REQUEST_SET_FORCE_PAUSE_TIMEOUT: + TestProtocol.sForcePauseTimeout = Long.parseLong(arg); + return response; + default: return null; } diff --git a/src/com/android/launcher3/testing/TestInformationProvider.java b/src/com/android/launcher3/testing/TestInformationProvider.java index bd177c0031..4f2619cc84 100644 --- a/src/com/android/launcher3/testing/TestInformationProvider.java +++ b/src/com/android/launcher3/testing/TestInformationProvider.java @@ -60,7 +60,7 @@ public class TestInformationProvider extends ContentProvider { if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { TestInformationHandler handler = TestInformationHandler.newInstance(getContext()); handler.init(getContext()); - return handler.call(method); + return handler.call(method, arg); } return null; } diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index 75c0d03f0b..d73c4b43a6 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -98,6 +98,9 @@ public final class TestProtocol { public static final String REQUEST_IS_TABLET = "is-tablet"; public static final String REQUEST_IS_TWO_PANELS = "is-two-panel"; + public static Long sForcePauseTimeout; + public static final String REQUEST_SET_FORCE_PAUSE_TIMEOUT = "set-force-pause-timeout"; + public static boolean sDebugTracing = false; public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing"; public static final String REQUEST_DISABLE_DEBUG_TRACING = "disable-debug-tracing"; diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 49934f7e46..b1278a7047 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -96,6 +96,7 @@ public final class LauncherInstrumentation { private static final String TAG = "Tapl"; private static final int ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME = 20; private static final int GESTURE_STEP_MS = 16; + private static final long FORCE_PAUSE_TIMEOUT_MS = 500; static final Pattern EVENT_TOUCH_DOWN = getTouchEventPattern("ACTION_DOWN"); static final Pattern EVENT_TOUCH_UP = getTouchEventPattern("ACTION_UP"); @@ -105,6 +106,7 @@ public final class LauncherInstrumentation { static final Pattern EVENT_TOUCH_DOWN_TIS = getTouchEventPatternTIS("ACTION_DOWN"); static final Pattern EVENT_TOUCH_UP_TIS = getTouchEventPatternTIS("ACTION_UP"); + private final String mLauncherPackage; private Boolean mIsLauncher3; private long mTestStartTime = -1; @@ -123,8 +125,6 @@ public final class LauncherInstrumentation { OUTSIDE_WITHOUT_PILFER, OUTSIDE_WITH_PILFER, INSIDE, INSIDE_TO_OUTSIDE } - ; - // Base class for launcher containers. static abstract class VisibleContainer { protected final LauncherInstrumentation mLauncher; @@ -272,9 +272,13 @@ public final class LauncherInstrumentation { } Bundle getTestInfo(String request) { + return getTestInfo(request, /*arg=*/ null); + } + + Bundle getTestInfo(String request, String arg) { try (ContentProviderClient client = getContext().getContentResolver() .acquireContentProviderClient(mTestProviderUri)) { - return client.call(request, null, null); + return client.call(request, arg, null); } catch (DeadObjectException e) { fail("Launcher crashed"); return null; @@ -298,6 +302,10 @@ public final class LauncherInstrumentation { .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD); } + private void setForcePauseTimeout(long timeout) { + getTestInfo(TestProtocol.REQUEST_SET_FORCE_PAUSE_TIMEOUT, Long.toString(timeout)); + } + void setActiveContainer(VisibleContainer container) { sActiveContainer = new WeakReference<>(container); } @@ -730,6 +738,7 @@ public final class LauncherInstrumentation { final String action; if (getNavigationModel() == NavigationModel.ZERO_BUTTON) { checkForAnomaly(); + setForcePauseTimeout(FORCE_PAUSE_TIMEOUT_MS); final Point displaySize = getRealDisplaySize(); boolean gestureStartFromLauncher = isTablet()