X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fbridge%2Fandroid_api_stub.h;fp=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fbridge%2Fandroid_api_stub.h;h=d95fd7bd90f90441fd8ce282276afb3edec03b71;hb=e26c1ec581be598521517829adba8c8dd23a768f;hp=0000000000000000000000000000000000000000;hpb=6699c1aea74eeb0eb400e6299079f0c7576f716f;p=iec.git diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/android_api_stub.h b/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/android_api_stub.h new file mode 100644 index 0000000..d95fd7b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/android_api_stub.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_BRIDGE_ANDROID_API_STUB_H_ +#define ANBOX_BRIDGE_ANDROID_API_STUB_H_ + +#include "anbox/application/manager.h" +#include "anbox/common/wait_handle.h" +#include "anbox/graphics/rect.h" + +#include +#include + +namespace anbox { +namespace protobuf { +namespace rpc { +class Void; +} // namespace bridge +} // namespace protobuf +namespace rpc { +class Channel; +} // namespace rpc +namespace bridge { +class AndroidApiStub : public anbox::application::Manager { + public: + AndroidApiStub(); + ~AndroidApiStub(); + + void set_rpc_channel(const std::shared_ptr &channel); + void reset_rpc_channel(); + + void set_focused_task(const std::int32_t &id); + void remove_task(const std::int32_t &id); + void resize_task(const std::int32_t &id, const anbox::graphics::Rect &rect, + const std::int32_t &resize_mode); + + void launch(const android::Intent &intent, + const graphics::Rect &launch_bounds = graphics::Rect::Invalid, + const wm::Stack::Id &stack = wm::Stack::Id::Default) override; + + core::Property& ready() override; + + private: + void ensure_rpc_channel(); + + template + struct Request { + Request() : response(std::make_shared()), success(true) {} + std::shared_ptr response; + bool success; + }; + + void application_launched(Request *request); + void focused_task_set(Request *request); + void task_removed(Request *request); + void task_resized(Request *request); + + mutable std::mutex mutex_; + std::shared_ptr channel_; + common::WaitHandle launch_wait_handle_; + common::WaitHandle set_focused_task_handle_; + common::WaitHandle remove_task_handle_; + common::WaitHandle resize_task_handle_; + graphics::Rect launch_bounds_ = graphics::Rect::Invalid; + core::Property ready_; +}; +} // namespace bridge +} // namespace anbox + +#endif