From 2edbe235136c0f4f95f90672563f8ba412d25f2d Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Wed, 18 May 2022 10:29:10 -0700 Subject: [PATCH] Update vibrations in the All set page to match the SUW welcome page. Fixes: 211844049 Test: opened the all set page on different devices, tested with different supported vibration effects Change-Id: I0b86dae3bec28ff56a3a23f9bb65dcbdb1b27325 --- .../quickstep/interaction/AllSetActivity.java | 79 ++++++++++--------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java index 3dab6162b3..b73f52decd 100644 --- a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java +++ b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java @@ -149,45 +149,50 @@ public class AllSetActivity extends Activity { } private void startBackgroundAnimation() { - if (Utilities.ATLEAST_S && mVibrator != null && mVibrator.areAllPrimitivesSupported( - VibrationEffect.Composition.PRIMITIVE_THUD)) { - if (mBackgroundAnimatorListener == null) { - mBackgroundAnimatorListener = - new Animator.AnimatorListener() { - @Override - public void onAnimationStart(Animator animation) { - runOnUiHelperThread(() -> mVibrator.vibrate(getVibrationEffect())); - } - - @Override - public void onAnimationRepeat(Animator animation) { - runOnUiHelperThread(() -> mVibrator.vibrate(getVibrationEffect())); - } - - @Override - public void onAnimationEnd(Animator animation) { - runOnUiHelperThread(mVibrator::cancel); - } - - @Override - public void onAnimationCancel(Animator animation) { - runOnUiHelperThread(mVibrator::cancel); - } - }; - } - mAnimatedBackground.addAnimatorListener(mBackgroundAnimatorListener); + if (!Utilities.ATLEAST_S || mVibrator == null) { + return; } - mAnimatedBackground.playAnimation(); - } + boolean supportsThud = mVibrator.areAllPrimitivesSupported( + VibrationEffect.Composition.PRIMITIVE_THUD); - /** - * Sets up the vibration effect for the next round of animation. The parameters vary between - * different illustrations. - */ - private VibrationEffect getVibrationEffect() { - return VibrationEffect.startComposition() - .addPrimitive(VibrationEffect.Composition.PRIMITIVE_THUD, 1.0f, 50) - .compose(); + if (!supportsThud && !mVibrator.areAllPrimitivesSupported( + VibrationEffect.Composition.PRIMITIVE_TICK)) { + return; + } + if (mBackgroundAnimatorListener == null) { + VibrationEffect vibrationEffect = VibrationEffect.startComposition() + .addPrimitive(supportsThud + ? VibrationEffect.Composition.PRIMITIVE_THUD + : VibrationEffect.Composition.PRIMITIVE_TICK, + /* scale= */ 1.0f, + /* delay= */ 50) + .compose(); + + mBackgroundAnimatorListener = + new Animator.AnimatorListener() { + @Override + public void onAnimationStart(Animator animation) { + runOnUiHelperThread(() -> mVibrator.vibrate(vibrationEffect)); + } + + @Override + public void onAnimationRepeat(Animator animation) { + runOnUiHelperThread(() -> mVibrator.vibrate(vibrationEffect)); + } + + @Override + public void onAnimationEnd(Animator animation) { + runOnUiHelperThread(mVibrator::cancel); + } + + @Override + public void onAnimationCancel(Animator animation) { + runOnUiHelperThread(mVibrator::cancel); + } + }; + } + mAnimatedBackground.addAnimatorListener(mBackgroundAnimatorListener); + mAnimatedBackground.playAnimation(); } @Override