blob: 8c792fd387dacfaca4fdad0415672809a0a17cdb [file] [log] [blame]
Ashutosh Joshi6104b272016-10-27 11:06:23 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.hardware.contexthub@1.0;
18
19import IContexthubCallback;
20
21interface IContexthub {
22 /*
23 * Enumerate all available context hubs on the system.
24 *
25 * @return hubs list of hubs on this system.
26 */
27 getHubs() generates (vec<ContextHub> hubs);
28
29 /*
30 * Register a callback for the HAL implementation to send asynchronous
31 * messages to the service from a context hub. There can be a maximum of
32 * one callback registered with the HAL. A call to this function when a
33 * callback has already been registered must override the previous
34 * registration.
35 *
36 * @param hubId identifier for the hub
37 * callback an implementation of the IContextHubCallbacks
38 *
39 * @return result OK on success
40 * BAD_VALUE if parameters are not sane
41 *
42 */
43 registerCallback(uint32_t hubId, IContexthubCallback cb) generates (Result result);
44
45 /**
46 * Send a message to a hub
47 *
48 * @param hubId identifier for hub to send message to
49 * msg message to be sent
50 *
51 * @return result OK if successful, error code otherwise
52 * BAD_VALUE if parameters are not sane
53 * TRANSACTION_FAILED if message send failed
54 */
55 sendMessageToHub(uint32_t hubId, ContextHubMsg msg)
56 generates (Result result);
57
58 /**
59 * Loads a nanoApp. After loading, the nanoApp's init method must be called.
60 * After the init method for nanoApp returns success, this must be indicated
61 * to the service by an asynchronous call to handleTxnResult.
62 *
Ashutosh Joshi69e3aa32016-11-22 14:08:20 -080063 * Loading a nanoapp must not take more than 30 seconds.
64 *
Ashutosh Joshi6104b272016-10-27 11:06:23 -070065 * @param hubId identifer of the contextHub
Ashutosh Joshi69e3aa32016-11-22 14:08:20 -080066 * appBinary serialized NanoApppBinary for the nanoApp
67 * transactionId transactionId for this call
Ashutosh Joshi6104b272016-10-27 11:06:23 -070068 *
69 * @return result OK if transation started
70 * BAD_VALUE if parameters are not sane
71 * TRANSACTION_PENDING if hub is busy with another
72 * load/unload transaction
73 * TRANSACTION_FAILED if load failed synchronously
74 *
75 */
Ashutosh Joshi69e3aa32016-11-22 14:08:20 -080076 loadNanoApp(uint32_t hubId,
77 vec<uint8_t> appBinary,
78 uint32_t transactionId)
Ashutosh Joshi6104b272016-10-27 11:06:23 -070079 generates (Result result);
80
81 /**
82 * Unloads a nanoApp. Before the unload, the apps deinit method is called.
83 * After this, success must be indicated to the service through an
84 * asynchronous call to handleTxnResult.
85 *
Ashutosh Joshi69e3aa32016-11-22 14:08:20 -080086 * Unloading a nanoapp must not take more than 5 seconds.
87 *
Ashutosh Joshi6104b272016-10-27 11:06:23 -070088 * @param hubId identifer of the contextHub
89 * appId appIdentifier returned by the HAL
90 * msg message to be sent
91 *
92 * @return result OK if transation started
93 * BAD_VALUE if parameters are not sane
94 * TRANSACTION_PENDING if hub is busy with another
95 * load/unload transaction
96 * TRANSACTION_FAILED if unload failed synchronously
97 *
98 */
99 unloadNanoApp(uint32_t hubId, uint64_t appId, uint32_t transactionId)
100 generates (Result result);
101
102 /**
103 * Enables a nanoApp. The app's init method is called.
104 * After this, success must be indicated to the service through an
105 * asynchronous message.
106 *
Ashutosh Joshi69e3aa32016-11-22 14:08:20 -0800107 * Enabling a nanoapp must not take more than 5 seconds.
108 *
Ashutosh Joshi6104b272016-10-27 11:06:23 -0700109 * @param hubId identifer of the contextHub
110 * appId appIdentifier returned by the HAL
111 * msg message to be sent
112 *
113 * @return result OK if transation started
114 * BAD_VALUE if parameters are not sane
115 * TRANSACTION_PENDING if hub is busy with another
116 * load/unload transaction
117 * FAILED_TRANSACTION if load fails immediately
118 *
119 */
120 enableNanoApp(uint32_t hubId, uint64_t appId, uint32_t transactionId)
121 generates (Result result);
122
123 /**
124 * Disables a nanoApp. The app's deinit method is called.
125 * After this, success must be indicated to the service through an
126 * asynchronous message.
127 *
Ashutosh Joshi69e3aa32016-11-22 14:08:20 -0800128 * Disabling a nanoapp must not take more than 5 seconds.
129 *
Ashutosh Joshi6104b272016-10-27 11:06:23 -0700130 * @param hubId identifer of the contextHub
131 * appId appIdentifier returned by the HAL
132 * msg message to be sent
133 *
134 * @return result OK if transation started
135 * BAD_VALUE if parameters are not sane
136 * TRANSACTION_PENDING if hub is busy with another
137 * load/unload transaction
138 * FAILED_TRANSACTION if load fails immediately
139 *
140 */
141 disableNanoApp(uint32_t hubId, uint64_t appId, uint32_t transactionId)
142 generates (Result result);
143
144 /**
145 * Queries for Loaded apps on the hub
146 *
147 * @param hubId identifer of the contextHub
148 *
Ashutosh Joshi69e3aa32016-11-22 14:08:20 -0800149 * @return apps all nanoApps on the hub.
150 * All nanoApps that can be modified by the service must
151 * be returned. A non-modifiable nanoapps must not be
152 * returned. A modifiable nanoApp is one that can be
153 * unloaded/disabled/enabled by the service.
Ashutosh Joshi6104b272016-10-27 11:06:23 -0700154 *
155 */
156 queryApps(uint32_t hubId) generates (Result result);
157
158 /**
159 * Reboots context hub OS, restarts all the nanoApps.
160 * No reboot notification is sent to nanoApps; reboot happens immediately
161 * and unconditionally; all volatile contexthub state and any data is lost
162 * as a result.
163 *
164 * @param hubId identifer of the contextHub
165 *
166 * @return result OK on success
167 * BAD_VALUE if parameters are not sane
168 *
169 */
170 reboot(uint32_t hubId) generates (Result result);
171};