Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a227c19e authored by Josh Gao's avatar Josh Gao Committed by Gerrit Code Review
Browse files

Merge changes Id8d9fa6c,I47d3ad50,I7cebbf75,Id10e320a

* changes:
  adbd: avoid compiling more code in the daemon.
  adb: don't run all of the tests again over TCP in coverage.
  adbd: respect ADB_TRACE on host adbd.
  adb: mark kMaxProcessNameLength as constexpr.
parents 8987016b 9f3064f2
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -109,7 +109,9 @@ void handle_online(atransport *t)
{
{
    D("adb: online");
    D("adb: online");
    t->online = 1;
    t->online = 1;
#if ADB_HOST
    t->SetConnectionEstablished(true);
    t->SetConnectionEstablished(true);
#endif
}
}


void handle_offline(atransport *t)
void handle_offline(atransport *t)
+10 −2
Original line number Original line Diff line number Diff line
@@ -73,6 +73,7 @@ static auto& listener_list_mutex = *new std::mutex();
typedef std::list<std::unique_ptr<alistener>> ListenerList;
typedef std::list<std::unique_ptr<alistener>> ListenerList;
static ListenerList& listener_list GUARDED_BY(listener_list_mutex) = *new ListenerList();
static ListenerList& listener_list GUARDED_BY(listener_list_mutex) = *new ListenerList();


#if ADB_HOST
static void ss_listener_event_func(int _fd, unsigned ev, void *_l) {
static void ss_listener_event_func(int _fd, unsigned ev, void *_l) {
    if (ev & FDE_READ) {
    if (ev & FDE_READ) {
        unique_fd fd(adb_socket_accept(_fd, nullptr, nullptr));
        unique_fd fd(adb_socket_accept(_fd, nullptr, nullptr));
@@ -88,6 +89,7 @@ static void ss_listener_event_func(int _fd, unsigned ev, void *_l) {
        }
        }
    }
    }
}
}
#endif


static void listener_event_func(int _fd, unsigned ev, void* _l)
static void listener_event_func(int _fd, unsigned ev, void* _l)
{
{
@@ -164,7 +166,7 @@ void remove_all_listeners() EXCLUDES(listener_list_mutex) {
    }
    }
}
}


void enable_daemon_sockets() EXCLUDES(listener_list_mutex) {
void enable_server_sockets() EXCLUDES(listener_list_mutex) {
    std::lock_guard<std::mutex> lock(listener_list_mutex);
    std::lock_guard<std::mutex> lock(listener_list_mutex);
    for (auto& l : listener_list) {
    for (auto& l : listener_list) {
        if (l->connect_to == "*smartsocket*") {
        if (l->connect_to == "*smartsocket*") {
@@ -173,6 +175,7 @@ void enable_daemon_sockets() EXCLUDES(listener_list_mutex) {
    }
    }
}
}


#if ADB_HOST
void close_smartsockets() EXCLUDES(listener_list_mutex) {
void close_smartsockets() EXCLUDES(listener_list_mutex) {
    std::lock_guard<std::mutex> lock(listener_list_mutex);
    std::lock_guard<std::mutex> lock(listener_list_mutex);
    auto pred = [](const std::unique_ptr<alistener>& listener) {
    auto pred = [](const std::unique_ptr<alistener>& listener) {
@@ -180,6 +183,7 @@ void close_smartsockets() EXCLUDES(listener_list_mutex) {
    };
    };
    listener_list.remove_if(pred);
    listener_list.remove_if(pred);
}
}
#endif


InstallStatus install_listener(const std::string& local_name, const char* connect_to,
InstallStatus install_listener(const std::string& local_name, const char* connect_to,
                               atransport* transport, int flags, int* resolved_tcp_port,
                               atransport* transport, int flags, int* resolved_tcp_port,
@@ -227,7 +231,11 @@ InstallStatus install_listener(const std::string& local_name, const char* connec


    close_on_exec(listener->fd);
    close_on_exec(listener->fd);
    if (listener->connect_to == "*smartsocket*") {
    if (listener->connect_to == "*smartsocket*") {
#if ADB_HOST
        listener->fde = fdevent_create(listener->fd, ss_listener_event_func, listener.get());
        listener->fde = fdevent_create(listener->fd, ss_listener_event_func, listener.get());
#else
        LOG(FATAL) << "attempted to connect to *smartsocket* in daemon";
#endif
    } else {
    } else {
        listener->fde = fdevent_create(listener->fd, listener_event_func, listener.get());
        listener->fde = fdevent_create(listener->fd, listener_event_func, listener.get());
    }
    }
+4 −5
Original line number Original line Diff line number Diff line
@@ -14,8 +14,7 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


#ifndef __ADB_LISTENERS_H
#pragma once
#define __ADB_LISTENERS_H


#include "adb.h"
#include "adb.h"


@@ -44,7 +43,7 @@ std::string format_listeners();
InstallStatus remove_listener(const char* local_name, atransport* transport);
InstallStatus remove_listener(const char* local_name, atransport* transport);
void remove_all_listeners(void);
void remove_all_listeners(void);


void enable_daemon_sockets();
#if ADB_HOST
void enable_server_sockets();
void close_smartsockets();
void close_smartsockets();

#endif
#endif /* __ADB_LISTENERS_H */
+1 −1
Original line number Original line Diff line number Diff line
@@ -90,7 +90,7 @@ void start_device_log(void) {
int adb_trace_mask;
int adb_trace_mask;


std::string get_trace_setting() {
std::string get_trace_setting() {
#if ADB_HOST
#if ADB_HOST || !defined(__ANDROID__)
    const char* setting = getenv("ADB_TRACE");
    const char* setting = getenv("ADB_TRACE");
    if (setting == nullptr) {
    if (setting == nullptr) {
        setting = "";
        setting = "";
+1 −1
Original line number Original line Diff line number Diff line
@@ -206,7 +206,7 @@ int adb_server_main(int is_daemon, const std::string& socket_spec, int ack_reply
        // We don't accept() client connections until this point: this way, clients
        // We don't accept() client connections until this point: this way, clients
        // can't see wonky state early in startup even if they're connecting directly
        // can't see wonky state early in startup even if they're connecting directly
        // to the server instead of going through the adb program.
        // to the server instead of going through the adb program.
        fdevent_run_on_main_thread([] { enable_daemon_sockets(); });
        fdevent_run_on_main_thread([] { enable_server_sockets(); });
    });
    });
    notify_thread.detach();
    notify_thread.detach();


Loading