From fc7049b27b9ee801ee3d727c8b195b0f00f93456 Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Wed, 22 Feb 2017 17:39:09 +0100 Subject: [PATCH] Create a marker to indicate that first boot has happened --- android/service/platform_api_stub.cpp | 16 +++++++++++++++- src/anbox/bridge/platform_api_skeleton.cpp | 5 ++--- src/anbox/protobuf/anbox_bridge.proto | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/android/service/platform_api_stub.cpp b/android/service/platform_api_stub.cpp index 6f4768e..37fa5d4 100644 --- a/android/service/platform_api_stub.cpp +++ b/android/service/platform_api_stub.cpp @@ -21,9 +21,17 @@ #include "anbox_rpc.pb.h" #include "anbox_bridge.pb.h" +#include + +#include + #define LOG_TAG "Anboxd" #include +namespace { +constexpr const char *first_boot_marker_path{"/data/.anbox_initialized"}; +} + namespace anbox { PlatformApiStub::PlatformApiStub(const std::shared_ptr &rpc_channel) : rpc_channel_(rpc_channel) { @@ -32,7 +40,13 @@ PlatformApiStub::PlatformApiStub(const std::shared_ptr &rpc_channe void PlatformApiStub::boot_finished() { protobuf::bridge::EventSequence seq; auto event = seq.mutable_boot_finished(); - (void) event; + + struct stat st; + if (stat(first_boot_marker_path, &st) != 0) { + event->set_first_boot_done(true); + std::ofstream marker(first_boot_marker_path); + } + rpc_channel_->send_event(seq); } diff --git a/src/anbox/bridge/platform_api_skeleton.cpp b/src/anbox/bridge/platform_api_skeleton.cpp index 55a2495..1c19e3f 100644 --- a/src/anbox/bridge/platform_api_skeleton.cpp +++ b/src/anbox/bridge/platform_api_skeleton.cpp @@ -63,9 +63,8 @@ void PlatformApiSkeleton::get_clipboard_data(anbox::protobuf::rpc::Void const *r } void PlatformApiSkeleton::handle_boot_finished_event(const anbox::protobuf::bridge::BootFinishedEvent &event) { - (void)event; - - if (boot_finished_handler_) boot_finished_handler_(); + if (boot_finished_handler_) + boot_finished_handler_(); } void PlatformApiSkeleton::handle_window_state_update_event(const anbox::protobuf::bridge::WindowStateUpdateEvent &event) { diff --git a/src/anbox/protobuf/anbox_bridge.proto b/src/anbox/protobuf/anbox_bridge.proto index 2210188..11bde22 100644 --- a/src/anbox/protobuf/anbox_bridge.proto +++ b/src/anbox/protobuf/anbox_bridge.proto @@ -58,6 +58,7 @@ message ClipboardData { } message BootFinishedEvent { + optional bool first_boot_done = 1; } message WindowStateUpdateEvent {