From 70c53f5d52fff73eff48c324883a5d670b78aa23 Mon Sep 17 00:00:00 2001 From: Yi-Yo Chiang Date: Wed, 8 Jun 2022 19:11:43 +0800 Subject: [PATCH] Auto enable usb adb if booting with debug ramdisk If booting with debug ramdisk (ro.force.debuggable is true), override the persistent property "persist.sys.usb.config" to always enable adb. This ensures a consistent debug experience. The developer can expect that after debug ramdisk (debug boot image) is flashed, 1. Device is rootable with (adb root) 2. adb is enabled automatically 3. no-auth (if $ADB_VENDOR_KEYS is used) Bug: 223517900 Test: 1. Flash & boot user build, verify device doesn't have usb debugging enabled. 2. Reboot to bootloader and flash vendor_boot-debug.img. 3. Boot and verify usb debugging is automatically enabled. 4. Enter Developer Options and manually turn off usb debugging. 5. Reboot and verify that usb debugging is automatically enabled. Change-Id: I729e961d645f2dd521ead8ca30b5cb8eb1d9f909 --- init/property_service.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/init/property_service.cpp b/init/property_service.cpp index a1f6e0466..7e925380f 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -1351,6 +1351,11 @@ static void HandleInitSocket() { InitPropertySet(persistent_property_record.name(), persistent_property_record.value()); } + // Apply debug ramdisk special settings after persistent properties are loaded. + if (android::base::GetBoolProperty("ro.force.debuggable", false)) { + // Always enable usb adb if device is booted with debug ramdisk. + update_sys_usb_config(); + } InitPropertySet("ro.persistent_properties.ready", "true"); persistent_properties_loaded = true; break;