From ce427bfe1657307b29e623f0873cdffef832b7fd Mon Sep 17 00:00:00 2001 From: Juan Sebastian Martinez Date: Thu, 21 Nov 2024 15:20:13 -0800 Subject: [PATCH] Adding MSDL Feedback when swiping up to reveal overview. Test: AbsSwipeUpHandlerTestCase Flag: com.android.launcher3.msdl_feedback Bug: 376282841 Change-Id: I90a76ea72f87066b9f9d33dda055f99d25249e77 --- .../android/quickstep/AbsSwipeUpHandler.java | 17 +++++++++++++++-- .../quickstep/FallbackSwipeHandler.java | 6 ++++-- .../quickstep/LauncherSwipeHandlerV2.java | 6 ++++-- .../quickstep/TouchInteractionService.java | 7 ++++--- .../window/RecentsWindowSwipeHandler.java | 5 +++-- .../quickstep/AbsSwipeUpHandlerTestCase.java | 18 ++++++++++++++++++ .../FallbackSwipeHandlerTestCase.java | 3 ++- .../quickstep/LauncherSwipeHandlerV2Test.kt | 4 ++++ .../LauncherSwipeHandlerV2TestCase.java | 3 ++- .../RecentsWindowSwipeHandlerTestCase.java | 3 ++- 10 files changed, 58 insertions(+), 14 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 39f9f8575f..cebe246724 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -33,6 +33,7 @@ import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAG import static com.android.launcher3.Flags.enableAdditionalHomeAnimations; import static com.android.launcher3.Flags.enableGridOnlyOverview; import static com.android.launcher3.Flags.enableScalingRevealHomeAnimation; +import static com.android.launcher3.Flags.msdlFeedback; import static com.android.launcher3.PagedView.INVALID_PAGE; import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE; @@ -121,6 +122,7 @@ import com.android.launcher3.taskbar.TaskbarThresholdUtils; import com.android.launcher3.taskbar.TaskbarUIController; import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.launcher3.util.DisplayController; +import com.android.launcher3.util.MSDLPlayerWrapper; import com.android.launcher3.util.SafeCloseable; import com.android.launcher3.util.TraceHelper; import com.android.launcher3.util.VibratorWrapper; @@ -164,6 +166,8 @@ import com.android.wm.shell.shared.TransactionPool; import com.android.wm.shell.shared.desktopmode.DesktopModeStatus; import com.android.wm.shell.shared.startingsurface.SplashScreenExitAnimationUtils; +import com.google.android.msdl.data.model.MSDLToken; + import kotlin.Unit; import java.util.ArrayList; @@ -362,10 +366,13 @@ public abstract class AbsSwipeUpHandler< @Nullable private RemoteAnimationTargets.ReleaseCheck mSwipePipToHomeReleaseCheck = null; + private final MSDLPlayerWrapper mMSDLPlayerWrapper; + public AbsSwipeUpHandler(Context context, RecentsAnimationDeviceState deviceState, TaskAnimationManager taskAnimationManager, GestureState gestureState, long touchTimeMs, boolean continuingLastGesture, - InputConsumerController inputConsumer, RecentsWindowFactory recentsWindowFactory) { + InputConsumerController inputConsumer, RecentsWindowFactory recentsWindowFactory, + MSDLPlayerWrapper msdlPlayerWrapper) { super(context, deviceState, gestureState); mContainerInterface = gestureState.getContainerInterface(); mContextInitListener = @@ -392,6 +399,8 @@ public abstract class AbsSwipeUpHandler< mSplashMainWindowShiftLength = -res .getDimensionPixelSize(R.dimen.starting_surface_exit_animation_window_shift_length); + mMSDLPlayerWrapper = msdlPlayerWrapper; + initTransitionEndpoints(mRemoteTargetHandles[0].getTaskViewSimulator() .getOrientationState().getLauncherDeviceProfile()); initStateCallbacks(); @@ -2272,7 +2281,11 @@ public abstract class AbsSwipeUpHandler< } protected void performHapticFeedback() { - VibratorWrapper.INSTANCE.get(mContext).vibrate(OVERVIEW_HAPTIC); + if (msdlFeedback()) { + mMSDLPlayerWrapper.playToken(MSDLToken.SWIPE_THRESHOLD_INDICATOR); + } else { + VibratorWrapper.INSTANCE.get(mContext).vibrate(OVERVIEW_HAPTIC); + } } public Consumer getRecentsViewDispatcher(float navbarRotation) { diff --git a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java index 9b56fd40b8..b0c69cff84 100644 --- a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java @@ -62,6 +62,7 @@ import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.anim.SpringAnimationBuilder; import com.android.launcher3.states.StateAnimationConfig; import com.android.launcher3.util.DisplayController; +import com.android.launcher3.util.MSDLPlayerWrapper; import com.android.quickstep.fallback.FallbackRecentsView; import com.android.quickstep.fallback.RecentsState; import com.android.quickstep.util.RectFSpringAnim; @@ -102,9 +103,10 @@ public class FallbackSwipeHandler extends public FallbackSwipeHandler(Context context, RecentsAnimationDeviceState deviceState, TaskAnimationManager taskAnimationManager, GestureState gestureState, long touchTimeMs, - boolean continuingLastGesture, InputConsumerController inputConsumer) { + boolean continuingLastGesture, InputConsumerController inputConsumer, + MSDLPlayerWrapper msdlPlayerWrapper) { super(context, deviceState, taskAnimationManager, gestureState, touchTimeMs, - continuingLastGesture, inputConsumer, null); + continuingLastGesture, inputConsumer, null, msdlPlayerWrapper); mRunningOverHome = mGestureState.getRunningTask() != null && mGestureState.getRunningTask().isHomeTask(); diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java index 6087dc214e..0ddd87bb1c 100644 --- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java +++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java @@ -41,6 +41,7 @@ import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.states.StateAnimationConfig; import com.android.launcher3.uioverrides.QuickstepLauncher; +import com.android.launcher3.util.MSDLPlayerWrapper; import com.android.launcher3.util.StableViewInfo; import com.android.launcher3.views.ClipIconView; import com.android.launcher3.views.FloatingIconView; @@ -67,9 +68,10 @@ public class LauncherSwipeHandlerV2 extends AbsSwipeUpHandler< public LauncherSwipeHandlerV2(Context context, RecentsAnimationDeviceState deviceState, TaskAnimationManager taskAnimationManager, GestureState gestureState, long touchTimeMs, - boolean continuingLastGesture, InputConsumerController inputConsumer) { + boolean continuingLastGesture, InputConsumerController inputConsumer, + MSDLPlayerWrapper msdlPlayerWrapper) { super(context, deviceState, taskAnimationManager, gestureState, touchTimeMs, - continuingLastGesture, inputConsumer, null); + continuingLastGesture, inputConsumer, null, msdlPlayerWrapper); } diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 564f9a2a77..4ddbcdb4e1 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -83,6 +83,7 @@ import com.android.launcher3.testing.shared.ResourceUtils; import com.android.launcher3.testing.shared.TestProtocol; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.LockedUserState; +import com.android.launcher3.util.MSDLPlayerWrapper; import com.android.launcher3.util.NavigationMode; import com.android.launcher3.util.PluginManagerWrapper; import com.android.launcher3.util.SafeCloseable; @@ -1274,20 +1275,20 @@ public class TouchInteractionService extends Service { GestureState gestureState, long touchTimeMs) { return new LauncherSwipeHandlerV2(this, mDeviceState, mTaskAnimationManager, gestureState, touchTimeMs, mTaskAnimationManager.isRecentsAnimationRunning(), - mInputConsumer); + mInputConsumer, MSDLPlayerWrapper.INSTANCE.get(this)); } private AbsSwipeUpHandler createFallbackSwipeHandler( GestureState gestureState, long touchTimeMs) { return new FallbackSwipeHandler(this, mDeviceState, mTaskAnimationManager, gestureState, touchTimeMs, mTaskAnimationManager.isRecentsAnimationRunning(), - mInputConsumer); + mInputConsumer, MSDLPlayerWrapper.INSTANCE.get(this)); } private AbsSwipeUpHandler createRecentsWindowSwipeHandler( GestureState gestureState, long touchTimeMs) { return new RecentsWindowSwipeHandler(this, mDeviceState, mTaskAnimationManager, gestureState, touchTimeMs, mTaskAnimationManager.isRecentsAnimationRunning(), - mInputConsumer, mRecentsWindowFactory); + mInputConsumer, mRecentsWindowFactory, MSDLPlayerWrapper.INSTANCE.get(this)); } } diff --git a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java index ea1d21bcab..4a08d12218 100644 --- a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java @@ -62,6 +62,7 @@ import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.anim.SpringAnimationBuilder; import com.android.launcher3.states.StateAnimationConfig; import com.android.launcher3.util.DisplayController; +import com.android.launcher3.util.MSDLPlayerWrapper; import com.android.quickstep.AbsSwipeUpHandler; import com.android.quickstep.GestureState; import com.android.quickstep.RecentsAnimationController; @@ -110,9 +111,9 @@ public class RecentsWindowSwipeHandler extends AbsSwipeUpHandler