From 5c953ed47d5233c07eda76daee137225a436798d Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Tue, 5 Jan 2021 12:52:34 -0800 Subject: [PATCH] Disabling fling gesture for assistant over deferred region Fixing missing trigger when using fling gesture Bug: 130186141 Bug: 175839420 Test: Verified fling does not work over keyboard dismiss button Change-Id: Id15320122cf9183c591416962634561a1ddc6fa0 --- .../quickstep/OverviewComponentObserver.java | 5 --- .../RecentsAnimationDeviceState.java | 10 ++++- .../quickstep/TouchInteractionService.java | 11 ++---- .../AssistantInputConsumer.java | 38 +++++++++---------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java index 49feef0862..7bf7712fd0 100644 --- a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java +++ b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java @@ -23,7 +23,6 @@ import static android.content.Intent.ACTION_PACKAGE_REMOVED; import static com.android.launcher3.config.FeatureFlags.SEPARATE_RECENTS_ACTIVITY; import static com.android.launcher3.util.PackageManagerHelper.getPackageFilter; import static com.android.systemui.shared.system.PackageManagerWrapper.ACTION_PREFERRED_ACTIVITY_CHANGED; -import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED; import android.content.BroadcastReceiver; import android.content.ComponentName; @@ -119,10 +118,6 @@ public final class OverviewComponentObserver { updateOverviewTargets(); } - public boolean assistantGestureIsConstrained() { - return (mDeviceState.getSystemUiStateFlags() & SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED) != 0; - } - /** * Update overview intent and {@link BaseActivityInterface} based off the current launcher home * component. diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java index d8064a2153..fb195f8a6f 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java @@ -24,6 +24,7 @@ import static com.android.quickstep.SysUINavigationMode.Mode.THREE_BUTTONS; import static com.android.quickstep.SysUINavigationMode.Mode.TWO_BUTTONS; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_CLICKABLE; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE; +import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_GLOBAL_ACTIONS_SHOWING; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_HOME_DISABLED; @@ -374,7 +375,7 @@ public class RecentsAnimationDeviceState implements * @return the system ui state flags. */ // TODO(141886704): See if we can remove this - public @SystemUiStateFlags int getSystemUiStateFlags() { + public int getSystemUiStateFlags() { return mSystemUiStateFlags; } @@ -406,6 +407,13 @@ public class RecentsAnimationDeviceState implements return (mSystemUiStateFlags & SYSUI_STATE_SCREEN_PINNING) != 0; } + /** + * @return whether assistant gesture is constraint + */ + public boolean isAssistantGestureIsConstrained() { + return (mSystemUiStateFlags & SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED) != 0; + } + /** * @return whether the bubble stack is expanded */ diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 1e0a00aec8..e59035cf5a 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -466,7 +466,8 @@ public class TouchInteractionService extends Service implements PluginListener mGestureDetector; public AssistantInputConsumer( Context context, GestureState gestureState, InputConsumer delegate, InputMonitorCompat inputMonitor, - boolean isAssistGestureConstrained) { + RecentsAnimationDeviceState deviceState, + MotionEvent startEvent) { super(delegate, inputMonitor); final Resources res = context.getResources(); mContext = context; - mIsAssistGestureConstrained = isAssistGestureConstrained; mDragDistThreshold = res.getDimension(R.dimen.gestures_assistant_drag_threshold); mFlingDistThreshold = res.getDimension(R.dimen.gestures_assistant_fling_threshold); mTimeThreshold = res.getInteger(R.integer.assistant_gesture_min_time_threshold); @@ -104,7 +106,11 @@ public class AssistantInputConsumer extends DelegateInputConsumer { mSquaredSlop = slop * slop; mActivityInterface = gestureState.getActivityInterface(); - mGestureDetector = new GestureDetector(context, new AssistantGestureListener()); + boolean flingDisabled = deviceState.isAssistantGestureIsConstrained() + || deviceState.isInDeferredGestureRegion(startEvent); + mGestureDetector = flingDisabled + ? ev -> { } + : new GestureDetector(context, new AssistantGestureListener())::onTouchEvent; } @Override @@ -201,7 +207,7 @@ public class AssistantInputConsumer extends DelegateInputConsumer { break; } - mGestureDetector.onTouchEvent(ev); + mGestureDetector.accept(ev); if (mState != STATE_ACTIVE) { mDelegate.onMotionEvent(ev); @@ -214,12 +220,6 @@ public class AssistantInputConsumer extends DelegateInputConsumer { if (mDistance >= mDragDistThreshold && mTimeFraction >= 1) { SystemUiProxy.INSTANCE.get(mContext).onAssistantGestureCompletion(0); startAssistantInternal(); - - Bundle args = new Bundle(); - args.putInt(OPA_BUNDLE_TRIGGER, OPA_BUNDLE_TRIGGER_DIAG_SWIPE_GESTURE); - args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE); - SystemUiProxy.INSTANCE.get(mContext).startAssistant(args); - mLaunchedAssistant = true; } else { SystemUiProxy.INSTANCE.get(mContext).onAssistantProgress(mLastProgress); } @@ -233,6 +233,12 @@ public class AssistantInputConsumer extends DelegateInputConsumer { 13, // HapticFeedbackConstants.GESTURE_END HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); } + + Bundle args = new Bundle(); + args.putInt(OPA_BUNDLE_TRIGGER, OPA_BUNDLE_TRIGGER_DIAG_SWIPE_GESTURE); + args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE); + SystemUiProxy.INSTANCE.get(mContext).startAssistant(args); + mLaunchedAssistant = true; } /** @@ -250,8 +256,7 @@ public class AssistantInputConsumer extends DelegateInputConsumer { private class AssistantGestureListener extends SimpleOnGestureListener { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { - if (!mIsAssistGestureConstrained - && isValidAssistantGestureAngle(velocityX, -velocityY) + if (isValidAssistantGestureAngle(velocityX, -velocityY) && mDistance >= mFlingDistThreshold && !mLaunchedAssistant && mState != STATE_DELEGATE_ACTIVE) { @@ -259,11 +264,6 @@ public class AssistantInputConsumer extends DelegateInputConsumer { SystemUiProxy.INSTANCE.get(mContext).onAssistantGestureCompletion( (float) Math.sqrt(velocityX * velocityX + velocityY * velocityY)); startAssistantInternal(); - - Bundle args = new Bundle(); - args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE); - SystemUiProxy.INSTANCE.get(mContext).startAssistant(args); - mLaunchedAssistant = true; } return true; }