blob: a9b8fdb7c291b83b678d0aa2521d5c0102f6d473 [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
Brian Duddie188552e2017-01-03 09:38:24 -080021/*
22 * The Context Hub HAL provides an interface to a separate low-power processing
23 * domain that has direct access to contextual information, such as sensors.
24 * Native applications that run within a context hub are known as nanoapps, and
25 * they execute within the Context Hub Runtime Environment (CHRE), which is
26 * standardized via the CHRE API, defined elsewhere.
27 */
Ashutosh Joshi6104b272016-10-27 11:06:23 -070028interface IContexthub {
29 /*
30 * Enumerate all available context hubs on the system.
31 *
32 * @return hubs list of hubs on this system.
33 */
34 getHubs() generates (vec<ContextHub> hubs);
35
36 /*
37 * Register a callback for the HAL implementation to send asynchronous
38 * messages to the service from a context hub. There can be a maximum of
39 * one callback registered with the HAL. A call to this function when a
40 * callback has already been registered must override the previous
41 * registration.
42 *
43 * @param hubId identifier for the hub
44 * callback an implementation of the IContextHubCallbacks
45 *
46 * @return result OK on success
47 * BAD_VALUE if parameters are not sane
48 *
49 */
50 registerCallback(uint32_t hubId, IContexthubCallback cb) generates (Result result);
51
52 /**
53 * Send a message to a hub
54 *
55 * @param hubId identifier for hub to send message to
56 * msg message to be sent
57 *
58 * @return result OK if successful, error code otherwise
59 * BAD_VALUE if parameters are not sane
60 * TRANSACTION_FAILED if message send failed
61 */
62 sendMessageToHub(uint32_t hubId, ContextHubMsg msg)
63 generates (Result result);
64
65 /**
66 * Loads a nanoApp. After loading, the nanoApp's init method must be called.
67 * After the init method for nanoApp returns success, this must be indicated
68 * to the service by an asynchronous call to handleTxnResult.
69 *
Ashutosh Joshi69e3aa32016-11-22 14:08:20 -080070 * Loading a nanoapp must not take more than 30 seconds.
71 *
Ashutosh Joshi6104b272016-10-27 11:06:23 -070072 * @param hubId identifer of the contextHub
Ashutosh Joshi69e3aa32016-11-22 14:08:20 -080073 * appBinary serialized NanoApppBinary for the nanoApp
74 * transactionId transactionId for this call
Ashutosh Joshi6104b272016-10-27 11:06:23 -070075 *
76 * @return result OK if transation started
77 * BAD_VALUE if parameters are not sane
78 * TRANSACTION_PENDING if hub is busy with another
79 * load/unload transaction
80 * TRANSACTION_FAILED if load failed synchronously
81 *
82 */
Ashutosh Joshi69e3aa32016-11-22 14:08:20 -080083 loadNanoApp(uint32_t hubId,
84 vec<uint8_t> appBinary,
85 uint32_t transactionId)
Ashutosh Joshi6104b272016-10-27 11:06:23 -070086 generates (Result result);
87
88 /**
89 * Unloads a nanoApp. Before the unload, the apps deinit method is called.
90 * After this, success must be indicated to the service through an
91 * asynchronous call to handleTxnResult.
92 *
Ashutosh Joshi69e3aa32016-11-22 14:08:20 -080093 * Unloading a nanoapp must not take more than 5 seconds.
94 *
Ashutosh Joshi6104b272016-10-27 11:06:23 -070095 * @param hubId identifer of the contextHub
96 * appId appIdentifier returned by the HAL
97 * msg message to be sent
98 *
99 * @return result OK if transation started
100 * BAD_VALUE if parameters are not sane
101 * TRANSACTION_PENDING if hub is busy with another
102 * load/unload transaction
103 * TRANSACTION_FAILED if unload failed synchronously
104 *
105 */
106 unloadNanoApp(uint32_t hubId, uint64_t appId, uint32_t transactionId)
107 generates (Result result);
108
109 /**
110 * Enables a nanoApp. The app's init method is called.
111 * After this, success must be indicated to the service through an
112 * asynchronous message.
113 *
Ashutosh Joshi69e3aa32016-11-22 14:08:20 -0800114 * Enabling a nanoapp must not take more than 5 seconds.
115 *
Ashutosh Joshi6104b272016-10-27 11:06:23 -0700116 * @param hubId identifer of the contextHub
117 * appId appIdentifier returned by the HAL
118 * msg message to be sent
119 *
120 * @return result OK if transation started
121 * BAD_VALUE if parameters are not sane
122 * TRANSACTION_PENDING if hub is busy with another
123 * load/unload transaction
124 * FAILED_TRANSACTION if load fails immediately
125 *
126 */
127 enableNanoApp(uint32_t hubId, uint64_t appId, uint32_t transactionId)
128 generates (Result result);
129
130 /**
131 * Disables a nanoApp. The app's deinit method is called.
132 * After this, success must be indicated to the service through an
133 * asynchronous message.
134 *
Ashutosh Joshi69e3aa32016-11-22 14:08:20 -0800135 * Disabling a nanoapp must not take more than 5 seconds.
136 *
Ashutosh Joshi6104b272016-10-27 11:06:23 -0700137 * @param hubId identifer of the contextHub
138 * appId appIdentifier returned by the HAL
139 * msg message to be sent
140 *
141 * @return result OK if transation started
142 * BAD_VALUE if parameters are not sane
143 * TRANSACTION_PENDING if hub is busy with another
144 * load/unload transaction
145 * FAILED_TRANSACTION if load fails immediately
146 *
147 */
148 disableNanoApp(uint32_t hubId, uint64_t appId, uint32_t transactionId)
149 generates (Result result);
150
151 /**
152 * Queries for Loaded apps on the hub
153 *
154 * @param hubId identifer of the contextHub
155 *
Ashutosh Joshi69e3aa32016-11-22 14:08:20 -0800156 * @return apps all nanoApps on the hub.
157 * All nanoApps that can be modified by the service must
158 * be returned. A non-modifiable nanoapps must not be
159 * returned. A modifiable nanoApp is one that can be
160 * unloaded/disabled/enabled by the service.
Ashutosh Joshi6104b272016-10-27 11:06:23 -0700161 *
162 */
163 queryApps(uint32_t hubId) generates (Result result);
164
165 /**
166 * Reboots context hub OS, restarts all the nanoApps.
167 * No reboot notification is sent to nanoApps; reboot happens immediately
168 * and unconditionally; all volatile contexthub state and any data is lost
169 * as a result.
170 *
171 * @param hubId identifer of the contextHub
172 *
173 * @return result OK on success
174 * BAD_VALUE if parameters are not sane
175 *
176 */
177 reboot(uint32_t hubId) generates (Result result);
178};