Add first stub methods to send window status updates from Android to host
This commit is contained in:
parent
a39c1b2bd2
commit
6ee8734cf3
10 changed files with 130 additions and 18 deletions
|
|
@ -52,7 +52,54 @@ void PlatformApiStub::boot_finished() {
|
|||
}
|
||||
|
||||
void PlatformApiStub::handle_boot_finished_response(Request<protobuf::rpc::Void>*) {
|
||||
ALOGI("handle_boot_finished_response");
|
||||
boot_finished_wait_handle_.result_received();
|
||||
}
|
||||
|
||||
void PlatformApiStub::update_window_state() {
|
||||
auto c = std::make_shared<Request<protobuf::rpc::Void>>();
|
||||
|
||||
ALOGI("Updating window state");
|
||||
|
||||
{
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
update_window_state_wait_handle_.expect_result();
|
||||
}
|
||||
|
||||
protobuf::rpc::Void message;
|
||||
|
||||
rpc_channel_->call_method(
|
||||
"update_window_state",
|
||||
&message, c->response.get(),
|
||||
google::protobuf::NewCallback(this, &PlatformApiStub::handle_update_window_state_response, c.get()));
|
||||
|
||||
update_window_state_wait_handle_.wait_for_all();
|
||||
}
|
||||
|
||||
void PlatformApiStub::handle_update_window_state_response(Request<protobuf::rpc::Void> *request) {
|
||||
update_window_state_wait_handle_.result_received();
|
||||
}
|
||||
|
||||
void PlatformApiStub::remove_window() {
|
||||
auto c = std::make_shared<Request<protobuf::rpc::Void>>();
|
||||
|
||||
ALOGI("Remove window");
|
||||
|
||||
{
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
remove_window_wait_handle_.expect_result();
|
||||
}
|
||||
|
||||
protobuf::rpc::Void message;
|
||||
|
||||
rpc_channel_->call_method(
|
||||
"remove_window",
|
||||
&message, c->response.get(),
|
||||
google::protobuf::NewCallback(this, &PlatformApiStub::handle_remove_window_response, c.get()));
|
||||
|
||||
remove_window_wait_handle_.wait_for_all();
|
||||
}
|
||||
|
||||
void PlatformApiStub::handle_remove_window_response(Request<protobuf::rpc::Void> *request) {
|
||||
update_window_state_wait_handle_.result_received();
|
||||
}
|
||||
} // namespace anbox
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ public:
|
|||
PlatformApiStub(const std::shared_ptr<rpc::Channel> &rpc_channel);
|
||||
|
||||
void boot_finished();
|
||||
void update_window_state();
|
||||
void remove_window();
|
||||
|
||||
private:
|
||||
template<typename Response>
|
||||
|
|
@ -46,9 +48,13 @@ private:
|
|||
};
|
||||
|
||||
void handle_boot_finished_response(Request<protobuf::rpc::Void> *request);
|
||||
void handle_update_window_state_response(Request<protobuf::rpc::Void> *request);
|
||||
void handle_remove_window_response(Request<protobuf::rpc::Void> *request);
|
||||
|
||||
mutable std::mutex mutex_;
|
||||
common::WaitHandle boot_finished_wait_handle_;
|
||||
common::WaitHandle update_window_state_wait_handle_;
|
||||
common::WaitHandle remove_window_wait_handle_;
|
||||
|
||||
std::shared_ptr<rpc::Channel> rpc_channel_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -33,4 +33,14 @@ status_t PlatformService::boot_finished() {
|
|||
platform_api_stub_->boot_finished();
|
||||
return OK;
|
||||
}
|
||||
|
||||
status_t PlatformService::update_window_state() {
|
||||
platform_api_stub_->update_window_state();
|
||||
return OK;
|
||||
}
|
||||
|
||||
status_t PlatformService::remove_window() {
|
||||
platform_api_stub_->remove_window();
|
||||
return OK;
|
||||
}
|
||||
} // namespace android
|
||||
|
|
|
|||
|
|
@ -29,11 +29,13 @@ class PlatformApiStub;
|
|||
namespace android {
|
||||
class PlatformService : public BnPlatformService {
|
||||
public:
|
||||
static const char* service_name() { return "anbox.PlatformService"; }
|
||||
static const char* service_name() { return "org.anbox.PlatformService"; }
|
||||
|
||||
PlatformService(const std::shared_ptr<anbox::PlatformApiStub> &platform_api_stub);
|
||||
|
||||
status_t boot_finished() override;
|
||||
status_t update_window_state() override;
|
||||
status_t remove_window() override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<anbox::PlatformApiStub> platform_api_stub_;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,19 @@ status_t BpPlatformService::boot_finished() {
|
|||
return remote()->transact(IPlatformService::BOOT_FINISHED, data, &reply);
|
||||
}
|
||||
|
||||
IMPLEMENT_META_INTERFACE(PlatformService, "anbox.IPlatformService");
|
||||
status_t BpPlatformService::update_window_state() {
|
||||
Parcel data, reply;
|
||||
data.writeInterfaceToken(IPlatformService::getInterfaceDescriptor());
|
||||
return remote()->transact(IPlatformService::UPDATE_WINDOW_STATE, data, &reply);
|
||||
}
|
||||
|
||||
status_t BpPlatformService::remove_window() {
|
||||
Parcel data, reply;
|
||||
data.writeInterfaceToken(IPlatformService::getInterfaceDescriptor());
|
||||
return remote()->transact(IPlatformService::REMOVE_WINDOW, data, &reply);
|
||||
}
|
||||
|
||||
IMPLEMENT_META_INTERFACE(PlatformService, "org.anbox.IPlatformService");
|
||||
|
||||
status_t BnPlatformService::onTransact(uint32_t code, const Parcel &data,
|
||||
Parcel *reply, uint32_t flags) {
|
||||
|
|
@ -36,6 +48,12 @@ status_t BnPlatformService::onTransact(uint32_t code, const Parcel &data,
|
|||
case BOOT_FINISHED:
|
||||
CHECK_INTERFACE(IPlatformService, data, reply);
|
||||
return boot_finished();
|
||||
case UPDATE_WINDOW_STATE:
|
||||
CHECK_INTERFACE(IPlatformService, data, reply);
|
||||
return update_window_state();
|
||||
case REMOVE_WINDOW:
|
||||
CHECK_INTERFACE(IPlatformService, data, reply);
|
||||
return remove_window();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,13 @@ public:
|
|||
|
||||
enum {
|
||||
BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
|
||||
UPDATE_WINDOW_STATE = IBinder::FIRST_CALL_TRANSACTION + 1,
|
||||
REMOVE_WINDOW = IBinder::FIRST_CALL_TRANSACTION + 2,
|
||||
};
|
||||
|
||||
virtual status_t boot_finished() = 0;
|
||||
virtual status_t update_window_state() = 0;
|
||||
virtual status_t remove_window() = 0;
|
||||
};
|
||||
|
||||
class BpPlatformService : public BpInterface<IPlatformService> {
|
||||
|
|
@ -44,6 +48,8 @@ public:
|
|||
BpPlatformService(const sp<IBinder> &binder);
|
||||
|
||||
status_t boot_finished() override;
|
||||
status_t update_window_state() override;
|
||||
status_t remove_window() override;
|
||||
};
|
||||
|
||||
class BnPlatformService : public BnInterface<IPlatformService> {
|
||||
|
|
|
|||
|
|
@ -48,10 +48,14 @@ public:
|
|||
anbox::protobuf::rpc::Void *response,
|
||||
google::protobuf::Closure *done) = 0;
|
||||
|
||||
virtual void handle_notification(anbox::protobuf::bridge::Notification const *request,
|
||||
virtual void update_window_state(anbox::protobuf::rpc::Void const *request,
|
||||
anbox::protobuf::rpc::Void *response,
|
||||
google::protobuf::Closure *done) = 0;
|
||||
|
||||
virtual void remove_window(anbox::protobuf::rpc::Void const *request,
|
||||
anbox::protobuf::rpc::Void *response,
|
||||
google::protobuf::Closure *done) = 0;
|
||||
|
||||
private:
|
||||
std::shared_ptr<rpc::PendingCallCache> pending_calls_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@ PlatformMessageProcessor::~PlatformMessageProcessor() {
|
|||
}
|
||||
|
||||
void PlatformMessageProcessor::dispatch(rpc::Invocation const& invocation) {
|
||||
if (invocation.method_name() == "handle_notification")
|
||||
invoke(this, server_.get(), &PlatformApiSkeleton::handle_notification, invocation);
|
||||
else if (invocation.method_name() == "boot_finished")
|
||||
if (invocation.method_name() == "boot_finished")
|
||||
invoke(this, server_.get(), &PlatformApiSkeleton::boot_finished, invocation);
|
||||
else if (invocation.method_name() == "update_window_state")
|
||||
invoke(this, server_.get(), &PlatformApiSkeleton::update_window_state, invocation);
|
||||
else if (invocation.method_name() == "remove_window")
|
||||
invoke(this, server_.get(), &PlatformApiSkeleton::remove_window, invocation);
|
||||
}
|
||||
|
||||
void PlatformMessageProcessor::process_event_sequence(const std::string&) {
|
||||
|
|
|
|||
|
|
@ -33,15 +33,6 @@ PlatformApiSekeleton::PlatformApiSekeleton(const std::shared_ptr<rpc::PendingCal
|
|||
PlatformApiSekeleton::~PlatformApiSekeleton() {
|
||||
}
|
||||
|
||||
void PlatformApiSekeleton::handle_notification(anbox::protobuf::bridge::Notification const *request,
|
||||
anbox::protobuf::rpc::Void *response,
|
||||
google::protobuf::Closure *done) {
|
||||
(void) request;
|
||||
(void) response;
|
||||
DEBUG("");
|
||||
done->Run();
|
||||
}
|
||||
|
||||
void PlatformApiSekeleton::boot_finished(anbox::protobuf::rpc::Void const *request,
|
||||
anbox::protobuf::rpc::Void *response,
|
||||
google::protobuf::Closure *done) {
|
||||
|
|
@ -54,6 +45,28 @@ void PlatformApiSekeleton::boot_finished(anbox::protobuf::rpc::Void const *reque
|
|||
done->Run();
|
||||
}
|
||||
|
||||
void PlatformApiSekeleton::update_window_state(anbox::protobuf::rpc::Void const *request,
|
||||
anbox::protobuf::rpc::Void *response,
|
||||
google::protobuf::Closure *done) {
|
||||
(void) request;
|
||||
(void) response;
|
||||
|
||||
DEBUG("");
|
||||
|
||||
done->Run();
|
||||
}
|
||||
|
||||
void PlatformApiSekeleton::remove_window(anbox::protobuf::rpc::Void const *request,
|
||||
anbox::protobuf::rpc::Void *response,
|
||||
google::protobuf::Closure *done) {
|
||||
(void) request;
|
||||
(void) response;
|
||||
|
||||
DEBUG("");
|
||||
|
||||
done->Run();
|
||||
}
|
||||
|
||||
void PlatformApiSekeleton::on_boot_finished(const std::function<void()> &action) {
|
||||
on_boot_finished_action_ = action;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,11 +36,15 @@ public:
|
|||
PlatformApiSekeleton(const std::shared_ptr<rpc::PendingCallCache> &pending_calls);
|
||||
virtual ~PlatformApiSekeleton();
|
||||
|
||||
void handle_notification(anbox::protobuf::bridge::Notification const *request,
|
||||
void boot_finished(anbox::protobuf::rpc::Void const *request,
|
||||
anbox::protobuf::rpc::Void *response,
|
||||
google::protobuf::Closure *done) override;
|
||||
|
||||
void update_window_state(anbox::protobuf::rpc::Void const *request,
|
||||
anbox::protobuf::rpc::Void *response,
|
||||
google::protobuf::Closure *done) override;
|
||||
|
||||
void boot_finished(anbox::protobuf::rpc::Void const *request,
|
||||
void remove_window(anbox::protobuf::rpc::Void const *request,
|
||||
anbox::protobuf::rpc::Void *response,
|
||||
google::protobuf::Closure *done) override;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue