Grant adb auth under recovery for unlocked & userdebug devices

During automatic tests, we sometimes want to reboot the device out of
the rescue party remotely. And per http://go/recovery-adb-access, we
need to grant the adb authorization to enable the adb access. The auth
are only granted for userdebug devices and those with an unlocked
bootloader. Since the user can always flash a custom recovery image if
the bootloader is unlocked.

This cl ignores the ro.adb.secure property under recovery. The other
option is to default this property to 0 when building the boot/recovery
image.

Bug: 141247819
Test: unlock bootloader, run adb under recovery in user build
Change-Id: I424cfed5bf51a1e31d8687256ae4c6eaaa5e6249
This commit is contained in:
Tianjie Xu 2019-10-30 10:37:32 -07:00
parent 8578a8a8ec
commit a933b43c02
1 changed files with 5 additions and 1 deletions

View File

@ -205,7 +205,11 @@ int adbd_main(int server_port) {
// descriptor will always be open.
adbd_cloexec_auth_socket();
#if defined(ALLOW_ADBD_NO_AUTH)
#if defined(__ANDROID_RECOVERY__)
if (is_device_unlocked() || __android_log_is_debuggable()) {
auth_required = false;
}
#elif defined(ALLOW_ADBD_NO_AUTH)
// If ro.adb.secure is unset, default to no authentication required.
auth_required = android::base::GetBoolProperty("ro.adb.secure", false);
#elif defined(__ANDROID__)