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

Commit 74ce8b3b authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

persist.sys.boot.reason is cleared once read by bootstat

To ensure a surprise reboot does not take the last boot reason on
face value especially if coming from more than one boot sessions ago.
We shift and clear the value from persist.sys.boot.reason to
sys.boot.reason.last and establish a correct last reboot reason in
the canonical sys.boot.reason property.  As a result, the power
manager should read the canonical sys.boot.reason for a definitive
result rather than relying on the possibly incorrect values in the
persistent storage.

The value in sys.boot.reason is not valid until bootstat has
signaled boot complete.

Test: compile
Bug: 86671991
Bug: 63736262
Change-Id: I80b3602821678f0cececf28b727c06135bf94960
parent 13cb6084
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -220,8 +220,8 @@ public final class PowerManagerService extends SystemService
    private static final int HALT_MODE_REBOOT = 1;
    private static final int HALT_MODE_REBOOT_SAFE_MODE = 2;

    // Persistent property for last reboot reason
    private static final String LAST_REBOOT_PROPERTY = "persist.sys.boot.reason";
    // property for last reboot reason
    private static final String REBOOT_PROPERTY = "sys.boot.reason";

    private final Context mContext;
    private final ServiceThread mHandlerThread;
@@ -4402,7 +4402,7 @@ public final class PowerManagerService extends SystemService

            final long ident = Binder.clearCallingIdentity();
            try {
                return getLastShutdownReasonInternal(LAST_REBOOT_PROPERTY);
                return getLastShutdownReasonInternal(REBOOT_PROPERTY);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }