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