Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 28a24306 authored by Schneider Victor-tulias's avatar Schneider Victor-tulias
Browse files

Fix jank when launching the All set page on devices that support vibrations

Moving haptics from the all set page background animation to the UI helper thread to reduce jank when launching the all set page from SUW.

Bug: 195711508
Test: manual with pixel 6 pro
Change-Id: Icca17a79161f177e3549dd780bfe9b78aa59fe51
parent 8a7617f1
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import androidx.core.graphics.ColorUtils;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.util.Executors;
import com.android.quickstep.AnimatedFloat;
import com.android.quickstep.GestureState;
import com.android.quickstep.TouchInteractionService.TISBinder;
@@ -136,6 +137,10 @@ public class AllSetActivity extends Activity {
        startBackgroundAnimation();
    }

    private void runOnUiHelperThread(Runnable runnable) {
        Executors.UI_HELPER_EXECUTOR.execute(runnable);
    }

    private void startBackgroundAnimation() {
        if (Utilities.ATLEAST_S && mVibrator != null && mVibrator.areAllPrimitivesSupported(
                VibrationEffect.Composition.PRIMITIVE_THUD)) {
@@ -144,22 +149,22 @@ public class AllSetActivity extends Activity {
                        new Animator.AnimatorListener() {
                            @Override
                            public void onAnimationStart(Animator animation) {
                                mVibrator.vibrate(getVibrationEffect());
                                runOnUiHelperThread(() -> mVibrator.vibrate(getVibrationEffect()));
                            }

                            @Override
                            public void onAnimationRepeat(Animator animation) {
                                mVibrator.vibrate(getVibrationEffect());
                                runOnUiHelperThread(() -> mVibrator.vibrate(getVibrationEffect()));
                            }

                            @Override
                            public void onAnimationEnd(Animator animation) {
                                mVibrator.cancel();
                                runOnUiHelperThread(mVibrator::cancel);
                            }

                            @Override
                            public void onAnimationCancel(Animator animation) {
                                mVibrator.cancel();
                                runOnUiHelperThread(mVibrator::cancel);
                            }
                        };
            }