ILocationAPI.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. /* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
  2. *
  3. * Redistribution and use in source and binary forms, with or without
  4. * modification, are permitted provided that the following conditions are
  5. * met:
  6. * * Redistributions of source code must retain the above copyright
  7. * notice, this list of conditions and the following disclaimer.
  8. * * Redistributions in binary form must reproduce the above
  9. * copyright notice, this list of conditions and the following
  10. * disclaimer in the documentation and/or other materials provided
  11. * with the distribution.
  12. * * Neither the name of The Linux Foundation nor the names of its
  13. * contributors may be used to endorse or promote products derived
  14. * from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  17. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  18. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
  19. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  20. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  21. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  22. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  23. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  24. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  25. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  26. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. #ifndef ILOCATIONAPI_H
  29. #define ILOCATIONAPI_H
  30. #include "LocationDataTypes.h"
  31. class ILocationAPI
  32. {
  33. public:
  34. virtual ~ILocationAPI(){};
  35. /** @brief Updates/changes the callbacks that will be called.
  36. mandatory callbacks must be present for callbacks to be successfully updated
  37. no return value */
  38. virtual void updateCallbacks(LocationCallbacks&) = 0;
  39. /* ================================== TRACKING ================================== */
  40. /** @brief Starts a tracking session, which returns a session id that will be
  41. used by the other tracking APIs and also in the responseCallback to match command
  42. with response. locations are reported on the registered trackingCallback
  43. periodically according to LocationOptions.
  44. @return session id
  45. responseCallback returns:
  46. LOCATION_ERROR_SUCCESS if session was successfully started
  47. LOCATION_ERROR_ALREADY_STARTED if a startTracking session is already in progress
  48. LOCATION_ERROR_CALLBACK_MISSING if no trackingCallback was passed
  49. LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameter is invalid */
  50. virtual uint32_t startTracking(TrackingOptions&) = 0;
  51. /** @brief Stops a tracking session associated with id parameter.
  52. responseCallback returns:
  53. LOCATION_ERROR_SUCCESS if successful
  54. LOCATION_ERROR_ID_UNKNOWN if id is not associated with a tracking session */
  55. virtual void stopTracking(uint32_t id) = 0;
  56. /** @brief Changes the LocationOptions of a tracking session associated with id.
  57. responseCallback returns:
  58. LOCATION_ERROR_SUCCESS if successful
  59. LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameters are invalid
  60. LOCATION_ERROR_ID_UNKNOWN if id is not associated with a tracking session */
  61. virtual void updateTrackingOptions(uint32_t id, TrackingOptions&) = 0;
  62. /* ================================== BATCHING ================================== */
  63. /** @brief starts a batching session, which returns a session id that will be
  64. used by the other batching APIs and also in the responseCallback to match command
  65. with response. locations are reported on the batchingCallback passed in createInstance
  66. periodically according to LocationOptions. A batching session starts tracking on
  67. the low power processor and delivers them in batches by the batchingCallback when
  68. the batch is full or when getBatchedLocations is called. This allows for the processor
  69. that calls this API to sleep when the low power processor can batch locations in the
  70. backgroup and wake up the processor calling the API only when the batch is full, thus
  71. saving power.
  72. @return session id
  73. responseCallback returns:
  74. LOCATION_ERROR_SUCCESS if session was successful
  75. LOCATION_ERROR_ALREADY_STARTED if a startBatching session is already in progress
  76. LOCATION_ERROR_CALLBACK_MISSING if no batchingCallback
  77. LOCATION_ERROR_INVALID_PARAMETER if a parameter is invalid
  78. LOCATION_ERROR_NOT_SUPPORTED if batching is not supported */
  79. virtual uint32_t startBatching(BatchingOptions&) = 0;
  80. /** @brief Stops a batching session associated with id parameter.
  81. responseCallback returns:
  82. LOCATION_ERROR_SUCCESS if successful
  83. LOCATION_ERROR_ID_UNKNOWN if id is not associated with batching session */
  84. virtual void stopBatching(uint32_t id) = 0;
  85. /** @brief Changes the LocationOptions of a batching session associated with id.
  86. responseCallback returns:
  87. LOCATION_ERROR_SUCCESS if successful
  88. LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameters are invalid
  89. LOCATION_ERROR_ID_UNKNOWN if id is not associated with a batching session */
  90. virtual void updateBatchingOptions(uint32_t id, BatchingOptions&) = 0;
  91. /** @brief Gets a number of locations that are currently stored/batched
  92. on the low power processor, delivered by the batchingCallback passed in createInstance.
  93. Location are then deleted from the batch stored on the low power processor.
  94. responseCallback returns:
  95. LOCATION_ERROR_SUCCESS if successful, will be followed by batchingCallback call
  96. LOCATION_ERROR_CALLBACK_MISSING if no batchingCallback
  97. LOCATION_ERROR_ID_UNKNOWN if id is not associated with a batching session */
  98. virtual void getBatchedLocations(uint32_t id, size_t count) = 0;
  99. /* ================================== GEOFENCE ================================== */
  100. /** @brief Adds any number of geofences and returns an array of geofence ids that
  101. will be used by the other geofence APIs and also in the collectiveResponseCallback to
  102. match command with response. The geofenceBreachCallback will deliver the status of each
  103. geofence according to the GeofenceOption for each. The geofence id array returned will
  104. be valid until the collectiveResponseCallback is called and has returned.
  105. @return id array
  106. collectiveResponseCallback returns:
  107. LOCATION_ERROR_SUCCESS if session was successful
  108. LOCATION_ERROR_CALLBACK_MISSING if no geofenceBreachCallback
  109. LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
  110. LOCATION_ERROR_NOT_SUPPORTED if geofence is not supported */
  111. virtual uint32_t* addGeofences(size_t count, GeofenceOption*, GeofenceInfo*) = 0;
  112. /** @brief Removes any number of geofences. Caller should delete ids array after
  113. removeGeofences returneds.
  114. collectiveResponseCallback returns:
  115. LOCATION_ERROR_SUCCESS if successful
  116. LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */
  117. virtual void removeGeofences(size_t count, uint32_t* ids) = 0;
  118. /** @brief Modifies any number of geofences. Caller should delete ids array after
  119. modifyGeofences returns.
  120. collectiveResponseCallback returns:
  121. LOCATION_ERROR_SUCCESS if successful
  122. LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session
  123. LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid */
  124. virtual void modifyGeofences(size_t count, uint32_t* ids, GeofenceOption* options) = 0;
  125. /** @brief Pauses any number of geofences, which is similar to removeGeofences,
  126. only that they can be resumed at any time. Caller should delete ids array after
  127. pauseGeofences returns.
  128. collectiveResponseCallback returns:
  129. LOCATION_ERROR_SUCCESS if successful
  130. LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */
  131. virtual void pauseGeofences(size_t count, uint32_t* ids) = 0;
  132. /** @brief Resumes any number of geofences that are currently paused. Caller should
  133. delete ids array after resumeGeofences returns.
  134. collectiveResponseCallback returns:
  135. LOCATION_ERROR_SUCCESS if successful
  136. LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */
  137. virtual void resumeGeofences(size_t count, uint32_t* ids) = 0;
  138. /* ================================== GNSS ====================================== */
  139. /** @brief gnssNiResponse is called in response to a gnssNiCallback.
  140. responseCallback returns:
  141. LOCATION_ERROR_SUCCESS if session was successful
  142. LOCATION_ERROR_INVALID_PARAMETER if any parameters in GnssNiResponse are invalid
  143. LOCATION_ERROR_ID_UNKNOWN if id does not match a gnssNiCallback */
  144. virtual void gnssNiResponse(uint32_t id, GnssNiResponse response) = 0;
  145. };
  146. class ILocationControlAPI
  147. {
  148. public:
  149. virtual ~ILocationControlAPI(){};
  150. /** @brief Updates the gnss specific configuration, which returns a session id array
  151. with an id for each of the bits set in GnssConfig.flags, order from low bits to high bits.
  152. The response for each config that is set will be returned in collectiveResponseCallback.
  153. The session id array returned will be valid until the collectiveResponseCallback is called
  154. and has returned. This effect is global for all clients of ILocationAPI.
  155. collectiveResponseCallback returns:
  156. LOCATION_ERROR_SUCCESS if session was successful
  157. LOCATION_ERROR_INVALID_PARAMETER if any other parameters are invalid
  158. LOCATION_ERROR_GENERAL_FAILURE if failure for any other reason */
  159. virtual uint32_t* gnssUpdateConfig(const GnssConfig& config) = 0;
  160. /** @brief Delete specific gnss aiding data for testing, which returns a session id
  161. that will be returned in responseCallback to match command with response.
  162. Only allowed in userdebug builds. This effect is global for all clients of ILocationAPI.
  163. responseCallback returns:
  164. LOCATION_ERROR_SUCCESS if successful
  165. LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
  166. LOCATION_ERROR_NOT_SUPPORTED if build is not userdebug */
  167. virtual uint32_t gnssDeleteAidingData(GnssAidingData& data) = 0;
  168. /** @brief
  169. Configure the constellation and SVs to be used by the GNSS engine on
  170. modem.
  171. @param
  172. constellationEnablementConfig: configuration to enable/disable SV
  173. constellation to be used by SPE engine. When size in
  174. constellationEnablementConfig is set to 0, this indicates to reset SV
  175. constellation configuration to modem NV default.
  176. blacklistSvConfig: configuration to blacklist or unblacklist SVs
  177. used by SPE engine
  178. @return
  179. A session id that will be returned in responseCallback to
  180. match command with response. This effect is global for all
  181. clients of LocationAPI responseCallback returns:
  182. LOCATION_ERROR_SUCCESS if successful
  183. LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
  184. */
  185. virtual uint32_t configConstellations(
  186. const GnssSvTypeConfig& constellationEnablementConfig,
  187. const GnssSvIdConfig& blacklistSvConfig) = 0;
  188. /** @brief
  189. Configure the secondary band of constellations to be used by
  190. the GNSS engine on modem.
  191. @param
  192. secondaryBandConfig: configuration the secondary band usage
  193. for SPE engine
  194. @return
  195. A session id that will be returned in responseCallback to
  196. match command with response. This effect is global for all
  197. clients of LocationAPI responseCallback returns:
  198. LOCATION_ERROR_SUCCESS if successful
  199. LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
  200. */
  201. virtual uint32_t configConstellationSecondaryBand(
  202. const GnssSvTypeConfig& secondaryBandConfig) = 0;
  203. /** @brief
  204. Enable or disable the constrained time uncertainty feature.
  205. @param
  206. enable: true to enable the constrained time uncertainty
  207. feature and false to disable the constrainted time
  208. uncertainty feature.
  209. @param
  210. tuncThreshold: this specifies the time uncertainty threshold
  211. that gps engine need to maintain, in units of milli-seconds.
  212. Default is 0.0 meaning that modem default value of time
  213. uncertainty threshold will be used. This parameter is
  214. ignored when requesting to disable this feature.
  215. @param
  216. energyBudget: this specifies the power budget that gps
  217. engine is allowed to spend to maintain the time uncertainty.
  218. Default is 0 meaning that GPS engine is not constained by
  219. power budget and can spend as much power as needed. The
  220. parameter need to be specified in units of 0.1 milli watt
  221. second. This parameter is ignored requesting to disable this
  222. feature.
  223. @return
  224. A session id that will be returned in responseCallback to
  225. match command with response. This effect is global for all
  226. clients of LocationAPI responseCallback returns:
  227. LOCATION_ERROR_SUCCESS if successful
  228. LOCATION_ERROR_INVALID_PARAMETER if any parameters
  229. are invalid
  230. */
  231. virtual uint32_t configConstrainedTimeUncertainty(
  232. bool enable, float tuncThreshold = 0.0,
  233. uint32_t energyBudget = 0) = 0;
  234. /** @brief
  235. Enable or disable position assisted clock estimator feature.
  236. @param
  237. enable: true to enable position assisted clock estimator and
  238. false to disable the position assisted clock estimator
  239. feature.
  240. @return
  241. A session id that will be returned in responseCallback to
  242. match command with response. This effect is global for all
  243. clients of LocationAPI responseCallback returns:
  244. LOCATION_ERROR_SUCCESS if successful
  245. LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
  246. */
  247. virtual uint32_t configPositionAssistedClockEstimator(bool enable) = 0;
  248. /** @brief
  249. Sets the lever arm parameters for the vehicle.
  250. @param
  251. configInfo: lever arm configuration info regarding below two
  252. types of lever arm info:
  253. a: GNSS Antenna w.r.t the origin at the IMU e.g.: inertial
  254. measurement unit.
  255. b: lever arm parameters regarding the OPF (output frame)
  256. w.r.t the origin (at the GPS Antenna). Vehicle manufacturers
  257. prefer the position output to be tied to a specific point in
  258. the vehicle rather than where the antenna is placed
  259. (midpoint of the rear axle is typical).
  260. Caller can choose types of lever arm info to configure via the
  261. leverMarkTypeMask.
  262. @return
  263. A session id that will be returned in responseCallback to
  264. match command with response. This effect is global for all
  265. clients of LocationAPI responseCallback returns:
  266. LOCATION_ERROR_SUCCESS if successful
  267. LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
  268. */
  269. virtual uint32_t configLeverArm(const LeverArmConfigInfo& configInfo) = 0;
  270. /** @brief
  271. Configure the robust location setting.
  272. @param
  273. enable: true to enable robust location and false to disable
  274. robust location.
  275. @param
  276. enableForE911: true to enable robust location when device is on
  277. E911 session and false to disable on E911 session.
  278. This parameter is only valid if robust location is enabled.
  279. @return
  280. A session id that will be returned in responseCallback to
  281. match command with response. This effect is global for all
  282. clients of LocationAPI responseCallback returns:
  283. LOCATION_ERROR_SUCCESS if successful
  284. LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
  285. */
  286. virtual uint32_t configRobustLocation(bool enable, bool enableForE911) = 0;
  287. /** @brief
  288. Config the minimum GPS week used by modem GNSS engine.
  289. @param
  290. minGpsWeek: minimum GPS week to be used by modem GNSS engine.
  291. @return
  292. A session id that will be returned in responseCallback to
  293. match command with response. This effect is global for all
  294. clients of LocationAPI responseCallback returns:
  295. LOCATION_ERROR_SUCCESS if successful
  296. LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
  297. */
  298. virtual uint32_t configMinGpsWeek(uint16_t minGpsWeek) = 0;
  299. /** @brief
  300. Configure the vehicle body-to-Sensor mount parameters and
  301. other parameters for dead reckoning position engine.
  302. @param
  303. dreConfig: vehicle body-to-Sensor mount angles and other
  304. parameters.
  305. @return
  306. A session id that will be returned in responseCallback to
  307. match command with response. This effect is global for all
  308. clients of LocationAPI responseCallback returns:
  309. LOCATION_ERROR_SUCCESS if successful
  310. LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
  311. */
  312. virtual uint32_t configDeadReckoningEngineParams(const DeadReckoningEngineConfig& dreConfig)=0;
  313. /** @brief
  314. This API is used to instruct the specified engine to be in
  315. the pause/resume state. <br/>
  316. When the engine is placed in paused state, the engine will
  317. stop. If there is an on-going session, engine will no longer
  318. produce fixes. In the paused state, calling API to delete
  319. aiding data from the paused engine may not have effect.
  320. Request to delete Aiding data shall be issued after
  321. engine resume. <br/>
  322. Currently, only DRE engine will support pause/resume
  323. request. responseCb() will return not supported when request
  324. is made to pause/resume none-DRE engine. <br/>
  325. Request to pause/resume DRE engine can be made with or
  326. without an on-going session. With QDR engine, on resume,
  327. GNSS position & heading re-acquisition is needed for DR
  328. engine to engage. If DR engine is already in the requested
  329. state, the request will be no-op. <br/>
  330. @param
  331. engType: the engine that is instructed to change its run
  332. state. <br/>
  333. engState: the new engine run state that the engine is
  334. instructed to be in. <br/>
  335. @return
  336. A session id that will be returned in responseCallback to
  337. match command with response. This effect is global for all
  338. clients of LocationAPI responseCallback returns:
  339. LOCATION_ERROR_SUCCESS if successful
  340. LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
  341. */
  342. virtual uint32_t configEngineRunState(PositioningEngineMask engType,
  343. LocEngineRunState engState) = 0;
  344. /** @brief
  345. This API is used to config the NMEA sentence types.
  346. Without prior calling this API, all NMEA sentences supported
  347. in the system, as defined in NmeaTypesMask, will get
  348. generated and delivered to all the location clients that
  349. register to receive NMEA sentences.
  350. The NMEA sentence types are per-device setting and calling
  351. this API will impact all the location api clients that
  352. register to receive NMEA sentences. This API call is not
  353. incremental and the new NMEA sentence types will completely
  354. overwrite the previous call.
  355. If one or more unspecified bits are set in the NMEA mask,
  356. those bits will be ignored, but the rest of the
  357. configuration will get applied.
  358. Please note that the configured NMEA sentence types are not
  359. persistent.
  360. @param
  361. enabledNmeaTypes: specify the set of NMEA sentences the
  362. device will generate and deliver to the location api clients
  363. that register to receive NMEA sentences. <br/>
  364. @return
  365. A session id that will be returned in responseCallback to
  366. match command with response.
  367. */
  368. virtual uint32_t configOutputNmeaTypes(
  369. GnssNmeaTypesMask enabledNmeaTypes) = 0;
  370. /** @brief
  371. This API is used to send platform power events to GNSS adapters in order
  372. to handle GNSS sessions as per platform power event.
  373. @param
  374. powerState: Current vehicle/platform power state.
  375. @return
  376. No return value.
  377. */
  378. virtual void powerStateEvent(PowerStateType powerState __unused) {};
  379. };
  380. #endif /* ILOCATIONAPI_H */