Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9199d0c1 authored by Michael Wright's avatar Michael Wright
Browse files

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
parent 47bf1b33
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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;