Loading system/service/Android.mk +31 −23 Original line number Diff line number Diff line Loading @@ -16,25 +16,9 @@ LOCAL_PATH:= $(call my-dir) ifeq ($(HOST_OS),linux) include $(CLEAR_VARS) LOCAL_SRC_FILES := \ settings.cpp \ test/settings_unittest.cpp \ test/uuid_unittest.cpp \ uuid.cpp LOCAL_C_INCLUDES += \ $(LOCAL_PATH)/../ LOCAL_CFLAGS += -std=c++11 LOCAL_MODULE_TAGS := tests LOCAL_MODULE := bt_service_unittests LOCAL_SHARED_LIBRARIES += libchrome-host include $(BUILD_HOST_NATIVE_TEST) endif include $(CLEAR_VARS) LOCAL_SRC_FILES := \ # Common variables # ======================================================== btserviceCommonSrc := \ a2dp_source.cpp \ core_stack.cpp \ daemon.cpp \ Loading @@ -44,13 +28,18 @@ LOCAL_SRC_FILES := \ ipc/ipc_manager.cpp \ ipc/unix_ipc_host.cpp \ logging_helpers.cpp \ main.cpp \ settings.cpp \ uuid.cpp LOCAL_C_INCLUDES += \ $(LOCAL_PATH)/../ btserviceCommonIncludes := $(LOCAL_PATH)/../ # Native system service for target # ======================================================== include $(CLEAR_VARS) LOCAL_SRC_FILES := \ $(btserviceCommonSrc) \ main.cpp LOCAL_C_INCLUDES += $(btserviceCommonIncludes) LOCAL_CFLAGS += -std=c++11 LOCAL_MODULE_TAGS := optional LOCAL_MODULE := bluetoothtbd Loading @@ -61,5 +50,24 @@ LOCAL_SHARED_LIBRARIES += \ libcutils \ libhardware \ liblog include $(BUILD_EXECUTABLE) # Native system service unittests for host # ======================================================== ifeq ($(HOST_OS),linux) include $(CLEAR_VARS) LOCAL_SRC_FILES := \ $(btserviceCommonSrc) \ test/fake_hal_util.cpp \ test/ipc_unix_unittest.cpp \ test/settings_unittest.cpp \ test/uuid_unittest.cpp LOCAL_C_INCLUDES += $(btserviceCommonIncludes) LOCAL_CFLAGS += -std=c++11 LOCAL_LDLIBS += -lrt LOCAL_MODULE_TAGS := tests LOCAL_MODULE := bt_service_unittests LOCAL_SHARED_LIBRARIES += libchrome-host LOCAL_STATIC_LIBRARIES += libgmock_host liblog include $(BUILD_HOST_NATIVE_TEST) endif system/service/BUILD.gn +4 −0 Original line number Diff line number Diff line Loading @@ -58,17 +58,21 @@ executable("bluetoothtbd") { executable("service_unittests") { testonly = true sources = [ "test/fake_hal_util.cpp", "test/ipc_unix_unittest.cpp", "test/settings_unittest.cpp", "test/uuid_unittest.cpp", ] include_dirs = [ "//", "//third_party/gmock/include", "//third_party/libchrome" ] deps = [ ":service", "//third_party/gmock:gmock_main", "//third_party/gtest:gtest_main", "//third_party/libchrome:base", "//third_party/modp_b64", Loading system/service/daemon.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ class DaemonImpl : public Daemon { // If an IPC socket path was given, initialize IPC with it. if ((!settings_->create_ipc_socket_path().empty() || !settings_->android_ipc_socket_suffix().empty()) && !ipc_manager_->Start(ipc::IPCManager::TYPE_UNIX)) { !ipc_manager_->Start(ipc::IPCManager::TYPE_UNIX, nullptr)) { LOG(ERROR) << "Failed to set up UNIX domain-socket IPCManager"; return false; } Loading system/service/ipc/ipc_handler.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -20,8 +20,10 @@ namespace ipc { IPCHandler::IPCHandler(bluetooth::CoreStack* core_stack) : core_stack_(core_stack) { IPCHandler::IPCHandler(bluetooth::CoreStack* core_stack, IPCManager::Delegate* delegate) : core_stack_(core_stack), delegate_(delegate) { CHECK(core_stack_); } Loading system/service/ipc/ipc_handler.h +17 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include <base/macros.h> #include <base/memory/ref_counted.h> #include "service/ipc/ipc_manager.h" namespace bluetooth { class CoreStack; } // namespace bluetooth Loading @@ -29,20 +31,31 @@ namespace ipc { // must conform to. class IPCHandler : public base::RefCountedThreadSafe<IPCHandler> { public: explicit IPCHandler(bluetooth::CoreStack* core_stack); IPCHandler(bluetooth::CoreStack* core_stack, IPCManager::Delegate* delegate); virtual ~IPCHandler(); // Initializes and runs the IPC mechanis. Returns true on success, false // Initializes and runs the IPC mechanism. Returns true on success, false // otherwise. virtual bool Run() = 0; // Stops the IPC mechanism. virtual void Stop() = 0; protected: // Weak reference to the global CoreStack instance. bluetooth::CoreStack* core_stack_; // Getters for private members to allow subclasses to access them in read-only // fashion. bluetooth::CoreStack* core_stack() const { return core_stack_; } IPCManager::Delegate* delegate() const { return delegate_; } private: IPCHandler() = default; // Weak reference to the global CoreStack instance. bluetooth::CoreStack* core_stack_; // The delegate that is interested in notifications from us. IPCManager::Delegate* delegate_; DISALLOW_COPY_AND_ASSIGN(IPCHandler); }; Loading Loading
system/service/Android.mk +31 −23 Original line number Diff line number Diff line Loading @@ -16,25 +16,9 @@ LOCAL_PATH:= $(call my-dir) ifeq ($(HOST_OS),linux) include $(CLEAR_VARS) LOCAL_SRC_FILES := \ settings.cpp \ test/settings_unittest.cpp \ test/uuid_unittest.cpp \ uuid.cpp LOCAL_C_INCLUDES += \ $(LOCAL_PATH)/../ LOCAL_CFLAGS += -std=c++11 LOCAL_MODULE_TAGS := tests LOCAL_MODULE := bt_service_unittests LOCAL_SHARED_LIBRARIES += libchrome-host include $(BUILD_HOST_NATIVE_TEST) endif include $(CLEAR_VARS) LOCAL_SRC_FILES := \ # Common variables # ======================================================== btserviceCommonSrc := \ a2dp_source.cpp \ core_stack.cpp \ daemon.cpp \ Loading @@ -44,13 +28,18 @@ LOCAL_SRC_FILES := \ ipc/ipc_manager.cpp \ ipc/unix_ipc_host.cpp \ logging_helpers.cpp \ main.cpp \ settings.cpp \ uuid.cpp LOCAL_C_INCLUDES += \ $(LOCAL_PATH)/../ btserviceCommonIncludes := $(LOCAL_PATH)/../ # Native system service for target # ======================================================== include $(CLEAR_VARS) LOCAL_SRC_FILES := \ $(btserviceCommonSrc) \ main.cpp LOCAL_C_INCLUDES += $(btserviceCommonIncludes) LOCAL_CFLAGS += -std=c++11 LOCAL_MODULE_TAGS := optional LOCAL_MODULE := bluetoothtbd Loading @@ -61,5 +50,24 @@ LOCAL_SHARED_LIBRARIES += \ libcutils \ libhardware \ liblog include $(BUILD_EXECUTABLE) # Native system service unittests for host # ======================================================== ifeq ($(HOST_OS),linux) include $(CLEAR_VARS) LOCAL_SRC_FILES := \ $(btserviceCommonSrc) \ test/fake_hal_util.cpp \ test/ipc_unix_unittest.cpp \ test/settings_unittest.cpp \ test/uuid_unittest.cpp LOCAL_C_INCLUDES += $(btserviceCommonIncludes) LOCAL_CFLAGS += -std=c++11 LOCAL_LDLIBS += -lrt LOCAL_MODULE_TAGS := tests LOCAL_MODULE := bt_service_unittests LOCAL_SHARED_LIBRARIES += libchrome-host LOCAL_STATIC_LIBRARIES += libgmock_host liblog include $(BUILD_HOST_NATIVE_TEST) endif
system/service/BUILD.gn +4 −0 Original line number Diff line number Diff line Loading @@ -58,17 +58,21 @@ executable("bluetoothtbd") { executable("service_unittests") { testonly = true sources = [ "test/fake_hal_util.cpp", "test/ipc_unix_unittest.cpp", "test/settings_unittest.cpp", "test/uuid_unittest.cpp", ] include_dirs = [ "//", "//third_party/gmock/include", "//third_party/libchrome" ] deps = [ ":service", "//third_party/gmock:gmock_main", "//third_party/gtest:gtest_main", "//third_party/libchrome:base", "//third_party/modp_b64", Loading
system/service/daemon.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ class DaemonImpl : public Daemon { // If an IPC socket path was given, initialize IPC with it. if ((!settings_->create_ipc_socket_path().empty() || !settings_->android_ipc_socket_suffix().empty()) && !ipc_manager_->Start(ipc::IPCManager::TYPE_UNIX)) { !ipc_manager_->Start(ipc::IPCManager::TYPE_UNIX, nullptr)) { LOG(ERROR) << "Failed to set up UNIX domain-socket IPCManager"; return false; } Loading
system/service/ipc/ipc_handler.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -20,8 +20,10 @@ namespace ipc { IPCHandler::IPCHandler(bluetooth::CoreStack* core_stack) : core_stack_(core_stack) { IPCHandler::IPCHandler(bluetooth::CoreStack* core_stack, IPCManager::Delegate* delegate) : core_stack_(core_stack), delegate_(delegate) { CHECK(core_stack_); } Loading
system/service/ipc/ipc_handler.h +17 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include <base/macros.h> #include <base/memory/ref_counted.h> #include "service/ipc/ipc_manager.h" namespace bluetooth { class CoreStack; } // namespace bluetooth Loading @@ -29,20 +31,31 @@ namespace ipc { // must conform to. class IPCHandler : public base::RefCountedThreadSafe<IPCHandler> { public: explicit IPCHandler(bluetooth::CoreStack* core_stack); IPCHandler(bluetooth::CoreStack* core_stack, IPCManager::Delegate* delegate); virtual ~IPCHandler(); // Initializes and runs the IPC mechanis. Returns true on success, false // Initializes and runs the IPC mechanism. Returns true on success, false // otherwise. virtual bool Run() = 0; // Stops the IPC mechanism. virtual void Stop() = 0; protected: // Weak reference to the global CoreStack instance. bluetooth::CoreStack* core_stack_; // Getters for private members to allow subclasses to access them in read-only // fashion. bluetooth::CoreStack* core_stack() const { return core_stack_; } IPCManager::Delegate* delegate() const { return delegate_; } private: IPCHandler() = default; // Weak reference to the global CoreStack instance. bluetooth::CoreStack* core_stack_; // The delegate that is interested in notifications from us. IPCManager::Delegate* delegate_; DISALLOW_COPY_AND_ASSIGN(IPCHandler); }; Loading