Merge "adbd: remove static dependency on libcutils." am: 744ba42d2d

Change-Id: I7b96502cbb480b8d5046867e851124de3910731a
This commit is contained in:
Automerger Merge Worker 2020-02-22 00:22:15 +00:00
commit 7ecfa1a7f8
20 changed files with 266 additions and 95 deletions

View file

@ -114,66 +114,6 @@ cc_defaults {
},
}
// libadbconnection
// =========================================================
// libadbconnection_client/server implement the socket handling for jdwp
// forwarding and the track-jdwp service.
cc_library {
name: "libadbconnection_server",
srcs: ["adbconnection/adbconnection_server.cpp"],
export_include_dirs: ["adbconnection/include"],
stl: "libc++_static",
shared_libs: ["liblog"],
static_libs: ["libbase"],
defaults: ["adbd_defaults", "host_adbd_supported"],
// Avoid getting duplicate symbol of android::build::getbuildnumber().
use_version_lib: false,
recovery_available: true,
compile_multilib: "both",
}
cc_library {
name: "libadbconnection_client",
srcs: ["adbconnection/adbconnection_client.cpp"],
export_include_dirs: ["adbconnection/include"],
stl: "libc++_static",
shared_libs: ["liblog"],
static_libs: ["libbase"],
defaults: ["adbd_defaults"],
visibility: [
"//art:__subpackages__",
"//system/core/adb/apex:__subpackages__",
],
apex_available: [
"com.android.adbd",
"test_com.android.adbd",
],
// libadbconnection_client doesn't need an embedded build number.
use_version_lib: false,
target: {
linux: {
version_script: "adbconnection/libadbconnection_client.map.txt",
},
},
stubs: {
symbol_file: "adbconnection/libadbconnection_client.map.txt",
versions: ["1"],
},
host_supported: true,
compile_multilib: "both",
}
// libadb
// =========================================================
// These files are compiled for both the host and the device.
@ -459,7 +399,6 @@ cc_library_static {
"libbase",
"libcrypto",
"libcrypto_utils",
"libcutils",
"liblog",
],
@ -483,7 +422,7 @@ cc_library_static {
},
}
cc_library {
cc_library_static {
name: "libadbd_services",
defaults: ["adbd_defaults", "host_adbd_supported"],
recovery_available: true,
@ -513,11 +452,11 @@ cc_library {
"libadb_protos",
"libadb_tls_connection",
"libadbd_auth",
"libadbd_fs",
"libasyncio",
"libbase",
"libcrypto",
"libcrypto_utils",
"libcutils",
"liblog",
],
@ -564,13 +503,19 @@ cc_library {
"libadb_pairing_connection",
"libadb_tls_connection",
"libadbd_auth",
"libadbd_services",
"libadbd_fs",
"libasyncio",
"libbase",
"libcrypto",
"libcrypto_utils",
"libcutils",
"liblog",
"libselinux",
],
static_libs: [
"libadbd_services",
"libcutils_sockets",
"libdiagnose_usb",
],
export_include_dirs: [
@ -605,7 +550,7 @@ cc_binary {
"libbase",
"libcap",
"libcrypto_utils",
"libcutils",
"libcutils_sockets",
"libdiagnose_usb",
"liblog",
"libmdnssd",
@ -620,10 +565,14 @@ cc_binary {
"libadb_protos",
"libadb_tls_connection",
"libadbd_auth",
"libadbd_fs",
"libcrypto",
],
required: ["libadbd_auth"],
required: [
"libadbd_auth",
"libadbd_fs",
],
}
phony {
@ -699,9 +648,9 @@ cc_test {
"libadb_pairing_connection_static",
"libadb_tls_connection_static",
"libbase",
"libcutils",
"libcrypto_utils",
"libcrypto_static",
"libcutils_sockets",
"libdiagnose_usb",
"liblog",
"libusb",

View file

@ -59,11 +59,4 @@ extern int adb_trace_mask;
void adb_trace_init(char**);
void adb_trace_enable(AdbTrace trace_tag);
// Include <atomic> before stdatomic.h (introduced in cutils/trace.h) to avoid compile error.
#include <atomic>
#define ATRACE_TAG ATRACE_TAG_ADB
#include <cutils/trace.h>
#include <utils/Trace.h>
#endif /* __ADB_TRACE_H */

View file

@ -17,6 +17,7 @@
#include "adb_install.h"
#include <fcntl.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

View file

@ -27,6 +27,7 @@
#include <android-base/endian.h>
#include <android-base/strings.h>
#include <inttypes.h>
#include <lz4.h>
#include <stdio.h>
#include <stdlib.h>

View file

@ -40,10 +40,13 @@
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <private/android_filesystem_config.h>
#include <adbd_fs.h>
// Needed for __android_log_security_bswrite.
#include <private/android_logger.h>
#if defined(__ANDROID__)
#include <linux/capability.h>
#include <selinux/android.h>
#include <sys/xattr.h>
#endif
@ -98,7 +101,7 @@ static bool secure_mkdirs(const std::string& path) {
for (const auto& path_component : path_components) {
uid_t uid = -1;
gid_t gid = -1;
unsigned int mode = 0775;
mode_t mode = 0775;
uint64_t capabilities = 0;
if (path_component.empty()) {
@ -111,7 +114,7 @@ static bool secure_mkdirs(const std::string& path) {
partial_path += path_component;
if (should_use_fs_config(partial_path)) {
fs_config(partial_path.c_str(), 1, nullptr, &uid, &gid, &mode, &capabilities);
adbd_fs_config(partial_path.c_str(), 1, nullptr, &uid, &gid, &mode, &capabilities);
}
if (adb_mkdir(partial_path.c_str(), mode) == -1) {
if (errno != EEXIST) {
@ -468,9 +471,7 @@ static bool do_send(int s, const std::string& spec, std::vector<char>& buffer) {
gid_t gid = -1;
uint64_t capabilities = 0;
if (should_use_fs_config(path)) {
unsigned int broken_api_hack = mode;
fs_config(path.c_str(), 0, nullptr, &uid, &gid, &broken_api_hack, &capabilities);
mode = broken_api_hack;
adbd_fs_config(path.c_str(), 0, nullptr, &uid, &gid, &mode, &capabilities);
}
result = handle_send_file(s, path.c_str(), &timestamp, uid, gid, capabilities, mode, buffer,
@ -550,7 +551,6 @@ static const char* sync_id_to_name(uint32_t id) {
static bool handle_sync_command(int fd, std::vector<char>& buffer) {
D("sync: waiting for request");
ATRACE_CALL();
SyncRequest request;
if (!ReadFdExactly(fd, &request, sizeof(request))) {
SendSyncFail(fd, "command read failure");
@ -569,8 +569,6 @@ static bool handle_sync_command(int fd, std::vector<char>& buffer) {
name[path_length] = 0;
std::string id_name = sync_id_to_name(request.id);
std::string trace_name = StringPrintf("%s(%s)", id_name.c_str(), name);
ATRACE_NAME(trace_name.c_str());
D("sync: %s('%s')", id_name.c_str(), name);
switch (request.id) {

View file

@ -19,6 +19,7 @@
#include "sysdeps.h"
#include <errno.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View file

@ -18,6 +18,8 @@
#include "apk_archive.h"
#include <inttypes.h>
#include "adb_trace.h"
#include "sysdeps.h"

View file

@ -0,0 +1 @@
../../.clang-format-2

View file

@ -0,0 +1,59 @@
// libadbconnection
// =========================================================
// libadbconnection_client/server implement the socket handling for jdwp
// forwarding and the track-jdwp service.
cc_library {
name: "libadbconnection_server",
srcs: ["adbconnection_server.cpp"],
export_include_dirs: ["include"],
stl: "libc++_static",
shared_libs: ["liblog"],
static_libs: ["libbase"],
defaults: ["adbd_defaults", "host_adbd_supported"],
// Avoid getting duplicate symbol of android::build::GetBuildNumber().
use_version_lib: false,
recovery_available: true,
compile_multilib: "both",
}
cc_library {
name: "libadbconnection_client",
srcs: ["adbconnection_client.cpp"],
export_include_dirs: ["include"],
stl: "libc++_static",
shared_libs: ["liblog"],
static_libs: ["libbase"],
defaults: ["adbd_defaults"],
visibility: [
"//art:__subpackages__",
"//system/core/adb/apex:__subpackages__",
],
apex_available: [
"com.android.adbd",
"test_com.android.adbd",
],
// libadbconnection_client doesn't need an embedded build number.
use_version_lib: false,
target: {
linux: {
version_script: "libadbconnection_client.map.txt",
},
},
stubs: {
symbol_file: "libadbconnection_client.map.txt",
versions: ["1"],
},
host_supported: true,
compile_multilib: "both",
}

View file

@ -0,0 +1,30 @@
// libadbd_fs
// =========================================================
cc_library {
name: "libadbd_fs",
defaults: ["adbd_defaults"],
srcs: ["adbd_fs.cpp"],
static_libs: [
"libbase",
"libcutils",
"liblog",
],
export_include_dirs: ["include"],
version_script: "libadbd_fs.map.txt",
stubs: {
versions: ["1"],
symbol_file: "libadbd_fs.map.txt",
},
host_supported: true,
recovery_available: true,
compile_multilib: "both",
target: {
darwin: {
enabled: false,
}
},
}

View file

@ -0,0 +1,30 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <adbd_fs.h>
#include <private/fs_config.h>
void adbd_fs_config(const char* path, int dir, const char* target_out_path, uid_t* uid, gid_t* gid,
mode_t* mode, uint64_t* capabilities) {
unsigned uid_hack;
unsigned gid_hack;
unsigned mode_hack;
fs_config(path, dir, target_out_path, &uid_hack, &gid_hack, &mode_hack, capabilities);
*uid = uid_hack;
*gid = gid_hack;
*mode = mode_hack;
}

View file

@ -0,0 +1,26 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <stdint.h>
#include <sys/types.h>
extern "C" {
// Thin wrapper around libcutils fs_config.
void adbd_fs_config(const char* path, int dir, const char* target_out_path, uid_t* uid, gid_t* gid,
mode_t* mode, uint64_t* capabilities);
}

View file

@ -0,0 +1,6 @@
LIBADBD_FS {
global:
adbd_fs_config; # apex
local:
*;
};

View file

@ -21,11 +21,6 @@ libcutils_nonwindows_sources = [
"fs.cpp",
"hashmap.cpp",
"multiuser.cpp",
"socket_inaddr_any_server_unix.cpp",
"socket_local_client_unix.cpp",
"socket_local_server_unix.cpp",
"socket_network_client_unix.cpp",
"sockets_unix.cpp",
"str_parms.cpp",
]
@ -49,6 +44,90 @@ cc_library_headers {
},
}
// Socket specific parts of libcutils that are safe to statically link into an APEX.
cc_library_static {
name: "libcutils_sockets",
vendor_available: true,
vndk: {
enabled: true,
support_system_process: true,
},
recovery_available: true,
host_supported: true,
native_bridge_supported: true,
apex_available: [
"//apex_available:platform",
"//apex_available:anyapex",
],
export_include_dirs: ["include"],
srcs: ["sockets.cpp"],
target: {
linux_bionic: {
enabled: true,
},
not_windows: {
srcs: [
"socket_inaddr_any_server_unix.cpp",
"socket_local_client_unix.cpp",
"socket_local_server_unix.cpp",
"socket_network_client_unix.cpp",
"sockets_unix.cpp",
],
},
// "not_windows" means "non-Windows host".
android: {
srcs: [
"android_get_control_file.cpp",
"socket_inaddr_any_server_unix.cpp",
"socket_local_client_unix.cpp",
"socket_local_server_unix.cpp",
"socket_network_client_unix.cpp",
"sockets_unix.cpp",
],
static_libs: ["libbase"],
},
windows: {
host_ldlibs: ["-lws2_32"],
srcs: [
"socket_inaddr_any_server_windows.cpp",
"socket_network_client_windows.cpp",
"sockets_windows.cpp",
],
enabled: true,
cflags: [
"-D_GNU_SOURCE",
],
},
},
}
cc_test {
name: "libcutils_sockets_test",
test_suites: ["device-tests"],
static_libs: ["libbase", "libcutils_sockets"],
cflags: [
"-Wall",
"-Wextra",
"-Werror",
],
srcs: ["sockets_test.cpp"],
target: {
android: {
srcs: [
"android_get_control_file_test.cpp",
"android_get_control_socket_test.cpp",
],
},
},
}
cc_library {
name: "libcutils",
vendor_available: true,
@ -66,7 +145,6 @@ cc_library {
"load_file.cpp",
"native_handle.cpp",
"record_stream.cpp",
"sockets.cpp",
"strlcpy.c",
"threads.cpp",
],
@ -86,9 +164,6 @@ cc_library {
host_ldlibs: ["-lws2_32"],
srcs: [
"socket_inaddr_any_server_windows.cpp",
"socket_network_client_windows.cpp",
"sockets_windows.cpp",
"trace-host.cpp",
],
@ -97,10 +172,8 @@ cc_library {
"-D_GNU_SOURCE",
],
},
android: {
srcs: libcutils_nonwindows_sources + [
"android_get_control_file.cpp",
"android_reboot.cpp",
"ashmem-dev.cpp",
"fs_config.cpp",
@ -172,6 +245,7 @@ cc_library {
}
},
whole_static_libs: ["libcutils_sockets"],
shared_libs: [
"liblog",
"libbase",