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
This commit is contained in:
@@ -441,7 +441,7 @@ public class VibratorService extends IVibratorService.Stub
|
||||
|
||||
private void delay(long duration) {
|
||||
if (duration > 0) {
|
||||
long bedtime = SystemClock.uptimeMillis();
|
||||
long bedtime = duration + SystemClock.uptimeMillis();
|
||||
do {
|
||||
try {
|
||||
this.wait(duration);
|
||||
@@ -451,8 +451,7 @@ public class VibratorService extends IVibratorService.Stub
|
||||
if (mDone) {
|
||||
break;
|
||||
}
|
||||
duration = duration
|
||||
- SystemClock.uptimeMillis() - bedtime;
|
||||
duration = bedtime - SystemClock.uptimeMillis();
|
||||
} while (duration > 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user