| Index: tools/android/forwarder2/host_controller.cc
|
| diff --git a/tools/android/forwarder2/host_controller.cc b/tools/android/forwarder2/host_controller.cc
|
| index 6fb3c81c5e8018dbdaa60beccba319769b0b4c3b..56a9f935a05ef043f3be78084ee73d7676b4eea0 100644
|
| --- a/tools/android/forwarder2/host_controller.cc
|
| +++ b/tools/android/forwarder2/host_controller.cc
|
| @@ -20,6 +20,7 @@ namespace forwarder2 {
|
|
|
| // static
|
| std::unique_ptr<HostController> HostController::Create(
|
| + const std::string& device_serial,
|
| int device_port,
|
| int host_port,
|
| int adb_port,
|
| @@ -31,7 +32,8 @@ std::unique_ptr<HostController> HostController::Create(
|
| adb_control_socket->AddEventFd(exit_notifier_fd);
|
| adb_control_socket->AddEventFd(delete_controller_notifier->receiver_fd());
|
| if (!adb_control_socket->ConnectTcp(std::string(), adb_port)) {
|
| - LOG(ERROR) << "Could not connect HostController socket on port: "
|
| + LOG(ERROR) << device_serial
|
| + << ": Could not connect HostController socket on port: "
|
| << adb_port;
|
| return host_controller;
|
| }
|
| @@ -44,11 +46,13 @@ std::unique_ptr<HostController> HostController::Create(
|
| if (!ReadCommand(
|
| adb_control_socket.get(), &device_port_allocated, &command) ||
|
| command != command::BIND_SUCCESS) {
|
| - LOG(ERROR) << "Device binding error using port " << device_port;
|
| + LOG(ERROR) << device_serial
|
| + << ": Device binding error using port "
|
| + << device_port;
|
| return host_controller;
|
| }
|
| host_controller.reset(new HostController(
|
| - device_port_allocated, host_port, adb_port, error_callback,
|
| + device_serial, device_port_allocated, host_port, adb_port, error_callback,
|
| std::move(adb_control_socket), std::move(delete_controller_notifier)));
|
| return host_controller;
|
| }
|
| @@ -64,6 +68,7 @@ void HostController::Start() {
|
| }
|
|
|
| HostController::HostController(
|
| + const std::string& device_serial,
|
| int device_port,
|
| int host_port,
|
| int adb_port,
|
| @@ -71,6 +76,7 @@ HostController::HostController(
|
| std::unique_ptr<Socket> adb_control_socket,
|
| std::unique_ptr<PipeNotifier> delete_controller_notifier)
|
| : self_deleter_helper_(this, error_callback),
|
| + device_serial_(device_serial),
|
| device_port_(device_port),
|
| host_port_(host_port),
|
| adb_port_(adb_port),
|
| @@ -88,7 +94,8 @@ void HostController::ReadNextCommandSoon() {
|
|
|
| void HostController::ReadCommandOnInternalThread() {
|
| if (!ReceivedCommand(command::ACCEPT_SUCCESS, adb_control_socket_.get())) {
|
| - LOG(ERROR) << "Did not receive ACCEPT_SUCCESS for port: "
|
| + LOG(ERROR) << device_serial_
|
| + << ": Did not receive ACCEPT_SUCCESS for port: "
|
| << host_port_;
|
| OnInternalThreadError();
|
| return;
|
| @@ -96,7 +103,8 @@ void HostController::ReadCommandOnInternalThread() {
|
| // Try to connect to host server.
|
| std::unique_ptr<Socket> host_server_data_socket(new Socket());
|
| if (!host_server_data_socket->ConnectTcp(std::string(), host_port_)) {
|
| - LOG(ERROR) << "Could not Connect HostServerData socket on port: "
|
| + LOG(ERROR) << device_serial_
|
| + << ": Could not Connect HostServerData socket on port: "
|
| << host_port_;
|
| SendCommand(
|
| command::HOST_SERVER_ERROR, device_port_, adb_control_socket_.get());
|
| @@ -110,7 +118,9 @@ void HostController::ReadCommandOnInternalThread() {
|
| OnInternalThreadError();
|
| return;
|
| }
|
| - LOG(INFO) << "Will send HOST_SERVER_SUCCESS: " << host_port_;
|
| + LOG(INFO) << device_serial_
|
| + << ": Will send HOST_SERVER_SUCCESS: "
|
| + << host_port_;
|
| SendCommand(
|
| command::HOST_SERVER_SUCCESS, device_port_, adb_control_socket_.get());
|
| StartForwarder(std::move(host_server_data_socket));
|
| @@ -121,7 +131,9 @@ void HostController::StartForwarder(
|
| std::unique_ptr<Socket> host_server_data_socket) {
|
| std::unique_ptr<Socket> adb_data_socket(new Socket());
|
| if (!adb_data_socket->ConnectTcp("", adb_port_)) {
|
| - LOG(ERROR) << "Could not connect AdbDataSocket on port: " << adb_port_;
|
| + LOG(ERROR) << device_serial_
|
| + << ": Could not connect AdbDataSocket on port: "
|
| + << adb_port_;
|
| OnInternalThreadError();
|
| return;
|
| }
|
| @@ -134,7 +146,8 @@ void HostController::StartForwarder(
|
| // DeviceListener thread just after the call to WaitForAdbDataSocket().
|
| if (!ReceivedCommand(command::ADB_DATA_SOCKET_SUCCESS,
|
| adb_control_socket_.get())) {
|
| - LOG(ERROR) << "Device could not handle the new Adb Data Connection.";
|
| + LOG(ERROR) << device_serial_
|
| + << ": Device could not handle the new Adb Data Connection.";
|
| OnInternalThreadError();
|
| return;
|
| }
|
| @@ -150,15 +163,21 @@ void HostController::OnInternalThreadError() {
|
| void HostController::UnmapPortOnDevice() {
|
| Socket socket;
|
| if (!socket.ConnectTcp("", adb_port_)) {
|
| - LOG(ERROR) << "Could not connect to device on port " << adb_port_;
|
| + LOG(ERROR) << device_serial_
|
| + << ": Could not connect to device on port "
|
| + << adb_port_;
|
| return;
|
| }
|
| if (!SendCommand(command::UNLISTEN, device_port_, &socket)) {
|
| - LOG(ERROR) << "Could not send unmap command for port " << device_port_;
|
| + LOG(ERROR) << device_serial_
|
| + << ": Could not send unmap command for port "
|
| + << device_port_;
|
| return;
|
| }
|
| if (!ReceivedCommand(command::UNLISTEN_SUCCESS, &socket)) {
|
| - LOG(ERROR) << "Unamp command failed for port " << device_port_;
|
| + LOG(ERROR) << device_serial_
|
| + << ": Unmap command failed for port "
|
| + << device_port_;
|
| return;
|
| }
|
| }
|
|
|