1 /* 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 17 // IWYU pragma: private, include "chre_api/chre.h" 18 // IWYU pragma: friend chre/.*\.h 19 20 #ifndef _CHRE_VERSION_H_ 21 #define _CHRE_VERSION_H_ 22 23 /** 24 * @file 25 * Definitions and methods for the versioning of the Context Hub Runtime 26 * Environment. 27 * 28 * The CHRE API versioning pertains to all header files in the CHRE API. 29 */ 30 31 #include <stdint.h> 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 /** 38 * Value for version 0.1 of the Context Hub Runtime Environment API interface. 39 * 40 * This is a legacy version of the CHRE API. Version 1.0 is considered the first 41 * official CHRE API version. 42 * 43 * @see CHRE_API_VERSION 44 */ 45 #define CHRE_API_VERSION_0_1 UINT32_C(0x00010000) 46 47 /** 48 * Value for version 1.0 of the Context Hub Runtime Environment API interface. 49 * 50 * This version of the CHRE API shipped with the Android Nougat release. 51 * 52 * @see CHRE_API_VERSION 53 */ 54 #define CHRE_API_VERSION_1_0 UINT32_C(0x01000000) 55 56 /** 57 * Value for version 1.1 of the Context Hub Runtime Environment API interface. 58 * 59 * This version of the CHRE API shipped with the Android O release. It adds 60 * initial support for new GNSS, WiFi, and WWAN modules. 61 * 62 * @see CHRE_API_VERSION 63 */ 64 #define CHRE_API_VERSION_1_1 UINT32_C(0x01010000) 65 66 /** 67 * Value for version 1.2 of the Context Hub Runtime Environment API interface. 68 * 69 * This version of the CHRE API shipped with the Android P release. It adds 70 * initial support for the new audio module. 71 * 72 * @see CHRE_API_VERSION 73 */ 74 #define CHRE_API_VERSION_1_2 UINT32_C(0x01020000) 75 76 /** 77 * Value for version 1.3 of the Context Hub Runtime Environment API interface. 78 * 79 * This version of the CHRE API shipped with the Android Q release. It adds 80 * support for GNSS location altitude/speed/bearing accuracy. It also adds step 81 * detect as a standard CHRE sensor and supports bias event delivery and sensor 82 * data flushing. 83 * 84 * @see CHRE_API_VERSION 85 */ 86 #define CHRE_API_VERSION_1_3 UINT32_C(0x01030000) 87 88 /** 89 * Value for version 1.4 of the Context Hub Runtime Environment API interface. 90 * 91 * This version of the CHRE API shipped with the Android R release. It adds 92 * support for collecting debug dump information from nanoapps, receiving L5 93 * GNSS measurements, determining if a sensor supports passive requests, 94 * receiving 5G cell info, and deprecates chreSendMessageToHost. 95 * 96 * @see CHRE_API_VERSION 97 */ 98 #define CHRE_API_VERSION_1_4 UINT32_C(0x01040000) 99 100 /** 101 * Value for version 1.5 of the Context Hub Runtime Environment API interface. 102 * 103 * This version of the CHRE API shipped with the Android S release. It adds 104 * support for multiple sensors of the same type, permissions for sensitive CHRE 105 * APIs / data usage, ability to receive user settings updates, step counter and 106 * hinge angle sensors, improved WiFi scan preferences to support power 107 * optimization, new WiFi security types, increased the lower bound for the 108 * maximum CHRE to host message size, and increased GNSS measurements in 109 * chreGnssDataEvent. 110 * 111 * @see CHRE_API_VERSION 112 */ 113 #define CHRE_API_VERSION_1_5 UINT32_C(0x01050000) 114 115 /** 116 * Value for version 1.6 of the Context Hub Runtime Environment API interface. 117 * 118 * This version of the CHRE API is shipped with the Android T release. It adds 119 * support for BLE scanning, subscribing to the WiFi NAN discovery engine, 120 * subscribing to host endpoint notifications, requesting metadata for a host 121 * endpoint ID, nanoapps publishing RPC services they support, and limits the 122 * nanoapp instance ID size to INT16_MAX. 123 * 124 * @see CHRE_API_VERSION 125 */ 126 #define CHRE_API_VERSION_1_6 UINT32_C(0x01060000) 127 128 /** 129 * Value for version 1.7 of the Context Hub Runtime Environment API interface. 130 * 131 * This version of the CHRE API is shipped with a post-launch update to the 132 * Android T release. It adds the BLE flush API. 133 * 134 * @see CHRE_API_VERSION 135 */ 136 #define CHRE_API_VERSION_1_7 UINT32_C(0x01070000) 137 138 /** 139 * Value for version 1.8 of the Context Hub Runtime Environment API interface. 140 * 141 * This version of the CHRE API is shipped with the Android U release. It adds 142 * support for filtering by manufacturer data in BLE scans, reading the RSSI 143 * value of a BLE connection, allowing the nanoapp to check BLE scan status, 144 * allowing the nanoapp to specify which RPC services it supports, and 145 * delivering batch complete events for batched BLE scans. 146 * 147 * @see CHRE_API_VERSION 148 */ 149 #define CHRE_API_VERSION_1_8 UINT32_C(0x01080000) 150 151 /** 152 * Value for version 1.9 of the Context Hub Runtime Environment API interface. 153 * 154 * This version of the CHRE API is shipped with a post-launch update to the 155 * Android U release. It adds the BLE Broadcaster Address filter. 156 * 157 * @see CHRE_API_VERSION 158 */ 159 #define CHRE_API_VERSION_1_9 UINT32_C(0x01090000) 160 161 /** 162 * Value for version 1.10 of the Context Hub Runtime Environment API interface. 163 * 164 * This version of the CHRE API is shipped with Android V. It adds support for 165 * reliable messaging. 166 * 167 * @note This version of the CHRE API has not been finalized yet, and is 168 * currently considered a preview that is subject to change. 169 * 170 * @see CHRE_API_VERSION 171 */ 172 #define CHRE_API_VERSION_1_10 UINT32_C(0x010a0000) 173 174 /** 175 * Major and Minor Version of this Context Hub Runtime Environment API. 176 * 177 * The major version changes when there is an incompatible API change. 178 * 179 * The minor version changes when there is an addition in functionality 180 * in a backwards-compatible manner. 181 * 182 * We define the version number as an unsigned 32-bit value. The most 183 * significant byte is the Major Version. The second-most significant byte 184 * is the Minor Version. The two least significant bytes are the Patch 185 * Version. The Patch Version is not defined by this header API, but 186 * is provided by a specific CHRE implementation (see chreGetVersion()). 187 * 188 * Note that version numbers can always be numerically compared with 189 * expected results, so 1.0.0 < 1.0.4 < 1.1.0 < 2.0.300 < 3.5.0. 190 */ 191 #define CHRE_API_VERSION CHRE_API_VERSION_1_10 192 193 /** 194 * Utility macro to extract only the API major version of a composite CHRE 195 * version. 196 * 197 * @param version A uint32_t version, e.g. the value returned by 198 * chreGetApiVersion() 199 * 200 * @return The API major version in the least significant byte, e.g. 0x01 201 */ 202 #define CHRE_EXTRACT_MAJOR_VERSION(version) \ 203 (uint32_t)(((version) & UINT32_C(0xFF000000)) >> 24) 204 205 /** 206 * Utility macro to extract only the API minor version of a composite CHRE 207 * version. 208 * 209 * @param version A uint32_t version, e.g. the CHRE_API_VERSION constant 210 * 211 * @return The API minor version in the least significant byte, e.g. 0x01 212 */ 213 #define CHRE_EXTRACT_MINOR_VERSION(version) \ 214 (uint32_t)(((version) & UINT32_C(0x00FF0000)) >> 16) 215 216 /** 217 * Utility macro to extract only the API minor version of a composite CHRE 218 * version. 219 * 220 * @param version A complete uint32_t version, e.g. the value returned by 221 * chreGetVersion() 222 * 223 * @return The implementation patch version in the least significant two bytes, 224 * e.g. 0x0123, with all other bytes set to 0 225 */ 226 #define CHRE_EXTRACT_PATCH_VERSION(version) (uint32_t)((version) & UINT32_C(0xFFFF)) 227 228 /** 229 * Get the API version the CHRE implementation was compiled against. 230 * 231 * This is not necessarily the CHRE_API_VERSION in the header the nanoapp was 232 * built against, and indeed may not have even appeared in the context_hub_os.h 233 * header which this nanoapp was built against. 234 * 235 * By definition, this will have the two least significant bytes set to 0, 236 * and only contain the major and minor version number. 237 * 238 * @return The API version. 239 */ 240 uint32_t chreGetApiVersion(void); 241 242 /** 243 * Get the version of this CHRE implementation. 244 * 245 * By definition, ((chreGetApiVersion() & UINT32_C(0xFFFF0000)) == 246 * (chreGetVersion() & UINT32_C(0xFFFF0000))). 247 * 248 * The Patch Version, in the lower two bytes, only have meaning in context 249 * of this specific platform ID. It is increased by the platform every time 250 * a backwards-compatible bug fix is released. 251 * 252 * @return The version. 253 * 254 * @see chreGetPlatformId() 255 */ 256 uint32_t chreGetVersion(void); 257 258 /** 259 * Get the Platform ID of this CHRE. 260 * 261 * The most significant five bytes are the vendor ID as set out by the 262 * NANOAPP_VENDOR convention in the original context hub HAL header file 263 * (context_hub.h), also used by nanoapp IDs. 264 * 265 * The least significant three bytes are set by the vendor, but must be 266 * unique for each different CHRE implementation/hardware that the vendor 267 * supplies. 268 * 269 * The idea is that in the case of known bugs in the field, a new nanoapp could 270 * be shipped with a workaround that would use this value, and chreGetVersion(), 271 * to have code that can conditionally work around the bug on a buggy version. 272 * Thus, we require this uniqueness to allow such a setup to work. 273 * 274 * @return The platform ID. 275 * 276 * @see CHRE_EXTRACT_VENDOR_ID 277 */ 278 uint64_t chreGetPlatformId(void); 279 280 #ifdef __cplusplus 281 } 282 #endif 283 284 #endif /* _CHRE_VERSION_H_ */ 285