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

Commit 1b989de3 authored by Mythri Alle's avatar Mythri Alle
Browse files

Don't enable jdwp by default on userdebug builds

We would like to have userdebug builds as close to user builds as
possible so don't enable jdwp by default on userdebug builds. This
means that we won't be able to attach a debugger to non-debuggable
builds in userdebug builds by default. However, this support can
be enabled by setting persist.debuggable.dalvik.vm.jdwp.enabled
property. Eng builds still enable jdwp by default.

Bug: 240410400
Test: System boots
Change-Id: Iad52254be9b9bc8c9deac8b3ad46e9db1b610160
parent 0075e993
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -1000,17 +1000,25 @@ public final class Zygote {
        }
    }

    /**
     * This will enable jdwp by default for all apps. It is OK to cache this property
     * because we expect to reboot the system whenever this property changes
     */
    private static final boolean ENABLE_JDWP = SystemProperties.get(
                          "persist.debuggable.dalvik.vm.jdwp.enabled").equals("1");

    /**
     * Applies debugger system properties to the zygote arguments.
     *
     * If "ro.debuggable" is "1", all apps are debuggable. Otherwise,
     * the debugger state is specified via the "--enable-jdwp" flag
     * in the spawn request.
     * For eng builds all apps are debuggable. On userdebug and user builds
     * if persist.debuggable.dalvik.vm.jdwp.enabled is 1 all apps are
     * debuggable. Otherwise, the debugger state is specified via the
     * "--enable-jdwp" flag in the spawn request.
     *
     * @param args non-null; zygote spawner args
     */
    static void applyDebuggerSystemProperty(ZygoteArguments args) {
        if (RoSystemProperties.DEBUGGABLE) {
        if (Build.IS_ENG || ENABLE_JDWP) {
            args.mRuntimeFlags |= Zygote.DEBUG_ENABLE_JDWP;
        }
    }