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 * @note This version of the CHRE API has not been finalized yet, and is 158 * currently considered a preview that is subject to change. 159 * 160 * @see CHRE_API_VERSION 161 */ 162 #define CHRE_API_VERSION_1_9 UINT32_C(0x01090000) 163 164 /** 165 * Major and Minor Version of this Context Hub Runtime Environment API. 166 * 167 * The major version changes when there is an incompatible API change. 168 * 169 * The minor version changes when there is an addition in functionality 170 * in a backwards-compatible manner. 171 * 172 * We define the version number as an unsigned 32-bit value. The most 173 * significant byte is the Major Version. The second-most significant byte 174 * is the Minor Version. The two least significant bytes are the Patch 175 * Version. The Patch Version is not defined by this header API, but 176 * is provided by a specific CHRE implementation (see chreGetVersion()). 177 * 178 * Note that version numbers can always be numerically compared with 179 * expected results, so 1.0.0 < 1.0.4 < 1.1.0 < 2.0.300 < 3.5.0. 180 */ 181 #define CHRE_API_VERSION CHRE_API_VERSION_1_9 182 183 /** 184 * Utility macro to extract only the API major version of a composite CHRE 185 * version. 186 * 187 * @param version A uint32_t version, e.g. the value returned by 188 * chreGetApiVersion() 189 * 190 * @return The API major version in the least significant byte, e.g. 0x01 191 */ 192 #define CHRE_EXTRACT_MAJOR_VERSION(version) \ 193 (uint32_t)(((version) & UINT32_C(0xFF000000)) >> 24) 194 195 /** 196 * Utility macro to extract only the API minor version of a composite CHRE 197 * version. 198 * 199 * @param version A uint32_t version, e.g. the CHRE_API_VERSION constant 200 * 201 * @return The API minor version in the least significant byte, e.g. 0x01 202 */ 203 #define CHRE_EXTRACT_MINOR_VERSION(version) \ 204 (uint32_t)(((version) & UINT32_C(0x00FF0000)) >> 16) 205 206 /** 207 * Utility macro to extract only the API minor version of a composite CHRE 208 * version. 209 * 210 * @param version A complete uint32_t version, e.g. the value returned by 211 * chreGetVersion() 212 * 213 * @return The implementation patch version in the least significant two bytes, 214 * e.g. 0x0123, with all other bytes set to 0 215 */ 216 #define CHRE_EXTRACT_PATCH_VERSION(version) (uint32_t)((version) & UINT32_C(0xFFFF)) 217 218 /** 219 * Get the API version the CHRE implementation was compiled against. 220 * 221 * This is not necessarily the CHRE_API_VERSION in the header the nanoapp was 222 * built against, and indeed may not have even appeared in the context_hub_os.h 223 * header which this nanoapp was built against. 224 * 225 * By definition, this will have the two least significant bytes set to 0, 226 * and only contain the major and minor version number. 227 * 228 * @return The API version. 229 */ 230 uint32_t chreGetApiVersion(void); 231 232 /** 233 * Get the version of this CHRE implementation. 234 * 235 * By definition, ((chreGetApiVersion() & UINT32_C(0xFFFF0000)) == 236 * (chreGetVersion() & UINT32_C(0xFFFF0000))). 237 * 238 * The Patch Version, in the lower two bytes, only have meaning in context 239 * of this specific platform ID. It is increased by the platform every time 240 * a backwards-compatible bug fix is released. 241 * 242 * @return The version. 243 * 244 * @see chreGetPlatformId() 245 */ 246 uint32_t chreGetVersion(void); 247 248 /** 249 * Get the Platform ID of this CHRE. 250 * 251 * The most significant five bytes are the vendor ID as set out by the 252 * NANOAPP_VENDOR convention in the original context hub HAL header file 253 * (context_hub.h), also used by nanoapp IDs. 254 * 255 * The least significant three bytes are set by the vendor, but must be 256 * unique for each different CHRE implementation/hardware that the vendor 257 * supplies. 258 * 259 * The idea is that in the case of known bugs in the field, a new nanoapp could 260 * be shipped with a workaround that would use this value, and chreGetVersion(), 261 * to have code that can conditionally work around the bug on a buggy version. 262 * Thus, we require this uniqueness to allow such a setup to work. 263 * 264 * @return The platform ID. 265 * 266 * @see CHRE_EXTRACT_VENDOR_ID 267 */ 268 uint64_t chreGetPlatformId(void); 269 270 #ifdef __cplusplus 271 } 272 #endif 273 274 #endif /* _CHRE_VERSION_H_ */ 275