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

Commit 96d6c345 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick Committed by Android (Google) Code Review
Browse files

Merge "Unify some duplicate StrictMode-enabling code." into gingerbread

parents fb85bc66 50d66f9f
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -3107,18 +3107,11 @@ public final class ActivityThread {
        /**
         * For system applications on userdebug/eng builds, log stack
         * traces of disk and network access to dropbox for analysis.
         *
         * Similar logic exists in SystemServer.java.
         */
        if ((data.appInfo.flags &
             (ApplicationInfo.FLAG_SYSTEM |
              ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0 &&
            !"user".equals(Build.TYPE)) {
            StrictMode.setThreadPolicy(
                StrictMode.DISALLOW_DISK_WRITE |
                StrictMode.DISALLOW_DISK_READ |
                StrictMode.DISALLOW_NETWORK |
                StrictMode.PENALTY_DROPBOX);
              ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0) {
            StrictMode.conditionallyEnableDebugLogging();
        }

        /**
+19 −0
Original line number Diff line number Diff line
@@ -200,6 +200,25 @@ public final class StrictMode {
        return oldPolicy;
    }

    /**
     * Enable DropBox logging for debug phone builds.
     *
     * @hide
     */
    public static boolean conditionallyEnableDebugLogging() {
        // For debug builds, log event loop stalls to dropbox for analysis.
        // Similar logic also appears in ActivityThread.java for system apps.
        if ("user".equals(Build.TYPE)) {
            return false;
        }
        StrictMode.setThreadPolicy(
            StrictMode.DISALLOW_DISK_WRITE |
            StrictMode.DISALLOW_DISK_READ |
            StrictMode.DISALLOW_NETWORK |
            StrictMode.PENALTY_DROPBOX);
        return true;
    }

    /**
     * Parses the BlockGuard policy mask out from the Exception's
     * getMessage() String value.  Kinda gross, but least
+2 −8
Original line number Diff line number Diff line
@@ -518,14 +518,8 @@ class ServerThread extends Thread {
        });

        // For debug builds, log event loop stalls to dropbox for analysis.
        // Similar logic also appears in ActivityThread.java for system apps.
        if (!"user".equals(Build.TYPE)) {
            Slog.i(TAG, "Enabling StrictMode for system server.");
            StrictMode.setThreadPolicy(
                StrictMode.DISALLOW_DISK_WRITE |
                StrictMode.DISALLOW_DISK_READ |
                StrictMode.DISALLOW_NETWORK |
                StrictMode.PENALTY_DROPBOX);
        if (StrictMode.conditionallyEnableDebugLogging()) {
            Slog.i(TAG, "Enabled StrictMode for system server main thread.");
        }

        Looper.loop();