From 6a71c2a6f5dcab5e1ac914ceebbd9f86e84b5117 Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Mon, 1 May 2023 11:03:52 -0700 Subject: [PATCH] [Trackpad] Gesture navigation in 3-button mode Back gesture will be in a separate change Bug: 279948218 Test: https://recall.googleplex.com/projects/3388b17c-d22f-46f8-b140-a102690377b4/sessions/0b8e838a-89b0-4451-ad44-df2916db877d Change-Id: I1f14ca873efa33684e36ac1f0f72d766815752ae --- .../uioverrides/QuickstepLauncher.java | 6 ++++ .../NavBarToHomeTouchController.java | 7 +++++ ...ButtonNavbarToOverviewTouchController.java | 7 +++++ .../NoButtonQuickSwitchTouchController.java | 7 +++++ .../android/quickstep/AbsSwipeUpHandler.java | 3 +- .../QuickstepTestInformationHandler.java | 3 +- .../RecentsAnimationDeviceState.java | 2 +- .../quickstep/TouchInteractionService.java | 29 ++++++++++++------- .../FallbackNavBarTouchController.java | 2 +- .../OtherActivityInputConsumer.java | 3 +- .../interaction/NavBarGestureHandler.java | 2 +- .../quickstep/util/NavBarPosition.java | 15 ++++++---- .../testing/TestInformationHandler.java | 9 +++++- .../testing/shared/TestProtocol.java | 1 + .../android/launcher3/tapl/Background.java | 14 +++++++++ .../tapl/LauncherInstrumentation.java | 21 ++++++++++++-- .../launcher3/tapl/OverviewActions.java | 2 +- 17 files changed, 105 insertions(+), 28 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index e62a778df0..d91e0488cd 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -559,8 +559,14 @@ public class QuickstepLauncher extends Launcher { list.add(new PortraitStatesTouchController(this)); break; case THREE_BUTTONS: + list.add(new NoButtonQuickSwitchTouchController(this)); + list.add(new NavBarToHomeTouchController(this)); + list.add(new NoButtonNavbarToOverviewTouchController(this)); + list.add(new PortraitStatesTouchController(this)); + break; default: list.add(new PortraitStatesTouchController(this)); + break; } if (!getDeviceProfile().isMultiWindowMode) { diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java index 8cbd6e8b47..f967e18422 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java @@ -21,11 +21,13 @@ import static com.android.launcher3.LauncherAnimUtils.SUCCESS_TRANSITION_PROGRES import static com.android.launcher3.LauncherAnimUtils.newCancelListener; import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.NORMAL; +import static com.android.launcher3.MotionEventsUtils.isTrackpadMotionEvent; import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PULL_BACK_ALPHA; import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PULL_BACK_TRANSLATION; import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback; import static com.android.launcher3.anim.Interpolators.DEACCEL_3; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_GESTURE; +import static com.android.launcher3.util.NavigationMode.THREE_BUTTONS; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; import android.animation.ValueAnimator; @@ -42,6 +44,7 @@ import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.compat.AccessibilityManagerCompat; import com.android.launcher3.touch.SingleAxisSwipeDetector; +import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.TouchController; import com.android.quickstep.TaskUtils; import com.android.quickstep.util.AnimatorControllerWithResistance; @@ -95,6 +98,10 @@ public class NavBarToHomeTouchController implements TouchController, } private boolean canInterceptTouch(MotionEvent ev) { + if (!isTrackpadMotionEvent(ev) && DisplayController.getNavigationMode(mLauncher) + == THREE_BUTTONS) { + return false; + } boolean cameFromNavBar = (ev.getEdgeFlags() & Utilities.EDGE_NAV_BAR) != 0; if (!cameFromNavBar) { return false; diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java index b7bafd8969..e3b3a793e1 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java @@ -22,9 +22,11 @@ import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.HINT_STATE; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.OVERVIEW; +import static com.android.launcher3.MotionEventsUtils.isTrackpadMotionEvent; import static com.android.launcher3.Utilities.EDGE_NAV_BAR; import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback; import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL; +import static com.android.launcher3.util.NavigationMode.THREE_BUTTONS; import static com.android.launcher3.util.VibratorWrapper.OVERVIEW_HAPTIC; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_ONE_HANDED_ACTIVE; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED; @@ -43,6 +45,7 @@ import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.states.StateAnimationConfig; import com.android.launcher3.taskbar.LauncherTaskbarUIController; import com.android.launcher3.uioverrides.QuickstepLauncher; +import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.VibratorWrapper; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.util.AnimatorControllerWithResistance; @@ -89,6 +92,10 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch @Override protected boolean canInterceptTouch(MotionEvent ev) { + if (!isTrackpadMotionEvent(ev) && DisplayController.getNavigationMode(mLauncher) + == THREE_BUTTONS) { + return false; + } mDidTouchStartInNavBar = (ev.getEdgeFlags() & EDGE_NAV_BAR) != 0; boolean isOneHandedModeActive = (SystemUiProxy.INSTANCE.get(mLauncher) .getLastSystemUiStateFlags() & SYSUI_STATE_ONE_HANDED_ACTIVE) != 0; diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java index 80f5558315..b4224bebae 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java @@ -24,6 +24,7 @@ import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.LauncherState.OVERVIEW_ACTIONS; import static com.android.launcher3.LauncherState.QUICK_SWITCH_FROM_HOME; import static com.android.launcher3.MotionEventsUtils.isTrackpadFourFingerSwipe; +import static com.android.launcher3.MotionEventsUtils.isTrackpadMotionEvent; import static com.android.launcher3.MotionEventsUtils.isTrackpadMultiFingerSwipe; import static com.android.launcher3.anim.AlphaUpdateListener.ALPHA_CUTOFF_THRESHOLD; import static com.android.launcher3.anim.AnimatorListeners.forEndCallback; @@ -46,6 +47,7 @@ import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW; import static com.android.launcher3.states.StateAnimationConfig.SKIP_SCRIM; import static com.android.launcher3.touch.BothAxesSwipeDetector.DIRECTION_RIGHT; import static com.android.launcher3.touch.BothAxesSwipeDetector.DIRECTION_UP; +import static com.android.launcher3.util.NavigationMode.THREE_BUTTONS; import static com.android.launcher3.util.VibratorWrapper.OVERVIEW_HAPTIC; import static com.android.launcher3.util.window.RefreshRateTracker.getSingleFrameMs; import static com.android.quickstep.views.RecentsView.ADJACENT_PAGE_HORIZONTAL_OFFSET; @@ -74,6 +76,7 @@ import com.android.launcher3.states.StateAnimationConfig; import com.android.launcher3.touch.BaseSwipeDetector; import com.android.launcher3.touch.BothAxesSwipeDetector; import com.android.launcher3.uioverrides.QuickstepLauncher; +import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.TouchController; import com.android.launcher3.util.VibratorWrapper; import com.android.quickstep.SystemUiProxy; @@ -170,6 +173,10 @@ public class NoButtonQuickSwitchTouchController implements TouchController, } private boolean canInterceptTouch(MotionEvent ev) { + if (!isTrackpadMotionEvent(ev) && DisplayController.getNavigationMode(mLauncher) + == THREE_BUTTONS) { + return false; + } if (!mLauncher.isInState(LauncherState.NORMAL)) { return false; } diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index f3689a9bbe..48fe6b5021 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -723,7 +723,8 @@ public abstract class AbsSwipeUpHandler, * @param moveRunningTask whether to move running task to front when attaching */ private void maybeUpdateRecentsAttachedState(boolean animate, boolean moveRunningTask) { - if (!mDeviceState.isFullyGesturalNavMode() || mRecentsView == null) { + if ((!mDeviceState.isFullyGesturalNavMode() && !mGestureState.isTrackpadGesture()) + || mRecentsView == null) { return; } RemoteAnimationTarget runningTaskTarget = mRecentsAnimationTargets != null diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java index 4c9cf8b897..031d409ece 100644 --- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java +++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java @@ -80,8 +80,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { } case TestProtocol.REQUEST_HAS_TIS: { - response.putBoolean( - TestProtocol.REQUEST_HAS_TIS, true); + response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, true); return response; } diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java index 64ec1d8a6d..74ca64f5cc 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java @@ -260,7 +260,7 @@ public class RecentsAnimationDeviceState implements DisplayInfoChangeListener { public void onDisplayInfoChanged(Context context, Info info, int flags) { if ((flags & (CHANGE_ROTATION | CHANGE_NAVIGATION_MODE)) != 0) { mMode = info.navigationMode; - mNavBarPosition = new NavBarPosition(mMode, info); + mNavBarPosition = new NavBarPosition(mContext, mMode, info); if (mMode == NO_BUTTON) { mExclusionListener.register(); diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index edaee8c74a..1ec1d2002b 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -24,6 +24,8 @@ import static android.view.MotionEvent.ACTION_POINTER_UP; import static android.view.MotionEvent.ACTION_UP; import static com.android.launcher3.Launcher.INTENT_ACTION_ALL_APPS_TOGGLE; +import static com.android.launcher3.MotionEventsUtils.isTrackpadMotionEvent; +import static com.android.launcher3.MotionEventsUtils.isTrackpadMultiFingerSwipe; import static com.android.launcher3.config.FeatureFlags.ENABLE_TRACKPAD_GESTURE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.quickstep.GestureState.DEFAULT_STATE; @@ -465,7 +467,7 @@ public class TouchInteractionService extends Service private void initInputMonitor(String reason) { disposeEventHandlers("Initializing input monitor due to: " + reason); - if (mDeviceState.isButtonNavMode()) { + if (mDeviceState.isButtonNavMode() && !ENABLE_TRACKPAD_GESTURE.get()) { return; } @@ -645,7 +647,8 @@ public class TouchInteractionService extends Service TestLogging.recordMotionEvent( TestProtocol.SEQUENCE_TIS, "TouchInteractionService.onInputEvent", event); - if (!mDeviceState.isUserUnlocked()) { + if (!mDeviceState.isUserUnlocked() || (mDeviceState.isButtonNavMode() + && !isTrackpadMotionEvent(event))) { return; } @@ -673,7 +676,8 @@ public class TouchInteractionService extends Service mGestureState = newGestureState; mConsumer = newConsumer(prevGestureState, mGestureState, event); mUncheckedConsumer = mConsumer; - } else if (mDeviceState.isUserUnlocked() && mDeviceState.isFullyGesturalNavMode() + } else if (mDeviceState.isUserUnlocked() + && (mDeviceState.isFullyGesturalNavMode() || isTrackpadMultiFingerSwipe(event)) && mDeviceState.canTriggerAssistantAction(event)) { mGestureState = createGestureState(mGestureState, getTrackpadGestureType(event)); @@ -850,11 +854,12 @@ public class TouchInteractionService extends Service .append(", trying to use default input consumer"); base = getDefaultInputConsumer(reasonString); } - if (mDeviceState.isGesturalNavMode()) { + if (mDeviceState.isGesturalNavMode() || newGestureState.isTrackpadGesture()) { handleOrientationSetup(base); } - if (mDeviceState.isFullyGesturalNavMode()) { - String reasonPrefix = "device is in gesture navigation mode"; + if (mDeviceState.isFullyGesturalNavMode() || newGestureState.isTrackpadGesture()) { + String reasonPrefix = "device is in gesture navigation mode or 3-button mode with a" + + "trackpad gesture"; if (mDeviceState.canTriggerAssistantAction(event)) { reasonString.append(NEWLINE_PREFIX) .append(reasonPrefix) @@ -1065,17 +1070,21 @@ public class TouchInteractionService extends Service private InputConsumer createDeviceLockedInputConsumer( GestureState gestureState, CompoundString reasonString) { - if (mDeviceState.isFullyGesturalNavMode() && gestureState.getRunningTask() != null) { + if ((mDeviceState.isFullyGesturalNavMode() || gestureState.isTrackpadGesture()) + && gestureState.getRunningTask() != null) { reasonString.append(SUBSTRING_PREFIX) - .append("device is in gesture nav mode and running task != null") + .append("device is in gesture nav mode or 3-button mode with a trackpad gesture" + + "and running task != null") .append(", using DeviceLockedInputConsumer"); return new DeviceLockedInputConsumer( this, mDeviceState, mTaskAnimationManager, gestureState, mInputMonitorCompat); } else { return getDefaultInputConsumer(reasonString .append(SUBSTRING_PREFIX) - .append(mDeviceState.isFullyGesturalNavMode() - ? "running task == null" : "device is not in gesture nav mode") + .append((mDeviceState.isFullyGesturalNavMode() + || gestureState.isTrackpadGesture()) + ? "running task == null" + : "device is not in gesture nav mode and it's not a trackpad gesture") .append(", trying to use default input consumer")); } } diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackNavBarTouchController.java b/quickstep/src/com/android/quickstep/fallback/FallbackNavBarTouchController.java index 8a87f63aaf..66f5c00860 100644 --- a/quickstep/src/com/android/quickstep/fallback/FallbackNavBarTouchController.java +++ b/quickstep/src/com/android/quickstep/fallback/FallbackNavBarTouchController.java @@ -42,7 +42,7 @@ public class FallbackNavBarTouchController implements TouchController, mActivity = activity; NavigationMode sysUINavigationMode = DisplayController.getNavigationMode(mActivity); if (sysUINavigationMode == NavigationMode.NO_BUTTON) { - NavBarPosition navBarPosition = new NavBarPosition(sysUINavigationMode, + NavBarPosition navBarPosition = new NavBarPosition(mActivity, sysUINavigationMode, DisplayController.INSTANCE.get(mActivity).getInfo()); mTriggerSwipeUpTracker = new TriggerSwipeUpTouchTracker(mActivity, true /* disableHorizontalSwipe */, navBarPosition, diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java index 7d0937fc8c..5b27f9bde1 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java @@ -351,7 +351,8 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC mInteractionHandler.updateDisplacement(displacement - mStartDisplacement); } - if (mDeviceState.isFullyGesturalNavMode()) { + if (mDeviceState.isFullyGesturalNavMode() + || mGestureState.isTrackpadGesture()) { boolean minSwipeMet = upDist >= Math.max(mMotionPauseMinDisplacement, mInteractionHandler.getThresholdToAllowMotionPause()); mInteractionHandler.setCanSlowSwipeGoHome(minSwipeMet); diff --git a/quickstep/src/com/android/quickstep/interaction/NavBarGestureHandler.java b/quickstep/src/com/android/quickstep/interaction/NavBarGestureHandler.java index 6cee6906d4..63e41d54fb 100644 --- a/quickstep/src/com/android/quickstep/interaction/NavBarGestureHandler.java +++ b/quickstep/src/com/android/quickstep/interaction/NavBarGestureHandler.java @@ -65,7 +65,7 @@ public class NavBarGestureHandler implements OnTouchListener, mDisplaySize.set(currentSize.x, currentSize.y); mSwipeUpTouchTracker = new TriggerSwipeUpTouchTracker(context, true /*disableHorizontalSwipe*/, - new NavBarPosition(NavigationMode.NO_BUTTON, displayRotation), + new NavBarPosition(mContext, NavigationMode.NO_BUTTON, displayRotation), null /*onInterceptTouch*/, this); mMotionPauseDetector = new MotionPauseDetector(context); diff --git a/quickstep/src/com/android/quickstep/util/NavBarPosition.java b/quickstep/src/com/android/quickstep/util/NavBarPosition.java index 59c82633d2..a89e7e3e51 100644 --- a/quickstep/src/com/android/quickstep/util/NavBarPosition.java +++ b/quickstep/src/com/android/quickstep/util/NavBarPosition.java @@ -16,7 +16,9 @@ package com.android.quickstep.util; import static com.android.launcher3.util.NavigationMode.NO_BUTTON; +import static com.android.systemui.shared.recents.utilities.Utilities.isLargeScreen; +import android.content.Context; import android.view.Surface; import com.android.launcher3.util.DisplayController.Info; @@ -27,25 +29,26 @@ import com.android.launcher3.util.NavigationMode; */ public class NavBarPosition { + private final boolean mIsLargeScreen; private final NavigationMode mMode; private final int mDisplayRotation; - public NavBarPosition(NavigationMode mode, Info info) { - mMode = mode; - mDisplayRotation = info.rotation; + public NavBarPosition(Context context, NavigationMode mode, Info info) { + this(context, mode, info.rotation); } - public NavBarPosition(NavigationMode mode, int displayRotation) { + public NavBarPosition(Context context, NavigationMode mode, int displayRotation) { + mIsLargeScreen = isLargeScreen(context); mMode = mode; mDisplayRotation = displayRotation; } public boolean isRightEdge() { - return mMode != NO_BUTTON && mDisplayRotation == Surface.ROTATION_90; + return mMode != NO_BUTTON && mDisplayRotation == Surface.ROTATION_90 && !mIsLargeScreen; } public boolean isLeftEdge() { - return mMode != NO_BUTTON && mDisplayRotation == Surface.ROTATION_270; + return mMode != NO_BUTTON && mDisplayRotation == Surface.ROTATION_270 && !mIsLargeScreen; } public float getRotation() { diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index e62ccbc208..0bb018dc49 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -16,6 +16,7 @@ package com.android.launcher3.testing; import static com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST; +import static com.android.launcher3.config.FeatureFlags.ENABLE_TRACKPAD_GESTURE; import static com.android.launcher3.config.FeatureFlags.FOLDABLE_SINGLE_PAGE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; @@ -229,7 +230,13 @@ public class TestInformationHandler implements ResourceBasedOverride { } case TestProtocol.REQUEST_HAS_TIS: { - response.putBoolean(TestProtocol.REQUEST_HAS_TIS, false); + response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, false); + return response; + } + + case TestProtocol.REQUEST_IS_TRACKPAD_GESTURE_ENABLED: { + response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, + ENABLE_TRACKPAD_GESTURE.get()); return response; } diff --git a/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java b/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java index 2b67cdde80..b5b78a4b8c 100644 --- a/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java +++ b/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java @@ -120,6 +120,7 @@ public final class TestProtocol { "get-activities-created-count"; public static final String REQUEST_GET_ACTIVITIES = "get-activities"; public static final String REQUEST_HAS_TIS = "has-touch-interaction-service"; + public static final String REQUEST_IS_TRACKPAD_GESTURE_ENABLED = "is-trackpad-gesture-enabled"; public static final String REQUEST_TASKBAR_ALL_APPS_TOP_PADDING = "taskbar-all-apps-top-padding"; public static final String REQUEST_ALL_APPS_TOP_PADDING = "all-apps-top-padding"; diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java index 5a96d95316..31e9aa28ef 100644 --- a/tests/tapl/com/android/launcher3/tapl/Background.java +++ b/tests/tapl/com/android/launcher3/tapl/Background.java @@ -18,6 +18,8 @@ package com.android.launcher3.tapl; import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; +import static com.android.launcher3.tapl.LauncherInstrumentation.EVENT_TOUCH_DOWN_TIS; +import static com.android.launcher3.tapl.LauncherInstrumentation.EVENT_TOUCH_UP_TIS; import static com.android.launcher3.tapl.OverviewTask.TASK_START_EVENT; import static com.android.launcher3.testing.shared.TestProtocol.OVERVIEW_STATE_ORDINAL; @@ -138,6 +140,10 @@ public abstract class Background extends LauncherInstrumentation.VisibleContaine mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_TOUCH_UP); } + if (mLauncher.isTrackpadGestureEnabled()) { + mLauncher.expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_DOWN_TIS); + mLauncher.expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_UP_TIS); + } mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT); mLauncher.runToState( () -> mLauncher.waitForNavigationUiObject("recent_apps").click(), @@ -280,6 +286,10 @@ public abstract class Background extends LauncherInstrumentation.VisibleContaine mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_TOUCH_UP); } + if (mLauncher.isTrackpadGestureEnabled()) { + mLauncher.expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_DOWN_TIS); + mLauncher.expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_UP_TIS); + } mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT); mLauncher.runToState(() -> recentsButton.click(), OVERVIEW_STATE_ORDINAL, "clicking Recents button for the first time"); @@ -290,6 +300,10 @@ public abstract class Background extends LauncherInstrumentation.VisibleContaine mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_TOUCH_UP); } + if (mLauncher.isTrackpadGestureEnabled()) { + mLauncher.expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_DOWN_TIS); + mLauncher.expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_UP_TIS); + } mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT); mLauncher.executeAndWaitForEvent( () -> recentsButton.click(), diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 80fded5872..2cd63a42a0 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -1035,6 +1035,10 @@ public final class LauncherInstrumentation { expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_TOUCH_DOWN); expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_TOUCH_UP); } + if (isTrackpadGestureEnabled()) { + expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_DOWN_TIS); + expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_UP_TIS); + } runToState( waitForNavigationUiObject("home")::click, @@ -1074,6 +1078,10 @@ public final class LauncherInstrumentation { expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_TOUCH_DOWN); expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_TOUCH_UP); } + if (isTrackpadGestureEnabled()) { + expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_DOWN_TIS); + expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_UP_TIS); + } } if (launcherVisible) { if (getContext().getApplicationInfo().isOnBackInvokedCallbackEnabled()) { @@ -1646,9 +1654,14 @@ public final class LauncherInstrumentation { } private boolean hasTIS() { - return getTestInfo(TestProtocol.REQUEST_HAS_TIS).getBoolean(TestProtocol.REQUEST_HAS_TIS); + return getTestInfo(TestProtocol.REQUEST_HAS_TIS).getBoolean( + TestProtocol.TEST_INFO_RESPONSE_FIELD); } + boolean isTrackpadGestureEnabled() { + return getTestInfo(TestProtocol.REQUEST_IS_TRACKPAD_GESTURE_ENABLED).getBoolean( + TestProtocol.TEST_INFO_RESPONSE_FIELD); + } public void sendPointer(long downTime, long currentTime, int action, Point point, GestureScope gestureScope) { @@ -1660,7 +1673,8 @@ public final class LauncherInstrumentation { && gestureScope != GestureScope.OUTSIDE_WITH_KEYCODE) { expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_TOUCH_DOWN); } - if (hasTIS && getNavigationModel() != NavigationModel.THREE_BUTTON) { + if (hasTIS && (isTrackpadGestureEnabled() + || getNavigationModel() != NavigationModel.THREE_BUTTON)) { expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_DOWN_TIS); } break; @@ -1679,7 +1693,8 @@ public final class LauncherInstrumentation { || gestureScope == GestureScope.OUTSIDE_WITHOUT_PILFER ? EVENT_TOUCH_UP : EVENT_TOUCH_CANCEL); } - if (hasTIS && getNavigationModel() != NavigationModel.THREE_BUTTON) { + if (hasTIS && (isTrackpadGestureEnabled() + || getNavigationModel() != NavigationModel.THREE_BUTTON)) { expectEvent(TestProtocol.SEQUENCE_TIS, gestureScope == GestureScope.INSIDE_TO_OUTSIDE_WITH_KEYCODE || gestureScope == GestureScope.OUTSIDE_WITH_KEYCODE diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewActions.java b/tests/tapl/com/android/launcher3/tapl/OverviewActions.java index 386deac579..2f7596e9fb 100644 --- a/tests/tapl/com/android/launcher3/tapl/OverviewActions.java +++ b/tests/tapl/com/android/launcher3/tapl/OverviewActions.java @@ -51,7 +51,7 @@ public class OverviewActions { "clicked screenshot button")) { UiObject2 closeScreenshot = mLauncher.waitForSystemUiObject( "screenshot_dismiss_image"); - if (mLauncher.getNavigationModel() + if (mLauncher.isTrackpadGestureEnabled() || mLauncher.getNavigationModel() != LauncherInstrumentation.NavigationModel.THREE_BUTTON) { mLauncher.expectEvent(TestProtocol.SEQUENCE_TIS, LauncherInstrumentation.EVENT_TOUCH_DOWN_TIS);