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

Commit 3c8e0afe authored by Scott James Remnant's avatar Scott James Remnant Committed by Android Git Automerger
Browse files

am 29768959: am f2f35b26: Rename IPCHandlerUnix to IPCHandlerLinux

* commit '29768959':
  Rename IPCHandlerUnix to IPCHandlerLinux
parents bfca3793 29768959
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -28,15 +28,17 @@ btserviceCommonSrc := \
	hal/bluetooth_gatt_interface.cpp \
	hal/bluetooth_gatt_interface.cpp \
	hal/bluetooth_interface.cpp \
	hal/bluetooth_interface.cpp \
	ipc/ipc_handler.cpp \
	ipc/ipc_handler.cpp \
	ipc/ipc_handler_unix.cpp \
	ipc/ipc_manager.cpp \
	ipc/ipc_manager.cpp \
	ipc/unix_ipc_host.cpp \
	logging_helpers.cpp \
	logging_helpers.cpp \
	low_energy_client.cpp \
	low_energy_client.cpp \
	settings.cpp \
	settings.cpp \
	util/atomic_string.cpp \
	util/atomic_string.cpp \
	uuid.cpp
	uuid.cpp


btserviceLinuxSrc := \
	ipc/ipc_handler_linux.cpp \
	ipc/linux_ipc_host.cpp

btserviceBinderSrc := \
btserviceBinderSrc := \
	ipc/binder/bluetooth_binder_server.cpp \
	ipc/binder/bluetooth_binder_server.cpp \
	ipc/binder/bluetooth_gatt_server_binder_server.cpp \
	ipc/binder/bluetooth_gatt_server_binder_server.cpp \
@@ -58,6 +60,7 @@ btserviceCommonIncludes := $(LOCAL_PATH)/../
include $(CLEAR_VARS)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
LOCAL_SRC_FILES := \
	$(btserviceBinderSrc) \
	$(btserviceBinderSrc) \
	$(btserviceLinuxSrc) \
	$(btserviceCommonSrc) \
	$(btserviceCommonSrc) \
	main.cpp
	main.cpp
LOCAL_C_INCLUDES += $(btserviceCommonIncludes)
LOCAL_C_INCLUDES += $(btserviceCommonIncludes)
@@ -82,12 +85,13 @@ ifeq ($(HOST_OS),linux)
include $(CLEAR_VARS)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
LOCAL_SRC_FILES := \
	$(btserviceCommonSrc) \
	$(btserviceCommonSrc) \
	$(btserviceLinuxSrc) \
	hal/fake_bluetooth_gatt_interface.cpp \
	hal/fake_bluetooth_gatt_interface.cpp \
	hal/fake_bluetooth_interface.cpp \
	hal/fake_bluetooth_interface.cpp \
	test/adapter_unittest.cpp \
	test/adapter_unittest.cpp \
	test/advertise_data_unittest.cpp \
	test/advertise_data_unittest.cpp \
	test/fake_hal_util.cpp \
	test/fake_hal_util.cpp \
	test/ipc_unix_unittest.cpp \
	test/ipc_linux_unittest.cpp \
	test/low_energy_client_unittest.cpp \
	test/low_energy_client_unittest.cpp \
	test/settings_unittest.cpp \
	test/settings_unittest.cpp \
	test/stub_ipc_handler_binder.cpp \
	test/stub_ipc_handler_binder.cpp \
+3 −3
Original line number Original line Diff line number Diff line
@@ -21,9 +21,9 @@ source_set("service") {
    "daemon.cpp",
    "daemon.cpp",
    "gatt_server.cpp",
    "gatt_server.cpp",
    "ipc/ipc_handler.cpp",
    "ipc/ipc_handler.cpp",
    "ipc/ipc_handler_unix.cpp",
    "ipc/ipc_handler_linux.cpp",
    "ipc/ipc_manager.cpp",
    "ipc/ipc_manager.cpp",
    "ipc/unix_ipc_host.cpp",
    "ipc/linux_ipc_host.cpp",
    "logging_helpers.cpp",
    "logging_helpers.cpp",
    "settings.cpp",
    "settings.cpp",
    "uuid.cpp"
    "uuid.cpp"
@@ -59,7 +59,7 @@ executable("service_unittests") {
  testonly = true
  testonly = true
  sources = [
  sources = [
    "test/fake_hal_util.cpp",
    "test/fake_hal_util.cpp",
    "test/ipc_unix_unittest.cpp",
    "test/ipc_linux_unittest.cpp",
    "test/settings_unittest.cpp",
    "test/settings_unittest.cpp",
    "test/uuid_unittest.cpp",
    "test/uuid_unittest.cpp",
  ]
  ]
+1 −1
Original line number Original line Diff line number Diff line
@@ -90,7 +90,7 @@ class DaemonImpl : public Daemon {
    // If an IPC socket path was given, initialize IPC with it. Otherwise
    // If an IPC socket path was given, initialize IPC with it. Otherwise
    // initialize Binder IPC.
    // initialize Binder IPC.
    if (settings_->UseSocketIPC()) {
    if (settings_->UseSocketIPC()) {
      if (!ipc_manager_->Start(ipc::IPCManager::TYPE_UNIX, nullptr)) {
      if (!ipc_manager_->Start(ipc::IPCManager::TYPE_LINUX, nullptr)) {
        LOG(ERROR) << "Failed to set up UNIX domain-socket IPCManager";
        LOG(ERROR) << "Failed to set up UNIX domain-socket IPCManager";
        return false;
        return false;
      }
      }
+22 −22
Original line number Original line Diff line number Diff line
@@ -14,7 +14,7 @@
//  limitations under the License.
//  limitations under the License.
//
//


#include "service/ipc/ipc_handler_unix.h"
#include "service/ipc/ipc_handler_linux.h"


#include <sys/socket.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/un.h>
@@ -23,27 +23,27 @@


#include "osi/include/socket_utils/sockets.h"
#include "osi/include/socket_utils/sockets.h"
#include "service/daemon.h"
#include "service/daemon.h"
#include "service/ipc/unix_ipc_host.h"
#include "service/ipc/linux_ipc_host.h"
#include "service/settings.h"
#include "service/settings.h"


namespace ipc {
namespace ipc {


IPCHandlerUnix::IPCHandlerUnix(bluetooth::Adapter* adapter,
IPCHandlerLinux::IPCHandlerLinux(bluetooth::Adapter* adapter,
                               IPCManager::Delegate* delegate)
                               IPCManager::Delegate* delegate)
    : IPCHandler(adapter, delegate),
    : IPCHandler(adapter, delegate),
      running_(false),
      running_(false),
      thread_("IPCHandlerUnix"),
      thread_("IPCHandlerLinux"),
      keep_running_(true) {
      keep_running_(true) {
}
}


IPCHandlerUnix::~IPCHandlerUnix() {
IPCHandlerLinux::~IPCHandlerLinux() {
  // This will only be set if the Settings::create_ipc_socket_path() was
  // This will only be set if the Settings::create_ipc_socket_path() was
  // originally provided.
  // originally provided.
  if (!socket_path_.empty())
  if (!socket_path_.empty())
    unlink(socket_path_.value().c_str());
    unlink(socket_path_.value().c_str());
}
}


bool IPCHandlerUnix::Run() {
bool IPCHandlerLinux::Run() {
  CHECK(!running_);
  CHECK(!running_);


  const std::string& android_suffix =
  const std::string& android_suffix =
@@ -106,19 +106,19 @@ bool IPCHandlerUnix::Run() {
  // Start an IO thread and post the listening task.
  // Start an IO thread and post the listening task.
  base::Thread::Options options(base::MessageLoop::TYPE_IO, 0);
  base::Thread::Options options(base::MessageLoop::TYPE_IO, 0);
  if (!thread_.StartWithOptions(options)) {
  if (!thread_.StartWithOptions(options)) {
    LOG(ERROR) << "Failed to start IPCHandlerUnix thread";
    LOG(ERROR) << "Failed to start IPCHandlerLinux thread";
    running_ = false;
    running_ = false;
    return false;
    return false;
  }
  }


  thread_.task_runner()->PostTask(
  thread_.task_runner()->PostTask(
      FROM_HERE,
      FROM_HERE,
      base::Bind(&IPCHandlerUnix::StartListeningOnThread, this));
      base::Bind(&IPCHandlerLinux::StartListeningOnThread, this));


  return true;
  return true;
}
}


void IPCHandlerUnix::Stop() {
void IPCHandlerLinux::Stop() {
  keep_running_ = false;
  keep_running_ = false;


  // At this moment the listening thread might be blocking on the accept
  // At this moment the listening thread might be blocking on the accept
@@ -135,7 +135,7 @@ void IPCHandlerUnix::Stop() {
  NotifyStoppedOnOriginThread();
  NotifyStoppedOnOriginThread();
}
}


void IPCHandlerUnix::StartListeningOnThread() {
void IPCHandlerLinux::StartListeningOnThread() {
  CHECK(socket_.is_valid());
  CHECK(socket_.is_valid());
  CHECK(adapter());
  CHECK(adapter());
  CHECK(running_);
  CHECK(running_);
@@ -147,7 +147,7 @@ void IPCHandlerUnix::StartListeningOnThread() {
    LOG(ERROR) << "Failed to listen on domain socket: " << strerror(errno);
    LOG(ERROR) << "Failed to listen on domain socket: " << strerror(errno);
    origin_task_runner_->PostTask(
    origin_task_runner_->PostTask(
        FROM_HERE,
        FROM_HERE,
        base::Bind(&IPCHandlerUnix::ShutDownOnOriginThread, this));
        base::Bind(&IPCHandlerLinux::ShutDownOnOriginThread, this));
    return;
    return;
  }
  }


@@ -168,7 +168,7 @@ void IPCHandlerUnix::StartListeningOnThread() {


    LOG(INFO) << "Established client connection: fd=" << client_socket;
    LOG(INFO) << "Established client connection: fd=" << client_socket;


    UnixIPCHost ipc_host(client_socket, adapter());
    LinuxIPCHost ipc_host(client_socket, adapter());


    // TODO(armansito): Use |thread_|'s MessageLoopForIO instead of using a
    // TODO(armansito): Use |thread_|'s MessageLoopForIO instead of using a
    // custom event loop to poll from the socket.
    // custom event loop to poll from the socket.
@@ -176,40 +176,40 @@ void IPCHandlerUnix::StartListeningOnThread() {
  }
  }
}
}


void IPCHandlerUnix::ShutDownOnOriginThread() {
void IPCHandlerLinux::ShutDownOnOriginThread() {
  LOG(INFO) << "Shutting down IPCHandlerUnix thread";
  LOG(INFO) << "Shutting down IPCHandlerLinux thread";
  thread_.Stop();
  thread_.Stop();
  running_ = false;
  running_ = false;


  NotifyStoppedOnCurrentThread();
  NotifyStoppedOnCurrentThread();
}
}


void IPCHandlerUnix::NotifyStartedOnOriginThread() {
void IPCHandlerLinux::NotifyStartedOnOriginThread() {
  if (!delegate())
  if (!delegate())
    return;
    return;


  origin_task_runner_->PostTask(
  origin_task_runner_->PostTask(
      FROM_HERE,
      FROM_HERE,
      base::Bind(&IPCHandlerUnix::NotifyStartedOnCurrentThread, this));
      base::Bind(&IPCHandlerLinux::NotifyStartedOnCurrentThread, this));
}
}


void IPCHandlerUnix::NotifyStartedOnCurrentThread() {
void IPCHandlerLinux::NotifyStartedOnCurrentThread() {
  if (delegate())
  if (delegate())
    delegate()->OnIPCHandlerStarted(IPCManager::TYPE_UNIX);
    delegate()->OnIPCHandlerStarted(IPCManager::TYPE_LINUX);
}
}


void IPCHandlerUnix::NotifyStoppedOnOriginThread() {
void IPCHandlerLinux::NotifyStoppedOnOriginThread() {
  if (!delegate())
  if (!delegate())
    return;
    return;


  origin_task_runner_->PostTask(
  origin_task_runner_->PostTask(
      FROM_HERE,
      FROM_HERE,
      base::Bind(&IPCHandlerUnix::NotifyStoppedOnCurrentThread, this));
      base::Bind(&IPCHandlerLinux::NotifyStoppedOnCurrentThread, this));
}
}


void IPCHandlerUnix::NotifyStoppedOnCurrentThread() {
void IPCHandlerLinux::NotifyStoppedOnCurrentThread() {
  if (delegate())
  if (delegate())
    delegate()->OnIPCHandlerStopped(IPCManager::TYPE_UNIX);
    delegate()->OnIPCHandlerStopped(IPCManager::TYPE_LINUX);
}
}


}  // namespace ipc
}  // namespace ipc
+6 −6
Original line number Original line Diff line number Diff line
@@ -32,19 +32,19 @@ class SingleThreadTaskRunner;


namespace ipc {
namespace ipc {


// Implements a UNIX domain-socket based IPCHandler
// Implements a Linux sequential packet domain-socket based IPCHandler
class IPCHandlerUnix : public IPCHandler {
class IPCHandlerLinux : public IPCHandler {
 public:
 public:
  IPCHandlerUnix(bluetooth::Adapter* adapter,
  IPCHandlerLinux(bluetooth::Adapter* adapter,
                 IPCManager::Delegate* delegate);
                 IPCManager::Delegate* delegate);
  ~IPCHandlerUnix() override;
  ~IPCHandlerLinux() override;


  // IPCHandler overrides:
  // IPCHandler overrides:
  bool Run() override;
  bool Run() override;
  void Stop() override;
  void Stop() override;


 private:
 private:
  IPCHandlerUnix() = default;
  IPCHandlerLinux() = default;


  // Starts listening for incoming connections. Posted on |thread_| by Run().
  // Starts listening for incoming connections. Posted on |thread_| by Run().
  void StartListeningOnThread();
  void StartListeningOnThread();
@@ -80,7 +80,7 @@ class IPCHandlerUnix : public IPCHandler {
  // The origin thread's task runner.
  // The origin thread's task runner.
  scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_;
  scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_;


  DISALLOW_COPY_AND_ASSIGN(IPCHandlerUnix);
  DISALLOW_COPY_AND_ASSIGN(IPCHandlerLinux);
};
};


}  // namespace ipc
}  // namespace ipc
Loading