android: adjust for recent rpc changes

This commit is contained in:
Simon Fels 2016-08-23 09:51:14 +02:00
commit 1c9ebae83d
10 changed files with 50 additions and 42 deletions

View file

@ -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 += \

View file

@ -17,6 +17,7 @@
#include "android/service/android_api_skeleton.h"
#include "anbox_rpc.pb.h"
#include "anbox_bridge.pb.h"
#include <core/posix/exec.h>
@ -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;

View file

@ -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

View file

@ -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 <functional>
#include <array>
@ -29,10 +29,10 @@
namespace anbox {
HostConnector::HostConnector() :
socket_(std::make_shared<LocalSocketConnection>("/dev/anbox_bridge")),
pending_calls_(std::make_shared<bridge::PendingCallCache>()),
pending_calls_(std::make_shared<rpc::PendingCallCache>()),
android_api_skeleton_(std::make_shared<AndroidApiSkeleton>()),
message_processor_(std::make_shared<MessageProcessor>(socket_, pending_calls_, android_api_skeleton_)),
rpc_channel_(std::make_shared<bridge::RpcChannel>(pending_calls_, socket_)),
rpc_channel_(std::make_shared<rpc::Channel>(pending_calls_, socket_)),
platform_api_stub_(std::make_shared<PlatformApiStub>(rpc_channel_)),
running_(false) {
}

View file

@ -23,10 +23,10 @@
#include <atomic>
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<LocalSocketConnection> socket_;
std::shared_ptr<bridge::PendingCallCache> pending_calls_;
std::shared_ptr<rpc::PendingCallCache> pending_calls_;
std::shared_ptr<AndroidApiSkeleton> android_api_skeleton_;
std::shared_ptr<MessageProcessor> message_processor_;
std::shared_ptr<bridge::RpcChannel> rpc_channel_;
std::shared_ptr<rpc::Channel> rpc_channel_;
std::shared_ptr<anbox::PlatformApiStub> platform_api_stub_;
std::thread thread_;
std::atomic<bool> running_;

View file

@ -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<network::MessageSender> &sender,
const std::shared_ptr<bridge::PendingCallCache> &pending_calls,
const std::shared_ptr<rpc::PendingCallCache> &pending_calls,
const std::shared_ptr<AndroidApiSkeleton> &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")

View file

@ -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<network::MessageSender> &sender,
const std::shared_ptr<bridge::PendingCallCache> &pending_calls,
const std::shared_ptr<rpc::PendingCallCache> &pending_calls,
const std::shared_ptr<AndroidApiSkeleton> &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:

View file

@ -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 <cutils/log.h>
namespace anbox {
PlatformApiStub::PlatformApiStub(const std::shared_ptr<bridge::RpcChannel> &rpc_channel) :
PlatformApiStub::PlatformApiStub(const std::shared_ptr<rpc::Channel> &rpc_channel) :
rpc_channel_(rpc_channel) {
}
void PlatformApiStub::boot_finished() {
auto c = std::make_shared<Request<protobuf::bridge::Void>>();
auto c = std::make_shared<Request<protobuf::rpc::Void>>();
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<protobuf::bridge::Void>*) {
void PlatformApiStub::handle_boot_finished_response(Request<protobuf::rpc::Void>*) {
ALOGI("handle_boot_finished_response");
boot_finished_wait_handle_.result_received();
}

View file

@ -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<bridge::RpcChannel> &rpc_channel);
PlatformApiStub(const std::shared_ptr<rpc::Channel> &rpc_channel);
void boot_finished();
@ -45,12 +45,12 @@ private:
bool success;
};
void handle_boot_finished_response(Request<protobuf::bridge::Void> *request);
void handle_boot_finished_response(Request<protobuf::rpc::Void> *request);
mutable std::mutex mutex_;
common::WaitHandle boot_finished_wait_handle_;
std::shared_ptr<bridge::RpcChannel> rpc_channel_;
std::shared_ptr<rpc::Channel> rpc_channel_;
};
} // namespace anbox

View file

@ -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 <cutils/log.h>