diff --git a/Android.mk b/Android.mk index 4dd9b16..fc69de5 100644 --- a/Android.mk +++ b/Android.mk @@ -34,9 +34,10 @@ LOCAL_SRC_FILES := \ android/service/platform_api_stub.cpp \ src/anbox/common/fd.cpp \ src/anbox/common/wait_handle.cpp \ - src/anbox/bridge/message_processor.cpp \ - src/anbox/bridge/pending_call_cache.cpp \ - src/anbox/bridge/rpc_channel.cpp \ + src/anbox/rpc/message_processor.cpp \ + src/anbox/rpc/pending_call_cache.cpp \ + src/anbox/rpc/channel.cpp \ + src/anbox/protobuf/anbox_rpc.proto \ src/anbox/protobuf/anbox_bridge.proto proto_header_dir := $(call local-generated-sources-dir)/proto/$(LOCAL_PATH)/src/anbox/protobuf LOCAL_C_INCLUDES += \ diff --git a/android/service/android_api_skeleton.cpp b/android/service/android_api_skeleton.cpp index 15ba582..3181787 100644 --- a/android/service/android_api_skeleton.cpp +++ b/android/service/android_api_skeleton.cpp @@ -17,6 +17,7 @@ #include "android/service/android_api_skeleton.h" +#include "anbox_rpc.pb.h" #include "anbox_bridge.pb.h" #include @@ -37,7 +38,7 @@ AndroidApiSkeleton::~AndroidApiSkeleton() { } void AndroidApiSkeleton::wait_for_process(core::posix::ChildProcess &process, - anbox::protobuf::bridge::Void *response) { + anbox::protobuf::rpc::Void *response) { const auto result = process.wait_for(core::posix::wait::Flags::untraced); if (result.status != core::posix::wait::Result::Status::exited || result.detail.if_exited.status != core::posix::exit::Status::success) { @@ -48,7 +49,7 @@ void AndroidApiSkeleton::wait_for_process(core::posix::ChildProcess &process, } void AndroidApiSkeleton::install_application(anbox::protobuf::bridge::InstallApplication const *request, - anbox::protobuf::bridge::Void *response, + anbox::protobuf::rpc::Void *response, google::protobuf::Closure *done) { (void) response; @@ -65,7 +66,7 @@ void AndroidApiSkeleton::install_application(anbox::protobuf::bridge::InstallApp } void AndroidApiSkeleton::launch_application(anbox::protobuf::bridge::LaunchApplication const *request, - anbox::protobuf::bridge::Void *response, + anbox::protobuf::rpc::Void *response, google::protobuf::Closure *done) { (void) response; @@ -86,7 +87,7 @@ void AndroidApiSkeleton::launch_application(anbox::protobuf::bridge::LaunchAppli } void AndroidApiSkeleton::set_dns_servers(anbox::protobuf::bridge::SetDnsServers const *request, - anbox::protobuf::bridge::Void *response, + anbox::protobuf::rpc::Void *response, google::protobuf::Closure *done) { (void) response; diff --git a/android/service/android_api_skeleton.h b/android/service/android_api_skeleton.h index ac7577a..8e8787b 100644 --- a/android/service/android_api_skeleton.h +++ b/android/service/android_api_skeleton.h @@ -36,8 +36,10 @@ namespace bridge { class InstallApplication; class LaunchApplication; class SetDnsServers; -class Void; } // namespace bridge +namespace rpc { +class Void; +} // namespace rpc } // namespace protobuf class AndroidApiSkeleton { public: @@ -45,20 +47,20 @@ public: ~AndroidApiSkeleton(); void install_application(anbox::protobuf::bridge::InstallApplication const *request, - anbox::protobuf::bridge::Void *response, + anbox::protobuf::rpc::Void *response, google::protobuf::Closure *done); void launch_application(anbox::protobuf::bridge::LaunchApplication const *request, - anbox::protobuf::bridge::Void *response, + anbox::protobuf::rpc::Void *response, google::protobuf::Closure *done); void set_dns_servers(anbox::protobuf::bridge::SetDnsServers const *request, - anbox::protobuf::bridge::Void *response, + anbox::protobuf::rpc::Void *response, google::protobuf::Closure *done); private: void wait_for_process(core::posix::ChildProcess &process, - anbox::protobuf::bridge::Void *response); + anbox::protobuf::rpc::Void *response); }; } // namespace anbox diff --git a/android/service/host_connector.cpp b/android/service/host_connector.cpp index 0da40d9..5739016 100644 --- a/android/service/host_connector.cpp +++ b/android/service/host_connector.cpp @@ -21,7 +21,7 @@ #include "android/service/android_api_skeleton.h" #include "android/service/platform_api_stub.h" -#include "anbox/bridge/rpc_channel.h" +#include "anbox/rpc/channel.h" #include #include @@ -29,10 +29,10 @@ namespace anbox { HostConnector::HostConnector() : socket_(std::make_shared("/dev/anbox_bridge")), - pending_calls_(std::make_shared()), + pending_calls_(std::make_shared()), android_api_skeleton_(std::make_shared()), message_processor_(std::make_shared(socket_, pending_calls_, android_api_skeleton_)), - rpc_channel_(std::make_shared(pending_calls_, socket_)), + rpc_channel_(std::make_shared(pending_calls_, socket_)), platform_api_stub_(std::make_shared(rpc_channel_)), running_(false) { } diff --git a/android/service/host_connector.h b/android/service/host_connector.h index 2360c72..707afb2 100644 --- a/android/service/host_connector.h +++ b/android/service/host_connector.h @@ -23,10 +23,10 @@ #include namespace anbox { -namespace bridge { +namespace rpc { class PendingCallCache; -class RpcChannel; -} // namespace bridge +class Channel; +} // namespace rpc class LocalSocketConnection; class MessageProcessor; class AndroidApiSkeleton; @@ -45,10 +45,10 @@ private: void main_loop(); std::shared_ptr socket_; - std::shared_ptr pending_calls_; + std::shared_ptr pending_calls_; std::shared_ptr android_api_skeleton_; std::shared_ptr message_processor_; - std::shared_ptr rpc_channel_; + std::shared_ptr rpc_channel_; std::shared_ptr platform_api_stub_; std::thread thread_; std::atomic running_; diff --git a/android/service/message_processor.cpp b/android/service/message_processor.cpp index 1aee351..3a035be 100644 --- a/android/service/message_processor.cpp +++ b/android/service/message_processor.cpp @@ -18,20 +18,23 @@ #include "android/service/message_processor.h" #include "android/service/android_api_skeleton.h" -#include "anbox/bridge/template_message_processor.h" +#include "anbox/rpc/template_message_processor.h" + +#include "anbox_rpc.pb.h" +#include "anbox_bridge.pb.h" namespace anbox { MessageProcessor::MessageProcessor(const std::shared_ptr &sender, - const std::shared_ptr &pending_calls, + const std::shared_ptr &pending_calls, const std::shared_ptr &platform_api) : - bridge::MessageProcessor(sender, pending_calls), + rpc::MessageProcessor(sender, pending_calls), platform_api_(platform_api) { } MessageProcessor::~MessageProcessor() { } -void MessageProcessor::dispatch(bridge::Invocation const& invocation) { +void MessageProcessor::dispatch(rpc::Invocation const& invocation) { if (invocation.method_name() == "install_application") invoke(this, platform_api_.get(), &AndroidApiSkeleton::install_application, invocation); else if (invocation.method_name() == "launch_application") diff --git a/android/service/message_processor.h b/android/service/message_processor.h index abb0769..9d9e1a5 100644 --- a/android/service/message_processor.h +++ b/android/service/message_processor.h @@ -18,18 +18,18 @@ #ifndef ANBOX_ANDROID_MESSAGE_PROCESSOR_H_ #define ANBOX_ANDROID_MESSAGE_PROCESSOR_H_ -#include "anbox/bridge/message_processor.h" +#include "anbox/rpc/message_processor.h" namespace anbox { class AndroidApiSkeleton; -class MessageProcessor : public bridge::MessageProcessor { +class MessageProcessor : public rpc::MessageProcessor { public: MessageProcessor(const std::shared_ptr &sender, - const std::shared_ptr &pending_calls, + const std::shared_ptr &pending_calls, const std::shared_ptr &platform_api); ~MessageProcessor(); - void dispatch(bridge::Invocation const& invocation) override; + void dispatch(rpc::Invocation const& invocation) override; void process_event_sequence(const std::string &event) override; private: diff --git a/android/service/platform_api_stub.cpp b/android/service/platform_api_stub.cpp index 7526fa1..373df0f 100644 --- a/android/service/platform_api_stub.cpp +++ b/android/service/platform_api_stub.cpp @@ -16,20 +16,21 @@ */ #include "android/service/platform_api_stub.h" -#include "anbox/bridge/rpc_channel.h" +#include "anbox/rpc/channel.h" +#include "anbox_rpc.pb.h" #include "anbox_bridge.pb.h" #define LOG_TAG "Anbox" #include namespace anbox { -PlatformApiStub::PlatformApiStub(const std::shared_ptr &rpc_channel) : +PlatformApiStub::PlatformApiStub(const std::shared_ptr &rpc_channel) : rpc_channel_(rpc_channel) { } void PlatformApiStub::boot_finished() { - auto c = std::make_shared>(); + auto c = std::make_shared>(); ALOGI("Boot finished"); @@ -38,7 +39,7 @@ void PlatformApiStub::boot_finished() { boot_finished_wait_handle_.expect_result(); } - protobuf::bridge::Void message; + protobuf::rpc::Void message; rpc_channel_->call_method( "boot_finished", @@ -50,7 +51,7 @@ void PlatformApiStub::boot_finished() { ALOGI("Boot finished sent successfully!"); } -void PlatformApiStub::handle_boot_finished_response(Request*) { +void PlatformApiStub::handle_boot_finished_response(Request*) { ALOGI("handle_boot_finished_response"); boot_finished_wait_handle_.result_received(); } diff --git a/android/service/platform_api_stub.h b/android/service/platform_api_stub.h index 5a8104c..a18bc55 100644 --- a/android/service/platform_api_stub.h +++ b/android/service/platform_api_stub.h @@ -24,16 +24,16 @@ namespace anbox { namespace protobuf { -namespace bridge { +namespace rpc { class Void; -} // namespace bridge +} // namespace rpc } // namespace protobuf -namespace bridge { -class RpcChannel; -} // namespace bridge +namespace rpc { +class Channel; +} // namespace rpc class PlatformApiStub { public: - PlatformApiStub(const std::shared_ptr &rpc_channel); + PlatformApiStub(const std::shared_ptr &rpc_channel); void boot_finished(); @@ -45,12 +45,12 @@ private: bool success; }; - void handle_boot_finished_response(Request *request); + void handle_boot_finished_response(Request *request); mutable std::mutex mutex_; common::WaitHandle boot_finished_wait_handle_; - std::shared_ptr rpc_channel_; + std::shared_ptr rpc_channel_; }; } // namespace anbox diff --git a/android/service/platform_service.cpp b/android/service/platform_service.cpp index 901f2d7..4335bc4 100644 --- a/android/service/platform_service.cpp +++ b/android/service/platform_service.cpp @@ -17,7 +17,7 @@ #include "android/service/platform_service.h" #include "android/service/platform_api_stub.h" -#include "anbox/bridge/rpc_channel.h" +#include "anbox/rpc/channel.h" #define LOG_TAG "Anboxd" #include