Using a dedicated thread executor for MSDL haptics

Some interactions have been experiencing delayed hapics (see bug in this
CL) due to haptics firing if a -sometimes- busy background thread. Like
in SysUI, we can avoid this by using a newSingleThreadExector when
firing one-shot MSDL feedback.

Test: manual. Rapidly selected different wallpapers and verified haptics
  played in sync with the UI update.
Flag: com.android.launcher3.msdl_feedback
Bug: 391384092

Change-Id: I1661c85976c4744058e046c7ff8386bb99c6d50b
This commit is contained in:
Juan Sebastian Martinez committed 2025-01-29 11:15:51 -08:00
1 parent e97c7b2a33
commit bdb090b9fb
1 file changed
+3 -3
@@ -16,8 +16,6 @@
package com.android.launcher3.util;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import android.content.Context;
import android.os.Vibrator;
@@ -50,7 +48,9 @@ public class MSDLPlayerWrapper {
@Inject
public MSDLPlayerWrapper(@ApplicationContext Context context) {
Vibrator vibrator = context.getSystemService(Vibrator.class);
mMSDLPlayer = MSDLPlayer.Companion.createPlayer(vibrator, UI_HELPER_EXECUTOR, null);
mMSDLPlayer = MSDLPlayer.Companion.createPlayer(vibrator,
java.util.concurrent.Executors.newSingleThreadExecutor(),
null /* useHapticFeedbackForToken */);
}
/** Perform MSDL feedback for a token with interaction properties */