Merge "Fix NPE / add downX,Y location for all swipes/ add extra debugging info Bug: 122700646 Bug: 127840207" into ub-launcher3-qt-dev
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/AssistantTouchConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/AssistantTouchConsumer.java
index be87a96..abd7c03 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/AssistantTouchConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/AssistantTouchConsumer.java
@@ -28,6 +28,7 @@
import static com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType.NAVBAR;
import android.animation.ValueAnimator;
+import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.PointF;
@@ -35,10 +36,12 @@
import android.os.RemoteException;
import android.os.SystemClock;
import android.util.Log;
+import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
+
+import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.logging.UserEventDispatcher;
-import com.android.quickstep.util.MotionPauseDetector;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.launcher3.R;
import com.android.systemui.shared.system.InputMonitorCompat;
@@ -77,12 +80,12 @@
private float mLastProgress;
private int mState;
private int mDirection;
+ private ActivityControlHelper mActivityControlHelper;
private final float mDistThreshold;
private final long mTimeThreshold;
private final int mAngleThreshold;
private final float mSlop;
- private final MotionPauseDetector mMotionPauseDetector;
private final ISystemUiProxy mSysUiProxy;
private final InputConsumer mConsumerDelegate;
private final Context mContext;
@@ -91,17 +94,18 @@
public AssistantTouchConsumer(Context context, ISystemUiProxy systemUiProxy,
- InputConsumer delegate, InputMonitorCompat inputMonitorCompat) {
+ InputConsumer delegate, InputMonitorCompat inputMonitorCompat,
+ ActivityControlHelper activityControlHelper) {
final Resources res = context.getResources();
mContext = context;
mSysUiProxy = systemUiProxy;
mConsumerDelegate = delegate;
- mMotionPauseDetector = new MotionPauseDetector(context);
mDistThreshold = res.getDimension(R.dimen.gestures_assistant_drag_threshold);
mTimeThreshold = res.getInteger(R.integer.assistant_gesture_min_time_threshold);
mAngleThreshold = res.getInteger(R.integer.assistant_gesture_corner_deg_threshold);
- mSlop = NavigationBarCompat.getQuickScrubTouchSlopPx();
+ mSlop = NavigationBarCompat.getQuickStepDragSlopPx();
mInputMonitorCompat = inputMonitorCompat;
+ mActivityControlHelper = activityControlHelper;
mState = STATE_INACTIVE;
}
@@ -111,8 +115,18 @@
}
@Override
- public boolean isActive() {
- return mState != STATE_INACTIVE;
+ public boolean useSharedSwipeState() {
+ if (mConsumerDelegate != null) {
+ return mConsumerDelegate.useSharedSwipeState();
+ }
+ return false;
+ }
+
+ @Override
+ public void onConsumerAboutToBeSwitched() {
+ if (mConsumerDelegate != null) {
+ mConsumerDelegate.onConsumerAboutToBeSwitched();
+ }
}
@Override
@@ -125,14 +139,6 @@
mDownPos.set(ev.getX(), ev.getY());
mLastPos.set(mDownPos);
mTimeFraction = 0;
-
- // Detect when the gesture decelerates to start the assistant
- mMotionPauseDetector.setOnMotionPauseListener(isPaused -> {
- if (isPaused && mState == STATE_ASSISTANT_ACTIVE) {
- mTimeFraction = 1;
- updateAssistantProgress();
- }
- });
break;
}
case ACTION_POINTER_UP: {
@@ -175,7 +181,7 @@
mDirection = angle > 90 ? UPLEFT : UPRIGHT;
angle = angle > 90 ? 180 - angle : angle;
- if (angle > mAngleThreshold && angle < 90 - mAngleThreshold) {
+ if (angle > mAngleThreshold && angle < 90) {
mState = STATE_ASSISTANT_ACTIVE;
if (mConsumerDelegate != null) {
@@ -193,7 +199,6 @@
// Movement
mDistance = (float) Math.hypot(mLastPos.x - mStartDragPos.x,
mLastPos.y - mStartDragPos.y);
- mMotionPauseDetector.addPosition(mDistance, 0, ev.getEventTime());
if (mDistance >= 0) {
final long diff = SystemClock.uptimeMillis() - mDragTime;
mTimeFraction = Math.min(diff * 1f / mTimeThreshold, 1);
@@ -222,8 +227,8 @@
animator.setInterpolator(Interpolators.DEACCEL_2);
animator.start();
}
+ mPassedSlop = false;
mState = STATE_INACTIVE;
- mMotionPauseDetector.clear();
break;
}
@@ -243,6 +248,14 @@
SWIPE, mDirection, NAVBAR);
Bundle args = new Bundle();
args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
+
+ BaseDraggingActivity launcherActivity = mActivityControlHelper.getCreatedActivity();
+ if (launcherActivity != null) {
+ launcherActivity.getRootView().
+ performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
+ HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
+ }
+
mSysUiProxy.startAssistant(args);
mLaunchedAssistant = true;
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/InputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/InputConsumer.java
index ad9fe78..e3f9e02 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/InputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/InputConsumer.java
@@ -34,7 +34,7 @@
int getType();
- default boolean isActive() {
+ default boolean useSharedSwipeState() {
return false;
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java
index 5a15f3d..36afdef 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java
@@ -414,7 +414,7 @@
}
@Override
- public boolean isActive() {
+ public boolean useSharedSwipeState() {
return mInteractionHandler != null;
}
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
index 95dea50..fc3f332 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
@@ -87,7 +87,7 @@
new LooperExecutor(UiThreadHelper.getBackgroundLooper());
private static final String NAVBAR_VERTICAL_SIZE = "navigation_bar_frame_height";
- private static final String NAVBAR_HORIZONTAL_SIZE = "navigation_bar_frame_width";
+ private static final String NAVBAR_HORIZONTAL_SIZE = "navigation_bar_width";
public static final EventLogArray TOUCH_INTERACTION_LOG =
new EventLogArray("touch_interaction_log", 40);
@@ -422,7 +422,7 @@
if (event.getAction() == ACTION_DOWN) {
if (isInValidSystemUiState()
&& mSwipeTouchRegion.contains(event.getX(), event.getY())) {
- boolean useSharedState = mConsumer.isActive();
+ boolean useSharedState = mConsumer.useSharedSwipeState();
mConsumer.onConsumerAboutToBeSwitched();
mConsumer = newConsumer(useSharedState, event);
TOUCH_INTERACTION_LOG.addLog("setInputConsumer", mConsumer.getType());
@@ -455,13 +455,18 @@
final ActivityControlHelper activityControl =
mOverviewComponentObserver.getActivityControlHelper();
+
if (runningTaskInfo == null && !mSwipeSharedState.goingToLauncher) {
return InputConsumer.NO_OP;
} else if (mAssistantAvailable
&& SysUINavigationMode.INSTANCE.get(this).getMode() == Mode.NO_BUTTON
&& AssistantTouchConsumer.withinTouchRegion(this, event)) {
- return new AssistantTouchConsumer(this, mISystemUiProxy, !activityControl.isResumed()
- ? createOtherActivityInputConsumer(event, runningTaskInfo) : null, mInputMonitorCompat);
+
+ boolean addDelegate = !activityControl.isResumed();
+ return new AssistantTouchConsumer(this, mISystemUiProxy, addDelegate ?
+ createOtherActivityInputConsumer(event, runningTaskInfo) : null,
+ mInputMonitorCompat, activityControl);
+
} else if (mSwipeSharedState.goingToLauncher || activityControl.isResumed()) {
return OverviewInputConsumer.newInstance(activityControl, false);
} else if (ENABLE_QUICKSTEP_LIVE_TILE.get() &&
diff --git a/quickstep/res/values/config.xml b/quickstep/res/values/config.xml
index e29d3df..95aea43 100644
--- a/quickstep/res/values/config.xml
+++ b/quickstep/res/values/config.xml
@@ -29,5 +29,5 @@
<!-- Assistant Gesture -->
<integer name="assistant_gesture_min_time_threshold">200</integer>
- <integer name="assistant_gesture_corner_deg_threshold">10</integer>
+ <integer name="assistant_gesture_corner_deg_threshold">20</integer>
</resources>
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index 75959d1..13a0435 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -66,7 +66,7 @@
<!-- Assistant Gestures -->
<dimen name="gestures_assistant_size">48dp</dimen>
- <dimen name="gestures_assistant_drag_threshold">70dp</dimen>
+ <dimen name="gestures_assistant_drag_threshold">55dp</dimen>
<!-- Distance to move elements when swiping up to go home from launcher -->
<dimen name="home_pullback_distance">28dp</dimen>