Merge "[Trackpad] Gesture navigation in 3-button mode" into udc-qpr-dev

This commit is contained in:
Tracy Zhou
2023-05-22 17:52:04 +00:00
committed by Android (Google) Code Review
17 changed files with 105 additions and 28 deletions
@@ -559,8 +559,14 @@ public class QuickstepLauncher extends Launcher {
list.add(new PortraitStatesTouchController(this)); list.add(new PortraitStatesTouchController(this));
break; break;
case THREE_BUTTONS: 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: default:
list.add(new PortraitStatesTouchController(this)); list.add(new PortraitStatesTouchController(this));
break;
} }
if (!getDeviceProfile().isMultiWindowMode) { if (!getDeviceProfile().isMultiWindowMode) {
@@ -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.LauncherAnimUtils.newCancelListener;
import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL; 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_ALPHA;
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PULL_BACK_TRANSLATION; 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.AnimatorListeners.forSuccessCallback;
import static com.android.launcher3.anim.Interpolators.DEACCEL_3; 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.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 static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
@@ -42,6 +44,7 @@ import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.compat.AccessibilityManagerCompat; import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.touch.SingleAxisSwipeDetector; import com.android.launcher3.touch.SingleAxisSwipeDetector;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.TouchController; import com.android.launcher3.util.TouchController;
import com.android.quickstep.TaskUtils; import com.android.quickstep.TaskUtils;
import com.android.quickstep.util.AnimatorControllerWithResistance; import com.android.quickstep.util.AnimatorControllerWithResistance;
@@ -95,6 +98,10 @@ public class NavBarToHomeTouchController implements TouchController,
} }
private boolean canInterceptTouch(MotionEvent ev) { private boolean canInterceptTouch(MotionEvent ev) {
if (!isTrackpadMotionEvent(ev) && DisplayController.getNavigationMode(mLauncher)
== THREE_BUTTONS) {
return false;
}
boolean cameFromNavBar = (ev.getEdgeFlags() & Utilities.EDGE_NAV_BAR) != 0; boolean cameFromNavBar = (ev.getEdgeFlags() & Utilities.EDGE_NAV_BAR) != 0;
if (!cameFromNavBar) { if (!cameFromNavBar) {
return false; return false;
@@ -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.HINT_STATE;
import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW; 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.Utilities.EDGE_NAV_BAR;
import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback; import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback;
import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL; 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.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_ONE_HANDED_ACTIVE;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED; 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.states.StateAnimationConfig;
import com.android.launcher3.taskbar.LauncherTaskbarUIController; import com.android.launcher3.taskbar.LauncherTaskbarUIController;
import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.VibratorWrapper; import com.android.launcher3.util.VibratorWrapper;
import com.android.quickstep.SystemUiProxy; import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.util.AnimatorControllerWithResistance; import com.android.quickstep.util.AnimatorControllerWithResistance;
@@ -89,6 +92,10 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch
@Override @Override
protected boolean canInterceptTouch(MotionEvent ev) { protected boolean canInterceptTouch(MotionEvent ev) {
if (!isTrackpadMotionEvent(ev) && DisplayController.getNavigationMode(mLauncher)
== THREE_BUTTONS) {
return false;
}
mDidTouchStartInNavBar = (ev.getEdgeFlags() & EDGE_NAV_BAR) != 0; mDidTouchStartInNavBar = (ev.getEdgeFlags() & EDGE_NAV_BAR) != 0;
boolean isOneHandedModeActive = (SystemUiProxy.INSTANCE.get(mLauncher) boolean isOneHandedModeActive = (SystemUiProxy.INSTANCE.get(mLauncher)
.getLastSystemUiStateFlags() & SYSUI_STATE_ONE_HANDED_ACTIVE) != 0; .getLastSystemUiStateFlags() & SYSUI_STATE_ONE_HANDED_ACTIVE) != 0;
@@ -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.OVERVIEW_ACTIONS;
import static com.android.launcher3.LauncherState.QUICK_SWITCH_FROM_HOME; import static com.android.launcher3.LauncherState.QUICK_SWITCH_FROM_HOME;
import static com.android.launcher3.MotionEventsUtils.isTrackpadFourFingerSwipe; 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.MotionEventsUtils.isTrackpadMultiFingerSwipe;
import static com.android.launcher3.anim.AlphaUpdateListener.ALPHA_CUTOFF_THRESHOLD; import static com.android.launcher3.anim.AlphaUpdateListener.ALPHA_CUTOFF_THRESHOLD;
import static com.android.launcher3.anim.AnimatorListeners.forEndCallback; 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.states.StateAnimationConfig.SKIP_SCRIM;
import static com.android.launcher3.touch.BothAxesSwipeDetector.DIRECTION_RIGHT; import static com.android.launcher3.touch.BothAxesSwipeDetector.DIRECTION_RIGHT;
import static com.android.launcher3.touch.BothAxesSwipeDetector.DIRECTION_UP; 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.VibratorWrapper.OVERVIEW_HAPTIC;
import static com.android.launcher3.util.window.RefreshRateTracker.getSingleFrameMs; import static com.android.launcher3.util.window.RefreshRateTracker.getSingleFrameMs;
import static com.android.quickstep.views.RecentsView.ADJACENT_PAGE_HORIZONTAL_OFFSET; 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.BaseSwipeDetector;
import com.android.launcher3.touch.BothAxesSwipeDetector; import com.android.launcher3.touch.BothAxesSwipeDetector;
import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.TouchController; import com.android.launcher3.util.TouchController;
import com.android.launcher3.util.VibratorWrapper; import com.android.launcher3.util.VibratorWrapper;
import com.android.quickstep.SystemUiProxy; import com.android.quickstep.SystemUiProxy;
@@ -170,6 +173,10 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
} }
private boolean canInterceptTouch(MotionEvent ev) { private boolean canInterceptTouch(MotionEvent ev) {
if (!isTrackpadMotionEvent(ev) && DisplayController.getNavigationMode(mLauncher)
== THREE_BUTTONS) {
return false;
}
if (!mLauncher.isInState(LauncherState.NORMAL)) { if (!mLauncher.isInState(LauncherState.NORMAL)) {
return false; return false;
} }
@@ -722,7 +722,8 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
* @param moveRunningTask whether to move running task to front when attaching * @param moveRunningTask whether to move running task to front when attaching
*/ */
private void maybeUpdateRecentsAttachedState(boolean animate, boolean moveRunningTask) { private void maybeUpdateRecentsAttachedState(boolean animate, boolean moveRunningTask) {
if (!mDeviceState.isFullyGesturalNavMode() || mRecentsView == null) { if ((!mDeviceState.isFullyGesturalNavMode() && !mGestureState.isTrackpadGesture())
|| mRecentsView == null) {
return; return;
} }
RemoteAnimationTarget runningTaskTarget = mRecentsAnimationTargets != null RemoteAnimationTarget runningTaskTarget = mRecentsAnimationTargets != null
@@ -80,8 +80,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
} }
case TestProtocol.REQUEST_HAS_TIS: { case TestProtocol.REQUEST_HAS_TIS: {
response.putBoolean( response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, true);
TestProtocol.REQUEST_HAS_TIS, true);
return response; return response;
} }
@@ -260,7 +260,7 @@ public class RecentsAnimationDeviceState implements DisplayInfoChangeListener {
public void onDisplayInfoChanged(Context context, Info info, int flags) { public void onDisplayInfoChanged(Context context, Info info, int flags) {
if ((flags & (CHANGE_ROTATION | CHANGE_NAVIGATION_MODE)) != 0) { if ((flags & (CHANGE_ROTATION | CHANGE_NAVIGATION_MODE)) != 0) {
mMode = info.navigationMode; mMode = info.navigationMode;
mNavBarPosition = new NavBarPosition(mMode, info); mNavBarPosition = new NavBarPosition(mContext, mMode, info);
if (mMode == NO_BUTTON) { if (mMode == NO_BUTTON) {
mExclusionListener.register(); mExclusionListener.register();
@@ -24,6 +24,8 @@ import static android.view.MotionEvent.ACTION_POINTER_UP;
import static android.view.MotionEvent.ACTION_UP; import static android.view.MotionEvent.ACTION_UP;
import static com.android.launcher3.Launcher.INTENT_ACTION_ALL_APPS_TOGGLE; 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.config.FeatureFlags.ENABLE_TRACKPAD_GESTURE;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.quickstep.GestureState.DEFAULT_STATE; import static com.android.quickstep.GestureState.DEFAULT_STATE;
@@ -465,7 +467,7 @@ public class TouchInteractionService extends Service
private void initInputMonitor(String reason) { private void initInputMonitor(String reason) {
disposeEventHandlers("Initializing input monitor due to: " + reason); disposeEventHandlers("Initializing input monitor due to: " + reason);
if (mDeviceState.isButtonNavMode()) { if (mDeviceState.isButtonNavMode() && !ENABLE_TRACKPAD_GESTURE.get()) {
return; return;
} }
@@ -645,7 +647,8 @@ public class TouchInteractionService extends Service
TestLogging.recordMotionEvent( TestLogging.recordMotionEvent(
TestProtocol.SEQUENCE_TIS, "TouchInteractionService.onInputEvent", event); TestProtocol.SEQUENCE_TIS, "TouchInteractionService.onInputEvent", event);
if (!mDeviceState.isUserUnlocked()) { if (!mDeviceState.isUserUnlocked() || (mDeviceState.isButtonNavMode()
&& !isTrackpadMotionEvent(event))) {
return; return;
} }
@@ -673,7 +676,8 @@ public class TouchInteractionService extends Service
mGestureState = newGestureState; mGestureState = newGestureState;
mConsumer = newConsumer(prevGestureState, mGestureState, event); mConsumer = newConsumer(prevGestureState, mGestureState, event);
mUncheckedConsumer = mConsumer; mUncheckedConsumer = mConsumer;
} else if (mDeviceState.isUserUnlocked() && mDeviceState.isFullyGesturalNavMode() } else if (mDeviceState.isUserUnlocked()
&& (mDeviceState.isFullyGesturalNavMode() || isTrackpadMultiFingerSwipe(event))
&& mDeviceState.canTriggerAssistantAction(event)) { && mDeviceState.canTriggerAssistantAction(event)) {
mGestureState = createGestureState(mGestureState, mGestureState = createGestureState(mGestureState,
getTrackpadGestureType(event)); getTrackpadGestureType(event));
@@ -850,11 +854,12 @@ public class TouchInteractionService extends Service
.append(", trying to use default input consumer"); .append(", trying to use default input consumer");
base = getDefaultInputConsumer(reasonString); base = getDefaultInputConsumer(reasonString);
} }
if (mDeviceState.isGesturalNavMode()) { if (mDeviceState.isGesturalNavMode() || newGestureState.isTrackpadGesture()) {
handleOrientationSetup(base); handleOrientationSetup(base);
} }
if (mDeviceState.isFullyGesturalNavMode()) { if (mDeviceState.isFullyGesturalNavMode() || newGestureState.isTrackpadGesture()) {
String reasonPrefix = "device is in gesture navigation mode"; String reasonPrefix = "device is in gesture navigation mode or 3-button mode with a"
+ "trackpad gesture";
if (mDeviceState.canTriggerAssistantAction(event)) { if (mDeviceState.canTriggerAssistantAction(event)) {
reasonString.append(NEWLINE_PREFIX) reasonString.append(NEWLINE_PREFIX)
.append(reasonPrefix) .append(reasonPrefix)
@@ -1065,17 +1070,21 @@ public class TouchInteractionService extends Service
private InputConsumer createDeviceLockedInputConsumer( private InputConsumer createDeviceLockedInputConsumer(
GestureState gestureState, CompoundString reasonString) { GestureState gestureState, CompoundString reasonString) {
if (mDeviceState.isFullyGesturalNavMode() && gestureState.getRunningTask() != null) { if ((mDeviceState.isFullyGesturalNavMode() || gestureState.isTrackpadGesture())
&& gestureState.getRunningTask() != null) {
reasonString.append(SUBSTRING_PREFIX) 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"); .append(", using DeviceLockedInputConsumer");
return new DeviceLockedInputConsumer( return new DeviceLockedInputConsumer(
this, mDeviceState, mTaskAnimationManager, gestureState, mInputMonitorCompat); this, mDeviceState, mTaskAnimationManager, gestureState, mInputMonitorCompat);
} else { } else {
return getDefaultInputConsumer(reasonString return getDefaultInputConsumer(reasonString
.append(SUBSTRING_PREFIX) .append(SUBSTRING_PREFIX)
.append(mDeviceState.isFullyGesturalNavMode() .append((mDeviceState.isFullyGesturalNavMode()
? "running task == null" : "device is not in gesture nav mode") || 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")); .append(", trying to use default input consumer"));
} }
} }
@@ -42,7 +42,7 @@ public class FallbackNavBarTouchController implements TouchController,
mActivity = activity; mActivity = activity;
NavigationMode sysUINavigationMode = DisplayController.getNavigationMode(mActivity); NavigationMode sysUINavigationMode = DisplayController.getNavigationMode(mActivity);
if (sysUINavigationMode == NavigationMode.NO_BUTTON) { if (sysUINavigationMode == NavigationMode.NO_BUTTON) {
NavBarPosition navBarPosition = new NavBarPosition(sysUINavigationMode, NavBarPosition navBarPosition = new NavBarPosition(mActivity, sysUINavigationMode,
DisplayController.INSTANCE.get(mActivity).getInfo()); DisplayController.INSTANCE.get(mActivity).getInfo());
mTriggerSwipeUpTracker = new TriggerSwipeUpTouchTracker(mActivity, mTriggerSwipeUpTracker = new TriggerSwipeUpTouchTracker(mActivity,
true /* disableHorizontalSwipe */, navBarPosition, true /* disableHorizontalSwipe */, navBarPosition,
@@ -351,7 +351,8 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
mInteractionHandler.updateDisplacement(displacement - mStartDisplacement); mInteractionHandler.updateDisplacement(displacement - mStartDisplacement);
} }
if (mDeviceState.isFullyGesturalNavMode()) { if (mDeviceState.isFullyGesturalNavMode()
|| mGestureState.isTrackpadGesture()) {
boolean minSwipeMet = upDist >= Math.max(mMotionPauseMinDisplacement, boolean minSwipeMet = upDist >= Math.max(mMotionPauseMinDisplacement,
mInteractionHandler.getThresholdToAllowMotionPause()); mInteractionHandler.getThresholdToAllowMotionPause());
mInteractionHandler.setCanSlowSwipeGoHome(minSwipeMet); mInteractionHandler.setCanSlowSwipeGoHome(minSwipeMet);
@@ -65,7 +65,7 @@ public class NavBarGestureHandler implements OnTouchListener,
mDisplaySize.set(currentSize.x, currentSize.y); mDisplaySize.set(currentSize.x, currentSize.y);
mSwipeUpTouchTracker = mSwipeUpTouchTracker =
new TriggerSwipeUpTouchTracker(context, true /*disableHorizontalSwipe*/, new TriggerSwipeUpTouchTracker(context, true /*disableHorizontalSwipe*/,
new NavBarPosition(NavigationMode.NO_BUTTON, displayRotation), new NavBarPosition(mContext, NavigationMode.NO_BUTTON, displayRotation),
null /*onInterceptTouch*/, this); null /*onInterceptTouch*/, this);
mMotionPauseDetector = new MotionPauseDetector(context); mMotionPauseDetector = new MotionPauseDetector(context);
@@ -16,7 +16,9 @@
package com.android.quickstep.util; package com.android.quickstep.util;
import static com.android.launcher3.util.NavigationMode.NO_BUTTON; 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 android.view.Surface;
import com.android.launcher3.util.DisplayController.Info; import com.android.launcher3.util.DisplayController.Info;
@@ -27,25 +29,26 @@ import com.android.launcher3.util.NavigationMode;
*/ */
public class NavBarPosition { public class NavBarPosition {
private final boolean mIsLargeScreen;
private final NavigationMode mMode; private final NavigationMode mMode;
private final int mDisplayRotation; private final int mDisplayRotation;
public NavBarPosition(NavigationMode mode, Info info) { public NavBarPosition(Context context, NavigationMode mode, Info info) {
mMode = mode; this(context, mode, info.rotation);
mDisplayRotation = info.rotation;
} }
public NavBarPosition(NavigationMode mode, int displayRotation) { public NavBarPosition(Context context, NavigationMode mode, int displayRotation) {
mIsLargeScreen = isLargeScreen(context);
mMode = mode; mMode = mode;
mDisplayRotation = displayRotation; mDisplayRotation = displayRotation;
} }
public boolean isRightEdge() { public boolean isRightEdge() {
return mMode != NO_BUTTON && mDisplayRotation == Surface.ROTATION_90; return mMode != NO_BUTTON && mDisplayRotation == Surface.ROTATION_90 && !mIsLargeScreen;
} }
public boolean isLeftEdge() { public boolean isLeftEdge() {
return mMode != NO_BUTTON && mDisplayRotation == Surface.ROTATION_270; return mMode != NO_BUTTON && mDisplayRotation == Surface.ROTATION_270 && !mIsLargeScreen;
} }
public float getRotation() { public float getRotation() {
@@ -16,6 +16,7 @@
package com.android.launcher3.testing; package com.android.launcher3.testing;
import static com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST; 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.config.FeatureFlags.FOLDABLE_SINGLE_PAGE;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
@@ -229,7 +230,13 @@ public class TestInformationHandler implements ResourceBasedOverride {
} }
case TestProtocol.REQUEST_HAS_TIS: { 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; return response;
} }
@@ -120,6 +120,7 @@ public final class TestProtocol {
"get-activities-created-count"; "get-activities-created-count";
public static final String REQUEST_GET_ACTIVITIES = "get-activities"; 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_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 = public static final String REQUEST_TASKBAR_ALL_APPS_TOP_PADDING =
"taskbar-all-apps-top-padding"; "taskbar-all-apps-top-padding";
public static final String REQUEST_ALL_APPS_TOP_PADDING = "all-apps-top-padding"; public static final String REQUEST_ALL_APPS_TOP_PADDING = "all-apps-top-padding";
@@ -18,6 +18,8 @@ package com.android.launcher3.tapl;
import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; 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.tapl.OverviewTask.TASK_START_EVENT;
import static com.android.launcher3.testing.shared.TestProtocol.OVERVIEW_STATE_ORDINAL; 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, mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN,
LauncherInstrumentation.EVENT_TOUCH_UP); 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.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT);
mLauncher.runToState( mLauncher.runToState(
() -> mLauncher.waitForNavigationUiObject("recent_apps").click(), () -> mLauncher.waitForNavigationUiObject("recent_apps").click(),
@@ -280,6 +286,10 @@ public abstract class Background extends LauncherInstrumentation.VisibleContaine
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN,
LauncherInstrumentation.EVENT_TOUCH_UP); 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.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT);
mLauncher.runToState(() -> recentsButton.click(), OVERVIEW_STATE_ORDINAL, mLauncher.runToState(() -> recentsButton.click(), OVERVIEW_STATE_ORDINAL,
"clicking Recents button for the first time"); "clicking Recents button for the first time");
@@ -290,6 +300,10 @@ public abstract class Background extends LauncherInstrumentation.VisibleContaine
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN,
LauncherInstrumentation.EVENT_TOUCH_UP); 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.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT);
mLauncher.executeAndWaitForEvent( mLauncher.executeAndWaitForEvent(
() -> recentsButton.click(), () -> recentsButton.click(),
@@ -1035,6 +1035,10 @@ public final class LauncherInstrumentation {
expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_TOUCH_DOWN); expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_TOUCH_DOWN);
expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_TOUCH_UP); 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( runToState(
waitForNavigationUiObject("home")::click, waitForNavigationUiObject("home")::click,
@@ -1074,6 +1078,10 @@ public final class LauncherInstrumentation {
expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_TOUCH_DOWN); expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_TOUCH_DOWN);
expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_TOUCH_UP); 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 (launcherVisible) {
if (getContext().getApplicationInfo().isOnBackInvokedCallbackEnabled()) { if (getContext().getApplicationInfo().isOnBackInvokedCallbackEnabled()) {
@@ -1646,9 +1654,14 @@ public final class LauncherInstrumentation {
} }
private boolean hasTIS() { 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, public void sendPointer(long downTime, long currentTime, int action, Point point,
GestureScope gestureScope) { GestureScope gestureScope) {
@@ -1660,7 +1673,8 @@ public final class LauncherInstrumentation {
&& gestureScope != GestureScope.OUTSIDE_WITH_KEYCODE) { && gestureScope != GestureScope.OUTSIDE_WITH_KEYCODE) {
expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_TOUCH_DOWN); 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); expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_DOWN_TIS);
} }
break; break;
@@ -1679,7 +1693,8 @@ public final class LauncherInstrumentation {
|| gestureScope == GestureScope.OUTSIDE_WITHOUT_PILFER || gestureScope == GestureScope.OUTSIDE_WITHOUT_PILFER
? EVENT_TOUCH_UP : EVENT_TOUCH_CANCEL); ? EVENT_TOUCH_UP : EVENT_TOUCH_CANCEL);
} }
if (hasTIS && getNavigationModel() != NavigationModel.THREE_BUTTON) { if (hasTIS && (isTrackpadGestureEnabled()
|| getNavigationModel() != NavigationModel.THREE_BUTTON)) {
expectEvent(TestProtocol.SEQUENCE_TIS, expectEvent(TestProtocol.SEQUENCE_TIS,
gestureScope == GestureScope.INSIDE_TO_OUTSIDE_WITH_KEYCODE gestureScope == GestureScope.INSIDE_TO_OUTSIDE_WITH_KEYCODE
|| gestureScope == GestureScope.OUTSIDE_WITH_KEYCODE || gestureScope == GestureScope.OUTSIDE_WITH_KEYCODE
@@ -51,7 +51,7 @@ public class OverviewActions {
"clicked screenshot button")) { "clicked screenshot button")) {
UiObject2 closeScreenshot = mLauncher.waitForSystemUiObject( UiObject2 closeScreenshot = mLauncher.waitForSystemUiObject(
"screenshot_dismiss_image"); "screenshot_dismiss_image");
if (mLauncher.getNavigationModel() if (mLauncher.isTrackpadGestureEnabled() || mLauncher.getNavigationModel()
!= LauncherInstrumentation.NavigationModel.THREE_BUTTON) { != LauncherInstrumentation.NavigationModel.THREE_BUTTON) {
mLauncher.expectEvent(TestProtocol.SEQUENCE_TIS, mLauncher.expectEvent(TestProtocol.SEQUENCE_TIS,
LauncherInstrumentation.EVENT_TOUCH_DOWN_TIS); LauncherInstrumentation.EVENT_TOUCH_DOWN_TIS);