adb: finish switching service creation to string_view.
Test: test_adb.py Test: test_device.py Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test Test: adb shell /data/nativetest64/adbd_test/adbd_test Change-Id: If4ea92aee1c0264d946de72483f8d715d96fcfd8
This commit is contained in:
parent
9dd1f5c0b7
commit
d19b77ac12
|
@ -357,9 +357,9 @@ void handle_packet(apacket *p, atransport *t)
|
|||
|
||||
case A_OPEN: /* OPEN(local-id, 0, "destination") */
|
||||
if (t->online && p->msg.arg0 != 0 && p->msg.arg1 == 0) {
|
||||
// TODO: Switch to string_view.
|
||||
std::string address(p->payload.begin(), p->payload.end());
|
||||
asocket* s = create_local_service_socket(address.c_str(), t);
|
||||
std::string_view address(p->payload.begin(), p->payload.size());
|
||||
|
||||
asocket* s = create_local_service_socket(address, t);
|
||||
if (s == nullptr) {
|
||||
send_close(0, p->msg.arg0, t);
|
||||
} else {
|
||||
|
|
|
@ -139,7 +139,7 @@ atransport* find_emulator_transport_by_adb_port(int adb_port);
|
|||
atransport* find_emulator_transport_by_console_port(int console_port);
|
||||
#endif
|
||||
|
||||
int service_to_fd(const char* name, atransport* transport);
|
||||
int service_to_fd(std::string_view name, atransport* transport);
|
||||
#if !ADB_HOST
|
||||
unique_fd daemon_service_to_fd(std::string_view name, atransport* transport);
|
||||
#endif
|
||||
|
|
|
@ -71,7 +71,7 @@ unique_fd create_service_thread(const char* service_name, std::function<void(uni
|
|||
return unique_fd(s[0]);
|
||||
}
|
||||
|
||||
int service_to_fd(const char* name, atransport* transport) {
|
||||
int service_to_fd(std::string_view name, atransport* transport) {
|
||||
int ret = -1;
|
||||
|
||||
if (is_socket_spec(name)) {
|
||||
|
|
|
@ -103,7 +103,7 @@ void remove_socket(asocket *s);
|
|||
void close_all_sockets(atransport *t);
|
||||
|
||||
asocket *create_local_socket(int fd);
|
||||
asocket* create_local_service_socket(const char* destination, atransport* transport);
|
||||
asocket* create_local_service_socket(std::string_view destination, atransport* transport);
|
||||
|
||||
asocket *create_remote_socket(unsigned id, atransport *t);
|
||||
void connect_to_remote(asocket *s, const char *destination);
|
||||
|
|
|
@ -346,7 +346,7 @@ asocket* create_local_socket(int fd) {
|
|||
return s;
|
||||
}
|
||||
|
||||
asocket* create_local_service_socket(const char* name, atransport* transport) {
|
||||
asocket* create_local_service_socket(std::string_view name, atransport* transport) {
|
||||
#if !ADB_HOST
|
||||
if (asocket* s = daemon_service_to_socket(name); s) {
|
||||
return s;
|
||||
|
@ -358,13 +358,12 @@ asocket* create_local_service_socket(const char* name, atransport* transport) {
|
|||
}
|
||||
|
||||
asocket* s = create_local_socket(fd);
|
||||
D("LS(%d): bound to '%s' via %d", s->id, name, fd);
|
||||
LOG(VERBOSE) << "LS(" << s->id << "): bound to '" << name << "' via " << fd;
|
||||
|
||||
#if !ADB_HOST
|
||||
if ((!strncmp(name, "root:", 5) && getuid() != 0 && __android_log_is_debuggable()) ||
|
||||
(!strncmp(name, "unroot:", 7) && getuid() == 0) ||
|
||||
!strncmp(name, "usb:", 4) ||
|
||||
!strncmp(name, "tcpip:", 6)) {
|
||||
if ((name.starts_with("root:") && getuid() != 0 && __android_log_is_debuggable()) ||
|
||||
(name.starts_with("unroot:") && getuid() == 0) || name.starts_with("usb:") ||
|
||||
name.starts_with("tcpip:")) {
|
||||
D("LS(%d): enabling exit_on_close", s->id);
|
||||
s->exit_on_close = 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue