Using correct gesture margins in overview
Change-Id: I0108858279559e10633825f7de22211515f0e9b7
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/QuickstepTestInformationHandler.java
new file mode 100644
index 0000000..b507044
--- /dev/null
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/QuickstepTestInformationHandler.java
@@ -0,0 +1,83 @@
+package com.android.quickstep;
+
+import android.content.Context;
+import android.os.Bundle;
+
+import com.android.launcher3.MainThreadExecutor;
+import com.android.launcher3.testing.TestInformationHandler;
+import com.android.launcher3.testing.TestProtocol;
+import com.android.launcher3.uioverrides.states.OverviewState;
+import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController;
+import com.android.quickstep.util.LayoutUtils;
+import com.android.quickstep.views.RecentsView;
+
+import java.util.concurrent.ExecutionException;
+
+public class QuickstepTestInformationHandler extends TestInformationHandler {
+
+ public QuickstepTestInformationHandler(Context context) {
+ }
+
+ @Override
+ public Bundle call(String method) {
+ final Bundle response = new Bundle();
+ switch (method) {
+ case TestProtocol.REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT: {
+ final float swipeHeight =
+ OverviewState.getDefaultSwipeHeight(mDeviceProfile);
+ response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
+ return response;
+ }
+
+ case TestProtocol.REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT: {
+ final float swipeHeight =
+ LayoutUtils.getShelfTrackingDistance(mContext, mDeviceProfile);
+ response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
+ return response;
+ }
+
+ case TestProtocol.REQUEST_IS_LAUNCHER_INITIALIZED: {
+ response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD,
+ TouchInteractionService.isInputMonitorInitialized());
+ return response;
+ }
+
+ case TestProtocol.REQUEST_HOTSEAT_TOP: {
+ if (mLauncher == null) return null;
+
+ response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD,
+ PortraitStatesTouchController.getHotseatTop(mLauncher));
+ return response;
+ }
+
+ case TestProtocol.REQUEST_OVERVIEW_LEFT_GESTURE_MARGIN: {
+ try {
+ final int leftMargin = new MainThreadExecutor().submit(() ->
+ mLauncher.<RecentsView>getOverviewPanel().getLeftGestureMargin()).get();
+ response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, leftMargin);
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return response;
+ }
+
+ case TestProtocol.REQUEST_OVERVIEW_RIGHT_GESTURE_MARGIN: {
+ try {
+ final int rightMargin = new MainThreadExecutor().submit(() ->
+ mLauncher.<RecentsView>getOverviewPanel().getRightGestureMargin()).
+ get();
+ response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, rightMargin);
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return response;
+ }
+ }
+
+ return super.call(method);
+ }
+}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
index 66ddc72..b566837 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
@@ -73,6 +73,7 @@
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
+import android.view.WindowInsets;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.ListView;
@@ -1742,4 +1743,14 @@
updateEnabledOverlays();
}
}
+
+ public int getLeftGestureMargin() {
+ final WindowInsets insets = getRootWindowInsets();
+ return Math.max(insets.getSystemGestureInsets().left, insets.getSystemWindowInsetLeft());
+ }
+
+ public int getRightGestureMargin() {
+ final WindowInsets insets = getRootWindowInsets();
+ return Math.max(insets.getSystemGestureInsets().right, insets.getSystemWindowInsetRight());
+ }
}
diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
deleted file mode 100644
index 57ed244..0000000
--- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.android.quickstep;
-
-import android.content.Context;
-import android.os.Bundle;
-
-import com.android.launcher3.testing.TestInformationHandler;
-import com.android.launcher3.testing.TestProtocol;
-import com.android.launcher3.uioverrides.states.OverviewState;
-import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController;
-import com.android.quickstep.util.LayoutUtils;
-
-public class QuickstepTestInformationHandler extends TestInformationHandler {
-
- public QuickstepTestInformationHandler(Context context) {
- }
-
- @Override
- public Bundle call(String method) {
- final Bundle response = new Bundle();
- switch (method) {
- case TestProtocol.REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT: {
- final float swipeHeight =
- OverviewState.getDefaultSwipeHeight(mDeviceProfile);
- response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
- return response;
- }
-
- case TestProtocol.REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT: {
- final float swipeHeight =
- LayoutUtils.getShelfTrackingDistance(mContext, mDeviceProfile);
- response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
- return response;
- }
-
- case TestProtocol.REQUEST_IS_LAUNCHER_INITIALIZED: {
- response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD,
- TouchInteractionService.isInputMonitorInitialized());
- return response;
- }
-
- case TestProtocol.REQUEST_HOTSEAT_TOP: {
- if (mLauncher == null) return null;
-
- response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD,
- PortraitStatesTouchController.getHotseatTop(mLauncher));
- return response;
- }
- }
-
- return super.call(method);
- }
-}
diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java
index f69b278..079ab6d 100644
--- a/src/com/android/launcher3/testing/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -71,6 +71,8 @@
public static final String REQUEST_FREEZE_APP_LIST = "freeze-app-list";
public static final String REQUEST_UNFREEZE_APP_LIST = "unfreeze-app-list";
public static final String REQUEST_APP_LIST_FREEZE_FLAGS = "app-list-freeze-flags";
+ public static final String REQUEST_OVERVIEW_LEFT_GESTURE_MARGIN = "overview-left-margin";
+ public static final String REQUEST_OVERVIEW_RIGHT_GESTURE_MARGIN = "overview-right-margin";
public static boolean sDebugTracing = false;
public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing";
diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
index ae93867..04a0f12 100644
--- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
+++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
@@ -23,6 +23,8 @@
import androidx.test.uiautomator.Direction;
import androidx.test.uiautomator.UiObject2;
+import com.android.launcher3.testing.TestProtocol;
+
import java.util.Collections;
import java.util.List;
@@ -30,7 +32,6 @@
* Common overview pane for both Launcher and fallback recents
*/
public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
- private static final int FLING_SPEED = LauncherInstrumentation.isAvd() ? 500 : 1500;
private static final int FLINGS_FOR_DISMISS_LIMIT = 40;
BaseOverview(LauncherInstrumentation launcher) {
@@ -51,8 +52,10 @@
mLauncher.addContextLayer("want to fling forward in overview")) {
LauncherInstrumentation.log("Overview.flingForward before fling");
final UiObject2 overview = verifyActiveContainer();
- mLauncher.scroll(overview, Direction.LEFT, 1,
- new Rect(mLauncher.getEdgeSensitivityWidth(), 0, 0, 0), 20);
+ final int leftMargin = mLauncher.getTestInfo(
+ TestProtocol.REQUEST_OVERVIEW_LEFT_GESTURE_MARGIN).
+ getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
+ mLauncher.scroll(overview, Direction.LEFT, 1, new Rect(leftMargin, 0, 0, 0), 20);
verifyActiveContainer();
}
}
@@ -87,8 +90,10 @@
mLauncher.addContextLayer("want to fling backward in overview")) {
LauncherInstrumentation.log("Overview.flingBackward before fling");
final UiObject2 overview = verifyActiveContainer();
- mLauncher.scroll(overview, Direction.RIGHT, 1,
- new Rect(0, 0, mLauncher.getEdgeSensitivityWidth(), 0), 20);
+ final int rightMargin = mLauncher.getTestInfo(
+ TestProtocol.REQUEST_OVERVIEW_RIGHT_GESTURE_MARGIN).
+ getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
+ mLauncher.scroll(overview, Direction.RIGHT, 1, new Rect(0, 0, rightMargin, 0), 20);
verifyActiveContainer();
}
}