Skip to content

Commit e4c56d9

Browse files
committed
VibratorService: Fix to ensure actual delay in a vibrate pattern
delay might timeout early as value of duration isn't updated correctly in the loop, should the wait be interrupted, to reflect the elapsed time. Fix is to update duration in the loop. Change-Id: I525b0e97799b288f46ae3a056cff7dcc69701bb0
1 parent dfac68e commit e4c56d9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

services/java/com/android/server/VibratorService.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ private class VibrateThread extends Thread {
441441

442442
private void delay(long duration) {
443443
if (duration > 0) {
444-
long bedtime = SystemClock.uptimeMillis();
444+
long bedtime = duration + SystemClock.uptimeMillis();
445445
do {
446446
try {
447447
this.wait(duration);
@@ -451,8 +451,7 @@ private void delay(long duration) {
451451
if (mDone) {
452452
break;
453453
}
454-
duration = duration
455-
- SystemClock.uptimeMillis() - bedtime;
454+
duration = bedtime - SystemClock.uptimeMillis();
456455
} while (duration > 0);
457456
}
458457
}

0 commit comments

Comments
 (0)