diff --git a/aconfig/launcher.aconfig b/aconfig/launcher.aconfig index b1a0b6194d..40c37979ec 100644 --- a/aconfig/launcher.aconfig +++ b/aconfig/launcher.aconfig @@ -316,6 +316,7 @@ flag { description: "Menu in Taskbar with options to launch and manage multiple instances of the same app" bug: "355237285" } + flag { name: "navigate_to_child_preference" namespace: "launcher" diff --git a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java index 84f6b5514f..a03c0f8b2a 100644 --- a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java +++ b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java @@ -37,6 +37,7 @@ import com.android.launcher3.testing.shared.TestProtocol; import com.android.launcher3.util.DisplayController.Info; import com.android.launcher3.util.NavigationMode; import com.android.launcher3.util.window.CachedDisplayInfo; +import com.android.systemui.shared.Flags; import java.io.PrintWriter; import java.util.HashMap; @@ -242,7 +243,8 @@ class OrientationTouchTransformer { int rotation = display.rotation; int touchHeight = mNavBarGesturalHeight; OrientationRectF orientationRectF = new OrientationRectF(0, 0, size.x, size.y, rotation); - if (mMode == NavigationMode.NO_BUTTON) { + if (mMode == NavigationMode.NO_BUTTON + || (mMode == NavigationMode.THREE_BUTTONS && Flags.threeButtonCornerSwipe())) { orientationRectF.top = orientationRectF.bottom - touchHeight; updateAssistantRegions(orientationRectF); } else { diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java index f902284fcb..51317743cd 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java @@ -74,6 +74,7 @@ import com.android.quickstep.util.AssistStateManager; import com.android.quickstep.util.GestureExclusionManager; import com.android.quickstep.util.GestureExclusionManager.ExclusionListener; import com.android.quickstep.util.NavBarPosition; +import com.android.systemui.shared.Flags; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags; @@ -547,6 +548,13 @@ public class RecentsAnimationDeviceState implements DisplayInfoChangeListener, E return mAssistantVisibility; } + /** + * @return whether the Assistant gesture can be used in 3 button navigation mode. + */ + public boolean supportsAssistantGestureInButtonNav() { + return Flags.threeButtonCornerSwipe(); + } + /** * @param ev An ACTION_DOWN motion event * @return whether the given motion event can trigger the assistant over the current task. diff --git a/quickstep/src/com/android/quickstep/RotationTouchHelper.java b/quickstep/src/com/android/quickstep/RotationTouchHelper.java index 6f1ab7d800..80c07196ae 100644 --- a/quickstep/src/com/android/quickstep/RotationTouchHelper.java +++ b/quickstep/src/com/android/quickstep/RotationTouchHelper.java @@ -41,6 +41,7 @@ import com.android.launcher3.util.MainThreadInitializedObject; import com.android.launcher3.util.NavigationMode; import com.android.launcher3.util.SafeCloseable; import com.android.quickstep.util.RecentsOrientedState; +import com.android.systemui.shared.Flags; import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.shared.system.TaskStackChangeListener; import com.android.systemui.shared.system.TaskStackChangeListeners; @@ -157,7 +158,7 @@ public class RotationTouchHelper implements DisplayInfoChangeListener, SafeClose // Register for navigation mode changes mDisplayController.addChangeListener(this); DisplayController.Info info = mDisplayController.getInfo(); - onDisplayInfoChangedInternal(info, CHANGE_ALL, info.getNavigationMode().hasGestures); + onDisplayInfoChangedInternal(info, CHANGE_ALL, hasGestures(info.getNavigationMode())); runOnDestroy(() -> mDisplayController.removeChangeListener(this)); mOrientationListener = new OrientationEventListener(mContext) { @@ -229,7 +230,7 @@ public class RotationTouchHelper implements DisplayInfoChangeListener, SafeClose * Updates the regions for detecting the swipe up/quickswitch and assistant gestures. */ public void updateGestureTouchRegions() { - if (!mMode.hasGestures) { + if (!hasGestures(mMode)) { return; } @@ -268,7 +269,7 @@ public class RotationTouchHelper implements DisplayInfoChangeListener, SafeClose | CHANGE_SUPPORTED_BOUNDS)) != 0) { mDisplayRotation = info.rotation; - if (mMode.hasGestures) { + if (hasGestures(mMode)) { updateGestureTouchRegions(); mOrientationTouchTransformer.createOrAddTouchRegion(info); mCurrentAppRotation = mDisplayRotation; @@ -295,9 +296,9 @@ public class RotationTouchHelper implements DisplayInfoChangeListener, SafeClose mOrientationTouchTransformer.setNavigationMode(newMode, mDisplayController.getInfo(), mContext.getResources()); - if (forceRegister || (!mMode.hasGestures && newMode.hasGestures)) { + if (forceRegister || (!hasGestures(mMode) && hasGestures(newMode))) { setupOrientationSwipeHandler(); - } else if (mMode.hasGestures && !newMode.hasGestures) { + } else if (hasGestures(mMode) && !hasGestures(newMode)) { destroyOrientationSwipeHandlerCallback(); } @@ -399,7 +400,7 @@ public class RotationTouchHelper implements DisplayInfoChangeListener, SafeClose } public int getCurrentActiveRotation() { - if (!mMode.hasGestures) { + if (!hasGestures(mMode)) { // touch rotation should always match that of display for 3 button return mDisplayRotation; } @@ -416,4 +417,8 @@ public class RotationTouchHelper implements DisplayInfoChangeListener, SafeClose public OrientationTouchTransformer getOrientationTouchTransformer() { return mOrientationTouchTransformer; } + + private boolean hasGestures(NavigationMode mode) { + return mode.hasGestures || (mode == THREE_BUTTONS && Flags.threeButtonCornerSwipe()); + } } diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 37ce3ebf36..b321b3e39e 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -675,8 +675,9 @@ public class TouchInteractionService extends Service { private void initInputMonitor(String reason) { disposeEventHandlers("Initializing input monitor due to: " + reason); - if (mDeviceState.isButtonNavMode() && (!ENABLE_TRACKPAD_GESTURE.get() - || mTrackpadsConnected.isEmpty())) { + if (mDeviceState.isButtonNavMode() + && !mDeviceState.supportsAssistantGestureInButtonNav() + && (!ENABLE_TRACKPAD_GESTURE.get() || mTrackpadsConnected.isEmpty())) { return; } @@ -858,7 +859,9 @@ public class TouchInteractionService extends Service { .append("); cancelling gesture."), NAVIGATION_MODE_SWITCHED); event.setAction(ACTION_CANCEL); - } else if (mDeviceState.isButtonNavMode() && !isTrackpadMotionEvent(event)) { + } else if (mDeviceState.isButtonNavMode() + && !mDeviceState.supportsAssistantGestureInButtonNav() + && !isTrackpadMotionEvent(event)) { ActiveGestureLog.INSTANCE.addLog(new CompoundString("TIS.onInputEvent: ") .append("Cannot process input event: ") .append("using 3-button nav and event is not a trackpad event")); @@ -910,7 +913,22 @@ public class TouchInteractionService extends Service { if (isInSwipeUpTouchRegion && tac != null) { tac.closeKeyboardQuickSwitchView(); } - if ((!isOneHandedModeActive && isInSwipeUpTouchRegion) + if (mDeviceState.isButtonNavMode() + && mDeviceState.supportsAssistantGestureInButtonNav()) { + reasonString.append("in three button mode which supports Assistant gesture"); + // Consume gesture event for Assistant (all other gestures should do nothing). + if (mDeviceState.canTriggerAssistantAction(event)) { + reasonString.append(" and event can trigger assistant action") + .append(", consuming gesture for assistant action"); + mGestureState = + createGestureState(mGestureState, getTrackpadGestureType(event)); + mUncheckedConsumer = tryCreateAssistantInputConsumer(mGestureState, event); + } else { + reasonString.append(" but event cannot trigger Assistant") + .append(", consuming gesture as no-op"); + mUncheckedConsumer = InputConsumer.NO_OP; + } + } else if ((!isOneHandedModeActive && isInSwipeUpTouchRegion) || isHoverActionWithoutConsumer || isOnBubbles) { reasonString.append(!isOneHandedModeActive && isInSwipeUpTouchRegion ? "one handed mode is not active and event is in swipe up region" @@ -932,8 +950,7 @@ public class TouchInteractionService extends Service { : "event is a trackpad multi-finger swipe") .append(" and event can trigger assistant action") .append(", consuming gesture for assistant action"); - mGestureState = createGestureState(mGestureState, - getTrackpadGestureType(event)); + mGestureState = createGestureState(mGestureState, getTrackpadGestureType(event)); // Do not change mConsumer as if there is an ongoing QuickSwitch gesture, we // should not interrupt it. QuickSwitch assumes that interruption can only // happen if the next gesture is also quick switch.