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
This commit is contained in:
Ahmad Khalil
2023-07-13 10:24:04 +00:00
parent c2e0258630
commit de483500f4

View File

@@ -167,7 +167,9 @@ final class SetAmplitudeVibratorStep extends AbstractVibratorStep {
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();