Adding MSDL Feedback when swiping up to reveal overview.

Test: AbsSwipeUpHandlerTestCase
Flag: com.android.launcher3.msdl_feedback
Bug: 376282841

Change-Id: I90a76ea72f87066b9f9d33dda055f99d25249e77
This commit is contained in:
Juan Sebastian Martinez
2024-11-21 15:20:13 -08:00
parent 9899283045
commit ce427bfe16
10 changed files with 58 additions and 14 deletions
@@ -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<MotionEvent> getRecentsViewDispatcher(float navbarRotation) {
@@ -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();
@@ -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);
}
@@ -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));
}
}
@@ -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<RecentsWindowMa
public RecentsWindowSwipeHandler(Context context, RecentsAnimationDeviceState deviceState,
TaskAnimationManager taskAnimationManager, GestureState gestureState, long touchTimeMs,
boolean continuingLastGesture, InputConsumerController inputConsumer,
RecentsWindowFactory recentsWindowFactory) {
RecentsWindowFactory recentsWindowFactory, MSDLPlayerWrapper msdlPlayerWrapper) {
super(context, deviceState, taskAnimationManager, gestureState, touchTimeMs,
continuingLastGesture, inputConsumer, recentsWindowFactory);
continuingLastGesture, inputConsumer, recentsWindowFactory, msdlPlayerWrapper);
mRunningOverHome = mGestureState.getRunningTask() != null
&& mGestureState.getRunningTask().isHomeTask();
@@ -30,7 +30,9 @@ import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import android.animation.ValueAnimator;
@@ -58,14 +60,18 @@ import com.android.launcher3.LauncherRootView;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.statemanager.BaseState;
import com.android.launcher3.statemanager.StatefulContainer;
import com.android.launcher3.util.MSDLPlayerWrapper;
import com.android.launcher3.util.SystemUiController;
import com.android.quickstep.fallback.window.RecentsWindowFactory;
import com.android.quickstep.util.ContextInitListener;
import com.android.quickstep.util.MotionPauseDetector;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.RecentsViewContainer;
import com.android.systemui.shared.Flags;
import com.android.systemui.shared.system.InputConsumerController;
import com.google.android.msdl.data.model.MSDLToken;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -123,6 +129,7 @@ public abstract class AbsSwipeUpHandlerTestCase<
@Mock protected LauncherRootView mRootView;
@Mock protected SystemUiController mSystemUiController;
@Mock protected GestureState mGestureState;
@Mock protected MSDLPlayerWrapper mMSDLPlayerWrapper;
@Rule
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
@@ -305,6 +312,17 @@ public abstract class AbsSwipeUpHandlerTestCase<
});
}
@Test
@EnableFlags(com.android.launcher3.Flags.FLAG_MSDL_FEEDBACK)
public void onMotionPauseDetected_playsSwipeThresholdToken() {
SWIPE_HANDLER handler = createSwipeHandler();
MotionPauseDetector.OnMotionPauseListener listener = handler.getMotionPauseListener();
listener.onMotionPauseDetected();
verify(mMSDLPlayerWrapper, times(1)).playToken(eq(MSDLToken.SWIPE_THRESHOLD_INDICATOR));
verifyNoMoreInteractions(mMSDLPlayerWrapper);
}
/**
* Verifies that RecentsAnimationController#finish() is called, and captures and runs any
* callback that was passed to it. This ensures that STATE_CURRENT_TASK_FINISHED is correctly
@@ -49,7 +49,8 @@ public class FallbackSwipeHandlerTestCase extends AbsSwipeUpHandlerTestCase<
mGestureState,
touchTimeMs,
continuingLastGesture,
mInputConsumerController);
mInputConsumerController,
mMSDLPlayerWrapper);
}
@NonNull
@@ -23,6 +23,7 @@ import com.android.launcher3.R
import com.android.launcher3.dagger.LauncherAppComponent
import com.android.launcher3.dagger.LauncherAppSingleton
import com.android.launcher3.util.LauncherModelHelper
import com.android.launcher3.util.MSDLPlayerWrapper
import com.android.quickstep.dagger.QuickStepModule
import com.android.systemui.contextualeducation.GestureType
import com.android.systemui.shared.system.InputConsumerController
@@ -51,6 +52,8 @@ class LauncherSwipeHandlerV2Test {
@Mock private lateinit var systemUiProxy: SystemUiProxy
@Mock private lateinit var msdlPlayerWrapper: MSDLPlayerWrapper
private lateinit var underTest: LauncherSwipeHandlerV2
@get:Rule val mockitoRule = MockitoJUnit.rule()
@@ -79,6 +82,7 @@ class LauncherSwipeHandlerV2Test {
0,
false,
inputConsumerController,
msdlPlayerWrapper,
)
underTest.onGestureStarted(/* isLikelyToStartNewTask= */ false)
}
@@ -78,7 +78,8 @@ public class LauncherSwipeHandlerV2TestCase extends AbsSwipeUpHandlerTestCase<
mGestureState,
touchTimeMs,
continuingLastGesture,
mInputConsumerController);
mInputConsumerController,
mMSDLPlayerWrapper);
}
@NonNull
@@ -65,7 +65,8 @@ public class RecentsWindowSwipeHandlerTestCase extends AbsSwipeUpHandlerTestCase
touchTimeMs,
continuingLastGesture,
mInputConsumerController,
mRecentsWindowFactory);
mRecentsWindowFactory,
mMSDLPlayerWrapper);
}
@Nullable