summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nikolas Havrikov <havrikov@google.com> 2023-04-12 12:42:28 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2023-04-12 12:42:28 +0000
commit4470759568d989a0256e2b38ebf99cd854a33caf (patch)
tree2b5464fa421ec10a2be1be86aa2d07c65509ee70
parent8a308008b214a08e3d263181d7a22aee9d0698a6 (diff)
parent844c5aec4826d6e12e6f25546a2cdd5b73205f2c (diff)
Merge "Only wait for successful vibration" into udc-dev am: 844c5aec48
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22426052 Change-Id: I5fc4b623ac5f7885b40a8ca733ffd62b8e4b138c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--services/core/java/com/android/server/power/ShutdownThread.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/power/ShutdownThread.java b/services/core/java/com/android/server/power/ShutdownThread.java
index c2d4ac694c39..b1430e7138e7 100644
--- a/services/core/java/com/android/server/power/ShutdownThread.java
+++ b/services/core/java/com/android/server/power/ShutdownThread.java
@@ -703,17 +703,20 @@ public final class ShutdownThread extends Thread {
// vibrate before shutting down
Vibrator vibrator = new SystemVibrator(context);
try {
- vibrator.vibrate(SHUTDOWN_VIBRATE_MS, VIBRATION_ATTRIBUTES);
+ if (vibrator.hasVibrator()) {
+ vibrator.vibrate(SHUTDOWN_VIBRATE_MS, VIBRATION_ATTRIBUTES);
+ // vibrator is asynchronous so we need to wait to avoid shutting down too soon.
+ try {
+ Thread.sleep(SHUTDOWN_VIBRATE_MS);
+ } catch (InterruptedException unused) {
+ // this is not critical and does not require logging
+ }
+ }
} 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);
- } catch (InterruptedException unused) {
- }
}
// Shutdown power
Log.i(TAG, "Performing low-level shutdown...");