commit | de483500f435e94099bb59db979c820d299713a3 | [log] [tgz] |
---|---|---|
author | Ahmad Khalil <khalilahmad@google.com> | Thu Jul 13 10:24:04 2023 +0000 |
committer | Ahmad Khalil <khalilahmad@google.com> | Thu Jul 13 10:24:07 2023 +0000 |
tree | 22a32736419509389440fba3b50ef36dad685584 | |
parent | c2e02586308b54ca57b7c0ada2d162bd1a091bc8 [diff] |
Fix vibration patterns with zero duration steps. SetAmplitudeVibratorStep is skipping the zero duration steps, so getVibratorOnDuration should also skip those steps to avoid breaking down the vibration pattern. Bug: 287549459 Merged-In: I49874c64e8fe0f0a31adca023fe7273e32149a9b Change-Id: I49874c64e8fe0f0a31adca023fe7273e32149a9b
diff --git a/services/core/java/com/android/server/vibrator/SetAmplitudeVibratorStep.java b/services/core/java/com/android/server/vibrator/SetAmplitudeVibratorStep.java index 6fb9111..959b94b 100644 --- a/services/core/java/com/android/server/vibrator/SetAmplitudeVibratorStep.java +++ b/services/core/java/com/android/server/vibrator/SetAmplitudeVibratorStep.java
@@ -167,7 +167,9 @@ while (i < segmentCount) { VibrationEffectSegment segment = segments.get(i); if (!(segment instanceof StepSegment) - || ((StepSegment) segment).getAmplitude() == 0) { + // play() will ignore segments with zero duration, so it's important that + // zero-duration segments don't affect this method. + || (segment.getDuration() > 0 && ((StepSegment) segment).getAmplitude() == 0)) { break; } timing += segment.getDuration();