2 * Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef ANBOX_BRIDGE_ANDROID_API_STUB_H_
19 #define ANBOX_BRIDGE_ANDROID_API_STUB_H_
21 #include "anbox/application/manager.h"
22 #include "anbox/common/wait_handle.h"
23 #include "anbox/graphics/rect.h"
33 } // namespace protobuf
38 class AndroidApiStub : public anbox::application::Manager {
43 void set_rpc_channel(const std::shared_ptr<rpc::Channel> &channel);
44 void reset_rpc_channel();
46 void set_focused_task(const std::int32_t &id);
47 void remove_task(const std::int32_t &id);
48 void resize_task(const std::int32_t &id, const anbox::graphics::Rect &rect,
49 const std::int32_t &resize_mode);
51 void launch(const android::Intent &intent,
52 const graphics::Rect &launch_bounds = graphics::Rect::Invalid,
53 const wm::Stack::Id &stack = wm::Stack::Id::Default) override;
55 core::Property<bool>& ready() override;
58 void ensure_rpc_channel();
60 template <typename Response>
62 Request() : response(std::make_shared<Response>()), success(true) {}
63 std::shared_ptr<Response> response;
67 void application_launched(Request<protobuf::rpc::Void> *request);
68 void focused_task_set(Request<protobuf::rpc::Void> *request);
69 void task_removed(Request<protobuf::rpc::Void> *request);
70 void task_resized(Request<protobuf::rpc::Void> *request);
72 mutable std::mutex mutex_;
73 std::shared_ptr<rpc::Channel> channel_;
74 common::WaitHandle launch_wait_handle_;
75 common::WaitHandle set_focused_task_handle_;
76 common::WaitHandle remove_task_handle_;
77 common::WaitHandle resize_task_handle_;
78 graphics::Rect launch_bounds_ = graphics::Rect::Invalid;
79 core::Property<bool> ready_;