From c151a1ba2816d6043fd77a253ce9abcdf491607b Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Mon, 16 Mar 2020 11:30:09 -0700 Subject: [PATCH] adbd: shrink libadbd.so, libadbd_services.so. We were ending up with multiple copies of the proto runtime in the recovery image, when we need zero. Before: 784K recovery/root/system/lib64/libadbd_services.so 832K recovery/root/system/lib64/libadbd.so After: 360K recovery/root/system/lib64/libadbd_services.so 344K recovery/root/system/lib64/libadbd.so Bug: http://b/150317254 Test: treehugger Change-Id: I39fbb3959128994f0de2ae0ea47dbc0800c516fe --- adb/Android.bp | 16 ++++++++-------- adb/daemon/jdwp_service.cpp | 27 ++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/adb/Android.bp b/adb/Android.bp index 1b7a26633..d8fa713e5 100644 --- a/adb/Android.bp +++ b/adb/Android.bp @@ -387,17 +387,17 @@ cc_library_static { generated_headers: ["platform_tools_version"], static_libs: [ - "libadbconnection_server", - "libapp_processes_protos_lite", "libdiagnose_usb", ], shared_libs: [ + "libadbconnection_server", "libadb_crypto", "libadb_pairing_connection", "libadb_protos", "libadb_tls_connection", "libadbd_auth", + "libapp_processes_protos_lite", "libasyncio", "libbase", "libcrypto", @@ -432,6 +432,7 @@ cc_library_static { exclude_shared_libs: [ "libadb_pairing_auth", "libadb_pairing_connection", + "libapp_processes_protos_lite", ], } }, @@ -458,9 +459,7 @@ cc_library { static_libs: [ "libadbconnection_server", "libadbd_core", - "libapp_processes_protos_lite", "libdiagnose_usb", - "libprotobuf-cpp-lite", ], shared_libs: [ @@ -470,12 +469,14 @@ cc_library { "libadb_tls_connection", "libadbd_auth", "libadbd_fs", + "libapp_processes_protos_lite", "libasyncio", "libbase", "libcrypto", "libcrypto_utils", "libcutils_sockets", "liblog", + "libprotobuf-cpp-lite", ], target: { @@ -514,15 +515,14 @@ cc_library { // libminadbd wants both, as it's used to build native tests. compile_multilib: "both", - // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library. whole_static_libs: [ - "libadbconnection_server", "libadbd_core", - "libapp_processes_protos_lite", - "libprotobuf-cpp-lite", ], shared_libs: [ + "libadbconnection_server", + "libapp_processes_protos_lite", + "libprotobuf-cpp-lite", "libadb_crypto", "libadb_pairing_connection", "libadb_tls_connection", diff --git a/adb/daemon/jdwp_service.cpp b/adb/daemon/jdwp_service.cpp index c99aead9c..adae9f7f4 100644 --- a/adb/daemon/jdwp_service.cpp +++ b/adb/daemon/jdwp_service.cpp @@ -16,6 +16,7 @@ #if !ADB_HOST +#if !defined(__ANDROID_RECOVERY__) #define TRACE_TAG JDWP #include "sysdeps.h" @@ -459,7 +460,7 @@ static int jdwp_tracker_enqueue(asocket* s, apacket::payload_type) { return -1; } -asocket* create_process_tracker_service_socket(TrackerKind kind) { +static asocket* create_process_tracker_service_socket(TrackerKind kind) { auto t = std::make_unique(kind, true); if (!t) { LOG(FATAL) << "failed to allocate JdwpTracker"; @@ -509,4 +510,28 @@ int init_jdwp(void) { return 0; } +#else // !defined(__ANDROID_RECOVERY) +#include "adb.h" + +asocket* create_jdwp_service_socket(void) { + return nullptr; +} + +unique_fd create_jdwp_connection_fd(int pid) { + return {}; +} + +asocket* create_app_tracker_service_socket() { + return nullptr; +} + +asocket* create_jdwp_tracker_service_socket() { + return nullptr; +} + +int init_jdwp() { + return 0; +} + +#endif /* defined(__ANDROID_RECOVERY__) */ #endif /* !ADB_HOST */