aboutsummaryrefslogtreecommitdiff
path: root/chre_api/legacy/v1_4/chre/version.h
blob: 08586a16cc4fe292dc71f24465fd94de2c6408ad (plain)
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/*
 * 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.
 */

#ifndef _CHRE_VERSION_H_
#define _CHRE_VERSION_H_

/**
 * @file
 * Definitions and methods for the versioning of the Context Hub Runtime
 * Environment.
 *
 * The CHRE API versioning pertains to all header files in the CHRE API.
 */

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * Value for version 0.1 of the Context Hub Runtime Environment API interface.
 *
 * This is a legacy version.  Version 1.0 is considered the first official
 * version of the API.
 *
 * @see CHRE_API_VERSION
 */
#define CHRE_API_VERSION_0_1  UINT32_C(0x00010000)

/**
 * Value for version 1.0 of the Context Hub Runtime Environment API interface.
 *
 * The version of the CHRE API which shipped with the Android Nougat release.
 *
 * @see CHRE_API_VERSION
 */
#define CHRE_API_VERSION_1_0  UINT32_C(0x01000000)

/**
 * Value for version 1.1 of the Context Hub Runtime Environment API interface.
 *
 * The version of the CHRE API shipped with the Android O release. It adds
 * initial support for new GNSS, WiFi, and WWAN modules.
 *
 * @see CHRE_API_VERSION
 */
#define CHRE_API_VERSION_1_1  UINT32_C(0x01010000)

/**
 * Value for version 1.2 of the Context Hub Runtime Environment API interface.
 *
 * The version of the CHRE API shipped with the Android P release. It adds
 * initial support for the new audio module.
 *
 * @see CHRE_API_VERSION
 */
#define CHRE_API_VERSION_1_2  UINT32_C(0x01020000)

/**
 * Value for version 1.3 of the Context Hub Runtime Environment API interface.
 *
 * The version of the CHRE API shipped with the Android Q release. It adds
 * support for GNSS location altitude/speed/bearing accuracy. It also adds step
 * detect as a standard CHRE sensor and supports bias event delivery and sensor
 * data flushing.
 *
 * @see CHRE_API_VERSION
 */
#define CHRE_API_VERSION_1_3  UINT32_C(0x01030000)

/**
 * Value for version 1.4 of the Context Hub Runtime Environment API interface.
 *
 * The version of the CHRE API shipped with the Android R release. It adds
 * support for collecting debug dump information from nanoapps, receiving L5
 * GNSS measurements, determining if a sensor supports passive requests,
 * receiving 5G cell info, and deprecates chreSendMessageToHost.
 *
 * @see CHRE_API_VERSION
 */
#define CHRE_API_VERSION_1_4  UINT32_C(0x01040000)

/**
 * Major and Minor Version of this Context Hub Runtime Environment API.
 *
 * The major version changes when there is an incompatible API change.
 *
 * The minor version changes when there is an addition in functionality
 * in a backwards-compatible manner.
 *
 * We define the version number as an unsigned 32-bit value.  The most
 * significant byte is the Major Version.  The second-most significant byte
 * is the Minor Version.  The two least significant bytes are the Patch
 * Version.  The Patch Version is not defined by this header API, but
 * is provided by a specific CHRE implementation (see chreGetVersion()).
 *
 * Note that version numbers can always be numerically compared with
 * expected results, so 1.0.0 < 1.0.4 < 1.1.0 < 2.0.300 < 3.5.0.
 */
#define CHRE_API_VERSION CHRE_API_VERSION_1_4

/**
 * Utility macro to extract only the API major version of a composite CHRE
 * version.
 *
 * @param version A uint32_t version, e.g. the value returned by
 *     chreGetApiVersion()
 *
 * @return The API major version in the least significant byte, e.g. 0x01
 */
#define CHRE_EXTRACT_MAJOR_VERSION(version) \
    (((version) & UINT32_C(0xFF000000)) >> 24)

/**
 * Utility macro to extract only the API minor version of a composite CHRE
 * version.
 *
 * @param version A uint32_t version, e.g. the CHRE_API_VERSION constant
 *
 * @return The API minor version in the least significant byte, e.g. 0x01
 */
#define CHRE_EXTRACT_MINOR_VERSION(version) \
    (((version) & UINT32_C(0x00FF0000)) >> 16)

/**
 * Utility macro to extract only the API minor version of a composite CHRE
 * version.
 *
 * @param version A complete uint32_t version, e.g. the value returned by
 *     chreGetVersion()
 *
 * @return The implementation patch version in the least significant two bytes,
 *     e.g. 0x0123, with all other bytes set to 0
 */
#define CHRE_EXTRACT_PATCH_VERSION(version)  ((version) & UINT32_C(0xFFFF))


/**
 * Get the API version the CHRE implementation was compiled against.
 *
 * This is not necessarily the CHRE_API_VERSION in the header the nanoapp was
 * built against, and indeed may not have even appeared in the context_hub_os.h
 * header which this nanoapp was built against.
 *
 * By definition, this will have the two least significant bytes set to 0,
 * and only contain the major and minor version number.
 *
 * @return The API version.
 */
uint32_t chreGetApiVersion(void);

/**
 * Get the version of this CHRE implementation.
 *
 * By definition, ((chreGetApiVersion() & UINT32_C(0xFFFF0000)) ==
 *                 (chreGetVersion()    & UINT32_C(0xFFFF0000))).
 *
 * The Patch Version, in the lower two bytes, only have meaning in context
 * of this specific platform ID.  It is increased by the platform every time
 * a backwards-compatible bug fix is released.
 *
 * @return The version.
 *
 * @see chreGetPlatformId()
 */
uint32_t chreGetVersion(void);

/**
 * Get the Platform ID of this CHRE.
 *
 * The most significant five bytes are the vendor ID as set out by the
 * NANOAPP_VENDOR convention in the original context hub HAL header file
 * (context_hub.h), also used by nanoapp IDs.
 *
 * The least significant three bytes are set by the vendor, but must be
 * unique for each different CHRE implementation/hardware that the vendor
 * supplies.
 *
 * The idea is that in the case of known bugs in the field, a new nanoapp could
 * be shipped with a workaround that would use this value, and chreGetVersion(),
 * to have code that can conditionally work around the bug on a buggy version.
 * Thus, we require this uniqueness to allow such a setup to work.
 *
 * @return The platform ID.
 *
 * @see CHRE_EXTRACT_VENDOR_ID
 */
uint64_t chreGetPlatformId(void);


#ifdef __cplusplus
}
#endif

#endif  /* _CHRE_VERSION_H_ */