I am trying to understand what the Android system property ro.debuggable actually does. I am using Arm Streamline to profile my android application and the documentation states that I can do application profiling using debuggable applications (applications built with the debuggable flag), or I can do a system-wide profile on a rooted device. Reading around I came across the ro.debuggable property and wondered if this would allow me to debug apps not built with the debuggable flag.
Best understanding I can glean so far from documentation is thet ro.debuggable=1 is usually the setting for eng and user-debug builds and somehow allows for a device to be rooted (though does not actually root a device), but what does it actually do? Does it just determine if a device can be rooted or not?
Let's start from the lifecycle of the Android application process:
Some application requests
system_serverto start an app to handle its request. For example, when a user clicks the WeChat icon on the launcher, the launcher requestssystem_serverto start the WeChat application to respond to the user's request.system_serverresolves the request (actually the request Intent) and finally makes a decision to spawn a new process for WeChat to fulfill the request.system_servercalls ProcessList.startProcess to spawn a new process to host WeChat. The process being spawned needs some basic information about the application it will run, such asinstruction-set,target-api, UID, etc. One of the important pieces of information is whether the application is debuggable.ProcessListretrieves most of this information fromPackageManagerService. For example, the debuggable option is set in the APK's manifest attributeandroid:debuggable.ProcessListcollects these options and forwards them toZygoteProcess.ZygoteProcesswrites these options to thezygoteorzygote64process using a Socket.ZygoteServerreceives the socket request and processes it in ZygoteConnection.processCommand, parsing the buffer intoZygoteArguments.Some default behaviors take effect on the parsed
ZygoteArguments. For example, applyDebuggerSystemProperty. If this is an ENG build or USER_DEBUG build withpersist.debug.dalvik.vm.jdwp.enabledset to 1, the debug options are enabled regardless of the options passed bysystem_server(the code in the main branch is slightly different from Android 13, which only takes into account thero.debuggableproperty).The newly spawned process uses the options to set up a JDWP server in EnableDebugFeatures, making the process present in DDMS and debuggable.
In summary, the
ro.debuggableproperty has nothing to do with root access but is a property that affects the debug server of every app process in Android 13 (as explained above).