From 0fc653c307807c41fbc876b3c117427de687e1c2 Mon Sep 17 00:00:00 2001 From: Mythri Alle Date: Thu, 15 Sep 2022 11:16:32 +0000 Subject: [PATCH] Reland "Don't enable jdwp by default on userdebug builds"" This reverts commit 50c258ca377f7a1e5494583d0e24e895e431bd1e. Reason for revert: Relanding after fixes for the failures Fixes: 1. Mark the com.android.perftests.core as profileable from shell so that we would be able to read /proc/self/io 2. Fix a JDWP test to expect the new behaviour on userdebug builds. We can no longer attach debugger on profileable apps on userdebug builds Bug: 240410400, 246616689 Test: System boots Change-Id: I6fff6f1a683893244bc2d40f930044747befb2ce --- apct-tests/perftests/core/AndroidManifest.xml | 1 + core/java/com/android/internal/os/Zygote.java | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/apct-tests/perftests/core/AndroidManifest.xml b/apct-tests/perftests/core/AndroidManifest.xml index 56fa70cfc2207..039548035f35f 100644 --- a/apct-tests/perftests/core/AndroidManifest.xml +++ b/apct-tests/perftests/core/AndroidManifest.xml @@ -15,6 +15,7 @@ + diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java index b1e7d15cbf4a9..deafd19e866f0 100644 --- a/core/java/com/android/internal/os/Zygote.java +++ b/core/java/com/android/internal/os/Zygote.java @@ -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.debug.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; } }