From 24f1076097588b7db1269044fb55af58bc420e58 Mon Sep 17 00:00:00 2001 From: Patrick Scott Date: Wed, 19 Aug 2009 09:03:56 -0400 Subject: [PATCH] Check for a timeout <= 0 before adding the vibration. A timeout of 0 could cause the vibration thread to run with a null pattern and crash the system server. Instead, we should just ignore vibrations that don't make any sense (similar to ignoring a bad pattern vibration). --- services/java/com/android/server/HardwareService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/java/com/android/server/HardwareService.java b/services/java/com/android/server/HardwareService.java index 7597f851e3a6e..6ac72e0d57c81 100755 --- a/services/java/com/android/server/HardwareService.java +++ b/services/java/com/android/server/HardwareService.java @@ -141,8 +141,11 @@ public class HardwareService extends IHardwareService.Stub { != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires VIBRATE permission"); } - if (mCurrentVibration != null - && mCurrentVibration.hasLongerTimeout(milliseconds)) { + // We're running in the system server so we cannot crash. Check for a + // timeout of 0 or negative. This will ensure that a vibration has + // either a timeout of > 0 or a non-null pattern. + if (milliseconds <= 0 || (mCurrentVibration != null + && mCurrentVibration.hasLongerTimeout(milliseconds))) { // Ignore this vibration since the current vibration will play for // longer than milliseconds. return;