From b063775eb90928ae3b0555025ca6d9c8ba2edebb Mon Sep 17 00:00:00 2001 From: Miranda Kephart Date: Thu, 16 May 2019 16:56:12 -0400 Subject: [PATCH] Pass in fling velocity for gesture progress Calls SystemUIProxy.onGestureCompletion for a completed gesture (either drag or fling) and passes in the velocity (0 for drags). Bug: 132356358 Test: manual Change-Id: I080adc401e19a6141627d1806b425056f7eefcbd --- .../AssistantTouchConsumer.java | 59 ++++++++++++------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java index 20ea3a1694..c864307299 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java @@ -218,31 +218,35 @@ public class AssistantTouchConsumer extends DelegateInputConsumer private void updateAssistantProgress() { if (!mLaunchedAssistant) { mLastProgress = Math.min(mDistance * 1f / mDistThreshold, 1) * mTimeFraction; - updateAssistant(SWIPE); + try { + if (mDistance >= mDistThreshold && mTimeFraction >= 1) { + mSysUiProxy.onAssistantGestureCompletion(0); + startAssistantInternal(SWIPE); + + Bundle args = new Bundle(); + args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE); + mSysUiProxy.startAssistant(args); + mLaunchedAssistant = true; + } else { + mSysUiProxy.onAssistantProgress(mLastProgress); + } + } catch (RemoteException e) { + Log.w(TAG, "Failed to send SysUI start/send assistant progress: " + mLastProgress, + e); + } } } - private void updateAssistant(int gestureType) { - try { - mSysUiProxy.onAssistantProgress(mLastProgress); - if (gestureType == FLING || (mDistance >= mDistThreshold && mTimeFraction >= 1)) { - UserEventDispatcher.newInstance(mContext) - .logActionOnContainer(gestureType, mDirection, NAVBAR); - Bundle args = new Bundle(); - args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE); + private void startAssistantInternal(int gestureType) { + UserEventDispatcher.newInstance(mContext) + .logActionOnContainer(gestureType, mDirection, NAVBAR); - BaseDraggingActivity launcherActivity = mActivityControlHelper.getCreatedActivity(); - if (launcherActivity != null) { - launcherActivity.getRootView().performHapticFeedback( - 13, // HapticFeedbackConstants.GESTURE_END - HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); - } - - mSysUiProxy.startAssistant(args); - mLaunchedAssistant = true; - } - } catch (RemoteException e) { - Log.w(TAG, "Failed to send SysUI start/send assistant progress: " + mLastProgress, e); + BaseDraggingActivity launcherActivity = mActivityControlHelper + .getCreatedActivity(); + if (launcherActivity != null) { + launcherActivity.getRootView().performHapticFeedback( + 13, // HapticFeedbackConstants.GESTURE_END + HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); } } @@ -268,7 +272,18 @@ public class AssistantTouchConsumer extends DelegateInputConsumer public void onDragEnd(float velocity, boolean fling) { if (fling && !mLaunchedAssistant) { mLastProgress = 1; - updateAssistant(FLING); + try { + mSysUiProxy.onAssistantGestureCompletion(velocity); + startAssistantInternal(FLING); + + Bundle args = new Bundle(); + args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE); + mSysUiProxy.startAssistant(args); + mLaunchedAssistant = true; + } catch (RemoteException e) { + Log.w(TAG, "Failed to send SysUI start/send assistant progress: " + mLastProgress, + e); + } } } }