diff options
| author | 2010-10-15 08:51:01 -0700 | |
|---|---|---|
| committer | 2010-10-15 08:51:01 -0700 | |
| commit | 33476b2db82b5a7f025eb9625fa56f94290e97f4 (patch) | |
| tree | 36bf9ffb7dd1284bb69f05a7cf4528a6df765bbe | |
| parent | 5f0cbfcecc4db20f897507c826296b3aac70c592 (diff) | |
| parent | feebaf35c0edaed87edc6eb33a33ad9df1a209d6 (diff) | |
am feebaf35: Merge "Don\'t crash on null Vibrator during reboot." into gingerbread
Merge commit 'feebaf35c0edaed87edc6eb33a33ad9df1a209d6' into gingerbread-plus-aosp
* commit 'feebaf35c0edaed87edc6eb33a33ad9df1a209d6':
Don't crash on null Vibrator during reboot.
| -rw-r--r-- | core/java/android/os/Vibrator.java | 22 | ||||
| -rw-r--r-- | core/java/com/android/internal/app/ShutdownThread.java | 2 |
2 files changed, 21 insertions, 3 deletions
diff --git a/core/java/android/os/Vibrator.java b/core/java/android/os/Vibrator.java index 1895cf83650c..58ed986ebe45 100644 --- a/core/java/android/os/Vibrator.java +++ b/core/java/android/os/Vibrator.java @@ -16,6 +16,8 @@ package android.os; +import android.util.Log; + /** * Class that operates the vibrator on the device. * <p> @@ -23,6 +25,8 @@ package android.os; */ public class Vibrator { + private static final String TAG = "Vibrator"; + IVibratorService mService; private final Binder mToken = new Binder(); @@ -40,9 +44,14 @@ public class Vibrator */ public void vibrate(long milliseconds) { + if (mService == null) { + Log.w(TAG, "Failed to vibrate; no vibrator service."); + return; + } try { mService.vibrate(milliseconds, mToken); - } catch (RemoteException e) { + } catch (Exception e) { + Log.w(TAG, "Failed to vibrate.", e); } } @@ -61,13 +70,18 @@ public class Vibrator */ public void vibrate(long[] pattern, int repeat) { + if (mService == null) { + Log.w(TAG, "Failed to vibrate; no vibrator service."); + return; + } // catch this here because the server will do nothing. pattern may // not be null, let that be checked, because the server will drop it // anyway if (repeat < pattern.length) { try { mService.vibratePattern(pattern, repeat, mToken); - } catch (RemoteException e) { + } catch (Exception e) { + Log.w(TAG, "Failed to vibrate.", e); } } else { throw new ArrayIndexOutOfBoundsException(); @@ -79,9 +93,13 @@ public class Vibrator */ public void cancel() { + if (mService == null) { + return; + } try { mService.cancelVibrate(mToken); } catch (RemoteException e) { + Log.w(TAG, "Failed to cancel vibration.", e); } } } diff --git a/core/java/com/android/internal/app/ShutdownThread.java b/core/java/com/android/internal/app/ShutdownThread.java index 0c2928a50d10..bdca8414ccb7 100644 --- a/core/java/com/android/internal/app/ShutdownThread.java +++ b/core/java/com/android/internal/app/ShutdownThread.java @@ -381,7 +381,7 @@ public final class ShutdownThread extends Thread { // vibrator is asynchronous so we need to wait to avoid shutting down too soon. try { Thread.sleep(SHUTDOWN_VIBRATE_MS); - } catch (InterruptedException e) { + } catch (InterruptedException unused) { } } |