From 717f15353f17f86cfad8dc952fd68c680f702dcc Mon Sep 17 00:00:00 2001 From: Nicolas Norvez Date: Tue, 6 Jun 2017 13:38:20 -0700 Subject: [PATCH] adbd: optionally use qemud pipe without ro.kernel.qemu adbd currently decides to use the QEMUD pipe if ro.kernel.qemu=1, as set for ranchu. The Android container in Chrome OS doesn't have that property set and it can't be set to 1 because it's used as equivalent to "runs inside an emulator" throughout Android and changes the way graphics are handled, whether Bluetooth is supported, etc., behaviour that we do not want to trigger in Chrome OS. adbd now also checks service.adb.transport to decide whether to use the QEMUD (goldfish) pipe. adbd still first checks for ro.kernel.qemu to preserve existing behaviour and will still fallback to TCP if it can't use Goldfish. Bug: 38497992 Test: tested by jmgao@ -thanks!- on aosp_angler, adb still works. Change-Id: I8370704145ae7301ac7aeef81c5cbd94cfcb7fd7 --- adb/transport_local.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/adb/transport_local.cpp b/adb/transport_local.cpp index a9e583faf..6cedd92b5 100644 --- a/adb/transport_local.cpp +++ b/adb/transport_local.cpp @@ -388,6 +388,25 @@ static void qemu_socket_thread(int port) { D("transport: qemu_socket_thread() exiting"); return; } + +// If adbd is running inside the emulator, it will normally use QEMUD pipe (aka +// goldfish) as the transport. This can either be explicitly set by the +// service.adb.transport property, or be inferred from ro.kernel.qemu that is +// set to "1" for ranchu/goldfish. +static bool use_qemu_goldfish() { + // Legacy way to detect if adbd should use the goldfish pipe is to check for + // ro.kernel.qemu, keep that behaviour for backward compatibility. + if (android::base::GetBoolProperty("ro.kernel.qemu", false)) { + return true; + } + // If service.adb.transport is present and is set to "goldfish", use the + // QEMUD pipe. + if (android::base::GetProperty("service.adb.transport", "") == "goldfish") { + return true; + } + return false; +} + #endif // !ADB_HOST void local_init(int port) @@ -401,13 +420,7 @@ void local_init(int port) #else // For the adbd daemon in the system image we need to distinguish // between the device, and the emulator. - if (android::base::GetBoolProperty("ro.kernel.qemu", false)) { - // Running inside the emulator: use QEMUD pipe as the transport. - func = qemu_socket_thread; - } else { - // Running inside the device: use TCP socket as the transport. - func = server_socket_thread; - } + func = use_qemu_goldfish() ? qemu_socket_thread : server_socket_thread; debug_name = "server"; #endif // !ADB_HOST