summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Michael Wright <michaelwr@google.com> 2017-05-10 21:35:13 +0100
committer Michael Wright <michaelwr@google.com> 2017-05-10 21:38:59 +0100
commit9199d0c1ffed3ff3e10c3e20fd7efad10798dc9a (patch)
tree100792da7bf5c8eb28651e3b9e0365bd69998b04
parent47bf1b334a24f719c8ede8145dda4d866c804dac (diff)
Avoid NPE when getting last shutdown reason.
This can be null if there is a file but it's totally empty, and the switch statement will throw an NPE when switching on a null string (thanks Java!) Bug: 38195795 Test: none Change-Id: I86901e001b088a4a9b14f15c82b763e12d11875f
-rw-r--r--services/core/java/com/android/server/power/PowerManagerService.java3
1 files changed, 3 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index 423bc0cc7884..a8d19e94dea5 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -4607,6 +4607,9 @@ public final class PowerManagerService extends SystemService
} catch (IOException e) {
Slog.e(TAG, "Failed to read last_reboot_reason file", e);
}
+ if (line == null) {
+ return PowerManager.SHUTDOWN_REASON_UNKNOWN;
+ }
switch (line) {
case REASON_SHUTDOWN:
return PowerManager.SHUTDOWN_REASON_SHUTDOWN;