From bdb090b9fbc568e156a576c453cd1f7e1ee0a988 Mon Sep 17 00:00:00 2001 From: Juan Sebastian Martinez Date: Wed, 29 Jan 2025 11:11:47 -0800 Subject: [PATCH] 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 --- src/com/android/launcher3/util/MSDLPlayerWrapper.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/util/MSDLPlayerWrapper.java b/src/com/android/launcher3/util/MSDLPlayerWrapper.java index 8a1d923709..fc3fa72fb7 100644 --- a/src/com/android/launcher3/util/MSDLPlayerWrapper.java +++ b/src/com/android/launcher3/util/MSDLPlayerWrapper.java @@ -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 */