Add support for chained steps to VibrationThread

Change the design of VibrationThread to allow all steps to be played
in a chain. Replace the generation of a predefined list of steps to
represent a combined effect by a design where each step played adds
the next ones to the queue.

This new approach will be necessary to allow mixing and chaining steps
to play composed and waveform effects, which will be required by the
PWLE waveform support.

Bug: 167947076
Test: VibratonThreadTest
Change-Id: I664f7477f7720af14fed963fa479ba38298a027c
This commit is contained in:
Lais Andrade
2021-02-10 19:12:09 +00:00
parent 8d90f15a45
commit 88abcd0d56
2 changed files with 621 additions and 600 deletions

View File

@@ -107,7 +107,8 @@ public class VibrationThreadTest {
waitForCompletion(thread);
verify(mControllerCallbacks, never()).onComplete(anyInt(), eq(vibrationId));
verify(mThreadCallbacks).onVibrationEnded(eq(vibrationId), eq(Vibration.Status.IGNORED));
verify(mThreadCallbacks).onVibrationEnded(eq(vibrationId),
eq(Vibration.Status.IGNORED_UNSUPPORTED));
}
@Test
@@ -121,7 +122,8 @@ public class VibrationThreadTest {
waitForCompletion(thread);
verify(mControllerCallbacks, never()).onComplete(anyInt(), eq(vibrationId));
verify(mThreadCallbacks).onVibrationEnded(eq(vibrationId), eq(Vibration.Status.IGNORED));
verify(mThreadCallbacks).onVibrationEnded(eq(vibrationId),
eq(Vibration.Status.IGNORED_UNSUPPORTED));
}
@Test
@@ -206,8 +208,8 @@ public class VibrationThreadTest {
thread.cancel();
waitForCompletion(thread);
verify(mIBatteryStatsMock, never()).noteVibratorOn(eq(UID), anyLong());
verify(mIBatteryStatsMock, never()).noteVibratorOff(eq(UID));
verify(mIBatteryStatsMock).noteVibratorOn(eq(UID), anyLong());
verify(mIBatteryStatsMock).noteVibratorOff(eq(UID));
verify(mThreadCallbacks).onVibrationEnded(eq(vibrationId), eq(Vibration.Status.CANCELLED));
assertFalse(thread.getVibrators().get(VIBRATOR_ID).isVibrating());