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

Commit ee2b4928 authored by Sami Tolvanen's avatar Sami Tolvanen
Browse files

Support persist.sys.audit_safemode

Don't leave safe more if persist.sys.audit_safemode is set, unless the
current build date is newer than the specified value.

This allows us to keep the device in safe mode across reboots until an
OTA has been applied or user data is wiped.

Bug: 26902605
Change-Id: I781c3059ea8d4fb2f0c923e4488b1932d69678d3
parent 9f935241
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -96,6 +96,9 @@ public final class ShutdownThread extends Thread {
    // Indicates whether we are rebooting into safe mode
    public static final String REBOOT_SAFEMODE_PROPERTY = "persist.sys.safemode";

    // Indicates whether we should stay in safe mode until ro.build.date.utc is newer than this
    public static final String AUDIT_SAFEMODE_PROPERTY = "persist.sys.audit_safemode";

    // static instance of this thread
    private static final ShutdownThread sInstance = new ShutdownThread();

+18 −2
Original line number Diff line number Diff line
@@ -305,6 +305,8 @@ public class WindowManagerService extends IWindowManager.Stub

    private static final String PROPERTY_EMULATOR_CIRCULAR = "ro.emulator.circular";

    private static final String PROPERTY_BUILD_DATE_UTC = "ro.build.date.utc";

    final private KeyguardDisableHandler mKeyguardDisableHandler;

    final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@@ -7629,8 +7631,22 @@ public class WindowManagerService extends IWindowManager.Stub
                || volumeDownState > 0;
        try {
            if (SystemProperties.getInt(ShutdownThread.REBOOT_SAFEMODE_PROPERTY, 0) != 0) {
                int auditSafeMode = SystemProperties.getInt(ShutdownThread.AUDIT_SAFEMODE_PROPERTY, 0);

                if (auditSafeMode == 0) {
                    mSafeMode = true;
                    SystemProperties.set(ShutdownThread.REBOOT_SAFEMODE_PROPERTY, "");
                } else {
                    // stay in safe mode until we have updated to a newer build
                    int buildDate = SystemProperties.getInt(PROPERTY_BUILD_DATE_UTC, 0);

                    if (auditSafeMode >= buildDate) {
                        mSafeMode = true;
                    } else {
                        SystemProperties.set(ShutdownThread.REBOOT_SAFEMODE_PROPERTY, "");
                        SystemProperties.set(ShutdownThread.AUDIT_SAFEMODE_PROPERTY, "");
                    }
                }
            }
        } catch (IllegalArgumentException e) {
        }