TYPE3
[iec.git] / src / type3_AndroidCloud / anbox-master / android / service / platform_service_interface.cpp
1 /*
2  * Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
3  *
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.
7  *
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.
12  *
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/>.
15  *
16  */
17
18 #include "android/service/platform_service_interface.h"
19
20 namespace android {
21 BpPlatformService::BpPlatformService(const sp<IBinder> &binder) :
22     BpInterface<IPlatformService>(binder) {
23 }
24
25 status_t BpPlatformService::boot_finished() {
26     Parcel data, reply;
27     data.writeInterfaceToken(IPlatformService::getInterfaceDescriptor());
28     return remote()->transact(IPlatformService::BOOT_FINISHED, data, &reply);
29 }
30
31 status_t BpPlatformService::update_window_state(const Parcel&) {
32     Parcel data, reply;
33     data.writeInterfaceToken(IPlatformService::getInterfaceDescriptor());
34     return remote()->transact(IPlatformService::UPDATE_WINDOW_STATE, data, &reply);
35 }
36
37 status_t BpPlatformService::update_application_list(const Parcel&) {
38     Parcel data, reply;
39     data.writeInterfaceToken(IPlatformService::getInterfaceDescriptor());
40     return remote()->transact(IPlatformService::UPDATE_APPLICATION_LIST, data, &reply);
41 }
42
43 status_t BpPlatformService::set_clipboard_data(const Parcel&) {
44     Parcel data, reply;
45     data.writeInterfaceToken(IPlatformService::getInterfaceDescriptor());
46     return remote()->transact(IPlatformService::SET_CLIPBOARD_DATA, data, &reply);
47 }
48
49 status_t BpPlatformService::get_clipboard_data(const Parcel&, Parcel*) {
50     Parcel data, reply;
51     data.writeInterfaceToken(IPlatformService::getInterfaceDescriptor());
52     return remote()->transact(IPlatformService::GET_CLIPBOARD_DATA, data, &reply);
53 }
54
55 IMPLEMENT_META_INTERFACE(PlatformService, "org.anbox.IPlatformService");
56
57 status_t BnPlatformService::onTransact(uint32_t code, const Parcel &data,
58                                        Parcel *reply, uint32_t flags) {
59     switch (code) {
60     case BOOT_FINISHED:
61         CHECK_INTERFACE(IPlatformService, data, reply);
62         return boot_finished();
63     case UPDATE_WINDOW_STATE:
64         CHECK_INTERFACE(IPlatformService, data, reply);
65         return update_window_state(data);
66     case UPDATE_APPLICATION_LIST:
67         CHECK_INTERFACE(IPlatformService, data, reply);
68         return update_application_list(data);
69     case SET_CLIPBOARD_DATA:
70         CHECK_INTERFACE(IPlatformService, data, reply);
71         return set_clipboard_data(data);
72     case GET_CLIPBOARD_DATA:
73         CHECK_INTERFACE(IPlatformService, data, reply);
74         return get_clipboard_data(data, reply);
75     default:
76         break;
77     }
78
79     return BBinder::onTransact(code, data, reply, flags);
80 }
81 } // namespace android