Loading adb/Android.mk +12 −6 Original line number Diff line number Diff line Loading @@ -96,6 +96,9 @@ LOCAL_STATIC_LIBRARIES := libcrypto_static ifeq ($(HOST_OS),windows) LOCAL_C_INCLUDES += development/host/windows/usb/api/ # Windows.h defines an awful ERROR macro that collides with base/logging.h. # Suppress it with NOGDI. LOCAL_CFLAGS += -DNOGDI endif include $(BUILD_HOST_STATIC_LIBRARY) Loading Loading @@ -162,6 +165,9 @@ ifeq ($(HOST_OS),darwin) endif ifeq ($(HOST_OS),windows) # Windows.h defines an awful ERROR macro that collides with base/logging.h. # Suppress it with NOGDI. LOCAL_CFLAGS += -DNOGDI LOCAL_LDLIBS += -lws2_32 -lgdi32 EXTRA_STATIC_LIBS := AdbWinApi endif Loading adb/adb_auth_host.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,11 @@ #define TRACE_TAG TRACE_AUTH #ifdef _WIN32 // This blocks some definitions we need on Windows. #undef NOGDI #endif #include "sysdeps.h" #include "adb_auth.h" Loading adb/adb_client.cpp +0 −30 Original line number Diff line number Diff line Loading @@ -80,36 +80,6 @@ void adb_set_tcp_name(const char* hostname) __adb_server_name = hostname; } int adb_get_emulator_console_port() { if (__adb_serial) { // The user specified a serial number; is it an emulator? int port; return (sscanf(__adb_serial, "emulator-%d", &port) == 1) ? port : -1; } // No specific device was given, so get the list of connected // devices and search for emulators. If there's one, we'll // take it. If there are more than one, that's an error. std::string devices; std::string error; if (!adb_query("host:devices", &devices, &error)) { printf("no emulator connected: %s\n", error.c_str()); return -1; } int port; size_t emulator_count = 0; for (auto& device : android::base::Split(devices, "\n")) { if (sscanf(device.c_str(), "emulator-%d", &port) == 1) { if (++emulator_count > 1) { return -2; } } } if (emulator_count == 0) return -1; return port; } static int switch_socket_transport(int fd, std::string* error) { std::string service; if (__adb_serial) { Loading adb/adb_client.h +28 −25 Original line number Diff line number Diff line /* * Copyright (C) 2015 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. */ #ifndef _ADB_CLIENT_H_ #define _ADB_CLIENT_H_ Loading @@ -5,16 +21,13 @@ #include <string> /* connect to adb, connect to the named service, and return ** a valid fd for interacting with that service upon success ** or a negative number on failure */ // Connect to adb, connect to the named service, and return a valid fd for // interacting with that service upon success or a negative number on failure. int adb_connect(const std::string& service, std::string* error); int _adb_connect(const std::string& service, std::string* error); /* connect to adb, connect to the named service, return 0 if ** the connection succeeded AND the service returned OKAY */ // Connect to adb, connect to the named service, return 0 if the connection // succeeded AND the service returned OKAY. int adb_command(const std::string& service, std::string* error); // Connects to the named adb service and fills 'result' with the response. Loading @@ -24,29 +37,19 @@ bool adb_query(const std::string& service, std::string* result, std::string* err // Set the preferred transport to connect to. void adb_set_transport(TransportType type, const char* serial); /* Set TCP specifics of the transport to use */ // Set TCP specifics of the transport to use. void adb_set_tcp_specifics(int server_port); /* Set TCP Hostname of the transport to use */ // Set TCP Hostname of the transport to use. void adb_set_tcp_name(const char* hostname); /* Return the console port of the currently connected emulator (if any) * of -1 if there is no emulator, and -2 if there is more than one. * assumes adb_set_transport() was alled previously... */ int adb_get_emulator_console_port(void); /* send commands to the current emulator instance. will fail if there * is zero, or more than one emulator connected (or if you use -s <serial> * with a <serial> that does not designate an emulator) */ int adb_send_emulator_command(int argc, const char** argv); // Send commands to the current emulator instance. Will fail if there is not // exactly one emulator connected (or if you use -s <serial> with a <serial> // that does not designate an emulator). int adb_send_emulator_command(int argc, const char** argv, const char* serial); // Reads a standard adb status response (OKAY|FAIL) and // returns true in the event of OKAY, false in the event of FAIL // or protocol error. // Reads a standard adb status response (OKAY|FAIL) and returns true in the // event of OKAY, false in the event of FAIL or protocol error. bool adb_status(int fd, std::string* error); #endif adb/commandline.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -1136,7 +1136,7 @@ int adb_commandline(int argc, const char **argv) { return adb_query_command(query); } else if (!strcmp(argv[0], "emu")) { return adb_send_emulator_command(argc, argv); return adb_send_emulator_command(argc, argv, serial); } else if (!strcmp(argv[0], "shell") || !strcmp(argv[0], "hell")) { char h = (argv[0][0] == 'h'); Loading Loading
adb/Android.mk +12 −6 Original line number Diff line number Diff line Loading @@ -96,6 +96,9 @@ LOCAL_STATIC_LIBRARIES := libcrypto_static ifeq ($(HOST_OS),windows) LOCAL_C_INCLUDES += development/host/windows/usb/api/ # Windows.h defines an awful ERROR macro that collides with base/logging.h. # Suppress it with NOGDI. LOCAL_CFLAGS += -DNOGDI endif include $(BUILD_HOST_STATIC_LIBRARY) Loading Loading @@ -162,6 +165,9 @@ ifeq ($(HOST_OS),darwin) endif ifeq ($(HOST_OS),windows) # Windows.h defines an awful ERROR macro that collides with base/logging.h. # Suppress it with NOGDI. LOCAL_CFLAGS += -DNOGDI LOCAL_LDLIBS += -lws2_32 -lgdi32 EXTRA_STATIC_LIBS := AdbWinApi endif Loading
adb/adb_auth_host.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,11 @@ #define TRACE_TAG TRACE_AUTH #ifdef _WIN32 // This blocks some definitions we need on Windows. #undef NOGDI #endif #include "sysdeps.h" #include "adb_auth.h" Loading
adb/adb_client.cpp +0 −30 Original line number Diff line number Diff line Loading @@ -80,36 +80,6 @@ void adb_set_tcp_name(const char* hostname) __adb_server_name = hostname; } int adb_get_emulator_console_port() { if (__adb_serial) { // The user specified a serial number; is it an emulator? int port; return (sscanf(__adb_serial, "emulator-%d", &port) == 1) ? port : -1; } // No specific device was given, so get the list of connected // devices and search for emulators. If there's one, we'll // take it. If there are more than one, that's an error. std::string devices; std::string error; if (!adb_query("host:devices", &devices, &error)) { printf("no emulator connected: %s\n", error.c_str()); return -1; } int port; size_t emulator_count = 0; for (auto& device : android::base::Split(devices, "\n")) { if (sscanf(device.c_str(), "emulator-%d", &port) == 1) { if (++emulator_count > 1) { return -2; } } } if (emulator_count == 0) return -1; return port; } static int switch_socket_transport(int fd, std::string* error) { std::string service; if (__adb_serial) { Loading
adb/adb_client.h +28 −25 Original line number Diff line number Diff line /* * Copyright (C) 2015 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. */ #ifndef _ADB_CLIENT_H_ #define _ADB_CLIENT_H_ Loading @@ -5,16 +21,13 @@ #include <string> /* connect to adb, connect to the named service, and return ** a valid fd for interacting with that service upon success ** or a negative number on failure */ // Connect to adb, connect to the named service, and return a valid fd for // interacting with that service upon success or a negative number on failure. int adb_connect(const std::string& service, std::string* error); int _adb_connect(const std::string& service, std::string* error); /* connect to adb, connect to the named service, return 0 if ** the connection succeeded AND the service returned OKAY */ // Connect to adb, connect to the named service, return 0 if the connection // succeeded AND the service returned OKAY. int adb_command(const std::string& service, std::string* error); // Connects to the named adb service and fills 'result' with the response. Loading @@ -24,29 +37,19 @@ bool adb_query(const std::string& service, std::string* result, std::string* err // Set the preferred transport to connect to. void adb_set_transport(TransportType type, const char* serial); /* Set TCP specifics of the transport to use */ // Set TCP specifics of the transport to use. void adb_set_tcp_specifics(int server_port); /* Set TCP Hostname of the transport to use */ // Set TCP Hostname of the transport to use. void adb_set_tcp_name(const char* hostname); /* Return the console port of the currently connected emulator (if any) * of -1 if there is no emulator, and -2 if there is more than one. * assumes adb_set_transport() was alled previously... */ int adb_get_emulator_console_port(void); /* send commands to the current emulator instance. will fail if there * is zero, or more than one emulator connected (or if you use -s <serial> * with a <serial> that does not designate an emulator) */ int adb_send_emulator_command(int argc, const char** argv); // Send commands to the current emulator instance. Will fail if there is not // exactly one emulator connected (or if you use -s <serial> with a <serial> // that does not designate an emulator). int adb_send_emulator_command(int argc, const char** argv, const char* serial); // Reads a standard adb status response (OKAY|FAIL) and // returns true in the event of OKAY, false in the event of FAIL // or protocol error. // Reads a standard adb status response (OKAY|FAIL) and returns true in the // event of OKAY, false in the event of FAIL or protocol error. bool adb_status(int fd, std::string* error); #endif
adb/commandline.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -1136,7 +1136,7 @@ int adb_commandline(int argc, const char **argv) { return adb_query_command(query); } else if (!strcmp(argv[0], "emu")) { return adb_send_emulator_command(argc, argv); return adb_send_emulator_command(argc, argv, serial); } else if (!strcmp(argv[0], "shell") || !strcmp(argv[0], "hell")) { char h = (argv[0][0] == 'h'); Loading