summaryrefslogtreecommitdiffstats
blob: 8dccd6727661d9334f0f1b6500c6283d81a1bfee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.contexthub@1.0;

import IContexthubCallback;

/**
 * The Context Hub HAL provides an interface to a separate low-power processing
 * domain that has direct access to contextual information, such as sensors.
 * Native applications that run within a context hub are known as nanoapps, and
 * they execute within the Context Hub Runtime Environment (CHRE), which is
 * standardized via the CHRE API, defined elsewhere.
 */
interface IContexthub {
    /**
     * Enumerate all available context hubs on the system.
     *
     * @return hubs list of hubs on this system.
     */
    getHubs() generates (vec<ContextHub> hubs);

    /**
     * Register a callback for the HAL implementation to send asynchronous
     * messages to the service from a context hub. There can be a maximum of
     * one callback registered with the HAL. A call to this function when a
     * callback has already been registered must override the previous
     * registration.
     *
     * @param hubId    identifier for the hub
     *        callback an implementation of the IContextHubCallbacks
     *
     * @return result OK on success
     *                BAD_VALUE if parameters are not sane
     *
     */
     registerCallback(uint32_t hubId, IContexthubCallback cb) generates (Result result);

    /**
     * Send a message to a hub
     *
     * @param hubId identifier for hub to send message to
     *        msg   message to be sent
     *
     * @return result OK if successful, error code otherwise
     *                BAD_VALUE if parameters are not sane
     *                TRANSACTION_FAILED if message send failed
     */
    sendMessageToHub(uint32_t hubId, ContextHubMsg msg)
            generates (Result result);

    /**
     * Loads a nanoApp. After loading, the nanoApp's init method must be called.
     * After the init method for nanoApp returns success, this must be indicated
     * to the service by an asynchronous call to handleTxnResult.
     *
     * Loading a nanoapp must not take more than 30 seconds.
     *
     * Depending on the implementation, nanoApps loaded via this API may or may
     * not persist across reboots of the hub. If they do persist, the
     * implementation must initially place nanoApps in the disabled state upon a
     * reboot, and not start them until a call is made to enableNanoApp(). In
     * this case, the app must also be unloaded upon a factory reset of the
     * device.
     *
     * @param hubId identifer of the contextHub
     *        appBinary contains the binary representation of the nanoApp, plus
     *                  metadata
     *        transactionId transactionId for this call
     *
     * @return result OK if transation started
     *                BAD_VALUE if parameters are not sane
     *                TRANSACTION_PENDING if hub is busy with another
     *                                    load/unload transaction
     *                TRANSACTION_FAILED if load failed synchronously
     *
     */
    loadNanoApp(uint32_t hubId,
                NanoAppBinary appBinary,
                uint32_t transactionId)
            generates (Result result);

    /**
     * Unloads a nanoApp. Before the unload, the apps deinit method is called.
     * After this, success must be indicated to the service through an
     * asynchronous call to handleTxnResult.
     *
     * Unloading a nanoapp must not take more than 5 seconds.
     *
     * @param hubId identifer of the contextHub
     *        appId appIdentifier returned by the HAL
     *        msg   message to be sent
     *
     * @return result OK if transation started
     *                BAD_VALUE if parameters are not sane
     *                TRANSACTION_PENDING if hub is busy with another
     *                                    load/unload transaction
     *                TRANSACTION_FAILED if unload failed synchronously
     *
     */
    unloadNanoApp(uint32_t hubId, uint64_t appId, uint32_t transactionId)
            generates (Result result);

    /**
     * Enables a nanoApp. The app's init method is called.
     * After this, success must be indicated to the service through an
     * asynchronous message.
     *
     * Enabling a nanoapp must not take more than 5 seconds.
     *
     * @param hubId identifer of the contextHub
     *        appId appIdentifier returned by the HAL
     *        msg   message to be sent
     *
     * @return result OK if transation started
     *                BAD_VALUE if parameters are not sane
     *                TRANSACTION_PENDING if hub is busy with another
     *                                    load/unload transaction
     *                FAILED_TRANSACTION if load fails immediately
     *
     */
    enableNanoApp(uint32_t hubId, uint64_t appId, uint32_t transactionId)
            generates (Result result);

    /**
     * Disables a nanoApp. The app's deinit method is called.
     * After this, success must be indicated to the service through an
     * asynchronous message.
     *
     * Disabling a nanoapp must not take more than 5 seconds.
     *
     * @param hubId identifer of the contextHub
     *        appId appIdentifier returned by the HAL
     *        msg   message to be sent
     *
     * @return result OK if transation started
     *                BAD_VALUE if parameters are not sane
     *                TRANSACTION_PENDING if hub is busy with another
     *                                    load/unload transaction
     *                FAILED_TRANSACTION if load fails immediately
     *
     */
    disableNanoApp(uint32_t hubId, uint64_t appId, uint32_t transactionId)
            generates (Result result);

    /**
     * Queries for Loaded apps on the hub
     *
     * @param hubId identifer of the contextHub
     *
     * @return apps all nanoApps on the hub.
     *              All nanoApps that can be modified by the service must
     *              be returned. A non-modifiable nanoapps must not be
     *              returned. A modifiable nanoApp is one that can be
     *              unloaded/disabled/enabled by the service.
     *
     */
    queryApps(uint32_t hubId) generates (Result result);
};