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

Commit bc6f0ce8 authored by Christopher Tate's avatar Christopher Tate
Browse files

Add persistent property to disable strict mode

Setting persist.sys.strictmode.disable to 'true' will disable strict
mode on eng/userdebug builds where it is turned on by default.
Explicitly enabling it in the Settings UI will override this, so
it's still possible to toggle it there even when this property
has been set on the device.

Change-Id: Ifd971f948fb2f803d509c2a06112c4bb932a5b1f
parent 236aea35
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -115,6 +115,14 @@ public final class StrictMode {
    private static final boolean IS_USER_BUILD = "user".equals(Build.TYPE);
    private static final boolean IS_ENG_BUILD = "eng".equals(Build.TYPE);

    /**
     * Boolean system property to disable strict mode checks outright.
     * Set this to 'true' to force disable; 'false' has no effect on other
     * enable/disable policy.
     * @hide
     */
    public static final String DISABLE_PROPERTY = "persist.sys.strictmode.disable";

    /**
     * The boolean system property to control screen flashes on violations.
     *
@@ -891,16 +899,24 @@ public final class StrictMode {
     * @hide
     */
    public static boolean conditionallyEnableDebugLogging() {
        boolean doFlashes = !amTheSystemServerProcess() &&
                SystemProperties.getBoolean(VISUAL_PROPERTY, IS_ENG_BUILD);
        boolean doFlashes = SystemProperties.getBoolean(VISUAL_PROPERTY, false)
                && !amTheSystemServerProcess();
        final boolean suppress = SystemProperties.getBoolean(DISABLE_PROPERTY, false);

        // For debug builds, log event loop stalls to dropbox for analysis.
        // Similar logic also appears in ActivityThread.java for system apps.
        if (IS_USER_BUILD && !doFlashes) {
        if (!doFlashes && (IS_USER_BUILD || suppress)) {
            setCloseGuardEnabled(false);
            return false;
        }

        // Eng builds have flashes on all the time.  The suppression property
        // overrides this, so we force the behavior only after the short-circuit
        // check above.
        if (IS_ENG_BUILD) {
            doFlashes = true;
        }

        // Thread policy controls BlockGuard.
        int threadPolicyMask = StrictMode.DETECT_DISK_WRITE |
                StrictMode.DETECT_DISK_READ |