loc_gps.h 86 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283
  1. /*
  2. * Copyright (C) 2010 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. Changes from Qualcomm Innovation Center are provided under the following license:
  18. Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  19. Redistribution and use in source and binary forms, with or without
  20. modification, are permitted (subject to the limitations in the
  21. disclaimer below) provided that the following conditions are met:
  22. * Redistributions of source code must retain the above copyright
  23. notice, this list of conditions and the following disclaimer.
  24. * Redistributions in binary form must reproduce the above
  25. copyright notice, this list of conditions and the following
  26. disclaimer in the documentation and/or other materials provided
  27. with the distribution.
  28. * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
  29. contributors may be used to endorse or promote products derived
  30. from this software without specific prior written permission.
  31. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
  32. GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
  33. HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
  34. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  35. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  36. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  37. ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  38. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  39. GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  40. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  41. IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  42. OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  43. IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  44. */
  45. #ifndef LOC_GPS_H
  46. #define LOC_GPS_H
  47. #include <stdint.h>
  48. #include <sys/cdefs.h>
  49. #include <sys/types.h>
  50. #include <pthread.h>
  51. #include <sys/socket.h>
  52. #include <stdbool.h>
  53. __BEGIN_DECLS
  54. #define LOC_FLP_STATUS_LOCATION_AVAILABLE 0
  55. #define LOC_FLP_STATUS_LOCATION_UNAVAILABLE 1
  56. #define LOC_CAPABILITY_GNSS (1U<<0)
  57. #define LOC_CAPABILITY_WIFI (1U<<1)
  58. #define LOC_CAPABILITY_CELL (1U<<3)
  59. /** Milliseconds since January 1, 1970 */
  60. typedef int64_t LocGpsUtcTime;
  61. /** Maximum number of SVs for loc_gps_sv_status_callback(). */
  62. #define LOC_GPS_MAX_SVS 32
  63. /** Maximum number of SVs for loc_gps_sv_status_callback(). */
  64. #define LOC_GNSS_MAX_SVS 64
  65. /** Maximum number of Measurements in loc_gps_measurement_callback(). */
  66. #define LOC_GPS_MAX_MEASUREMENT 32
  67. /** Maximum number of Measurements in loc_gnss_measurement_callback(). */
  68. #define LOC_GNSS_MAX_MEASUREMENT 64
  69. /** Requested operational mode for GPS operation. */
  70. typedef uint32_t LocGpsPositionMode;
  71. /* IMPORTANT: Note that the following values must match
  72. * constants in GpsLocationProvider.java. */
  73. /** Mode for running GPS standalone (no assistance). */
  74. #define LOC_GPS_POSITION_MODE_STANDALONE 0
  75. /** AGPS MS-Based mode. */
  76. #define LOC_GPS_POSITION_MODE_MS_BASED 1
  77. /**
  78. * AGPS MS-Assisted mode. This mode is not maintained by the platform anymore.
  79. * It is strongly recommended to use LOC_GPS_POSITION_MODE_MS_BASED instead.
  80. */
  81. #define LOC_GPS_POSITION_MODE_MS_ASSISTED 2
  82. /** Requested recurrence mode for GPS operation. */
  83. typedef uint32_t LocGpsPositionRecurrence;
  84. /* IMPORTANT: Note that the following values must match
  85. * constants in GpsLocationProvider.java. */
  86. /** Receive GPS fixes on a recurring basis at a specified period. */
  87. #define LOC_GPS_POSITION_RECURRENCE_PERIODIC 0
  88. /** Request a single shot GPS fix. */
  89. #define LOC_GPS_POSITION_RECURRENCE_SINGLE 1
  90. /** GPS status event values. */
  91. typedef uint16_t LocGpsStatusValue;
  92. /* IMPORTANT: Note that the following values must match
  93. * constants in GpsLocationProvider.java. */
  94. /** GPS status unknown. */
  95. #define LOC_GPS_STATUS_NONE 0
  96. /** GPS has begun navigating. */
  97. #define LOC_GPS_STATUS_SESSION_BEGIN 1
  98. /** GPS has stopped navigating. */
  99. #define LOC_GPS_STATUS_SESSION_END 2
  100. /** GPS has powered on but is not navigating. */
  101. #define LOC_GPS_STATUS_ENGINE_ON 3
  102. /** GPS is powered off. */
  103. #define LOC_GPS_STATUS_ENGINE_OFF 4
  104. /** Flags to indicate which values are valid in a LocGpsLocation. */
  105. typedef uint16_t LocGpsLocationFlags;
  106. /* IMPORTANT: Note that the following values must match
  107. * constants in GpsLocationProvider.java. */
  108. /** LocGpsLocation has valid latitude and longitude. */
  109. #define LOC_GPS_LOCATION_HAS_LAT_LONG 0x0001
  110. /** LocGpsLocation has valid altitude. */
  111. #define LOC_GPS_LOCATION_HAS_ALTITUDE 0x0002
  112. /** LocGpsLocation has valid speed. */
  113. #define LOC_GPS_LOCATION_HAS_SPEED 0x0004
  114. /** LocGpsLocation has valid bearing. */
  115. #define LOC_GPS_LOCATION_HAS_BEARING 0x0008
  116. /** LocGpsLocation has valid accuracy. */
  117. #define LOC_GPS_LOCATION_HAS_ACCURACY 0x0010
  118. /** LocGpsLocation has valid vertical uncertainity */
  119. #define LOC_GPS_LOCATION_HAS_VERT_UNCERTAINITY 0x0020
  120. /** LocGpsLocation has valid speed accuracy */
  121. #define LOC_GPS_LOCATION_HAS_SPEED_ACCURACY 0x0040
  122. /** LocGpsLocation has valid bearing accuracy */
  123. #define LOC_GPS_LOCATION_HAS_BEARING_ACCURACY 0x0080
  124. /** LocGpsLocation has valid spoof mask */
  125. #define LOC_GPS_LOCATION_HAS_SPOOF_MASK 0x0100
  126. /** Location has valid source information. */
  127. #define LOC_GPS_LOCATION_HAS_SOURCE_INFO 0x0200
  128. /** Spoof mask in LocGpsLocation */
  129. typedef uint32_t LocGpsSpoofMask;
  130. #define LOC_GPS_LOCATION_NONE_SPOOFED 0x0000
  131. #define LOC_GPS_LOCATION_POSITION_SPOOFED 0x0001
  132. #define LOC_GPS_LOCATION_TIME_SPOOFED 0x0002
  133. #define LOC_GPS_LOCATION_NAVIGATION_DATA_SPOOFED 0x0004
  134. /** Flags for the loc_gps_set_capabilities callback. */
  135. /**
  136. * GPS HAL schedules fixes for LOC_GPS_POSITION_RECURRENCE_PERIODIC mode. If this is
  137. * not set, then the framework will use 1000ms for min_interval and will start
  138. * and call start() and stop() to schedule the GPS.
  139. */
  140. #define LOC_GPS_CAPABILITY_SCHEDULING (1 << 0)
  141. /** GPS supports MS-Based AGPS mode */
  142. #define LOC_GPS_CAPABILITY_MSB (1 << 1)
  143. /** GPS supports MS-Assisted AGPS mode */
  144. #define LOC_GPS_CAPABILITY_MSA (1 << 2)
  145. /** GPS supports single-shot fixes */
  146. #define LOC_GPS_CAPABILITY_SINGLE_SHOT (1 << 3)
  147. /** GPS supports on demand time injection */
  148. #define LOC_GPS_CAPABILITY_ON_DEMAND_TIME (1 << 4)
  149. /** GPS supports Geofencing */
  150. #define LOC_GPS_CAPABILITY_GEOFENCING (1 << 5)
  151. /** GPS supports Measurements. */
  152. #define LOC_GPS_CAPABILITY_MEASUREMENTS (1 << 6)
  153. /** GPS supports Navigation Messages */
  154. #define LOC_GPS_CAPABILITY_NAV_MESSAGES (1 << 7)
  155. /**
  156. * Flags used to specify which aiding data to delete when calling
  157. * delete_aiding_data().
  158. */
  159. typedef uint16_t LocGpsAidingData;
  160. /* IMPORTANT: Note that the following values must match
  161. * constants in GpsLocationProvider.java. */
  162. #define LOC_GPS_DELETE_EPHEMERIS 0x0001
  163. #define LOC_GPS_DELETE_ALMANAC 0x0002
  164. #define LOC_GPS_DELETE_POSITION 0x0004
  165. #define LOC_GPS_DELETE_TIME 0x0008
  166. #define LOC_GPS_DELETE_IONO 0x0010
  167. #define LOC_GPS_DELETE_UTC 0x0020
  168. #define LOC_GPS_DELETE_HEALTH 0x0040
  169. #define LOC_GPS_DELETE_SVDIR 0x0080
  170. #define LOC_GPS_DELETE_SVSTEER 0x0100
  171. #define LOC_GPS_DELETE_SADATA 0x0200
  172. #define LOC_GPS_DELETE_RTI 0x0400
  173. #define LOC_GPS_DELETE_MB_DATA 0x0800
  174. #define LOC_GPS_DELETE_CELLDB_INFO 0x8000
  175. #define LOC_GPS_DELETE_ALL 0xFFFF
  176. /** AGPS type */
  177. typedef uint16_t LocAGpsType;
  178. #define LOC_AGPS_TYPE_ANY 0
  179. #define LOC_AGPS_TYPE_SUPL 1
  180. #define LOC_AGPS_TYPE_C2K 2
  181. #define LOC_AGPS_TYPE_WWAN_ANY 3
  182. #define LOC_AGPS_TYPE_WIFI 4
  183. #define LOC_AGPS_TYPE_SUPL_ES 5
  184. typedef uint16_t LocSubId;
  185. #define LOC_DEFAULT_SUB 0
  186. #define LOC_PRIMARY_SUB 1
  187. #define LOC_SECONDARY_SUB 2
  188. #define LOC_TERTIARY_SUB 3
  189. typedef uint16_t LocAGpsSetIDType;
  190. #define LOC_AGPS_SETID_TYPE_NONE 0
  191. #define LOC_AGPS_SETID_TYPE_IMSI 1
  192. #define LOC_AGPS_SETID_TYPE_MSISDN 2
  193. typedef uint16_t LocApnIpType;
  194. #define LOC_APN_IP_INVALID 0
  195. #define LOC_APN_IP_IPV4 1
  196. #define LOC_APN_IP_IPV6 2
  197. #define LOC_APN_IP_IPV4V6 3
  198. /**
  199. * String length constants
  200. */
  201. #define LOC_GPS_NI_SHORT_STRING_MAXLEN 256
  202. #define LOC_GPS_NI_LONG_STRING_MAXLEN 2048
  203. /**
  204. * LocGpsNiType constants
  205. */
  206. typedef uint32_t LocGpsNiType;
  207. #define LOC_GPS_NI_TYPE_VOICE 1
  208. #define LOC_GPS_NI_TYPE_UMTS_SUPL 2
  209. #define LOC_GPS_NI_TYPE_UMTS_CTRL_PLANE 3
  210. /*Emergency SUPL*/
  211. #define LOC_GPS_NI_TYPE_EMERGENCY_SUPL 4
  212. /**
  213. * LocGpsNiNotifyFlags constants
  214. */
  215. typedef uint32_t LocGpsNiNotifyFlags;
  216. /** NI requires notification */
  217. #define LOC_GPS_NI_NEED_NOTIFY 0x0001
  218. /** NI requires verification */
  219. #define LOC_GPS_NI_NEED_VERIFY 0x0002
  220. /** NI requires privacy override, no notification/minimal trace */
  221. #define LOC_GPS_NI_PRIVACY_OVERRIDE 0x0004
  222. /**
  223. * GPS NI responses, used to define the response in
  224. * NI structures
  225. */
  226. typedef int LocGpsUserResponseType;
  227. #define LOC_GPS_NI_RESPONSE_ACCEPT 1
  228. #define LOC_GPS_NI_RESPONSE_DENY 2
  229. #define LOC_GPS_NI_RESPONSE_NORESP 3
  230. /**
  231. * NI data encoding scheme
  232. */
  233. typedef int LocGpsNiEncodingType;
  234. #define LOC_GPS_ENC_NONE 0
  235. #define LOC_GPS_ENC_SUPL_GSM_DEFAULT 1
  236. #define LOC_GPS_ENC_SUPL_UTF8 2
  237. #define LOC_GPS_ENC_SUPL_UCS2 3
  238. #define LOC_GPS_ENC_UNKNOWN -1
  239. /** AGPS status event values. */
  240. typedef uint8_t LocAGpsStatusValue;
  241. /** GPS requests data connection for AGPS. */
  242. #define LOC_GPS_REQUEST_AGPS_DATA_CONN 1
  243. /** GPS releases the AGPS data connection. */
  244. #define LOC_GPS_RELEASE_AGPS_DATA_CONN 2
  245. /** AGPS data connection initiated */
  246. #define LOC_GPS_AGPS_DATA_CONNECTED 3
  247. /** AGPS data connection completed */
  248. #define LOC_GPS_AGPS_DATA_CONN_DONE 4
  249. /** AGPS data connection failed */
  250. #define LOC_GPS_AGPS_DATA_CONN_FAILED 5
  251. typedef uint16_t LocAGpsRefLocationType;
  252. #define LOC_AGPS_REF_LOCATION_TYPE_GSM_CELLID 1
  253. #define LOC_AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2
  254. #define LOC_AGPS_REF_LOCATION_TYPE_MAC 3
  255. #define LOC_AGPS_REF_LOCATION_TYPE_LTE_CELLID 4
  256. /* Deprecated, to be removed in the next Android release. */
  257. #define LOC_AGPS_REG_LOCATION_TYPE_MAC 3
  258. /** Network types for update_network_state "type" parameter */
  259. #define LOC_AGPS_RIL_NETWORK_TYPE_MOBILE 0
  260. #define LOC_AGPS_RIL_NETWORK_TYPE_WIFI 1
  261. #define LOC_AGPS_RIL_NETWORK_TYPE_MOBILE_MMS 2
  262. #define LOC_AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL 3
  263. #define LOC_AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN 4
  264. #define LOC_AGPS_RIL_NETWORK_TTYPE_MOBILE_HIPRI 5
  265. #define LOC_AGPS_RIL_NETWORK_TTYPE_WIMAX 6
  266. /* The following typedef together with its constants below are deprecated, and
  267. * will be removed in the next release. */
  268. typedef uint16_t LocGpsClockFlags;
  269. #define LOC_GPS_CLOCK_HAS_LEAP_SECOND (1<<0)
  270. #define LOC_GPS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1)
  271. #define LOC_GPS_CLOCK_HAS_FULL_BIAS (1<<2)
  272. #define LOC_GPS_CLOCK_HAS_BIAS (1<<3)
  273. #define LOC_GPS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4)
  274. #define LOC_GPS_CLOCK_HAS_DRIFT (1<<5)
  275. #define LOC_GPS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6)
  276. /**
  277. * Flags to indicate what fields in LocGnssClock are valid.
  278. */
  279. typedef uint16_t LocGnssClockFlags;
  280. /** A valid 'leap second' is stored in the data structure. */
  281. #define LOC_GNSS_CLOCK_HAS_LEAP_SECOND (1<<0)
  282. /** A valid 'time uncertainty' is stored in the data structure. */
  283. #define LOC_GNSS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1)
  284. /** A valid 'full bias' is stored in the data structure. */
  285. #define LOC_GNSS_CLOCK_HAS_FULL_BIAS (1<<2)
  286. /** A valid 'bias' is stored in the data structure. */
  287. #define LOC_GNSS_CLOCK_HAS_BIAS (1<<3)
  288. /** A valid 'bias uncertainty' is stored in the data structure. */
  289. #define LOC_GNSS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4)
  290. /** A valid 'drift' is stored in the data structure. */
  291. #define LOC_GNSS_CLOCK_HAS_DRIFT (1<<5)
  292. /** A valid 'drift uncertainty' is stored in the data structure. */
  293. #define LOC_GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6)
  294. /* The following typedef together with its constants below are deprecated, and
  295. * will be removed in the next release. */
  296. typedef uint8_t LocGpsClockType;
  297. #define LOC_GPS_CLOCK_TYPE_UNKNOWN 0
  298. #define LOC_GPS_CLOCK_TYPE_LOCAL_HW_TIME 1
  299. #define LOC_GPS_CLOCK_TYPE_GPS_TIME 2
  300. /* The following typedef together with its constants below are deprecated, and
  301. * will be removed in the next release. */
  302. typedef uint32_t LocGpsMeasurementFlags;
  303. #define LOC_GPS_MEASUREMENT_HAS_SNR (1<<0)
  304. #define LOC_GPS_MEASUREMENT_HAS_ELEVATION (1<<1)
  305. #define LOC_GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY (1<<2)
  306. #define LOC_GPS_MEASUREMENT_HAS_AZIMUTH (1<<3)
  307. #define LOC_GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY (1<<4)
  308. #define LOC_GPS_MEASUREMENT_HAS_PSEUDORANGE (1<<5)
  309. #define LOC_GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY (1<<6)
  310. #define LOC_GPS_MEASUREMENT_HAS_CODE_PHASE (1<<7)
  311. #define LOC_GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY (1<<8)
  312. #define LOC_GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9)
  313. #define LOC_GPS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10)
  314. #define LOC_GPS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11)
  315. #define LOC_GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12)
  316. #define LOC_GPS_MEASUREMENT_HAS_BIT_NUMBER (1<<13)
  317. #define LOC_GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT (1<<14)
  318. #define LOC_GPS_MEASUREMENT_HAS_DOPPLER_SHIFT (1<<15)
  319. #define LOC_GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY (1<<16)
  320. #define LOC_GPS_MEASUREMENT_HAS_USED_IN_FIX (1<<17)
  321. #define LOC_GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE (1<<18)
  322. /**
  323. * Flags to indicate what fields in LocGnssMeasurement are valid.
  324. */
  325. typedef uint32_t LocGnssMeasurementFlags;
  326. /** A valid 'snr' is stored in the data structure. */
  327. #define LOC_GNSS_MEASUREMENT_HAS_SNR (1<<0)
  328. /** A valid 'carrier frequency' is stored in the data structure. */
  329. #define LOC_GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9)
  330. /** A valid 'carrier cycles' is stored in the data structure. */
  331. #define LOC_GNSS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10)
  332. /** A valid 'carrier phase' is stored in the data structure. */
  333. #define LOC_GNSS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11)
  334. /** A valid 'carrier phase uncertainty' is stored in the data structure. */
  335. #define LOC_GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12)
  336. /* The following typedef together with its constants below are deprecated, and
  337. * will be removed in the next release. */
  338. typedef uint8_t LocGpsLossOfLock;
  339. #define LOC_GPS_LOSS_OF_LOCK_UNKNOWN 0
  340. #define LOC_GPS_LOSS_OF_LOCK_OK 1
  341. #define LOC_GPS_LOSS_OF_LOCK_CYCLE_SLIP 2
  342. /* The following typedef together with its constants below are deprecated, and
  343. * will be removed in the next release. Use LocGnssMultipathIndicator instead.
  344. */
  345. typedef uint8_t LocGpsMultipathIndicator;
  346. #define LOC_GPS_MULTIPATH_INDICATOR_UNKNOWN 0
  347. #define LOC_GPS_MULTIPATH_INDICATOR_DETECTED 1
  348. #define LOC_GPS_MULTIPATH_INDICATOR_NOT_USED 2
  349. /**
  350. * Enumeration of available values for the GNSS Measurement's multipath
  351. * indicator.
  352. */
  353. typedef uint8_t LocGnssMultipathIndicator;
  354. /** The indicator is not available or unknown. */
  355. #define LOC_GNSS_MULTIPATH_INDICATOR_UNKNOWN 0
  356. /** The measurement is indicated to be affected by multipath. */
  357. #define LOC_GNSS_MULTIPATH_INDICATOR_PRESENT 1
  358. /** The measurement is indicated to be not affected by multipath. */
  359. #define LOC_GNSS_MULTIPATH_INDICATOR_NOT_PRESENT 2
  360. /* The following typedef together with its constants below are deprecated, and
  361. * will be removed in the next release. */
  362. typedef uint16_t LocGpsMeasurementState;
  363. #define LOC_GPS_MEASUREMENT_STATE_UNKNOWN 0
  364. #define LOC_GPS_MEASUREMENT_STATE_CODE_LOCK (1<<0)
  365. #define LOC_GPS_MEASUREMENT_STATE_BIT_SYNC (1<<1)
  366. #define LOC_GPS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2)
  367. #define LOC_GPS_MEASUREMENT_STATE_TOW_DECODED (1<<3)
  368. #define LOC_GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4)
  369. /**
  370. * Flags indicating the GNSS measurement state.
  371. *
  372. * The expected behavior here is for GPS HAL to set all the flags that applies.
  373. * For example, if the state for a satellite is only C/A code locked and bit
  374. * synchronized, and there is still millisecond ambiguity, the state should be
  375. * set as:
  376. *
  377. * LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK | LOC_GNSS_MEASUREMENT_STATE_BIT_SYNC |
  378. * LOC_GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS
  379. *
  380. * If GNSS is still searching for a satellite, the corresponding state should be
  381. * set to LOC_GNSS_MEASUREMENT_STATE_UNKNOWN(0).
  382. */
  383. typedef uint32_t LocGnssMeasurementState;
  384. #define LOC_GNSS_MEASUREMENT_STATE_UNKNOWN 0
  385. #define LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK (1<<0)
  386. #define LOC_GNSS_MEASUREMENT_STATE_BIT_SYNC (1<<1)
  387. #define LOC_GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2)
  388. #define LOC_GNSS_MEASUREMENT_STATE_TOW_DECODED (1<<3)
  389. #define LOC_GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4)
  390. #define LOC_GNSS_MEASUREMENT_STATE_SYMBOL_SYNC (1<<5)
  391. #define LOC_GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC (1<<6)
  392. #define LOC_GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED (1<<7)
  393. #define LOC_GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC (1<<8)
  394. #define LOC_GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC (1<<9)
  395. #define LOC_GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK (1<<10)
  396. #define LOC_GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK (1<<11)
  397. #define LOC_GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC (1<<12)
  398. #define LOC_GNSS_MEASUREMENT_STATE_SBAS_SYNC (1<<13)
  399. /* The following typedef together with its constants below are deprecated, and
  400. * will be removed in the next release. */
  401. typedef uint16_t LocGpsAccumulatedDeltaRangeState;
  402. #define LOC_GPS_ADR_STATE_UNKNOWN 0
  403. #define LOC_GPS_ADR_STATE_VALID (1<<0)
  404. #define LOC_GPS_ADR_STATE_RESET (1<<1)
  405. #define LOC_GPS_ADR_STATE_CYCLE_SLIP (1<<2)
  406. /**
  407. * Flags indicating the Accumulated Delta Range's states.
  408. */
  409. typedef uint16_t LocGnssAccumulatedDeltaRangeState;
  410. #define LOC_GNSS_ADR_STATE_UNKNOWN 0
  411. #define LOC_GNSS_ADR_STATE_VALID (1<<0)
  412. #define LOC_GNSS_ADR_STATE_RESET (1<<1)
  413. #define LOC_GNSS_ADR_STATE_CYCLE_SLIP (1<<2)
  414. #if 0
  415. /* The following typedef together with its constants below are deprecated, and
  416. * will be removed in the next release. */
  417. typedef uint8_t GpsNavigationMessageType;
  418. #define GPS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0
  419. #define GPS_NAVIGATION_MESSAGE_TYPE_L1CA 1
  420. #define GPS_NAVIGATION_MESSAGE_TYPE_L2CNAV 2
  421. #define GPS_NAVIGATION_MESSAGE_TYPE_L5CNAV 3
  422. #define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2 4
  423. /**
  424. * Enumeration of available values to indicate the GNSS Navigation message
  425. * types.
  426. *
  427. * For convenience, first byte is the LocGnssConstellationType on which that signal
  428. * is typically transmitted
  429. */
  430. typedef int16_t GnssNavigationMessageType;
  431. #define GNSS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0
  432. /** GPS L1 C/A message contained in the structure. */
  433. #define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L1CA 0x0101
  434. /** GPS L2-CNAV message contained in the structure. */
  435. #define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L2CNAV 0x0102
  436. /** GPS L5-CNAV message contained in the structure. */
  437. #define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L5CNAV 0x0103
  438. /** GPS CNAV-2 message contained in the structure. */
  439. #define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_CNAV2 0x0104
  440. /** Glonass L1 CA message contained in the structure. */
  441. #define GNSS_NAVIGATION_MESSAGE_TYPE_GLO_L1CA 0x0301
  442. /** Beidou D1 message contained in the structure. */
  443. #define GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D1 0x0501
  444. /** Beidou D2 message contained in the structure. */
  445. #define GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D2 0x0502
  446. /** Galileo I/NAV message contained in the structure. */
  447. #define GNSS_NAVIGATION_MESSAGE_TYPE_GAL_I 0x0601
  448. /** Galileo F/NAV message contained in the structure. */
  449. #define GNSS_NAVIGATION_MESSAGE_TYPE_GAL_F 0x0602
  450. /**
  451. * Status of Navigation Message
  452. * When a message is received properly without any parity error in its navigation words, the
  453. * status should be set to NAV_MESSAGE_STATUS_PARITY_PASSED. But if a message is received
  454. * with words that failed parity check, but GPS is able to correct those words, the status
  455. * should be set to NAV_MESSAGE_STATUS_PARITY_REBUILT.
  456. * No need to send any navigation message that contains words with parity error and cannot be
  457. * corrected.
  458. */
  459. typedef uint16_t NavigationMessageStatus;
  460. #define NAV_MESSAGE_STATUS_UNKNOWN 0
  461. #define NAV_MESSAGE_STATUS_PARITY_PASSED (1<<0)
  462. #define NAV_MESSAGE_STATUS_PARITY_REBUILT (1<<1)
  463. /* This constant is deprecated, and will be removed in the next release. */
  464. #define NAV_MESSAGE_STATUS_UNKONW 0
  465. #endif
  466. /**
  467. * Flags that indicate information about the satellite
  468. */
  469. typedef uint8_t LocGnssSvFlags;
  470. #define LOC_GNSS_SV_FLAGS_NONE 0
  471. #define LOC_GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA (1 << 0)
  472. #define LOC_GNSS_SV_FLAGS_HAS_ALMANAC_DATA (1 << 1)
  473. #define LOC_GNSS_SV_FLAGS_USED_IN_FIX (1 << 2)
  474. /**
  475. * Constellation type of LocGnssSvInfo
  476. */
  477. typedef uint8_t LocGnssConstellationType;
  478. #define LOC_GNSS_CONSTELLATION_UNKNOWN 0
  479. #define LOC_GNSS_CONSTELLATION_GPS 1
  480. #define LOC_GNSS_CONSTELLATION_SBAS 2
  481. #define LOC_GNSS_CONSTELLATION_GLONASS 3
  482. #define LOC_GNSS_CONSTELLATION_QZSS 4
  483. #define LOC_GNSS_CONSTELLATION_BEIDOU 5
  484. #define LOC_GNSS_CONSTELLATION_GALILEO 6
  485. /**
  486. * Name for the GPS XTRA interface.
  487. */
  488. #define LOC_GPS_XTRA_INTERFACE "gps-xtra"
  489. /**
  490. * Name for the GPS DEBUG interface.
  491. */
  492. #define LOC_GPS_DEBUG_INTERFACE "gps-debug"
  493. /**
  494. * Name for the AGPS interface.
  495. */
  496. #define LOC_AGPS_INTERFACE "agps"
  497. /**
  498. * Name of the Supl Certificate interface.
  499. */
  500. #define LOC_SUPL_CERTIFICATE_INTERFACE "supl-certificate"
  501. /**
  502. * Name for NI interface
  503. */
  504. #define LOC_GPS_NI_INTERFACE "gps-ni"
  505. /**
  506. * Name for the AGPS-RIL interface.
  507. */
  508. #define LOC_AGPS_RIL_INTERFACE "agps_ril"
  509. /**
  510. * Name for the GPS_Geofencing interface.
  511. */
  512. #define LOC_GPS_GEOFENCING_INTERFACE "gps_geofencing"
  513. /**
  514. * Name of the GPS Measurements interface.
  515. */
  516. #define LOC_GPS_MEASUREMENT_INTERFACE "gps_measurement"
  517. /**
  518. * Name of the GPS navigation message interface.
  519. */
  520. #define LOC_GPS_NAVIGATION_MESSAGE_INTERFACE "gps_navigation_message"
  521. /**
  522. * Name of the GNSS/GPS configuration interface.
  523. */
  524. #define LOC_GNSS_CONFIGURATION_INTERFACE "gnss_configuration"
  525. /** Represents a location. */
  526. typedef struct {
  527. /** set to sizeof(LocGpsLocation) */
  528. uint32_t size;
  529. /** Contains LocGpsLocationFlags bits. */
  530. uint16_t flags;
  531. /** The spoof mask */
  532. LocGpsSpoofMask spoof_mask;
  533. /** Represents latitude in degrees. */
  534. double latitude;
  535. /** Represents longitude in degrees. */
  536. double longitude;
  537. /**
  538. * Represents altitude in meters above the WGS 84 reference ellipsoid.
  539. */
  540. double altitude;
  541. /** Represents horizontal speed in meters per second. */
  542. float speed;
  543. /** Represents heading in degrees. */
  544. float bearing;
  545. /** Represents expected accuracy in meters. */
  546. float accuracy;
  547. /** Represents the expected vertical uncertainity in meters*/
  548. float vertUncertainity;
  549. /** Timestamp for the location fix. */
  550. LocGpsUtcTime timestamp;
  551. /** Elapsed RealTime in nanosends */
  552. uint64_t elapsedRealTime;
  553. /** Elapsed Real Time Uncertainty in nanosends */
  554. uint64_t elapsedRealTimeUnc;
  555. } LocGpsLocation;
  556. /** Represents the status. */
  557. typedef struct {
  558. /** set to sizeof(LocGpsStatus) */
  559. size_t size;
  560. LocGpsStatusValue status;
  561. } LocGpsStatus;
  562. /**
  563. * Legacy struct to represents SV information.
  564. * Deprecated, to be removed in the next Android release.
  565. * Use LocGnssSvInfo instead.
  566. */
  567. typedef struct {
  568. /** set to sizeof(LocGpsSvInfo) */
  569. size_t size;
  570. /** Pseudo-random number for the SV. */
  571. int prn;
  572. /** Signal to noise ratio. */
  573. float snr;
  574. /** Elevation of SV in degrees. */
  575. float elevation;
  576. /** Azimuth of SV in degrees. */
  577. float azimuth;
  578. } LocGpsSvInfo;
  579. typedef struct {
  580. /** set to sizeof(LocGnssSvInfo) */
  581. size_t size;
  582. /**
  583. * Pseudo-random number for the SV, or FCN/OSN number for Glonass. The
  584. * distinction is made by looking at constellation field. Values should be
  585. * in the range of:
  586. *
  587. * - GPS: 1-32
  588. * - SBAS: 120-151, 183-192
  589. * - GLONASS: 1-24, the orbital slot number (OSN), if known. Or, if not:
  590. * 93-106, the frequency channel number (FCN) (-7 to +6) offset by + 100
  591. * i.e. report an FCN of -7 as 93, FCN of 0 as 100, and FCN of +6 as 106.
  592. * - QZSS: 193-200
  593. * - Galileo: 1-36
  594. * - Beidou: 1-37
  595. */
  596. int16_t svid;
  597. /**
  598. * Defines the constellation of the given SV. Value should be one of those
  599. * LOC_GNSS_CONSTELLATION_* constants
  600. */
  601. LocGnssConstellationType constellation;
  602. /**
  603. * Carrier-to-noise density in dB-Hz, typically in the range [0, 63].
  604. * It contains the measured C/N0 value for the signal at the antenna port.
  605. *
  606. * This is a mandatory value.
  607. */
  608. float c_n0_dbhz;
  609. /** Elevation of SV in degrees. */
  610. float elevation;
  611. /** Azimuth of SV in degrees. */
  612. float azimuth;
  613. /**
  614. * Contains additional data about the given SV. Value should be one of those
  615. * LOC_GNSS_SV_FLAGS_* constants
  616. */
  617. LocGnssSvFlags flags;
  618. } LocGnssSvInfo;
  619. /**
  620. * Legacy struct to represents SV status.
  621. * Deprecated, to be removed in the next Android release.
  622. * Use LocGnssSvStatus instead.
  623. */
  624. typedef struct {
  625. /** set to sizeof(LocGpsSvStatus) */
  626. size_t size;
  627. int num_svs;
  628. LocGpsSvInfo sv_list[LOC_GPS_MAX_SVS];
  629. uint32_t ephemeris_mask;
  630. uint32_t almanac_mask;
  631. uint32_t used_in_fix_mask;
  632. } LocGpsSvStatus;
  633. /**
  634. * Represents SV status.
  635. */
  636. typedef struct {
  637. /** set to sizeof(LocGnssSvStatus) */
  638. size_t size;
  639. /** Number of GPS SVs currently visible, refers to the SVs stored in sv_list */
  640. int num_svs;
  641. /**
  642. * Pointer to an array of SVs information for all GNSS constellations,
  643. * except GPS, which is reported using sv_list
  644. */
  645. LocGnssSvInfo gnss_sv_list[LOC_GNSS_MAX_SVS];
  646. } LocGnssSvStatus;
  647. /* CellID for 2G, 3G and LTE, used in AGPS. */
  648. typedef struct {
  649. LocAGpsRefLocationType type;
  650. /** Mobile Country Code. */
  651. uint16_t mcc;
  652. /** Mobile Network Code .*/
  653. uint16_t mnc;
  654. /** Location Area Code in 2G, 3G and LTE. In 3G lac is discarded. In LTE,
  655. * lac is populated with tac, to ensure that we don't break old clients that
  656. * might rely in the old (wrong) behavior.
  657. */
  658. uint16_t lac;
  659. /** Cell id in 2G. Utran Cell id in 3G. Cell Global Id EUTRA in LTE. */
  660. uint32_t cid;
  661. /** Tracking Area Code in LTE. */
  662. uint16_t tac;
  663. /** Physical Cell id in LTE (not used in 2G and 3G) */
  664. uint16_t pcid;
  665. } LocAGpsRefLocationCellID;
  666. typedef struct {
  667. uint8_t mac[6];
  668. } LocAGpsRefLocationMac;
  669. /** Represents ref locations */
  670. typedef struct {
  671. LocAGpsRefLocationType type;
  672. union {
  673. LocAGpsRefLocationCellID cellID;
  674. LocAGpsRefLocationMac mac;
  675. } u;
  676. } LocAGpsRefLocation;
  677. /**
  678. * Callback with location information. Can only be called from a thread created
  679. * by create_thread_cb.
  680. */
  681. typedef void (* loc_gps_location_callback)(LocGpsLocation* location);
  682. /**
  683. * Callback with status information. Can only be called from a thread created by
  684. * create_thread_cb.
  685. */
  686. typedef void (* loc_gps_status_callback)(LocGpsStatus* status);
  687. /**
  688. * Legacy callback with SV status information.
  689. * Can only be called from a thread created by create_thread_cb.
  690. *
  691. * This callback is deprecated, and will be removed in the next release. Use
  692. * loc_gnss_sv_status_callback() instead.
  693. */
  694. typedef void (* loc_gps_sv_status_callback)(LocGpsSvStatus* sv_info);
  695. /**
  696. * Callback with SV status information.
  697. * Can only be called from a thread created by create_thread_cb.
  698. */
  699. typedef void (* loc_gnss_sv_status_callback)(LocGnssSvStatus* sv_info);
  700. /**
  701. * Callback for reporting NMEA sentences. Can only be called from a thread
  702. * created by create_thread_cb.
  703. */
  704. typedef void (* loc_gps_nmea_callback)(LocGpsUtcTime timestamp, const char* nmea, int length);
  705. /**
  706. * Callback to inform framework of the GPS engine's capabilities. Capability
  707. * parameter is a bit field of LOC_GPS_CAPABILITY_* flags.
  708. */
  709. typedef void (* loc_gps_set_capabilities)(uint32_t capabilities);
  710. /**
  711. * Callback utility for acquiring the GPS wakelock. This can be used to prevent
  712. * the CPU from suspending while handling GPS events.
  713. */
  714. typedef void (* loc_gps_acquire_wakelock)();
  715. /** Callback utility for releasing the GPS wakelock. */
  716. typedef void (* loc_gps_release_wakelock)();
  717. /** Callback for requesting NTP time */
  718. typedef void (* loc_gps_request_utc_time)();
  719. /**
  720. * Callback for creating a thread that can call into the Java framework code.
  721. * This must be used to create any threads that report events up to the
  722. * framework.
  723. */
  724. typedef pthread_t (* loc_gps_create_thread)(const char* name, void (*start)(void *), void* arg);
  725. /**
  726. * Provides information about how new the underlying GPS/GNSS hardware and
  727. * software is.
  728. *
  729. * This information will be available for Android Test Applications. If a GPS
  730. * HAL does not provide this information, it will be considered "2015 or
  731. * earlier".
  732. *
  733. * If a GPS HAL does provide this information, then newer years will need to
  734. * meet newer CTS standards. E.g. if the date are 2016 or above, then N+ level
  735. * LocGpsMeasurement support will be verified.
  736. */
  737. typedef struct {
  738. /** Set to sizeof(LocGnssSystemInfo) */
  739. size_t size;
  740. /* year in which the last update was made to the underlying hardware/firmware
  741. * used to capture GNSS signals, e.g. 2016 */
  742. uint16_t year_of_hw;
  743. } LocGnssSystemInfo;
  744. /**
  745. * Callback to inform framework of the engine's hardware version information.
  746. */
  747. typedef void (*loc_gnss_set_system_info)(const LocGnssSystemInfo* info);
  748. /** New GPS callback structure. */
  749. typedef struct {
  750. /** set to sizeof(LocGpsCallbacks) */
  751. size_t size;
  752. loc_gps_location_callback location_cb;
  753. loc_gps_status_callback status_cb;
  754. loc_gps_sv_status_callback sv_status_cb;
  755. loc_gps_nmea_callback nmea_cb;
  756. loc_gps_set_capabilities set_capabilities_cb;
  757. loc_gps_acquire_wakelock acquire_wakelock_cb;
  758. loc_gps_release_wakelock release_wakelock_cb;
  759. loc_gps_create_thread create_thread_cb;
  760. loc_gps_request_utc_time request_utc_time_cb;
  761. loc_gnss_set_system_info set_system_info_cb;
  762. loc_gnss_sv_status_callback gnss_sv_status_cb;
  763. } LocGpsCallbacks;
  764. /** Represents the standard GPS interface. */
  765. typedef struct {
  766. /** set to sizeof(LocGpsInterface) */
  767. size_t size;
  768. /**
  769. * Opens the interface and provides the callback routines
  770. * to the implementation of this interface.
  771. */
  772. int (*init)( LocGpsCallbacks* callbacks );
  773. /** Starts navigating. */
  774. int (*start)( void );
  775. /** Stops navigating. */
  776. int (*stop)( void );
  777. /** Closes the interface. */
  778. void (*cleanup)( void );
  779. /** Injects the current time. */
  780. int (*inject_time)(LocGpsUtcTime time, int64_t timeReference,
  781. int uncertainty);
  782. /**
  783. * Injects current location from another location provider (typically cell
  784. * ID). Latitude and longitude are measured in degrees expected accuracy is
  785. * measured in meters
  786. */
  787. int (*inject_location)(double latitude, double longitude, float accuracy);
  788. /**
  789. * Specifies that the next call to start will not use the
  790. * information defined in the flags. LOC_GPS_DELETE_ALL is passed for
  791. * a cold start.
  792. */
  793. void (*delete_aiding_data)(LocGpsAidingData flags);
  794. /**
  795. * min_interval represents the time between fixes in milliseconds.
  796. * preferred_accuracy represents the requested fix accuracy in meters.
  797. * preferred_time represents the requested time to first fix in milliseconds.
  798. *
  799. * 'mode' parameter should be one of LOC_GPS_POSITION_MODE_MS_BASED
  800. * or LOC_GPS_POSITION_MODE_STANDALONE.
  801. * It is allowed by the platform (and it is recommended) to fallback to
  802. * LOC_GPS_POSITION_MODE_MS_BASED if LOC_GPS_POSITION_MODE_MS_ASSISTED is passed in, and
  803. * LOC_GPS_POSITION_MODE_MS_BASED is supported.
  804. */
  805. int (*set_position_mode)(LocGpsPositionMode mode, LocGpsPositionRecurrence recurrence,
  806. uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time);
  807. /** Get a pointer to extension information. */
  808. const void* (*get_extension)(const char* name);
  809. } LocGpsInterface;
  810. /**
  811. * Callback to request the client to download XTRA data. The client should
  812. * download XTRA data and inject it by calling inject_xtra_data(). Can only be
  813. * called from a thread created by create_thread_cb.
  814. */
  815. typedef void (* loc_gps_xtra_download_request)();
  816. /** Callback structure for the XTRA interface. */
  817. typedef struct {
  818. loc_gps_xtra_download_request download_request_cb;
  819. loc_gps_create_thread create_thread_cb;
  820. } LocGpsXtraCallbacks;
  821. /** Extended interface for XTRA support. */
  822. typedef struct {
  823. /** set to sizeof(LocGpsXtraInterface) */
  824. size_t size;
  825. /**
  826. * Opens the XTRA interface and provides the callback routines
  827. * to the implementation of this interface.
  828. */
  829. int (*init)( LocGpsXtraCallbacks* callbacks );
  830. /** Injects XTRA data into the GPS. */
  831. int (*inject_xtra_data)( char* data, int length );
  832. } LocGpsXtraInterface;
  833. #if 0
  834. /** Extended interface for DEBUG support. */
  835. typedef struct {
  836. /** set to sizeof(LocGpsDebugInterface) */
  837. size_t size;
  838. /**
  839. * This function should return any information that the native
  840. * implementation wishes to include in a bugreport.
  841. */
  842. size_t (*get_internal_state)(char* buffer, size_t bufferSize);
  843. } LocGpsDebugInterface;
  844. #endif
  845. /*
  846. * Represents the status of AGPS augmented to support IPv4 and IPv6.
  847. */
  848. typedef struct {
  849. /** set to sizeof(LocAGpsStatus) */
  850. size_t size;
  851. LocAGpsType type;
  852. LocAGpsStatusValue status;
  853. /**
  854. * Must be set to a valid IPv4 address if the field 'addr' contains an IPv4
  855. * address, or set to INADDR_NONE otherwise.
  856. */
  857. uint32_t ipaddr;
  858. /**
  859. * Must contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report.
  860. * Any other value of addr.ss_family will be rejected.
  861. */
  862. struct sockaddr_storage addr;
  863. } LocAGpsStatus;
  864. /**
  865. * Callback with AGPS status information. Can only be called from a thread
  866. * created by create_thread_cb.
  867. */
  868. typedef void (* loc_agps_status_callback)(LocAGpsStatus* status);
  869. /** Callback structure for the AGPS interface. */
  870. typedef struct {
  871. loc_agps_status_callback status_cb;
  872. loc_gps_create_thread create_thread_cb;
  873. } LocAGpsCallbacks;
  874. /**
  875. * Extended interface for AGPS support, it is augmented to enable to pass
  876. * extra APN data.
  877. */
  878. typedef struct {
  879. /** set to sizeof(LocAGpsInterface) */
  880. size_t size;
  881. /**
  882. * Opens the AGPS interface and provides the callback routines to the
  883. * implementation of this interface.
  884. */
  885. void (*init)(LocAGpsCallbacks* callbacks);
  886. /**
  887. * Deprecated.
  888. * If the HAL supports LocAGpsInterface_v2 this API will not be used, see
  889. * data_conn_open_with_apn_ip_type for more information.
  890. */
  891. int (*data_conn_open)(const char* apn);
  892. /**
  893. * Notifies that the AGPS data connection has been closed.
  894. */
  895. int (*data_conn_closed)();
  896. /**
  897. * Notifies that a data connection is not available for AGPS.
  898. */
  899. int (*data_conn_failed)();
  900. /**
  901. * Sets the hostname and port for the AGPS server.
  902. */
  903. int (*set_server)(LocAGpsType type, const char* hostname, int port);
  904. /**
  905. * Notifies that a data connection is available and sets the name of the
  906. * APN, and its IP type, to be used for SUPL connections.
  907. */
  908. int (*data_conn_open_with_apn_ip_type)(
  909. const char* apn,
  910. LocApnIpType apnIpType);
  911. } LocAGpsInterface;
  912. /** Error codes associated with certificate operations */
  913. #define LOC_AGPS_CERTIFICATE_OPERATION_SUCCESS 0
  914. #define LOC_AGPS_CERTIFICATE_ERROR_GENERIC -100
  915. #define LOC_AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES -101
  916. /** A data structure that represents an X.509 certificate using DER encoding */
  917. typedef struct {
  918. size_t length;
  919. u_char* data;
  920. } LocDerEncodedCertificate;
  921. /**
  922. * A type definition for SHA1 Fingerprints used to identify X.509 Certificates
  923. * The Fingerprint is a digest of the DER Certificate that uniquely identifies it.
  924. */
  925. typedef struct {
  926. u_char data[20];
  927. } LocSha1CertificateFingerprint;
  928. /** AGPS Interface to handle SUPL certificate operations */
  929. typedef struct {
  930. /** set to sizeof(LocSuplCertificateInterface) */
  931. size_t size;
  932. /**
  933. * Installs a set of Certificates used for SUPL connections to the AGPS server.
  934. * If needed the HAL should find out internally any certificates that need to be removed to
  935. * accommodate the certificates to install.
  936. * The certificates installed represent a full set of valid certificates needed to connect to
  937. * AGPS SUPL servers.
  938. * The list of certificates is required, and all must be available at the same time, when trying
  939. * to establish a connection with the AGPS Server.
  940. *
  941. * Parameters:
  942. * certificates - A pointer to an array of DER encoded certificates that are need to be
  943. * installed in the HAL.
  944. * length - The number of certificates to install.
  945. * Returns:
  946. * LOC_AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully
  947. * LOC_AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES if the HAL cannot store the number of
  948. * certificates attempted to be installed, the state of the certificates stored should
  949. * remain the same as before on this error case.
  950. *
  951. * IMPORTANT:
  952. * If needed the HAL should find out internally the set of certificates that need to be
  953. * removed to accommodate the certificates to install.
  954. */
  955. int (*install_certificates) ( const LocDerEncodedCertificate* certificates, size_t length );
  956. /**
  957. * Notifies the HAL that a list of certificates used for SUPL connections are revoked. It is
  958. * expected that the given set of certificates is removed from the internal store of the HAL.
  959. *
  960. * Parameters:
  961. * fingerprints - A pointer to an array of SHA1 Fingerprints to identify the set of
  962. * certificates to revoke.
  963. * length - The number of fingerprints provided.
  964. * Returns:
  965. * LOC_AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully.
  966. *
  967. * IMPORTANT:
  968. * If any of the certificates provided (through its fingerprint) is not known by the HAL,
  969. * it should be ignored and continue revoking/deleting the rest of them.
  970. */
  971. int (*revoke_certificates) ( const LocSha1CertificateFingerprint* fingerprints, size_t length );
  972. } LocSuplCertificateInterface;
  973. /** Represents an NI request */
  974. typedef struct {
  975. /** set to sizeof(LocGpsNiNotification) */
  976. size_t size;
  977. /**
  978. * An ID generated by HAL to associate NI notifications and UI
  979. * responses
  980. */
  981. int notification_id;
  982. /**
  983. * An NI type used to distinguish different categories of NI
  984. * events, such as LOC_GPS_NI_TYPE_VOICE, LOC_GPS_NI_TYPE_UMTS_SUPL, ...
  985. */
  986. LocGpsNiType ni_type;
  987. /**
  988. * Notification/verification options, combinations of LocGpsNiNotifyFlags constants
  989. */
  990. LocGpsNiNotifyFlags notify_flags;
  991. /**
  992. * Timeout period to wait for user response.
  993. * Set to 0 for no time out limit.
  994. */
  995. int timeout;
  996. /**
  997. * Default response when time out.
  998. */
  999. LocGpsUserResponseType default_response;
  1000. /**
  1001. * Requestor ID
  1002. */
  1003. char requestor_id[LOC_GPS_NI_SHORT_STRING_MAXLEN];
  1004. /**
  1005. * Notification message. It can also be used to store client_id in some cases
  1006. */
  1007. char text[LOC_GPS_NI_LONG_STRING_MAXLEN];
  1008. /**
  1009. * Client name decoding scheme
  1010. */
  1011. LocGpsNiEncodingType requestor_id_encoding;
  1012. /**
  1013. * Client name decoding scheme
  1014. */
  1015. LocGpsNiEncodingType text_encoding;
  1016. /**
  1017. * A pointer to extra data. Format:
  1018. * key_1 = value_1
  1019. * key_2 = value_2
  1020. */
  1021. char extras[LOC_GPS_NI_LONG_STRING_MAXLEN];
  1022. } LocGpsNiNotification;
  1023. /**
  1024. * Callback with NI notification. Can only be called from a thread created by
  1025. * create_thread_cb.
  1026. */
  1027. typedef void (*loc_gps_ni_notify_callback)(LocGpsNiNotification *notification);
  1028. /** GPS NI callback structure. */
  1029. typedef struct
  1030. {
  1031. /**
  1032. * Sends the notification request from HAL to GPSLocationProvider.
  1033. */
  1034. loc_gps_ni_notify_callback notify_cb;
  1035. loc_gps_create_thread create_thread_cb;
  1036. } LocGpsNiCallbacks;
  1037. /**
  1038. * Extended interface for Network-initiated (NI) support.
  1039. */
  1040. typedef struct
  1041. {
  1042. /** set to sizeof(LocGpsNiInterface) */
  1043. size_t size;
  1044. /** Registers the callbacks for HAL to use. */
  1045. void (*init) (LocGpsNiCallbacks *callbacks);
  1046. /** Sends a response to HAL. */
  1047. void (*respond) (int notif_id, LocGpsUserResponseType user_response);
  1048. } LocGpsNiInterface;
  1049. #define LOC_AGPS_RIL_REQUEST_SETID_IMSI (1<<0L)
  1050. #define LOC_AGPS_RIL_REQUEST_SETID_MSISDN (1<<1L)
  1051. #define LOC_AGPS_RIL_REQUEST_REFLOC_CELLID (1<<0L)
  1052. #define LOC_AGPS_RIL_REQUEST_REFLOC_MAC (1<<1L)
  1053. typedef void (*loc_agps_ril_request_set_id)(uint32_t flags);
  1054. typedef void (*loc_agps_ril_request_ref_loc)(uint32_t flags);
  1055. typedef struct {
  1056. loc_agps_ril_request_set_id request_setid;
  1057. loc_agps_ril_request_ref_loc request_refloc;
  1058. loc_gps_create_thread create_thread_cb;
  1059. } LocAGpsRilCallbacks;
  1060. /** Extended interface for AGPS_RIL support. */
  1061. typedef struct {
  1062. /** set to sizeof(LocAGpsRilInterface) */
  1063. size_t size;
  1064. /**
  1065. * Opens the AGPS interface and provides the callback routines
  1066. * to the implementation of this interface.
  1067. */
  1068. void (*init)( LocAGpsRilCallbacks* callbacks );
  1069. /**
  1070. * Sets the reference location.
  1071. */
  1072. void (*set_ref_location) (const LocAGpsRefLocation *agps_reflocation, size_t sz_struct);
  1073. /**
  1074. * Sets the set ID.
  1075. */
  1076. void (*set_set_id) (LocAGpsSetIDType type, const char* setid);
  1077. /**
  1078. * Send network initiated message.
  1079. */
  1080. void (*ni_message) (uint8_t *msg, size_t len);
  1081. /**
  1082. * Notify GPS of network status changes.
  1083. * These parameters match values in the android.net.NetworkInfo class.
  1084. */
  1085. void (*update_network_state) (int connected, int type, int roaming, const char* extra_info);
  1086. /**
  1087. * Notify GPS of network status changes.
  1088. * These parameters match values in the android.net.NetworkInfo class.
  1089. */
  1090. void (*update_network_availability) (int avaiable, const char* apn);
  1091. } LocAGpsRilInterface;
  1092. /**
  1093. * GPS Geofence.
  1094. * There are 3 states associated with a Geofence: Inside, Outside, Unknown.
  1095. * There are 3 transitions: ENTERED, EXITED, UNCERTAIN.
  1096. *
  1097. * An example state diagram with confidence level: 95% and Unknown time limit
  1098. * set as 30 secs is shown below. (confidence level and Unknown time limit are
  1099. * explained latter)
  1100. * ____________________________
  1101. * | Unknown (30 secs) |
  1102. * """"""""""""""""""""""""""""
  1103. * ^ | | ^
  1104. * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN
  1105. * | v v |
  1106. * ________ EXITED _________
  1107. * | Inside | -----------> | Outside |
  1108. * | | <----------- | |
  1109. * """""""" ENTERED """""""""
  1110. *
  1111. * Inside state: We are 95% confident that the user is inside the geofence.
  1112. * Outside state: We are 95% confident that the user is outside the geofence
  1113. * Unknown state: Rest of the time.
  1114. *
  1115. * The Unknown state is better explained with an example:
  1116. *
  1117. * __________
  1118. * | c|
  1119. * | ___ | _______
  1120. * | |a| | | b |
  1121. * | """ | """""""
  1122. * | |
  1123. * """"""""""
  1124. * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy
  1125. * circle reported by the GPS subsystem. Now with regard to "b", the system is
  1126. * confident that the user is outside. But with regard to "a" is not confident
  1127. * whether it is inside or outside the geofence. If the accuracy remains the
  1128. * same for a sufficient period of time, the UNCERTAIN transition would be
  1129. * triggered with the state set to Unknown. If the accuracy improves later, an
  1130. * appropriate transition should be triggered. This "sufficient period of time"
  1131. * is defined by the parameter in the add_geofence_area API.
  1132. * In other words, Unknown state can be interpreted as a state in which the
  1133. * GPS subsystem isn't confident enough that the user is either inside or
  1134. * outside the Geofence. It moves to Unknown state only after the expiry of the
  1135. * timeout.
  1136. *
  1137. * The geofence callback needs to be triggered for the ENTERED and EXITED
  1138. * transitions, when the GPS system is confident that the user has entered
  1139. * (Inside state) or exited (Outside state) the Geofence. An implementation
  1140. * which uses a value of 95% as the confidence is recommended. The callback
  1141. * should be triggered only for the transitions requested by the
  1142. * add_geofence_area call.
  1143. *
  1144. * Even though the diagram and explanation talks about states and transitions,
  1145. * the callee is only interested in the transistions. The states are mentioned
  1146. * here for illustrative purposes.
  1147. *
  1148. * Startup Scenario: When the device boots up, if an application adds geofences,
  1149. * and then we get an accurate GPS location fix, it needs to trigger the
  1150. * appropriate (ENTERED or EXITED) transition for every Geofence it knows about.
  1151. * By default, all the Geofences will be in the Unknown state.
  1152. *
  1153. * When the GPS system is unavailable, loc_gps_geofence_status_callback should be
  1154. * called to inform the upper layers of the same. Similarly, when it becomes
  1155. * available the callback should be called. This is a global state while the
  1156. * UNKNOWN transition described above is per geofence.
  1157. *
  1158. * An important aspect to note is that users of this API (framework), will use
  1159. * other subsystems like wifi, sensors, cell to handle Unknown case and
  1160. * hopefully provide a definitive state transition to the third party
  1161. * application. GPS Geofence will just be a signal indicating what the GPS
  1162. * subsystem knows about the Geofence.
  1163. *
  1164. */
  1165. #define LOC_GPS_GEOFENCE_ENTERED (1<<0L)
  1166. #define LOC_GPS_GEOFENCE_EXITED (1<<1L)
  1167. #define LOC_GPS_GEOFENCE_UNCERTAIN (1<<2L)
  1168. #define LOC_GPS_GEOFENCE_DWELL_INSIDE (1<<0L)
  1169. #define LOC_GPS_GEOFENCE_DWELL_OUTSIDE (1<<1L)
  1170. #define LOC_GPS_GEOFENCE_CONFIDENCE_LOW 1
  1171. #define LOC_GPS_GEOFENCE_CONFIDENCE_MEDIUM 2
  1172. #define LOC_GPS_GEOFENCE_CONFIDENCE_HIGH 3
  1173. #define LOC_GPS_GEOFENCE_UNAVAILABLE (1<<0L)
  1174. #define LOC_GPS_GEOFENCE_AVAILABLE (1<<1L)
  1175. #define LOC_GPS_GEOFENCE_OPERATION_SUCCESS 0
  1176. #define LOC_GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES -100
  1177. #define LOC_GPS_GEOFENCE_ERROR_ID_EXISTS -101
  1178. #define LOC_GPS_GEOFENCE_ERROR_ID_UNKNOWN -102
  1179. #define LOC_GPS_GEOFENCE_ERROR_INVALID_TRANSITION -103
  1180. #define LOC_GPS_GEOFENCE_ERROR_GENERIC -149
  1181. /**
  1182. * The callback associated with the geofence.
  1183. * Parameters:
  1184. * geofence_id - The id associated with the add_geofence_area.
  1185. * location - The current GPS location.
  1186. * transition - Can be one of LOC_GPS_GEOFENCE_ENTERED, LOC_GPS_GEOFENCE_EXITED,
  1187. * LOC_GPS_GEOFENCE_UNCERTAIN.
  1188. * timestamp - Timestamp when the transition was detected.
  1189. *
  1190. * The callback should only be called when the caller is interested in that
  1191. * particular transition. For instance, if the caller is interested only in
  1192. * ENTERED transition, then the callback should NOT be called with the EXITED
  1193. * transition.
  1194. *
  1195. * IMPORTANT: If a transition is triggered resulting in this callback, the GPS
  1196. * subsystem will wake up the application processor, if its in suspend state.
  1197. */
  1198. typedef void (*loc_gps_geofence_transition_callback) (int32_t geofence_id, LocGpsLocation* location,
  1199. int32_t transition, LocGpsUtcTime timestamp);
  1200. /**
  1201. * The callback associated with the availability of the GPS system for geofencing
  1202. * monitoring. If the GPS system determines that it cannot monitor geofences
  1203. * because of lack of reliability or unavailability of the GPS signals, it will
  1204. * call this callback with LOC_GPS_GEOFENCE_UNAVAILABLE parameter.
  1205. *
  1206. * Parameters:
  1207. * status - LOC_GPS_GEOFENCE_UNAVAILABLE or LOC_GPS_GEOFENCE_AVAILABLE.
  1208. * last_location - Last known location.
  1209. */
  1210. typedef void (*loc_gps_geofence_status_callback) (int32_t status, LocGpsLocation* last_location);
  1211. /**
  1212. * The callback associated with the add_geofence call.
  1213. *
  1214. * Parameter:
  1215. * geofence_id - Id of the geofence.
  1216. * status - LOC_GPS_GEOFENCE_OPERATION_SUCCESS
  1217. * LOC_GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached.
  1218. * LOC_GPS_GEOFENCE_ERROR_ID_EXISTS - geofence with id already exists
  1219. * LOC_GPS_GEOFENCE_ERROR_INVALID_TRANSITION - the monitorTransition contains an
  1220. * invalid transition
  1221. * LOC_GPS_GEOFENCE_ERROR_GENERIC - for other errors.
  1222. */
  1223. typedef void (*loc_gps_geofence_add_callback) (int32_t geofence_id, int32_t status);
  1224. /**
  1225. * The callback associated with the remove_geofence call.
  1226. *
  1227. * Parameter:
  1228. * geofence_id - Id of the geofence.
  1229. * status - LOC_GPS_GEOFENCE_OPERATION_SUCCESS
  1230. * LOC_GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
  1231. * LOC_GPS_GEOFENCE_ERROR_GENERIC for others.
  1232. */
  1233. typedef void (*loc_gps_geofence_remove_callback) (int32_t geofence_id, int32_t status);
  1234. /**
  1235. * The callback associated with the pause_geofence call.
  1236. *
  1237. * Parameter:
  1238. * geofence_id - Id of the geofence.
  1239. * status - LOC_GPS_GEOFENCE_OPERATION_SUCCESS
  1240. * LOC_GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
  1241. * LOC_GPS_GEOFENCE_ERROR_INVALID_TRANSITION -
  1242. * when monitor_transitions is invalid
  1243. * LOC_GPS_GEOFENCE_ERROR_GENERIC for others.
  1244. */
  1245. typedef void (*loc_gps_geofence_pause_callback) (int32_t geofence_id, int32_t status);
  1246. /**
  1247. * The callback associated with the resume_geofence call.
  1248. *
  1249. * Parameter:
  1250. * geofence_id - Id of the geofence.
  1251. * status - LOC_GPS_GEOFENCE_OPERATION_SUCCESS
  1252. * LOC_GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
  1253. * LOC_GPS_GEOFENCE_ERROR_GENERIC for others.
  1254. */
  1255. typedef void (*loc_gps_geofence_resume_callback) (int32_t geofence_id, int32_t status);
  1256. typedef struct {
  1257. loc_gps_geofence_transition_callback geofence_transition_callback;
  1258. loc_gps_geofence_status_callback geofence_status_callback;
  1259. loc_gps_geofence_add_callback geofence_add_callback;
  1260. loc_gps_geofence_remove_callback geofence_remove_callback;
  1261. loc_gps_geofence_pause_callback geofence_pause_callback;
  1262. loc_gps_geofence_resume_callback geofence_resume_callback;
  1263. loc_gps_create_thread create_thread_cb;
  1264. } LocGpsGeofenceCallbacks;
  1265. /** Extended interface for GPS_Geofencing support */
  1266. typedef struct {
  1267. /** set to sizeof(LocGpsGeofencingInterface) */
  1268. size_t size;
  1269. /**
  1270. * Opens the geofence interface and provides the callback routines
  1271. * to the implementation of this interface.
  1272. */
  1273. void (*init)( LocGpsGeofenceCallbacks* callbacks );
  1274. /**
  1275. * Add a geofence area. This api currently supports circular geofences.
  1276. * Parameters:
  1277. * geofence_id - The id for the geofence. If a geofence with this id
  1278. * already exists, an error value (LOC_GPS_GEOFENCE_ERROR_ID_EXISTS)
  1279. * should be returned.
  1280. * latitude, longtitude, radius_meters - The lat, long and radius
  1281. * (in meters) for the geofence
  1282. * last_transition - The current state of the geofence. For example, if
  1283. * the system already knows that the user is inside the geofence,
  1284. * this will be set to LOC_GPS_GEOFENCE_ENTERED. In most cases, it
  1285. * will be LOC_GPS_GEOFENCE_UNCERTAIN.
  1286. * monitor_transition - Which transitions to monitor. Bitwise OR of
  1287. * LOC_GPS_GEOFENCE_ENTERED, LOC_GPS_GEOFENCE_EXITED and
  1288. * LOC_GPS_GEOFENCE_UNCERTAIN.
  1289. * notification_responsiveness_ms - Defines the best-effort description
  1290. * of how soon should the callback be called when the transition
  1291. * associated with the Geofence is triggered. For instance, if set
  1292. * to 1000 millseconds with LOC_GPS_GEOFENCE_ENTERED, the callback
  1293. * should be called 1000 milliseconds within entering the geofence.
  1294. * This parameter is defined in milliseconds.
  1295. * NOTE: This is not to be confused with the rate that the GPS is
  1296. * polled at. It is acceptable to dynamically vary the rate of
  1297. * sampling the GPS for power-saving reasons; thus the rate of
  1298. * sampling may be faster or slower than this.
  1299. * unknown_timer_ms - The time limit after which the UNCERTAIN transition
  1300. * should be triggered. This parameter is defined in milliseconds.
  1301. * See above for a detailed explanation.
  1302. */
  1303. void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude,
  1304. double radius_meters, int last_transition, int monitor_transitions,
  1305. int notification_responsiveness_ms, int unknown_timer_ms);
  1306. /**
  1307. * Pause monitoring a particular geofence.
  1308. * Parameters:
  1309. * geofence_id - The id for the geofence.
  1310. */
  1311. void (*pause_geofence) (int32_t geofence_id);
  1312. /**
  1313. * Resume monitoring a particular geofence.
  1314. * Parameters:
  1315. * geofence_id - The id for the geofence.
  1316. * monitor_transitions - Which transitions to monitor. Bitwise OR of
  1317. * LOC_GPS_GEOFENCE_ENTERED, LOC_GPS_GEOFENCE_EXITED and
  1318. * LOC_GPS_GEOFENCE_UNCERTAIN.
  1319. * This supersedes the value associated provided in the
  1320. * add_geofence_area call.
  1321. */
  1322. void (*resume_geofence) (int32_t geofence_id, int monitor_transitions);
  1323. /**
  1324. * Remove a geofence area. After the function returns, no notifications
  1325. * should be sent.
  1326. * Parameter:
  1327. * geofence_id - The id for the geofence.
  1328. */
  1329. void (*remove_geofence_area) (int32_t geofence_id);
  1330. } LocGpsGeofencingInterface;
  1331. /**
  1332. * Legacy struct to represent an estimate of the GPS clock time.
  1333. * Deprecated, to be removed in the next Android release.
  1334. * Use LocGnssClock instead.
  1335. */
  1336. typedef struct {
  1337. /** set to sizeof(LocGpsClock) */
  1338. size_t size;
  1339. LocGpsClockFlags flags;
  1340. int16_t leap_second;
  1341. LocGpsClockType type;
  1342. int64_t time_ns;
  1343. double time_uncertainty_ns;
  1344. int64_t full_bias_ns;
  1345. double bias_ns;
  1346. double bias_uncertainty_ns;
  1347. double drift_nsps;
  1348. double drift_uncertainty_nsps;
  1349. } LocGpsClock;
  1350. /**
  1351. * Represents an estimate of the GPS clock time.
  1352. */
  1353. typedef struct {
  1354. /** set to sizeof(LocGnssClock) */
  1355. size_t size;
  1356. /**
  1357. * A set of flags indicating the validity of the fields in this data
  1358. * structure.
  1359. */
  1360. LocGnssClockFlags flags;
  1361. /**
  1362. * Leap second data.
  1363. * The sign of the value is defined by the following equation:
  1364. * utc_time_ns = time_ns - (full_bias_ns + bias_ns) - leap_second *
  1365. * 1,000,000,000
  1366. *
  1367. * If the data is available 'flags' must contain LOC_GNSS_CLOCK_HAS_LEAP_SECOND.
  1368. */
  1369. int16_t leap_second;
  1370. /**
  1371. * The GNSS receiver internal clock value. This is the local hardware clock
  1372. * value.
  1373. *
  1374. * For local hardware clock, this value is expected to be monotonically
  1375. * increasing while the hardware clock remains power on. (For the case of a
  1376. * HW clock that is not continuously on, see the
  1377. * hw_clock_discontinuity_count field). The receiver's estimate of GPS time
  1378. * can be derived by substracting the sum of full_bias_ns and bias_ns (when
  1379. * available) from this value.
  1380. *
  1381. * This GPS time is expected to be the best estimate of current GPS time
  1382. * that GNSS receiver can achieve.
  1383. *
  1384. * Sub-nanosecond accuracy can be provided by means of the 'bias_ns' field.
  1385. * The value contains the 'time uncertainty' in it.
  1386. *
  1387. * This field is mandatory.
  1388. */
  1389. int64_t time_ns;
  1390. /**
  1391. * 1-Sigma uncertainty associated with the clock's time in nanoseconds.
  1392. * The uncertainty is represented as an absolute (single sided) value.
  1393. *
  1394. * If the data is available, 'flags' must contain
  1395. * LOC_GNSS_CLOCK_HAS_TIME_UNCERTAINTY. This value is effectively zero (it is
  1396. * the reference local clock, by which all other times and time
  1397. * uncertainties are measured.) (And thus this field can be not provided,
  1398. * per LOC_GNSS_CLOCK_HAS_TIME_UNCERTAINTY flag, or provided & set to 0.)
  1399. */
  1400. double time_uncertainty_ns;
  1401. /**
  1402. * The difference between hardware clock ('time' field) inside GPS receiver
  1403. * and the true GPS time since 0000Z, January 6, 1980, in nanoseconds.
  1404. *
  1405. * The sign of the value is defined by the following equation:
  1406. * local estimate of GPS time = time_ns - (full_bias_ns + bias_ns)
  1407. *
  1408. * This value is mandatory if the receiver has estimated GPS time. If the
  1409. * computed time is for a non-GPS constellation, the time offset of that
  1410. * constellation to GPS has to be applied to fill this value. The error
  1411. * estimate for the sum of this and the bias_ns is the bias_uncertainty_ns,
  1412. * and the caller is responsible for using this uncertainty (it can be very
  1413. * large before the GPS time has been solved for.) If the data is available
  1414. * 'flags' must contain LOC_GNSS_CLOCK_HAS_FULL_BIAS.
  1415. */
  1416. int64_t full_bias_ns;
  1417. /**
  1418. * Sub-nanosecond bias.
  1419. * The error estimate for the sum of this and the full_bias_ns is the
  1420. * bias_uncertainty_ns
  1421. *
  1422. * If the data is available 'flags' must contain LOC_GNSS_CLOCK_HAS_BIAS. If GPS
  1423. * has computed a position fix. This value is mandatory if the receiver has
  1424. * estimated GPS time.
  1425. */
  1426. double bias_ns;
  1427. /**
  1428. * 1-Sigma uncertainty associated with the local estimate of GPS time (clock
  1429. * bias) in nanoseconds. The uncertainty is represented as an absolute
  1430. * (single sided) value.
  1431. *
  1432. * If the data is available 'flags' must contain
  1433. * LOC_GNSS_CLOCK_HAS_BIAS_UNCERTAINTY. This value is mandatory if the receiver
  1434. * has estimated GPS time.
  1435. */
  1436. double bias_uncertainty_ns;
  1437. /**
  1438. * The clock's drift in nanoseconds (per second).
  1439. *
  1440. * A positive value means that the frequency is higher than the nominal
  1441. * frequency, and that the (full_bias_ns + bias_ns) is growing more positive
  1442. * over time.
  1443. *
  1444. * The value contains the 'drift uncertainty' in it.
  1445. * If the data is available 'flags' must contain LOC_GNSS_CLOCK_HAS_DRIFT.
  1446. *
  1447. * This value is mandatory if the receiver has estimated GNSS time
  1448. */
  1449. double drift_nsps;
  1450. /**
  1451. * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per second).
  1452. * The uncertainty is represented as an absolute (single sided) value.
  1453. *
  1454. * If the data is available 'flags' must contain
  1455. * LOC_GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY. If GPS has computed a position fix this
  1456. * field is mandatory and must be populated.
  1457. */
  1458. double drift_uncertainty_nsps;
  1459. /**
  1460. * When there are any discontinuities in the HW clock, this field is
  1461. * mandatory.
  1462. *
  1463. * A "discontinuity" is meant to cover the case of a switch from one source
  1464. * of clock to another. A single free-running crystal oscillator (XO)
  1465. * should generally not have any discontinuities, and this can be set and
  1466. * left at 0.
  1467. *
  1468. * If, however, the time_ns value (HW clock) is derived from a composite of
  1469. * sources, that is not as smooth as a typical XO, or is otherwise stopped &
  1470. * restarted, then this value shall be incremented each time a discontinuity
  1471. * occurs. (E.g. this value may start at zero at device boot-up and
  1472. * increment each time there is a change in clock continuity. In the
  1473. * unlikely event that this value reaches full scale, rollover (not
  1474. * clamping) is required, such that this value continues to change, during
  1475. * subsequent discontinuity events.)
  1476. *
  1477. * While this number stays the same, between LocGnssClock reports, it can be
  1478. * safely assumed that the time_ns value has been running continuously, e.g.
  1479. * derived from a single, high quality clock (XO like, or better, that's
  1480. * typically used during continuous GNSS signal sampling.)
  1481. *
  1482. * It is expected, esp. during periods where there are few GNSS signals
  1483. * available, that the HW clock be discontinuity-free as long as possible,
  1484. * as this avoids the need to use (waste) a GNSS measurement to fully
  1485. * re-solve for the GPS clock bias and drift, when using the accompanying
  1486. * measurements, from consecutive LocGnssData reports.
  1487. */
  1488. uint32_t hw_clock_discontinuity_count;
  1489. } LocGnssClock;
  1490. /**
  1491. * Legacy struct to represent a GPS Measurement, it contains raw and computed
  1492. * information.
  1493. * Deprecated, to be removed in the next Android release.
  1494. * Use LocGnssMeasurement instead.
  1495. */
  1496. typedef struct {
  1497. /** set to sizeof(LocGpsMeasurement) */
  1498. size_t size;
  1499. LocGpsMeasurementFlags flags;
  1500. int8_t prn;
  1501. double time_offset_ns;
  1502. LocGpsMeasurementState state;
  1503. int64_t received_gps_tow_ns;
  1504. int64_t received_gps_tow_uncertainty_ns;
  1505. double c_n0_dbhz;
  1506. double pseudorange_rate_mps;
  1507. double pseudorange_rate_uncertainty_mps;
  1508. LocGpsAccumulatedDeltaRangeState accumulated_delta_range_state;
  1509. double accumulated_delta_range_m;
  1510. double accumulated_delta_range_uncertainty_m;
  1511. double pseudorange_m;
  1512. double pseudorange_uncertainty_m;
  1513. double code_phase_chips;
  1514. double code_phase_uncertainty_chips;
  1515. float carrier_frequency_hz;
  1516. int64_t carrier_cycles;
  1517. double carrier_phase;
  1518. double carrier_phase_uncertainty;
  1519. LocGpsLossOfLock loss_of_lock;
  1520. int32_t bit_number;
  1521. int16_t time_from_last_bit_ms;
  1522. double doppler_shift_hz;
  1523. double doppler_shift_uncertainty_hz;
  1524. LocGpsMultipathIndicator multipath_indicator;
  1525. double snr_db;
  1526. double elevation_deg;
  1527. double elevation_uncertainty_deg;
  1528. double azimuth_deg;
  1529. double azimuth_uncertainty_deg;
  1530. bool used_in_fix;
  1531. } LocGpsMeasurement;
  1532. /**
  1533. * Represents a GNSS Measurement, it contains raw and computed information.
  1534. *
  1535. * Independence - All signal measurement information (e.g. sv_time,
  1536. * pseudorange_rate, multipath_indicator) reported in this struct should be
  1537. * based on GNSS signal measurements only. You may not synthesize measurements
  1538. * by calculating or reporting expected measurements based on known or estimated
  1539. * position, velocity, or time.
  1540. */
  1541. typedef struct {
  1542. /** set to sizeof(LocGnssMeasurement) */
  1543. size_t size;
  1544. /** A set of flags indicating the validity of the fields in this data structure. */
  1545. LocGnssMeasurementFlags flags;
  1546. /**
  1547. * Satellite vehicle ID number, as defined in LocGnssSvInfo::svid
  1548. * This is a mandatory value.
  1549. */
  1550. int16_t svid;
  1551. /**
  1552. * Defines the constellation of the given SV. Value should be one of those
  1553. * LOC_GNSS_CONSTELLATION_* constants
  1554. */
  1555. LocGnssConstellationType constellation;
  1556. /**
  1557. * Time offset at which the measurement was taken in nanoseconds.
  1558. * The reference receiver's time is specified by LocGpsData::clock::time_ns and should be
  1559. * interpreted in the same way as indicated by LocGpsClock::type.
  1560. *
  1561. * The sign of time_offset_ns is given by the following equation:
  1562. * measurement time = LocGpsClock::time_ns + time_offset_ns
  1563. *
  1564. * It provides an individual time-stamp for the measurement, and allows sub-nanosecond accuracy.
  1565. * This is a mandatory value.
  1566. */
  1567. double time_offset_ns;
  1568. /**
  1569. * Per satellite sync state. It represents the current sync state for the associated satellite.
  1570. * Based on the sync state, the 'received GPS tow' field should be interpreted accordingly.
  1571. *
  1572. * This is a mandatory value.
  1573. */
  1574. LocGnssMeasurementState state;
  1575. /**
  1576. * The received GNSS Time-of-Week at the measurement time, in nanoseconds.
  1577. * Ensure that this field is independent (see comment at top of
  1578. * LocGnssMeasurement struct.)
  1579. *
  1580. * For GPS & QZSS, this is:
  1581. * Received GPS Time-of-Week at the measurement time, in nanoseconds.
  1582. * The value is relative to the beginning of the current GPS week.
  1583. *
  1584. * Given the highest sync state that can be achieved, per each satellite, valid range
  1585. * for this field can be:
  1586. * Searching : [ 0 ] : LOC_GNSS_MEASUREMENT_STATE_UNKNOWN
  1587. * C/A code lock : [ 0 1ms ] : LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK is set
  1588. * Bit sync : [ 0 20ms ] : LOC_GNSS_MEASUREMENT_STATE_BIT_SYNC is set
  1589. * Subframe sync : [ 0 6s ] : LOC_GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set
  1590. * TOW decoded : [ 0 1week ] : LOC_GNSS_MEASUREMENT_STATE_TOW_DECODED is set
  1591. *
  1592. * Note well: if there is any ambiguity in integer millisecond,
  1593. * LOC_GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS should be set accordingly, in the 'state' field.
  1594. *
  1595. * This value must be populated if 'state' != LOC_GNSS_MEASUREMENT_STATE_UNKNOWN.
  1596. *
  1597. * For Glonass, this is:
  1598. * Received Glonass time of day, at the measurement time in nanoseconds.
  1599. *
  1600. * Given the highest sync state that can be achieved, per each satellite, valid range for
  1601. * this field can be:
  1602. * Searching : [ 0 ] : LOC_GNSS_MEASUREMENT_STATE_UNKNOWN
  1603. * C/A code lock : [ 0 1ms ] : LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK is set
  1604. * Symbol sync : [ 0 10ms ] : LOC_GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set
  1605. * Bit sync : [ 0 20ms ] : LOC_GNSS_MEASUREMENT_STATE_BIT_SYNC is set
  1606. * String sync : [ 0 2s ] : LOC_GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC is set
  1607. * Time of day : [ 0 1day ] : LOC_GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED is set
  1608. *
  1609. * For Beidou, this is:
  1610. * Received Beidou time of week, at the measurement time in nanoseconds.
  1611. *
  1612. * Given the highest sync state that can be achieved, per each satellite, valid range for
  1613. * this field can be:
  1614. * Searching : [ 0 ] : LOC_GNSS_MEASUREMENT_STATE_UNKNOWN
  1615. * C/A code lock: [ 0 1ms ] : LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK is set
  1616. * Bit sync (D2): [ 0 2ms ] : LOC_GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC is set
  1617. * Bit sync (D1): [ 0 20ms ] : LOC_GNSS_MEASUREMENT_STATE_BIT_SYNC is set
  1618. * Subframe (D2): [ 0 0.6s ] : LOC_GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC is set
  1619. * Subframe (D1): [ 0 6s ] : LOC_GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set
  1620. * Time of week : [ 0 1week ] : LOC_GNSS_MEASUREMENT_STATE_TOW_DECODED is set
  1621. *
  1622. * For Galileo, this is:
  1623. * Received Galileo time of week, at the measurement time in nanoseconds.
  1624. *
  1625. * E1BC code lock : [ 0 4ms ] : LOC_GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK is set
  1626. * E1C 2nd code lock: [ 0 100ms ] :
  1627. * LOC_GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK is set
  1628. *
  1629. * E1B page : [ 0 2s ] : LOC_GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC is set
  1630. * Time of week: [ 0 1week ] : LOC_GNSS_MEASUREMENT_STATE_TOW_DECODED is set
  1631. *
  1632. * For SBAS, this is:
  1633. * Received SBAS time, at the measurement time in nanoseconds.
  1634. *
  1635. * Given the highest sync state that can be achieved, per each satellite,
  1636. * valid range for this field can be:
  1637. * Searching : [ 0 ] : LOC_GNSS_MEASUREMENT_STATE_UNKNOWN
  1638. * C/A code lock: [ 0 1ms ] : LOC_GNSS_MEASUREMENT_STATE_CODE_LOCK is set
  1639. * Symbol sync : [ 0 2ms ] : LOC_GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set
  1640. * Message : [ 0 1s ] : LOC_GNSS_MEASUREMENT_STATE_SBAS_SYNC is set
  1641. */
  1642. int64_t received_sv_time_in_ns;
  1643. /**
  1644. * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds.
  1645. *
  1646. * This value must be populated if 'state' != LOC_GPS_MEASUREMENT_STATE_UNKNOWN.
  1647. */
  1648. int64_t received_sv_time_uncertainty_in_ns;
  1649. /**
  1650. * Carrier-to-noise density in dB-Hz, typically in the range [0, 63].
  1651. * It contains the measured C/N0 value for the signal at the antenna port.
  1652. *
  1653. * This is a mandatory value.
  1654. */
  1655. double c_n0_dbhz;
  1656. /**
  1657. * Pseudorange rate at the timestamp in m/s. The correction of a given
  1658. * Pseudorange Rate value includes corrections for receiver and satellite
  1659. * clock frequency errors. Ensure that this field is independent (see
  1660. * comment at top of LocGnssMeasurement struct.)
  1661. *
  1662. * It is mandatory to provide the 'uncorrected' 'pseudorange rate', and provide LocGpsClock's
  1663. * 'drift' field as well (When providing the uncorrected pseudorange rate, do not apply the
  1664. * corrections described above.)
  1665. *
  1666. * The value includes the 'pseudorange rate uncertainty' in it.
  1667. * A positive 'uncorrected' value indicates that the SV is moving away from the receiver.
  1668. *
  1669. * The sign of the 'uncorrected' 'pseudorange rate' and its relation to the sign of 'doppler
  1670. * shift' is given by the equation:
  1671. * pseudorange rate = -k * doppler shift (where k is a constant)
  1672. *
  1673. * This should be the most accurate pseudorange rate available, based on
  1674. * fresh signal measurements from this channel.
  1675. *
  1676. * It is mandatory that this value be provided at typical carrier phase PRR
  1677. * quality (few cm/sec per second of uncertainty, or better) - when signals
  1678. * are sufficiently strong & stable, e.g. signals from a GPS simulator at >=
  1679. * 35 dB-Hz.
  1680. */
  1681. double pseudorange_rate_mps;
  1682. /**
  1683. * 1-Sigma uncertainty of the pseudorange_rate_mps.
  1684. * The uncertainty is represented as an absolute (single sided) value.
  1685. *
  1686. * This is a mandatory value.
  1687. */
  1688. double pseudorange_rate_uncertainty_mps;
  1689. /**
  1690. * Accumulated delta range's state. It indicates whether ADR is reset or there is a cycle slip
  1691. * (indicating loss of lock).
  1692. *
  1693. * This is a mandatory value.
  1694. */
  1695. LocGnssAccumulatedDeltaRangeState accumulated_delta_range_state;
  1696. /**
  1697. * Accumulated delta range since the last channel reset in meters.
  1698. * A positive value indicates that the SV is moving away from the receiver.
  1699. *
  1700. * The sign of the 'accumulated delta range' and its relation to the sign of 'carrier phase'
  1701. * is given by the equation:
  1702. * accumulated delta range = -k * carrier phase (where k is a constant)
  1703. *
  1704. * This value must be populated if 'accumulated delta range state' != LOC_GPS_ADR_STATE_UNKNOWN.
  1705. * However, it is expected that the data is only accurate when:
  1706. * 'accumulated delta range state' == LOC_GPS_ADR_STATE_VALID.
  1707. */
  1708. double accumulated_delta_range_m;
  1709. /**
  1710. * 1-Sigma uncertainty of the accumulated delta range in meters.
  1711. * This value must be populated if 'accumulated delta range state' != LOC_GPS_ADR_STATE_UNKNOWN.
  1712. */
  1713. double accumulated_delta_range_uncertainty_m;
  1714. /**
  1715. * Carrier frequency at which codes and messages are modulated, it can be L1 or L2.
  1716. * If the field is not set, the carrier frequency is assumed to be L1.
  1717. *
  1718. * If the data is available, 'flags' must contain
  1719. * LOC_GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY.
  1720. */
  1721. float carrier_frequency_hz;
  1722. /**
  1723. * The number of full carrier cycles between the satellite and the receiver.
  1724. * The reference frequency is given by the field 'carrier_frequency_hz'.
  1725. * Indications of possible cycle slips and resets in the accumulation of
  1726. * this value can be inferred from the accumulated_delta_range_state flags.
  1727. *
  1728. * If the data is available, 'flags' must contain
  1729. * LOC_GNSS_MEASUREMENT_HAS_CARRIER_CYCLES.
  1730. */
  1731. int64_t carrier_cycles;
  1732. /**
  1733. * The RF phase detected by the receiver, in the range [0.0, 1.0].
  1734. * This is usually the fractional part of the complete carrier phase measurement.
  1735. *
  1736. * The reference frequency is given by the field 'carrier_frequency_hz'.
  1737. * The value contains the 'carrier-phase uncertainty' in it.
  1738. *
  1739. * If the data is available, 'flags' must contain
  1740. * LOC_GNSS_MEASUREMENT_HAS_CARRIER_PHASE.
  1741. */
  1742. double carrier_phase;
  1743. /**
  1744. * 1-Sigma uncertainty of the carrier-phase.
  1745. * If the data is available, 'flags' must contain
  1746. * LOC_GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY.
  1747. */
  1748. double carrier_phase_uncertainty;
  1749. /**
  1750. * An enumeration that indicates the 'multipath' state of the event.
  1751. *
  1752. * The multipath Indicator is intended to report the presence of overlapping
  1753. * signals that manifest as distorted correlation peaks.
  1754. *
  1755. * - if there is a distorted correlation peak shape, report that multipath
  1756. * is LOC_GNSS_MULTIPATH_INDICATOR_PRESENT.
  1757. * - if there is not a distorted correlation peak shape, report
  1758. * LOC_GNSS_MULTIPATH_INDICATOR_NOT_PRESENT
  1759. * - if signals are too weak to discern this information, report
  1760. * LOC_GNSS_MULTIPATH_INDICATOR_UNKNOWN
  1761. *
  1762. * Example: when doing the standardized overlapping Multipath Performance
  1763. * test (3GPP TS 34.171) the Multipath indicator should report
  1764. * LOC_GNSS_MULTIPATH_INDICATOR_PRESENT for those signals that are tracked, and
  1765. * contain multipath, and LOC_GNSS_MULTIPATH_INDICATOR_NOT_PRESENT for those
  1766. * signals that are tracked and do not contain multipath.
  1767. */
  1768. LocGnssMultipathIndicator multipath_indicator;
  1769. /**
  1770. * Signal-to-noise ratio at correlator output in dB.
  1771. * If the data is available, 'flags' must contain LOC_GNSS_MEASUREMENT_HAS_SNR.
  1772. * This is the power ratio of the "correlation peak height above the
  1773. * observed noise floor" to "the noise RMS".
  1774. */
  1775. double snr_db;
  1776. } LocGnssMeasurement;
  1777. /**
  1778. * Legacy struct to represents a reading of GPS measurements.
  1779. * Deprecated, to be removed in the next Android release.
  1780. * Use LocGnssData instead.
  1781. */
  1782. typedef struct {
  1783. /** set to sizeof(LocGpsData) */
  1784. size_t size;
  1785. size_t measurement_count;
  1786. LocGpsMeasurement measurements[LOC_GPS_MAX_MEASUREMENT];
  1787. /** The GPS clock time reading. */
  1788. LocGpsClock clock;
  1789. } LocGpsData;
  1790. /**
  1791. * Represents a reading of GNSS measurements. For devices where LocGnssSystemInfo's
  1792. * year_of_hw is set to 2016+, it is mandatory that these be provided, on
  1793. * request, when the GNSS receiver is searching/tracking signals.
  1794. *
  1795. * - Reporting of GPS constellation measurements is mandatory.
  1796. * - Reporting of all tracked constellations are encouraged.
  1797. */
  1798. typedef struct {
  1799. /** set to sizeof(LocGnssData) */
  1800. size_t size;
  1801. /** Number of measurements. */
  1802. size_t measurement_count;
  1803. /** The array of measurements. */
  1804. LocGnssMeasurement measurements[LOC_GNSS_MAX_MEASUREMENT];
  1805. /** The GPS clock time reading. */
  1806. LocGnssClock clock;
  1807. } LocGnssData;
  1808. /**
  1809. * The legacy callback for to report measurements from the HAL.
  1810. *
  1811. * This callback is deprecated, and will be removed in the next release. Use
  1812. * loc_gnss_measurement_callback() instead.
  1813. *
  1814. * Parameters:
  1815. * data - A data structure containing the measurements.
  1816. */
  1817. typedef void (*loc_gps_measurement_callback) (LocGpsData* data);
  1818. /**
  1819. * The callback for to report measurements from the HAL.
  1820. *
  1821. * Parameters:
  1822. * data - A data structure containing the measurements.
  1823. */
  1824. typedef void (*loc_gnss_measurement_callback) (LocGnssData* data);
  1825. typedef struct {
  1826. /** set to sizeof(LocGpsMeasurementCallbacks) */
  1827. size_t size;
  1828. loc_gps_measurement_callback measurement_callback;
  1829. loc_gnss_measurement_callback loc_gnss_measurement_callback;
  1830. } LocGpsMeasurementCallbacks;
  1831. #define LOC_GPS_MEASUREMENT_OPERATION_SUCCESS 0
  1832. #define LOC_GPS_MEASUREMENT_ERROR_ALREADY_INIT -100
  1833. #define LOC_GPS_MEASUREMENT_ERROR_GENERIC -101
  1834. /**
  1835. * Extended interface for GPS Measurements support.
  1836. */
  1837. typedef struct {
  1838. /** Set to sizeof(LocGpsMeasurementInterface) */
  1839. size_t size;
  1840. /**
  1841. * Initializes the interface and registers the callback routines with the HAL.
  1842. * After a successful call to 'init' the HAL must begin to provide updates at its own phase.
  1843. *
  1844. * Status:
  1845. * LOC_GPS_MEASUREMENT_OPERATION_SUCCESS
  1846. * LOC_GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a
  1847. * corresponding call to 'close'
  1848. * LOC_GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL
  1849. * will not generate any updates upon returning this error code.
  1850. */
  1851. int (*init) (LocGpsMeasurementCallbacks* callbacks);
  1852. /**
  1853. * Stops updates from the HAL, and unregisters the callback routines.
  1854. * After a call to stop, the previously registered callbacks must be considered invalid by the
  1855. * HAL.
  1856. * If stop is invoked without a previous 'init', this function should perform no work.
  1857. */
  1858. void (*close) ();
  1859. } LocGpsMeasurementInterface;
  1860. #if 0
  1861. /**
  1862. * Legacy struct to represents a GPS navigation message (or a fragment of it).
  1863. * Deprecated, to be removed in the next Android release.
  1864. * Use GnssNavigationMessage instead.
  1865. */
  1866. typedef struct {
  1867. /** set to sizeof(GpsNavigationMessage) */
  1868. size_t size;
  1869. int8_t prn;
  1870. GpsNavigationMessageType type;
  1871. NavigationMessageStatus status;
  1872. int16_t message_id;
  1873. int16_t submessage_id;
  1874. size_t data_length;
  1875. uint8_t* data;
  1876. } GpsNavigationMessage;
  1877. /** Represents a GPS navigation message (or a fragment of it). */
  1878. typedef struct {
  1879. /** set to sizeof(GnssNavigationMessage) */
  1880. size_t size;
  1881. /**
  1882. * Satellite vehicle ID number, as defined in LocGnssSvInfo::svid
  1883. * This is a mandatory value.
  1884. */
  1885. int16_t svid;
  1886. /**
  1887. * The type of message contained in the structure.
  1888. * This is a mandatory value.
  1889. */
  1890. GnssNavigationMessageType type;
  1891. /**
  1892. * The status of the received navigation message.
  1893. * No need to send any navigation message that contains words with parity error and cannot be
  1894. * corrected.
  1895. */
  1896. NavigationMessageStatus status;
  1897. /**
  1898. * Message identifier. It provides an index so the complete Navigation
  1899. * Message can be assembled.
  1900. *
  1901. * - For GPS L1 C/A subframe 4 and 5, this value corresponds to the 'frame
  1902. * id' of the navigation message, in the range of 1-25 (Subframe 1, 2, 3
  1903. * does not contain a 'frame id' and this value can be set to -1.)
  1904. *
  1905. * - For Glonass L1 C/A, this refers to the frame ID, in the range of 1-5.
  1906. *
  1907. * - For BeiDou D1, this refers to the frame number in the range of 1-24
  1908. *
  1909. * - For Beidou D2, this refers to the frame number, in the range of 1-120
  1910. *
  1911. * - For Galileo F/NAV nominal frame structure, this refers to the subframe
  1912. * number, in the range of 1-12
  1913. *
  1914. * - For Galileo I/NAV nominal frame structure, this refers to the subframe
  1915. * number in the range of 1-24
  1916. */
  1917. int16_t message_id;
  1918. /**
  1919. * Sub-message identifier. If required by the message 'type', this value
  1920. * contains a sub-index within the current message (or frame) that is being
  1921. * transmitted.
  1922. *
  1923. * - For GPS L1 C/A, BeiDou D1 & BeiDou D2, the submessage id corresponds to
  1924. * the subframe number of the navigation message, in the range of 1-5.
  1925. *
  1926. * - For Glonass L1 C/A, this refers to the String number, in the range from
  1927. * 1-15
  1928. *
  1929. * - For Galileo F/NAV, this refers to the page type in the range 1-6
  1930. *
  1931. * - For Galileo I/NAV, this refers to the word type in the range 1-10+
  1932. */
  1933. int16_t submessage_id;
  1934. /**
  1935. * The length of the data (in bytes) contained in the current message.
  1936. * If this value is different from zero, 'data' must point to an array of the same size.
  1937. * e.g. for L1 C/A the size of the sub-frame will be 40 bytes (10 words, 30 bits/word).
  1938. *
  1939. * This is a mandatory value.
  1940. */
  1941. size_t data_length;
  1942. /**
  1943. * The data of the reported GPS message. The bytes (or words) specified
  1944. * using big endian format (MSB first).
  1945. *
  1946. * - For GPS L1 C/A, Beidou D1 & Beidou D2, each subframe contains 10 30-bit
  1947. * words. Each word (30 bits) should be fit into the last 30 bits in a
  1948. * 4-byte word (skip B31 and B32), with MSB first, for a total of 40
  1949. * bytes, covering a time period of 6, 6, and 0.6 seconds, respectively.
  1950. *
  1951. * - For Glonass L1 C/A, each string contains 85 data bits, including the
  1952. * checksum. These bits should be fit into 11 bytes, with MSB first (skip
  1953. * B86-B88), covering a time period of 2 seconds.
  1954. *
  1955. * - For Galileo F/NAV, each word consists of 238-bit (sync & tail symbols
  1956. * excluded). Each word should be fit into 30-bytes, with MSB first (skip
  1957. * B239, B240), covering a time period of 10 seconds.
  1958. *
  1959. * - For Galileo I/NAV, each page contains 2 page parts, even and odd, with
  1960. * a total of 2x114 = 228 bits, (sync & tail excluded) that should be fit
  1961. * into 29 bytes, with MSB first (skip B229-B232).
  1962. */
  1963. uint8_t* data;
  1964. } GnssNavigationMessage;
  1965. /**
  1966. * The legacy callback to report an available fragment of a GPS navigation
  1967. * messages from the HAL.
  1968. *
  1969. * This callback is deprecated, and will be removed in the next release. Use
  1970. * gnss_navigation_message_callback() instead.
  1971. *
  1972. * Parameters:
  1973. * message - The GPS navigation submessage/subframe representation.
  1974. */
  1975. typedef void (*gps_navigation_message_callback) (GpsNavigationMessage* message);
  1976. /**
  1977. * The callback to report an available fragment of a GPS navigation messages from the HAL.
  1978. *
  1979. * Parameters:
  1980. * message - The GPS navigation submessage/subframe representation.
  1981. */
  1982. typedef void (*gnss_navigation_message_callback) (GnssNavigationMessage* message);
  1983. typedef struct {
  1984. /** set to sizeof(GpsNavigationMessageCallbacks) */
  1985. size_t size;
  1986. gps_navigation_message_callback navigation_message_callback;
  1987. gnss_navigation_message_callback gnss_navigation_message_callback;
  1988. } GpsNavigationMessageCallbacks;
  1989. #define GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS 0
  1990. #define GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT -100
  1991. #define GPS_NAVIGATION_MESSAGE_ERROR_GENERIC -101
  1992. /**
  1993. * Extended interface for GPS navigation message reporting support.
  1994. */
  1995. typedef struct {
  1996. /** Set to sizeof(GpsNavigationMessageInterface) */
  1997. size_t size;
  1998. /**
  1999. * Initializes the interface and registers the callback routines with the HAL.
  2000. * After a successful call to 'init' the HAL must begin to provide updates as they become
  2001. * available.
  2002. *
  2003. * Status:
  2004. * GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS
  2005. * GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT - if a callback has already been registered
  2006. * without a corresponding call to 'close'.
  2007. * GPS_NAVIGATION_MESSAGE_ERROR_GENERIC - if any other error occurred, it is expected that
  2008. * the HAL will not generate any updates upon returning this error code.
  2009. */
  2010. int (*init) (GpsNavigationMessageCallbacks* callbacks);
  2011. /**
  2012. * Stops updates from the HAL, and unregisters the callback routines.
  2013. * After a call to stop, the previously registered callbacks must be considered invalid by the
  2014. * HAL.
  2015. * If stop is invoked without a previous 'init', this function should perform no work.
  2016. */
  2017. void (*close) ();
  2018. } GpsNavigationMessageInterface;
  2019. #endif
  2020. /**
  2021. * Interface for passing GNSS configuration contents from platform to HAL.
  2022. */
  2023. typedef struct {
  2024. /** Set to sizeof(LocGnssConfigurationInterface) */
  2025. size_t size;
  2026. /**
  2027. * Deliver GNSS configuration contents to HAL.
  2028. * Parameters:
  2029. * config_data - a pointer to a char array which holds what usually is expected from
  2030. file(/vendor/etc/gps.conf), i.e., a sequence of UTF8 strings separated by '\n'.
  2031. * length - total number of UTF8 characters in configuraiton data.
  2032. *
  2033. * IMPORTANT:
  2034. * GPS HAL should expect this function can be called multiple times. And it may be
  2035. * called even when GpsLocationProvider is already constructed and enabled. GPS HAL
  2036. * should maintain the existing requests for various callback regardless the change
  2037. * in configuration data.
  2038. */
  2039. void (*configuration_update) (const char* config_data, int32_t length);
  2040. } LocGnssConfigurationInterface;
  2041. __END_DECLS
  2042. #endif /* LOC_GPS_H */