From 93e66a66464aa30ca7184e4a7378c8e8d752cbe1 Mon Sep 17 00:00:00 2001 From: Arman Uguray Date: Thu, 20 Aug 2015 13:07:18 -0700 Subject: [PATCH] service: Move UNIX IPC code into ipc/unix/ Moved the UNIX IPC related code into a new ipc/unix subdirectory. Added new namespace levels for unix and binder that mimic the directory structure. Change-Id: I58954d0c3dd1a6fe9c141c3122d42530385265f6 --- service/Android.mk | 4 ++-- service/ipc/binder/ipc_handler_binder.cpp | 2 ++ service/ipc/binder/ipc_handler_binder.h | 2 ++ service/ipc/ipc_manager.cpp | 6 +++--- service/ipc/{ => unix}/ipc_handler_unix.cpp | 6 ++++-- service/ipc/{ => unix}/ipc_handler_unix.h | 2 ++ service/ipc/{ => unix}/unix_ipc_host.cpp | 4 +++- service/ipc/{ => unix}/unix_ipc_host.h | 2 ++ service/test/stub_ipc_handler_binder.cpp | 4 +++- 9 files changed, 23 insertions(+), 9 deletions(-) rename service/ipc/{ => unix}/ipc_handler_unix.cpp (98%) rename service/ipc/{ => unix}/ipc_handler_unix.h (98%) rename service/ipc/{ => unix}/unix_ipc_host.cpp (99%) rename service/ipc/{ => unix}/unix_ipc_host.h (98%) diff --git a/service/Android.mk b/service/Android.mk index 956e534cc..d6de98bab 100644 --- a/service/Android.mk +++ b/service/Android.mk @@ -25,9 +25,9 @@ btserviceCommonSrc := \ gatt_server.cpp \ hal/bluetooth_interface.cpp \ ipc/ipc_handler.cpp \ - ipc/ipc_handler_unix.cpp \ ipc/ipc_manager.cpp \ - ipc/unix_ipc_host.cpp \ + ipc/unix/ipc_handler_unix.cpp \ + ipc/unix/unix_ipc_host.cpp \ logging_helpers.cpp \ settings.cpp \ util/atomic_string.cpp \ diff --git a/service/ipc/binder/ipc_handler_binder.cpp b/service/ipc/binder/ipc_handler_binder.cpp index 46e8a5f96..bb97d382b 100644 --- a/service/ipc/binder/ipc_handler_binder.cpp +++ b/service/ipc/binder/ipc_handler_binder.cpp @@ -31,6 +31,7 @@ using android::status_t; using android::String16; namespace ipc { +namespace binder { IPCHandlerBinder::IPCHandlerBinder( bluetooth::Adapter* adapter, @@ -79,4 +80,5 @@ void IPCHandlerBinder::NotifyStarted() { delegate()->OnIPCHandlerStarted(IPCManager::TYPE_BINDER); } +} // namespace binder } // namespace ipc diff --git a/service/ipc/binder/ipc_handler_binder.h b/service/ipc/binder/ipc_handler_binder.h index ef8621b79..3a8931f4d 100644 --- a/service/ipc/binder/ipc_handler_binder.h +++ b/service/ipc/binder/ipc_handler_binder.h @@ -22,6 +22,7 @@ #include "service/ipc/ipc_manager.h" namespace ipc { +namespace binder { // Implements a Binder based IPCHandler. class IPCHandlerBinder : public IPCHandler { @@ -43,4 +44,5 @@ class IPCHandlerBinder : public IPCHandler { DISALLOW_COPY_AND_ASSIGN(IPCHandlerBinder); }; +} // namespace binder } // namespace ipc diff --git a/service/ipc/ipc_manager.cpp b/service/ipc/ipc_manager.cpp index 40d57a313..aeabd1fe0 100644 --- a/service/ipc/ipc_manager.cpp +++ b/service/ipc/ipc_manager.cpp @@ -17,7 +17,7 @@ #include "service/ipc/ipc_manager.h" #include "service/ipc/binder/ipc_handler_binder.h" -#include "service/ipc/ipc_handler_unix.h" +#include "service/ipc/unix/ipc_handler_unix.h" namespace ipc { @@ -43,7 +43,7 @@ bool IPCManager::Start(Type type, Delegate* delegate) { return false; } - unix_handler_ = new IPCHandlerUnix(adapter_, delegate); + unix_handler_ = new unix::IPCHandlerUnix(adapter_, delegate); if (!unix_handler_->Run()) { unix_handler_ = nullptr; return false; @@ -56,7 +56,7 @@ bool IPCManager::Start(Type type, Delegate* delegate) { return false; } - binder_handler_ = new IPCHandlerBinder(adapter_, delegate); + binder_handler_ = new binder::IPCHandlerBinder(adapter_, delegate); if (!binder_handler_->Run()) { binder_handler_ = nullptr; return false; diff --git a/service/ipc/ipc_handler_unix.cpp b/service/ipc/unix/ipc_handler_unix.cpp similarity index 98% rename from service/ipc/ipc_handler_unix.cpp rename to service/ipc/unix/ipc_handler_unix.cpp index eaba84db0..a847e9b51 100644 --- a/service/ipc/ipc_handler_unix.cpp +++ b/service/ipc/unix/ipc_handler_unix.cpp @@ -14,7 +14,7 @@ // limitations under the License. // -#include "service/ipc/ipc_handler_unix.h" +#include "service/ipc/unix/ipc_handler_unix.h" #include #include @@ -23,10 +23,11 @@ #include "osi/include/socket_utils/sockets.h" #include "service/daemon.h" -#include "service/ipc/unix_ipc_host.h" +#include "service/ipc/unix/unix_ipc_host.h" #include "service/settings.h" namespace ipc { +namespace unix { IPCHandlerUnix::IPCHandlerUnix(bluetooth::Adapter* adapter, IPCManager::Delegate* delegate) @@ -212,4 +213,5 @@ void IPCHandlerUnix::NotifyStoppedOnCurrentThread() { delegate()->OnIPCHandlerStopped(IPCManager::TYPE_UNIX); } +} // namespace unix } // namespace ipc diff --git a/service/ipc/ipc_handler_unix.h b/service/ipc/unix/ipc_handler_unix.h similarity index 98% rename from service/ipc/ipc_handler_unix.h rename to service/ipc/unix/ipc_handler_unix.h index 4b9174037..da3913c1e 100644 --- a/service/ipc/ipc_handler_unix.h +++ b/service/ipc/unix/ipc_handler_unix.h @@ -31,6 +31,7 @@ class SingleThreadTaskRunner; } // namespace base namespace ipc { +namespace unix { // Implements a UNIX domain-socket based IPCHandler class IPCHandlerUnix : public IPCHandler { @@ -83,4 +84,5 @@ class IPCHandlerUnix : public IPCHandler { DISALLOW_COPY_AND_ASSIGN(IPCHandlerUnix); }; +} // namespace unix } // namespace ipc diff --git a/service/ipc/unix_ipc_host.cpp b/service/ipc/unix/unix_ipc_host.cpp similarity index 99% rename from service/ipc/unix_ipc_host.cpp rename to service/ipc/unix/unix_ipc_host.cpp index 2f801d4f5..ee284fbe1 100644 --- a/service/ipc/unix_ipc_host.cpp +++ b/service/ipc/unix/unix_ipc_host.cpp @@ -16,7 +16,7 @@ #define LOG_TAG "bt_bluetooth_host" -#include "service/ipc/unix_ipc_host.h" +#include "service/ipc/unix/unix_ipc_host.h" #include #include @@ -74,6 +74,7 @@ bool TokenBool(const std::string& text) { } // namespace namespace ipc { +namespace unix { UnixIPCHost::UnixIPCHost(int sockfd, Adapter* adapter) : adapter_(adapter), pfds_(1, {sockfd, POLLIN, 0}) {} @@ -336,4 +337,5 @@ bool UnixIPCHost::OnGattWrite() { return true; } +} // namespace unix } // namespace ipc diff --git a/service/ipc/unix_ipc_host.h b/service/ipc/unix/unix_ipc_host.h similarity index 98% rename from service/ipc/unix_ipc_host.h rename to service/ipc/unix/unix_ipc_host.h index 1ebf60a19..af84db4ad 100644 --- a/service/ipc/unix_ipc_host.h +++ b/service/ipc/unix/unix_ipc_host.h @@ -29,6 +29,7 @@ class Adapter; } // namespace bluetooth namespace ipc { +namespace unix { // This implements a single threaded event loop which dispatches // reads from a set of FDs (pfds_) to a set of handlers. @@ -104,4 +105,5 @@ class UnixIPCHost { gatt_servers_; }; +} // namespace unix } // namespace ipc diff --git a/service/test/stub_ipc_handler_binder.cpp b/service/test/stub_ipc_handler_binder.cpp index 6f5a13dfe..a1e7874d5 100644 --- a/service/test/stub_ipc_handler_binder.cpp +++ b/service/test/stub_ipc_handler_binder.cpp @@ -21,6 +21,7 @@ // unit tests for host. namespace ipc { +namespace binder { IPCHandlerBinder::IPCHandlerBinder( bluetooth::Adapter* adapter, @@ -46,4 +47,5 @@ void IPCHandlerBinder::NotifyStarted() { // Stub } -} // namespace +} // namespace binder +} // namespace ipc -- 2.11.0