adb: factor out socket specification.
Move the logic for string socket specification out to separate
functions to facilitate using arbitrary sockets for the adb command
socket.
Bug: http://b/30445394
Change-Id: Icd8fdb853272edc029fb3a0f5b18e941dc8ef52c
Test: adb_test, adbd_test, test_device.py
diff --git a/sysdeps.h b/sysdeps.h
index 322f992..8d99722 100644
--- a/sysdeps.h
+++ b/sysdeps.h
@@ -277,6 +277,15 @@
int network_loopback_client(int port, int type, std::string* error);
int network_loopback_server(int port, int type, std::string* error);
int network_inaddr_any_server(int port, int type, std::string* error);
+
+inline int network_local_client(const char* name, int namespace_id, int type, std::string* error) {
+ abort();
+}
+
+inline int network_local_server(const char* name, int namespace_id, int type, std::string* error) {
+ abort();
+}
+
int network_connect(const std::string& host, int port, int type, int timeout,
std::string* error);
@@ -638,10 +647,12 @@
return _fd_set_error_str(socket_inaddr_any_server(port, type), error);
}
-inline int network_local_server(const char *name, int namespace_id, int type,
- std::string* error) {
- return _fd_set_error_str(socket_local_server(name, namespace_id, type),
- error);
+inline int network_local_client(const char* name, int namespace_id, int type, std::string* error) {
+ return _fd_set_error_str(socket_local_client(name, namespace_id, type), error);
+}
+
+inline int network_local_server(const char* name, int namespace_id, int type, std::string* error) {
+ return _fd_set_error_str(socket_local_server(name, namespace_id, type), error);
}
inline int network_connect(const std::string& host, int port, int type,