Fix Vibrator permission CTS test broken earlier.
Bug: 3106964
Change-Id: I76138780ac64f761fe09ef8ba74382c7ee05d794
diff --git a/core/java/android/os/Vibrator.java b/core/java/android/os/Vibrator.java
index 58ed986..be818da 100644
--- a/core/java/android/os/Vibrator.java
+++ b/core/java/android/os/Vibrator.java
@@ -50,7 +50,7 @@
}
try {
mService.vibrate(milliseconds, mToken);
- } catch (Exception e) {
+ } catch (RemoteException e) {
Log.w(TAG, "Failed to vibrate.", e);
}
}
@@ -80,7 +80,7 @@
if (repeat < pattern.length) {
try {
mService.vibratePattern(pattern, repeat, mToken);
- } catch (Exception e) {
+ } catch (RemoteException e) {
Log.w(TAG, "Failed to vibrate.", e);
}
} else {
diff --git a/core/java/com/android/internal/app/ShutdownThread.java b/core/java/com/android/internal/app/ShutdownThread.java
index 1fcd654..b7255bb 100644
--- a/core/java/com/android/internal/app/ShutdownThread.java
+++ b/core/java/com/android/internal/app/ShutdownThread.java
@@ -360,7 +360,13 @@
} else if (SHUTDOWN_VIBRATE_MS > 0) {
// vibrate before shutting down
Vibrator vibrator = new Vibrator();
- vibrator.vibrate(SHUTDOWN_VIBRATE_MS);
+ try {
+ vibrator.vibrate(SHUTDOWN_VIBRATE_MS);
+ } catch (Exception e) {
+ // Failure to vibrate shouldn't interrupt shutdown. Just log it.
+ Log.w(TAG, "Failed to vibrate during shutdown.", e);
+ }
+
// vibrator is asynchronous so we need to wait to avoid shutting down too soon.
try {
Thread.sleep(SHUTDOWN_VIBRATE_MS);