* commit '20e8b384c6ad8718764e138cc9013623cad8f400': adb: poll for emulator connection.
This commit is contained in:
commit
2df4804ace
2 changed files with 16 additions and 17 deletions
|
|
@ -68,13 +68,6 @@ static bool should_drop_privileges() {
|
||||||
#if defined(ALLOW_ADBD_ROOT)
|
#if defined(ALLOW_ADBD_ROOT)
|
||||||
char value[PROPERTY_VALUE_MAX];
|
char value[PROPERTY_VALUE_MAX];
|
||||||
|
|
||||||
// The emulator is never secure, so don't drop privileges there.
|
|
||||||
// TODO: this seems like a bug --- shouldn't the emulator behave like a device?
|
|
||||||
property_get("ro.kernel.qemu", value, "");
|
|
||||||
if (strcmp(value, "1") == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The properties that affect `adb root` and `adb unroot` are ro.secure and
|
// The properties that affect `adb root` and `adb unroot` are ro.secure and
|
||||||
// ro.debuggable. In this context the names don't make the expected behavior
|
// ro.debuggable. In this context the names don't make the expected behavior
|
||||||
// particularly obvious.
|
// particularly obvious.
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,10 @@ int local_connect_arbitrary_ports(int console_port, int adb_port, std::string* e
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
||||||
#if ADB_HOST
|
#if ADB_HOST
|
||||||
|
if (find_emulator_transport_by_adb_port(adb_port) != nullptr) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
const char *host = getenv("ADBHOST");
|
const char *host = getenv("ADBHOST");
|
||||||
if (host) {
|
if (host) {
|
||||||
fd = network_connect(host, adb_port, SOCK_STREAM, 0, error);
|
fd = network_connect(host, adb_port, SOCK_STREAM, 0, error);
|
||||||
|
|
@ -108,8 +112,10 @@ int local_connect_arbitrary_ports(int console_port, int adb_port, std::string* e
|
||||||
close_on_exec(fd);
|
close_on_exec(fd);
|
||||||
disable_tcp_nagle(fd);
|
disable_tcp_nagle(fd);
|
||||||
std::string serial = android::base::StringPrintf("emulator-%d", console_port);
|
std::string serial = android::base::StringPrintf("emulator-%d", console_port);
|
||||||
register_socket_transport(fd, serial.c_str(), adb_port, 1);
|
if (register_socket_transport(fd, serial.c_str(), adb_port, 1) == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
adb_close(fd);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -118,16 +124,16 @@ int local_connect_arbitrary_ports(int console_port, int adb_port, std::string* e
|
||||||
static void *client_socket_thread(void *x)
|
static void *client_socket_thread(void *x)
|
||||||
{
|
{
|
||||||
#if ADB_HOST
|
#if ADB_HOST
|
||||||
int port = DEFAULT_ADB_LOCAL_TRANSPORT_PORT;
|
|
||||||
int count = ADB_LOCAL_TRANSPORT_MAX;
|
|
||||||
|
|
||||||
D("transport: client_socket_thread() starting\n");
|
D("transport: client_socket_thread() starting\n");
|
||||||
|
while (true) {
|
||||||
|
int port = DEFAULT_ADB_LOCAL_TRANSPORT_PORT;
|
||||||
|
int count = ADB_LOCAL_TRANSPORT_MAX;
|
||||||
|
|
||||||
/* try to connect to any number of running emulator instances */
|
// Try to connect to any number of running emulator instances.
|
||||||
/* this is only done when ADB starts up. later, each new emulator */
|
for ( ; count > 0; count--, port += 2 ) {
|
||||||
/* will send a message to ADB to indicate that is is starting up */
|
local_connect(port);
|
||||||
for ( ; count > 0; count--, port += 2 ) {
|
}
|
||||||
local_connect(port);
|
sleep(1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue