diff --git a/adb/adb.cpp b/adb/adb.cpp index 725aa9193d38..1f76a1acda48 100644 --- a/adb/adb.cpp +++ b/adb/adb.cpp @@ -199,8 +199,14 @@ std::string get_connection_string() { "ro.product.device", }; +#if ADB_NON_ANDROID + { + char value[PROPERTY_VALUE_MAX] = "ADB non-Android"; + const auto& prop_name = cnxn_props[0]; +#else for (const auto& prop_name : cnxn_props) { char value[PROPERTY_VALUE_MAX]; +#endif property_get(prop_name, value, ""); connection_properties.push_back( android::base::StringPrintf("%s=%s", prop_name, value)); diff --git a/adb/adb_auth.cpp b/adb/adb_auth.cpp index 215bbe65461d..73360f1088ff 100644 --- a/adb/adb_auth.cpp +++ b/adb/adb_auth.cpp @@ -28,7 +28,11 @@ #include "adb.h" #include "transport.h" +#if ADB_NON_ANDROID +bool auth_required = false; +#else bool auth_required = true; +#endif void send_auth_request(atransport *t) { diff --git a/adb/daemon/main.cpp b/adb/daemon/main.cpp index 5265deadf89d..e0d1ac4f1d68 100644 --- a/adb/daemon/main.cpp +++ b/adb/daemon/main.cpp @@ -30,12 +30,12 @@ #include #include -#ifndef ADB_NON_ANDROID -#include -#endif #include "cutils/properties.h" -#ifndef ADB_NON_ANDROID + +#if !ADB_NON_ANDROID +#include + #include "debuggerd/client.h" #include "private/android_filesystem_config.h" #include "selinux/android.h" @@ -49,7 +49,7 @@ static const char* root_seclabel = nullptr; -#ifndef ADB_NON_ANDROID +#if !ADB_NON_ANDROID static void drop_capabilities_bounding_set_if_needed(struct minijail *j) { #if defined(ALLOW_ADBD_ROOT) char value[PROPERTY_VALUE_MAX]; @@ -167,9 +167,11 @@ int adbd_main(int server_port) { // descriptor will always be open. adbd_cloexec_auth_socket(); +#if !ADB_NON_ANDROID if (ALLOW_ADBD_NO_AUTH && property_get_bool("ro.adb.secure", 0) == 0) { auth_required = false; } +#endif adbd_auth_init(); @@ -183,7 +185,7 @@ int adbd_main(int server_port) { " unchanged.\n"); } -#ifndef ADB_NON_ANDROID +#if !ADB_NON_ANDROID drop_privileges(server_port); #endif @@ -197,7 +199,11 @@ int adbd_main(int server_port) { // If one of these properties is set, also listen on that port. // If one of the properties isn't set and we couldn't listen on usb, listen // on the default port. +#if ADB_NON_ANDROID + char prop_port[PROPERTY_VALUE_MAX] = "5555"; +#else char prop_port[PROPERTY_VALUE_MAX]; +#endif property_get("service.adb.tcp.port", prop_port, ""); if (prop_port[0] == '\0') { property_get("persist.adb.tcp.port", prop_port, ""); @@ -213,7 +219,7 @@ int adbd_main(int server_port) { local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT); } -#ifndef ADB_NON_ANDROID +#if !ADB_NON_ANDROID D("adbd_main(): pre init_jdwp()"); init_jdwp(); D("adbd_main(): post init_jdwp()"); @@ -260,7 +266,7 @@ int main(int argc, char** argv) { close_stdin(); -#ifndef ADB_NON_ANDROID +#if !ADB_NON_ANDROID debuggerd_init(nullptr); #endif adb_trace_init(argv); diff --git a/adb/file_sync_service.cpp b/adb/file_sync_service.cpp index 31d3494f2de7..984a0d53c4d1 100644 --- a/adb/file_sync_service.cpp +++ b/adb/file_sync_service.cpp @@ -40,11 +40,9 @@ #include #include #include -#ifndef ADB_NON_ANDROID +#if !ADB_NON_ANDROID #include -#endif -#if !ADB_NON_ANDROID static bool should_use_fs_config(const std::string& path) { // TODO: use fs_config to configure permissions on /data. return android::base::StartsWith(path, "/system/") || diff --git a/adb/services.cpp b/adb/services.cpp index 8496dcddd8a2..79c6388fec3a 100644 --- a/adb/services.cpp +++ b/adb/services.cpp @@ -72,7 +72,11 @@ void restart_root_service(int fd, void *cookie) { WriteFdExactly(fd, "adbd is already running as root\n"); adb_close(fd); } else { +#if ADB_NON_ANDROID + char value[PROPERTY_VALUE_MAX] = "1"; +#else char value[PROPERTY_VALUE_MAX]; +#endif property_get("ro.debuggable", value, ""); if (strcmp(value, "1") != 0) { WriteFdExactly(fd, "adbd cannot run as root in production builds\n"); @@ -319,7 +323,7 @@ int service_to_fd(const char* name, const atransport* transport) { ret = unix_open(name + 4, O_RDWR | O_CLOEXEC); } else if(!strncmp(name, "framebuffer:", 12)) { ret = create_service_thread(framebuffer_service, 0); -#ifndef ADB_NON_ANDROID +#if !ADB_NON_ANDROID } else if (!strncmp(name, "jdwp:", 5)) { ret = create_jdwp_connection_fd(atoi(name+5)); #endif diff --git a/adb/sockets.cpp b/adb/sockets.cpp index 4521de3d136f..defe4cfce6d9 100644 --- a/adb/sockets.cpp +++ b/adb/sockets.cpp @@ -417,7 +417,11 @@ asocket* create_local_service_socket(const char* name, const atransport* transpo D("LS(%d): bound to '%s' via %d", s->id, name, fd); #if !ADB_HOST +#if ADB_NON_ANDROID + char debug[PROPERTY_VALUE_MAX] = "1"; +#else char debug[PROPERTY_VALUE_MAX]; +#endif if (!strncmp(name, "root:", 5)) { property_get("ro.debuggable", debug, ""); } diff --git a/adb/transport_local.cpp b/adb/transport_local.cpp index d918cc7ac5fd..a2e62e05bb71 100644 --- a/adb/transport_local.cpp +++ b/adb/transport_local.cpp @@ -357,7 +357,11 @@ 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 ADB_NON_ANDROID + char is_qemu[PROPERTY_VALUE_MAX] = "0"; +#else char is_qemu[PROPERTY_VALUE_MAX]; +#endif property_get("ro.kernel.qemu", is_qemu, ""); if (!strcmp(is_qemu, "1")) { /* Running inside the emulator: use QEMUD pipe as the transport. */ diff --git a/base/utf8.cpp b/base/utf8.cpp index 089c8d5e7bcf..9545eb7ea829 100755 --- a/base/utf8.cpp +++ b/base/utf8.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#ifndef ADB_NON_ANDROID +#ifdef _WIN32 #include #endif