blob: 2f719cebbbe2b8f26f30bae327f70c01bfb60fcc [file] [log] [blame]
Mike Lockwood9b0b1c32010-02-23 18:42:37 -05001/*
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 ANDROID_INCLUDE_HARDWARE_GPS_H
18#define ANDROID_INCLUDE_HARDWARE_GPS_H
19
20#include <stdint.h>
21#include <sys/cdefs.h>
22#include <sys/types.h>
Mike Lockwood4453b5b2010-06-20 14:23:10 -070023#include <pthread.h>
destradaaf48cc672014-06-05 11:07:09 -070024#include <sys/socket.h>
destradaa9f7c3732014-04-29 10:50:22 -070025#include <stdbool.h>
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050026
27#include <hardware/hardware.h>
28
Hridya Valsarajubd0aa252017-01-18 09:21:15 -080029#include "gnss-base.h"
30
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050031__BEGIN_DECLS
32
Hridya Valsarajubd0aa252017-01-18 09:21:15 -080033/*
34 * Enums defined in HIDL in hardware/interfaces are auto-generated and present
35 * in gnss-base.h.
36 */
37
38/* for compatibility */
39
40/** Maximum number of SVs for gps_sv_status_callback(). */
41#define GNSS_MAX_SVS GNSS_MAX_SVS_COUNT
42/** Maximum number of Measurements in gnss_measurement_callback(). */
43#define GNSS_MAX_MEASUREMENT GNSS_MAX_SVS_COUNT
44
45#define GPS_REQUEST_AGPS_DATA_CONN GNSS_REQUEST_AGNSS_DATA_CONN
46#define GPS_RELEASE_AGPS_DATA_CONN GNSS_RELEASE_AGNSS_DATA_CONN
47#define GPS_AGPS_DATA_CONNECTED GNSS_AGNSS_DATA_CONNECTED
48#define GPS_AGPS_DATA_CONN_DONE GNSS_AGNSS_DATA_CONN_DONE
49#define GPS_AGPS_DATA_CONN_FAILED GNSS_AGNSS_DATA_CONN_FAILED
50#define AGPS_RIL_NETWORK_TYPE_MOBILE_MMS AGPS_RIL_NETWORK_TYPE_MMS
51#define AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL AGPS_RIL_NETWORK_TYPE_SUPL
52#define AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN AGPS_RIL_NETWORK_TYPE_DUN
53#define AGPS_RIL_NETWORK_TTYPE_MOBILE_HIPRI AGPS_RIL_NETWORK_TYPE_HIPRI
54#define AGPS_RIL_NETWORK_TTYPE_WIMAX AGPS_RIL_NETWORK_TYPE_WIMAX
55#define GNSS_MULTIPATH_INDICATOR_NOT_PRESENT GNSS_MULTIPATH_INDICATIOR_NOT_PRESENT
56#define AGPS_SETID_TYPE_MSISDN AGPS_SETID_TYPE_MSISDM
57#define GPS_MEASUREMENT_OPERATION_SUCCESS GPS_MEASUREMENT_SUCCESS
58#define GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS GPS_NAVIGATION_MESSAGE_SUCCESS
59#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L1CA GNSS_NAVIGATION_MESSAGE_TYPE_GNSS_L1CA
60#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L2CNAV GNSS_NAVIGATION_MESSAGE_TYPE_GNSS_L2CNAV
61#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L5CNAV GNSS_NAVIGATION_MESSAGE_TYPE_GNSS_L5CNAV
62#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_CNAV2 GNSS_NAVIGATION_MESSAGE_TYPE_GNSS_CNAV2
63
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050064/**
65 * The id of this module
66 */
67#define GPS_HARDWARE_MODULE_ID "gps"
68
69
70/** Milliseconds since January 1, 1970 */
71typedef int64_t GpsUtcTime;
72
73/** Maximum number of SVs for gps_sv_status_callback(). */
74#define GPS_MAX_SVS 32
75
destradaa9f7c3732014-04-29 10:50:22 -070076/** Maximum number of Measurements in gps_measurement_callback(). */
77#define GPS_MAX_MEASUREMENT 32
78
Mike Lockwoodb15879a2010-04-14 15:36:34 -040079/** Requested operational mode for GPS operation. */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050080typedef uint32_t GpsPositionMode;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050081
Mike Lockwoodb15879a2010-04-14 15:36:34 -040082/** Requested recurrence mode for GPS operation. */
83typedef uint32_t GpsPositionRecurrence;
Mike Lockwoodb15879a2010-04-14 15:36:34 -040084
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050085/** GPS status event values. */
86typedef uint16_t GpsStatusValue;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050087
88/** Flags to indicate which values are valid in a GpsLocation. */
89typedef uint16_t GpsLocationFlags;
Mike Lockwoodb15879a2010-04-14 15:36:34 -040090
Lifu Tangdf0fcf72015-10-27 14:58:25 -070091/**
92 * Flags used to specify which aiding data to delete when calling
93 * delete_aiding_data().
94 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050095typedef uint16_t GpsAidingData;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050096
97/** AGPS type */
98typedef uint16_t AGpsType;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050099
Miguel Torroja5f404f52010-07-27 06:34:15 +0200100typedef uint16_t AGpsSetIDType;
Miguel Torroja5f404f52010-07-27 06:34:15 +0200101
destradaaf48cc672014-06-05 11:07:09 -0700102typedef uint16_t ApnIpType;
destradaaf48cc672014-06-05 11:07:09 -0700103
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500104/**
105 * String length constants
106 */
107#define GPS_NI_SHORT_STRING_MAXLEN 256
108#define GPS_NI_LONG_STRING_MAXLEN 2048
109
110/**
111 * GpsNiType constants
112 */
113typedef uint32_t GpsNiType;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500114
115/**
116 * GpsNiNotifyFlags constants
117 */
118typedef uint32_t GpsNiNotifyFlags;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500119
120/**
121 * GPS NI responses, used to define the response in
122 * NI structures
123 */
124typedef int GpsUserResponseType;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500125
126/**
127 * NI data encoding scheme
128 */
129typedef int GpsNiEncodingType;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500130
131/** AGPS status event values. */
132typedef uint16_t AGpsStatusValue;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500133
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700134typedef uint16_t AGpsRefLocationType;
Miguel Torroja5f404f52010-07-27 06:34:15 +0200135
Lifu Tang3fc3bc82016-03-13 22:58:33 -0700136/* Deprecated, to be removed in the next Android release. */
137#define AGPS_REG_LOCATION_TYPE_MAC 3
138
Lifu Tanga1ca5742016-02-16 17:42:13 -0800139/* The following typedef together with its constants below are deprecated, and
140 * will be removed in the next release. */
destradaa9f7c3732014-04-29 10:50:22 -0700141typedef uint16_t GpsClockFlags;
destradaa9f7c3732014-04-29 10:50:22 -0700142#define GPS_CLOCK_HAS_LEAP_SECOND (1<<0)
destradaa9f7c3732014-04-29 10:50:22 -0700143#define GPS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1)
destradaa75843eb2014-07-17 14:04:50 -0700144#define GPS_CLOCK_HAS_FULL_BIAS (1<<2)
destradaa75843eb2014-07-17 14:04:50 -0700145#define GPS_CLOCK_HAS_BIAS (1<<3)
destradaa75843eb2014-07-17 14:04:50 -0700146#define GPS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4)
destradaa75843eb2014-07-17 14:04:50 -0700147#define GPS_CLOCK_HAS_DRIFT (1<<5)
destradaa75843eb2014-07-17 14:04:50 -0700148#define GPS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6)
149
150/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800151 * Flags to indicate what fields in GnssClock are valid.
destradaa75843eb2014-07-17 14:04:50 -0700152 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800153typedef uint16_t GnssClockFlags;
Lifu Tanga1ca5742016-02-16 17:42:13 -0800154
155/* The following typedef together with its constants below are deprecated, and
156 * will be removed in the next release. */
destradaa75843eb2014-07-17 14:04:50 -0700157typedef uint8_t GpsClockType;
destradaa75843eb2014-07-17 14:04:50 -0700158#define GPS_CLOCK_TYPE_UNKNOWN 0
destradaa75843eb2014-07-17 14:04:50 -0700159#define GPS_CLOCK_TYPE_LOCAL_HW_TIME 1
destradaa75843eb2014-07-17 14:04:50 -0700160#define GPS_CLOCK_TYPE_GPS_TIME 2
destradaa9f7c3732014-04-29 10:50:22 -0700161
Lifu Tanga1ca5742016-02-16 17:42:13 -0800162/* The following typedef together with its constants below are deprecated, and
163 * will be removed in the next release. */
destradaa9f7c3732014-04-29 10:50:22 -0700164typedef uint32_t GpsMeasurementFlags;
destradaa9f7c3732014-04-29 10:50:22 -0700165#define GPS_MEASUREMENT_HAS_SNR (1<<0)
destradaa9f7c3732014-04-29 10:50:22 -0700166#define GPS_MEASUREMENT_HAS_ELEVATION (1<<1)
destradaa9f7c3732014-04-29 10:50:22 -0700167#define GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY (1<<2)
destradaa9f7c3732014-04-29 10:50:22 -0700168#define GPS_MEASUREMENT_HAS_AZIMUTH (1<<3)
destradaa9f7c3732014-04-29 10:50:22 -0700169#define GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY (1<<4)
destradaa9f7c3732014-04-29 10:50:22 -0700170#define GPS_MEASUREMENT_HAS_PSEUDORANGE (1<<5)
destradaa9f7c3732014-04-29 10:50:22 -0700171#define GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY (1<<6)
destradaa9f7c3732014-04-29 10:50:22 -0700172#define GPS_MEASUREMENT_HAS_CODE_PHASE (1<<7)
destradaa9f7c3732014-04-29 10:50:22 -0700173#define GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY (1<<8)
destradaa9f7c3732014-04-29 10:50:22 -0700174#define GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9)
destradaa9f7c3732014-04-29 10:50:22 -0700175#define GPS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10)
destradaa9f7c3732014-04-29 10:50:22 -0700176#define GPS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11)
destradaa9f7c3732014-04-29 10:50:22 -0700177#define GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12)
destradaa9f7c3732014-04-29 10:50:22 -0700178#define GPS_MEASUREMENT_HAS_BIT_NUMBER (1<<13)
destradaa9f7c3732014-04-29 10:50:22 -0700179#define GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT (1<<14)
destradaa9f7c3732014-04-29 10:50:22 -0700180#define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT (1<<15)
destradaa9f7c3732014-04-29 10:50:22 -0700181#define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY (1<<16)
destradaa9f7c3732014-04-29 10:50:22 -0700182#define GPS_MEASUREMENT_HAS_USED_IN_FIX (1<<17)
destradaa00caa892015-04-09 18:41:46 -0700183#define GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE (1<<18)
destradaa9f7c3732014-04-29 10:50:22 -0700184
185/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800186 * Flags to indicate what fields in GnssMeasurement are valid.
destradaa9f7c3732014-04-29 10:50:22 -0700187 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800188typedef uint32_t GnssMeasurementFlags;
Lifu Tanga1ca5742016-02-16 17:42:13 -0800189
190/* The following typedef together with its constants below are deprecated, and
191 * will be removed in the next release. */
destradaa9f7c3732014-04-29 10:50:22 -0700192typedef uint8_t GpsLossOfLock;
destradaa9f7c3732014-04-29 10:50:22 -0700193#define GPS_LOSS_OF_LOCK_UNKNOWN 0
destradaa9f7c3732014-04-29 10:50:22 -0700194#define GPS_LOSS_OF_LOCK_OK 1
destradaa9f7c3732014-04-29 10:50:22 -0700195#define GPS_LOSS_OF_LOCK_CYCLE_SLIP 2
196
Lifu Tanga1ca5742016-02-16 17:42:13 -0800197/* The following typedef together with its constants below are deprecated, and
Lifu Tang1d4183c2016-02-24 13:50:19 -0800198 * will be removed in the next release. Use GnssMultipathIndicator instead.
199 */
destradaa9f7c3732014-04-29 10:50:22 -0700200typedef uint8_t GpsMultipathIndicator;
destradaa9f7c3732014-04-29 10:50:22 -0700201#define GPS_MULTIPATH_INDICATOR_UNKNOWN 0
destradaa9f7c3732014-04-29 10:50:22 -0700202#define GPS_MULTIPATH_INDICATOR_DETECTED 1
destradaa9f7c3732014-04-29 10:50:22 -0700203#define GPS_MULTIPATH_INDICATOR_NOT_USED 2
204
205/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800206 * Enumeration of available values for the GNSS Measurement's multipath
207 * indicator.
destradaa75843eb2014-07-17 14:04:50 -0700208 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800209typedef uint8_t GnssMultipathIndicator;
Lifu Tanga1ca5742016-02-16 17:42:13 -0800210
211/* The following typedef together with its constants below are deprecated, and
212 * will be removed in the next release. */
destradaa75843eb2014-07-17 14:04:50 -0700213typedef uint16_t GpsMeasurementState;
214#define GPS_MEASUREMENT_STATE_UNKNOWN 0
215#define GPS_MEASUREMENT_STATE_CODE_LOCK (1<<0)
216#define GPS_MEASUREMENT_STATE_BIT_SYNC (1<<1)
217#define GPS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2)
218#define GPS_MEASUREMENT_STATE_TOW_DECODED (1<<3)
Tsuwei Chena90cf192014-10-23 12:49:12 -0700219#define GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4)
destradaa75843eb2014-07-17 14:04:50 -0700220
221/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800222 * Flags indicating the GNSS measurement state.
223 *
224 * The expected behavior here is for GPS HAL to set all the flags that applies.
225 * For example, if the state for a satellite is only C/A code locked and bit
226 * synchronized, and there is still millisecond ambiguity, the state should be
227 * set as:
228 *
229 * GNSS_MEASUREMENT_STATE_CODE_LOCK | GNSS_MEASUREMENT_STATE_BIT_SYNC |
230 * GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS
231 *
232 * If GNSS is still searching for a satellite, the corresponding state should be
233 * set to GNSS_MEASUREMENT_STATE_UNKNOWN(0).
destradaa75843eb2014-07-17 14:04:50 -0700234 */
Lifu Tang3fc3bc82016-03-13 22:58:33 -0700235typedef uint32_t GnssMeasurementState;
Lifu Tanga1ca5742016-02-16 17:42:13 -0800236
237/* The following typedef together with its constants below are deprecated, and
238 * will be removed in the next release. */
destradaa75843eb2014-07-17 14:04:50 -0700239typedef uint16_t GpsAccumulatedDeltaRangeState;
240#define GPS_ADR_STATE_UNKNOWN 0
241#define GPS_ADR_STATE_VALID (1<<0)
242#define GPS_ADR_STATE_RESET (1<<1)
243#define GPS_ADR_STATE_CYCLE_SLIP (1<<2)
244
245/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800246 * Flags indicating the Accumulated Delta Range's states.
destradaa9f7c3732014-04-29 10:50:22 -0700247 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800248typedef uint16_t GnssAccumulatedDeltaRangeState;
Lifu Tanga1ca5742016-02-16 17:42:13 -0800249
250/* The following typedef together with its constants below are deprecated, and
251 * will be removed in the next release. */
destradaa9f7c3732014-04-29 10:50:22 -0700252typedef uint8_t GpsNavigationMessageType;
destradaa9f7c3732014-04-29 10:50:22 -0700253#define GPS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0
destradaa9f7c3732014-04-29 10:50:22 -0700254#define GPS_NAVIGATION_MESSAGE_TYPE_L1CA 1
destradaa9f7c3732014-04-29 10:50:22 -0700255#define GPS_NAVIGATION_MESSAGE_TYPE_L2CNAV 2
destradaa9f7c3732014-04-29 10:50:22 -0700256#define GPS_NAVIGATION_MESSAGE_TYPE_L5CNAV 3
destradaa9f7c3732014-04-29 10:50:22 -0700257#define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2 4
258
Tsuwei Chena90cf192014-10-23 12:49:12 -0700259/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800260 * Enumeration of available values to indicate the GNSS Navigation message
261 * types.
262 *
263 * For convenience, first byte is the GnssConstellationType on which that signal
264 * is typically transmitted
265 */
266typedef int16_t GnssNavigationMessageType;
267
Lifu Tanga1ca5742016-02-16 17:42:13 -0800268/**
Tsuwei Chena90cf192014-10-23 12:49:12 -0700269 * Status of Navigation Message
270 * When a message is received properly without any parity error in its navigation words, the
271 * status should be set to NAV_MESSAGE_STATUS_PARITY_PASSED. But if a message is received
272 * with words that failed parity check, but GPS is able to correct those words, the status
273 * should be set to NAV_MESSAGE_STATUS_PARITY_REBUILT.
274 * No need to send any navigation message that contains words with parity error and cannot be
275 * corrected.
276 */
277typedef uint16_t NavigationMessageStatus;
destradaa9f7c3732014-04-29 10:50:22 -0700278
Lifu Tang1d4183c2016-02-24 13:50:19 -0800279/* This constant is deprecated, and will be removed in the next release. */
280#define NAV_MESSAGE_STATUS_UNKONW 0
281
destradaa9f7c3732014-04-29 10:50:22 -0700282/**
Lifu Tang1d4183c2016-02-24 13:50:19 -0800283 * Flags that indicate information about the satellite
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700284 */
285typedef uint8_t GnssSvFlags;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700286
287/**
288 * Constellation type of GnssSvInfo
289 */
290typedef uint8_t GnssConstellationType;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700291
292/**
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500293 * Name for the GPS XTRA interface.
294 */
295#define GPS_XTRA_INTERFACE "gps-xtra"
296
297/**
298 * Name for the GPS DEBUG interface.
299 */
300#define GPS_DEBUG_INTERFACE "gps-debug"
301
302/**
303 * Name for the AGPS interface.
304 */
305#define AGPS_INTERFACE "agps"
306
307/**
destradaaa1f4c0a2013-09-13 15:45:03 -0700308 * Name of the Supl Certificate interface.
309 */
310#define SUPL_CERTIFICATE_INTERFACE "supl-certificate"
311
312/**
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500313 * Name for NI interface
314 */
315#define GPS_NI_INTERFACE "gps-ni"
316
Miguel Torroja5f404f52010-07-27 06:34:15 +0200317/**
318 * Name for the AGPS-RIL interface.
319 */
320#define AGPS_RIL_INTERFACE "agps_ril"
321
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -0800322/**
323 * Name for the GPS_Geofencing interface.
324 */
325#define GPS_GEOFENCING_INTERFACE "gps_geofencing"
326
destradaa9f7c3732014-04-29 10:50:22 -0700327/**
328 * Name of the GPS Measurements interface.
329 */
330#define GPS_MEASUREMENT_INTERFACE "gps_measurement"
331
332/**
333 * Name of the GPS navigation message interface.
334 */
Tsuwei Chen167d31f2014-08-26 16:34:19 -0700335#define GPS_NAVIGATION_MESSAGE_INTERFACE "gps_navigation_message"
336
337/**
338 * Name of the GNSS/GPS configuration interface.
339 */
340#define GNSS_CONFIGURATION_INTERFACE "gnss_configuration"
destradaa9f7c3732014-04-29 10:50:22 -0700341
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500342/** Represents a location. */
343typedef struct {
344 /** set to sizeof(GpsLocation) */
345 size_t size;
346 /** Contains GpsLocationFlags bits. */
347 uint16_t flags;
348 /** Represents latitude in degrees. */
349 double latitude;
350 /** Represents longitude in degrees. */
351 double longitude;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700352 /**
353 * Represents altitude in meters above the WGS 84 reference ellipsoid.
354 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500355 double altitude;
356 /** Represents speed in meters per second. */
357 float speed;
358 /** Represents heading in degrees. */
359 float bearing;
360 /** Represents expected accuracy in meters. */
361 float accuracy;
362 /** Timestamp for the location fix. */
363 GpsUtcTime timestamp;
364} GpsLocation;
365
366/** Represents the status. */
367typedef struct {
368 /** set to sizeof(GpsStatus) */
369 size_t size;
370 GpsStatusValue status;
371} GpsStatus;
372
Lifu Tanga1ca5742016-02-16 17:42:13 -0800373/**
374 * Legacy struct to represents SV information.
375 * Deprecated, to be removed in the next Android release.
376 * Use GnssSvInfo instead.
377 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500378typedef struct {
379 /** set to sizeof(GpsSvInfo) */
380 size_t size;
381 /** Pseudo-random number for the SV. */
382 int prn;
383 /** Signal to noise ratio. */
384 float snr;
385 /** Elevation of SV in degrees. */
386 float elevation;
387 /** Azimuth of SV in degrees. */
388 float azimuth;
389} GpsSvInfo;
390
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500391typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700392 /** set to sizeof(GnssSvInfo) */
393 size_t size;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500394
395 /**
Lifu Tang1d4183c2016-02-24 13:50:19 -0800396 * Pseudo-random number for the SV, or FCN/OSN number for Glonass. The
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700397 * distinction is made by looking at constellation field. Values should be
398 * in the range of:
399 *
400 * - GPS: 1-32
401 * - SBAS: 120-151, 183-192
Wyatt Riley80181862016-05-18 13:01:05 -0700402 * - GLONASS: 1-24, the orbital slot number (OSN), if known. Or, if not:
403 * 93-106, the frequency channel number (FCN) (-7 to +6) offset by + 100
404 * i.e. report an FCN of -7 as 93, FCN of 0 as 100, and FCN of +6 as 106.
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700405 * - QZSS: 193-200
Lifu Tang1d4183c2016-02-24 13:50:19 -0800406 * - Galileo: 1-36
407 * - Beidou: 1-37
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500408 */
Lifu Tang7e33bb22016-02-07 18:09:30 -0800409 int16_t svid;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700410
Lifu Tanga1ca5742016-02-16 17:42:13 -0800411 /**
412 * Defines the constellation of the given SV. Value should be one of those
413 * GNSS_CONSTELLATION_* constants
414 */
415 GnssConstellationType constellation;
416
Lifu Tang1d4183c2016-02-24 13:50:19 -0800417 /**
418 * Carrier-to-noise density in dB-Hz, typically in the range [0, 63].
419 * It contains the measured C/N0 value for the signal at the antenna port.
420 *
421 * This is a mandatory value.
422 */
423 float c_n0_dbhz;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700424
425 /** Elevation of SV in degrees. */
426 float elevation;
427
428 /** Azimuth of SV in degrees. */
429 float azimuth;
430
431 /**
432 * Contains additional data about the given SV. Value should be one of those
433 * GNSS_SV_FLAGS_* constants
434 */
435 GnssSvFlags flags;
436
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700437} GnssSvInfo;
438
439/**
Lifu Tang7e33bb22016-02-07 18:09:30 -0800440 * Legacy struct to represents SV status.
441 * Deprecated, to be removed in the next Android release.
442 * Use GnssSvStatus instead.
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700443 */
444typedef struct {
445 /** set to sizeof(GpsSvStatus) */
446 size_t size;
Lifu Tang7e33bb22016-02-07 18:09:30 -0800447 int num_svs;
448 GpsSvInfo sv_list[GPS_MAX_SVS];
449 uint32_t ephemeris_mask;
450 uint32_t almanac_mask;
451 uint32_t used_in_fix_mask;
452} GpsSvStatus;
453
454/**
455 * Represents SV status.
456 */
457typedef struct {
458 /** set to sizeof(GnssSvStatus) */
459 size_t size;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700460
461 /** Number of GPS SVs currently visible, refers to the SVs stored in sv_list */
462 int num_svs;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700463 /**
464 * Pointer to an array of SVs information for all GNSS constellations,
465 * except GPS, which is reported using sv_list
466 */
Lifu Tang7e33bb22016-02-07 18:09:30 -0800467 GnssSvInfo gnss_sv_list[GNSS_MAX_SVS];
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700468
Lifu Tang7e33bb22016-02-07 18:09:30 -0800469} GnssSvStatus;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500470
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700471/* CellID for 2G, 3G and LTE, used in AGPS. */
Miguel Torroja5f404f52010-07-27 06:34:15 +0200472typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700473 AGpsRefLocationType type;
474 /** Mobile Country Code. */
Miguel Torroja5f404f52010-07-27 06:34:15 +0200475 uint16_t mcc;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700476 /** Mobile Network Code .*/
Miguel Torroja5f404f52010-07-27 06:34:15 +0200477 uint16_t mnc;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700478 /** Location Area Code in 2G, 3G and LTE. In 3G lac is discarded. In LTE,
479 * lac is populated with tac, to ensure that we don't break old clients that
480 * might rely in the old (wrong) behavior.
481 */
Miguel Torroja5f404f52010-07-27 06:34:15 +0200482 uint16_t lac;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700483 /** Cell id in 2G. Utran Cell id in 3G. Cell Global Id EUTRA in LTE. */
Miguel Torroja5f404f52010-07-27 06:34:15 +0200484 uint32_t cid;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700485 /** Tracking Area Code in LTE. */
486 uint16_t tac;
487 /** Physical Cell id in LTE (not used in 2G and 3G) */
488 uint16_t pcid;
Miguel Torroja5f404f52010-07-27 06:34:15 +0200489} AGpsRefLocationCellID;
490
491typedef struct {
492 uint8_t mac[6];
493} AGpsRefLocationMac;
494
495/** Represents ref locations */
496typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700497 AGpsRefLocationType type;
Miguel Torroja5f404f52010-07-27 06:34:15 +0200498 union {
499 AGpsRefLocationCellID cellID;
500 AGpsRefLocationMac mac;
501 } u;
502} AGpsRefLocation;
503
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700504/**
505 * Callback with location information. Can only be called from a thread created
506 * by create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700507 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500508typedef void (* gps_location_callback)(GpsLocation* location);
509
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700510/**
511 * Callback with status information. Can only be called from a thread created by
512 * create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700513 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500514typedef void (* gps_status_callback)(GpsStatus* status);
515
destradaa9f7c3732014-04-29 10:50:22 -0700516/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800517 * Legacy callback with SV status information.
destradaa9f7c3732014-04-29 10:50:22 -0700518 * Can only be called from a thread created by create_thread_cb.
Lifu Tanga1ca5742016-02-16 17:42:13 -0800519 *
520 * This callback is deprecated, and will be removed in the next release. Use
521 * gnss_sv_status_callback() instead.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700522 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500523typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info);
524
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700525/**
Lifu Tang7e33bb22016-02-07 18:09:30 -0800526 * Callback with SV status information.
527 * Can only be called from a thread created by create_thread_cb.
528 */
529typedef void (* gnss_sv_status_callback)(GnssSvStatus* sv_info);
530
531/**
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700532 * Callback for reporting NMEA sentences. Can only be called from a thread
533 * created by create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700534 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500535typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length);
536
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700537/**
538 * Callback to inform framework of the GPS engine's capabilities. Capability
539 * parameter is a bit field of GPS_CAPABILITY_* flags.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700540 */
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400541typedef void (* gps_set_capabilities)(uint32_t capabilities);
542
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700543/**
544 * Callback utility for acquiring the GPS wakelock. This can be used to prevent
545 * the CPU from suspending while handling GPS events.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700546 */
Mike Lockwoodd20bbae2010-04-07 09:04:25 -0400547typedef void (* gps_acquire_wakelock)();
548
549/** Callback utility for releasing the GPS wakelock. */
550typedef void (* gps_release_wakelock)();
551
Mike Lockwood8aac5912011-06-29 15:10:36 -0400552/** Callback for requesting NTP time */
553typedef void (* gps_request_utc_time)();
554
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700555/**
556 * Callback for creating a thread that can call into the Java framework code.
557 * This must be used to create any threads that report events up to the
558 * framework.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700559 */
560typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg);
561
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700562/**
563 * Provides information about how new the underlying GPS/GNSS hardware and
564 * software is.
565 *
566 * This information will be available for Android Test Applications. If a GPS
567 * HAL does not provide this information, it will be considered "2015 or
568 * earlier".
569 *
570 * If a GPS HAL does provide this information, then newer years will need to
571 * meet newer CTS standards. E.g. if the date are 2016 or above, then N+ level
572 * GpsMeasurement support will be verified.
573 */
574typedef struct {
Lifu Tanga1ca5742016-02-16 17:42:13 -0800575 /** Set to sizeof(GnssSystemInfo) */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700576 size_t size;
577 /* year in which the last update was made to the underlying hardware/firmware
578 * used to capture GNSS signals, e.g. 2016 */
579 uint16_t year_of_hw;
Lifu Tanga1ca5742016-02-16 17:42:13 -0800580} GnssSystemInfo;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700581
582/**
583 * Callback to inform framework of the engine's hardware version information.
584 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800585typedef void (*gnss_set_system_info)(const GnssSystemInfo* info);
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700586
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700587/** New GPS callback structure. */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500588typedef struct {
Mike Lockwoodd20bbae2010-04-07 09:04:25 -0400589 /** set to sizeof(GpsCallbacks) */
590 size_t size;
591 gps_location_callback location_cb;
592 gps_status_callback status_cb;
593 gps_sv_status_callback sv_status_cb;
594 gps_nmea_callback nmea_cb;
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400595 gps_set_capabilities set_capabilities_cb;
Mike Lockwoodd20bbae2010-04-07 09:04:25 -0400596 gps_acquire_wakelock acquire_wakelock_cb;
597 gps_release_wakelock release_wakelock_cb;
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700598 gps_create_thread create_thread_cb;
Mike Lockwood8aac5912011-06-29 15:10:36 -0400599 gps_request_utc_time request_utc_time_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500600
Lifu Tanga1ca5742016-02-16 17:42:13 -0800601 gnss_set_system_info set_system_info_cb;
Lifu Tang7e33bb22016-02-07 18:09:30 -0800602 gnss_sv_status_callback gnss_sv_status_cb;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700603} GpsCallbacks;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500604
605/** Represents the standard GPS interface. */
606typedef struct {
607 /** set to sizeof(GpsInterface) */
608 size_t size;
609 /**
610 * Opens the interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -0700611 * to the implementation of this interface.
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500612 */
613 int (*init)( GpsCallbacks* callbacks );
614
615 /** Starts navigating. */
616 int (*start)( void );
617
618 /** Stops navigating. */
619 int (*stop)( void );
620
621 /** Closes the interface. */
622 void (*cleanup)( void );
623
624 /** Injects the current time. */
625 int (*inject_time)(GpsUtcTime time, int64_t timeReference,
626 int uncertainty);
627
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700628 /**
629 * Injects current location from another location provider (typically cell
630 * ID). Latitude and longitude are measured in degrees expected accuracy is
631 * measured in meters
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500632 */
633 int (*inject_location)(double latitude, double longitude, float accuracy);
634
635 /**
636 * Specifies that the next call to start will not use the
637 * information defined in the flags. GPS_DELETE_ALL is passed for
638 * a cold start.
639 */
640 void (*delete_aiding_data)(GpsAidingData flags);
641
642 /**
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400643 * min_interval represents the time between fixes in milliseconds.
644 * preferred_accuracy represents the requested fix accuracy in meters.
645 * preferred_time represents the requested time to first fix in milliseconds.
destradaa81534882015-04-28 13:10:56 -0700646 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700647 * 'mode' parameter should be one of GPS_POSITION_MODE_MS_BASED
destradaa81534882015-04-28 13:10:56 -0700648 * or GPS_POSITION_MODE_STANDALONE.
649 * It is allowed by the platform (and it is recommended) to fallback to
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700650 * GPS_POSITION_MODE_MS_BASED if GPS_POSITION_MODE_MS_ASSISTED is passed in, and
destradaa81534882015-04-28 13:10:56 -0700651 * GPS_POSITION_MODE_MS_BASED is supported.
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500652 */
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400653 int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence,
654 uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time);
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500655
656 /** Get a pointer to extension information. */
657 const void* (*get_extension)(const char* name);
658} GpsInterface;
659
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700660/**
661 * Callback to request the client to download XTRA data. The client should
662 * download XTRA data and inject it by calling inject_xtra_data(). Can only be
663 * called from a thread created by create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700664 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500665typedef void (* gps_xtra_download_request)();
666
667/** Callback structure for the XTRA interface. */
668typedef struct {
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700669 gps_xtra_download_request download_request_cb;
670 gps_create_thread create_thread_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500671} GpsXtraCallbacks;
672
673/** Extended interface for XTRA support. */
674typedef struct {
675 /** set to sizeof(GpsXtraInterface) */
676 size_t size;
677 /**
678 * Opens the XTRA interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -0700679 * to the implementation of this interface.
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500680 */
681 int (*init)( GpsXtraCallbacks* callbacks );
682 /** Injects XTRA data into the GPS. */
683 int (*inject_xtra_data)( char* data, int length );
684} GpsXtraInterface;
685
686/** Extended interface for DEBUG support. */
687typedef struct {
688 /** set to sizeof(GpsDebugInterface) */
689 size_t size;
690
691 /**
692 * This function should return any information that the native
693 * implementation wishes to include in a bugreport.
694 */
695 size_t (*get_internal_state)(char* buffer, size_t bufferSize);
696} GpsDebugInterface;
697
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700698/*
699 * Represents the status of AGPS augmented to support IPv4 and IPv6.
700 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500701typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700702 /** set to sizeof(AGpsStatus) */
destradaaf48cc672014-06-05 11:07:09 -0700703 size_t size;
704
705 AGpsType type;
706 AGpsStatusValue status;
707
708 /**
709 * Must be set to a valid IPv4 address if the field 'addr' contains an IPv4
710 * address, or set to INADDR_NONE otherwise.
711 */
712 uint32_t ipaddr;
713
714 /**
715 * Must contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report.
716 * Any other value of addr.ss_family will be rejected.
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700717 */
destradaaf48cc672014-06-05 11:07:09 -0700718 struct sockaddr_storage addr;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700719} AGpsStatus;
destradaaf48cc672014-06-05 11:07:09 -0700720
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700721/**
722 * Callback with AGPS status information. Can only be called from a thread
723 * created by create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700724 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500725typedef void (* agps_status_callback)(AGpsStatus* status);
726
727/** Callback structure for the AGPS interface. */
728typedef struct {
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700729 agps_status_callback status_cb;
730 gps_create_thread create_thread_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500731} AGpsCallbacks;
732
destradaaf48cc672014-06-05 11:07:09 -0700733/**
734 * Extended interface for AGPS support, it is augmented to enable to pass
735 * extra APN data.
736 */
737typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700738 /** set to sizeof(AGpsInterface) */
destradaaf48cc672014-06-05 11:07:09 -0700739 size_t size;
740
741 /**
742 * Opens the AGPS interface and provides the callback routines to the
743 * implementation of this interface.
744 */
745 void (*init)(AGpsCallbacks* callbacks);
746 /**
747 * Deprecated.
748 * If the HAL supports AGpsInterface_v2 this API will not be used, see
749 * data_conn_open_with_apn_ip_type for more information.
750 */
751 int (*data_conn_open)(const char* apn);
752 /**
753 * Notifies that the AGPS data connection has been closed.
754 */
755 int (*data_conn_closed)();
756 /**
757 * Notifies that a data connection is not available for AGPS.
758 */
759 int (*data_conn_failed)();
760 /**
761 * Sets the hostname and port for the AGPS server.
762 */
763 int (*set_server)(AGpsType type, const char* hostname, int port);
764
765 /**
766 * Notifies that a data connection is available and sets the name of the
767 * APN, and its IP type, to be used for SUPL connections.
768 */
769 int (*data_conn_open_with_apn_ip_type)(
770 const char* apn,
771 ApnIpType apnIpType);
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700772} AGpsInterface;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500773
destradaaa1f4c0a2013-09-13 15:45:03 -0700774/** Error codes associated with certificate operations */
775#define AGPS_CERTIFICATE_OPERATION_SUCCESS 0
776#define AGPS_CERTIFICATE_ERROR_GENERIC -100
777#define AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES -101
778
779/** A data structure that represents an X.509 certificate using DER encoding */
780typedef struct {
781 size_t length;
782 u_char* data;
783} DerEncodedCertificate;
784
785/**
786 * A type definition for SHA1 Fingerprints used to identify X.509 Certificates
787 * The Fingerprint is a digest of the DER Certificate that uniquely identifies it.
788 */
789typedef struct {
790 u_char data[20];
791} Sha1CertificateFingerprint;
792
destradaa9f7c3732014-04-29 10:50:22 -0700793/** AGPS Interface to handle SUPL certificate operations */
destradaaa1f4c0a2013-09-13 15:45:03 -0700794typedef struct {
795 /** set to sizeof(SuplCertificateInterface) */
796 size_t size;
797
798 /**
799 * Installs a set of Certificates used for SUPL connections to the AGPS server.
800 * If needed the HAL should find out internally any certificates that need to be removed to
801 * accommodate the certificates to install.
802 * The certificates installed represent a full set of valid certificates needed to connect to
803 * AGPS SUPL servers.
804 * The list of certificates is required, and all must be available at the same time, when trying
805 * to establish a connection with the AGPS Server.
806 *
807 * Parameters:
808 * certificates - A pointer to an array of DER encoded certificates that are need to be
809 * installed in the HAL.
810 * length - The number of certificates to install.
811 * Returns:
812 * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully
813 * AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES if the HAL cannot store the number of
814 * certificates attempted to be installed, the state of the certificates stored should
815 * remain the same as before on this error case.
816 *
817 * IMPORTANT:
818 * If needed the HAL should find out internally the set of certificates that need to be
819 * removed to accommodate the certificates to install.
820 */
821 int (*install_certificates) ( const DerEncodedCertificate* certificates, size_t length );
822
823 /**
824 * Notifies the HAL that a list of certificates used for SUPL connections are revoked. It is
825 * expected that the given set of certificates is removed from the internal store of the HAL.
826 *
827 * Parameters:
828 * fingerprints - A pointer to an array of SHA1 Fingerprints to identify the set of
829 * certificates to revoke.
830 * length - The number of fingerprints provided.
831 * Returns:
832 * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully.
833 *
834 * IMPORTANT:
835 * If any of the certificates provided (through its fingerprint) is not known by the HAL,
836 * it should be ignored and continue revoking/deleting the rest of them.
837 */
838 int (*revoke_certificates) ( const Sha1CertificateFingerprint* fingerprints, size_t length );
destradaa7ddd4d72013-11-07 13:47:59 -0800839} SuplCertificateInterface;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500840
841/** Represents an NI request */
842typedef struct {
843 /** set to sizeof(GpsNiNotification) */
844 size_t size;
845
846 /**
847 * An ID generated by HAL to associate NI notifications and UI
848 * responses
849 */
850 int notification_id;
851
852 /**
853 * An NI type used to distinguish different categories of NI
854 * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ...
855 */
856 GpsNiType ni_type;
857
858 /**
859 * Notification/verification options, combinations of GpsNiNotifyFlags constants
860 */
861 GpsNiNotifyFlags notify_flags;
862
863 /**
864 * Timeout period to wait for user response.
865 * Set to 0 for no time out limit.
866 */
867 int timeout;
868
869 /**
870 * Default response when time out.
871 */
872 GpsUserResponseType default_response;
873
874 /**
875 * Requestor ID
876 */
877 char requestor_id[GPS_NI_SHORT_STRING_MAXLEN];
878
879 /**
880 * Notification message. It can also be used to store client_id in some cases
881 */
882 char text[GPS_NI_LONG_STRING_MAXLEN];
883
884 /**
885 * Client name decoding scheme
886 */
887 GpsNiEncodingType requestor_id_encoding;
888
889 /**
890 * Client name decoding scheme
891 */
892 GpsNiEncodingType text_encoding;
893
894 /**
895 * A pointer to extra data. Format:
896 * key_1 = value_1
897 * key_2 = value_2
898 */
899 char extras[GPS_NI_LONG_STRING_MAXLEN];
900
901} GpsNiNotification;
902
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700903/**
904 * Callback with NI notification. Can only be called from a thread created by
905 * create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700906 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500907typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification);
908
909/** GPS NI callback structure. */
910typedef struct
911{
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700912 /**
913 * Sends the notification request from HAL to GPSLocationProvider.
914 */
915 gps_ni_notify_callback notify_cb;
916 gps_create_thread create_thread_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500917} GpsNiCallbacks;
918
919/**
920 * Extended interface for Network-initiated (NI) support.
921 */
922typedef struct
923{
924 /** set to sizeof(GpsNiInterface) */
925 size_t size;
926
927 /** Registers the callbacks for HAL to use. */
928 void (*init) (GpsNiCallbacks *callbacks);
929
930 /** Sends a response to HAL. */
931 void (*respond) (int notif_id, GpsUserResponseType user_response);
932} GpsNiInterface;
933
934struct gps_device_t {
935 struct hw_device_t common;
936
937 /**
938 * Set the provided lights to the provided values.
939 *
940 * Returns: 0 on succes, error code on failure.
941 */
942 const GpsInterface* (*get_gps_interface)(struct gps_device_t* dev);
943};
944
Miguel Torroja5f404f52010-07-27 06:34:15 +0200945#define AGPS_RIL_REQUEST_REFLOC_CELLID (1<<0L)
946#define AGPS_RIL_REQUEST_REFLOC_MAC (1<<1L)
947
948typedef void (*agps_ril_request_set_id)(uint32_t flags);
949typedef void (*agps_ril_request_ref_loc)(uint32_t flags);
950
951typedef struct {
952 agps_ril_request_set_id request_setid;
953 agps_ril_request_ref_loc request_refloc;
954 gps_create_thread create_thread_cb;
955} AGpsRilCallbacks;
956
957/** Extended interface for AGPS_RIL support. */
958typedef struct {
959 /** set to sizeof(AGpsRilInterface) */
960 size_t size;
961 /**
962 * Opens the AGPS interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -0700963 * to the implementation of this interface.
Miguel Torroja5f404f52010-07-27 06:34:15 +0200964 */
965 void (*init)( AGpsRilCallbacks* callbacks );
966
967 /**
968 * Sets the reference location.
969 */
970 void (*set_ref_location) (const AGpsRefLocation *agps_reflocation, size_t sz_struct);
971 /**
972 * Sets the set ID.
973 */
974 void (*set_set_id) (AGpsSetIDType type, const char* setid);
975
976 /**
977 * Send network initiated message.
978 */
979 void (*ni_message) (uint8_t *msg, size_t len);
Mike Lockwood455e83b2010-10-11 06:16:57 -0400980
981 /**
982 * Notify GPS of network status changes.
983 * These parameters match values in the android.net.NetworkInfo class.
984 */
985 void (*update_network_state) (int connected, int type, int roaming, const char* extra_info);
Kevin Tangb82c2db2011-04-13 17:15:55 -0700986
987 /**
988 * Notify GPS of network status changes.
989 * These parameters match values in the android.net.NetworkInfo class.
990 */
991 void (*update_network_availability) (int avaiable, const char* apn);
Miguel Torroja5f404f52010-07-27 06:34:15 +0200992} AGpsRilInterface;
993
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -0800994/**
995 * GPS Geofence.
996 * There are 3 states associated with a Geofence: Inside, Outside, Unknown.
997 * There are 3 transitions: ENTERED, EXITED, UNCERTAIN.
998 *
999 * An example state diagram with confidence level: 95% and Unknown time limit
1000 * set as 30 secs is shown below. (confidence level and Unknown time limit are
1001 * explained latter)
1002 * ____________________________
1003 * | Unknown (30 secs) |
1004 * """"""""""""""""""""""""""""
1005 * ^ | | ^
1006 * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN
1007 * | v v |
1008 * ________ EXITED _________
1009 * | Inside | -----------> | Outside |
1010 * | | <----------- | |
1011 * """""""" ENTERED """""""""
1012 *
1013 * Inside state: We are 95% confident that the user is inside the geofence.
1014 * Outside state: We are 95% confident that the user is outside the geofence
1015 * Unknown state: Rest of the time.
1016 *
1017 * The Unknown state is better explained with an example:
1018 *
1019 * __________
1020 * | c|
1021 * | ___ | _______
1022 * | |a| | | b |
1023 * | """ | """""""
1024 * | |
1025 * """"""""""
1026 * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy
1027 * circle reported by the GPS subsystem. Now with regard to "b", the system is
1028 * confident that the user is outside. But with regard to "a" is not confident
1029 * whether it is inside or outside the geofence. If the accuracy remains the
1030 * same for a sufficient period of time, the UNCERTAIN transition would be
1031 * triggered with the state set to Unknown. If the accuracy improves later, an
1032 * appropriate transition should be triggered. This "sufficient period of time"
1033 * is defined by the parameter in the add_geofence_area API.
1034 * In other words, Unknown state can be interpreted as a state in which the
1035 * GPS subsystem isn't confident enough that the user is either inside or
1036 * outside the Geofence. It moves to Unknown state only after the expiry of the
1037 * timeout.
1038 *
1039 * The geofence callback needs to be triggered for the ENTERED and EXITED
1040 * transitions, when the GPS system is confident that the user has entered
1041 * (Inside state) or exited (Outside state) the Geofence. An implementation
1042 * which uses a value of 95% as the confidence is recommended. The callback
1043 * should be triggered only for the transitions requested by the
1044 * add_geofence_area call.
1045 *
1046 * Even though the diagram and explanation talks about states and transitions,
1047 * the callee is only interested in the transistions. The states are mentioned
1048 * here for illustrative purposes.
1049 *
1050 * Startup Scenario: When the device boots up, if an application adds geofences,
1051 * and then we get an accurate GPS location fix, it needs to trigger the
1052 * appropriate (ENTERED or EXITED) transition for every Geofence it knows about.
1053 * By default, all the Geofences will be in the Unknown state.
1054 *
1055 * When the GPS system is unavailable, gps_geofence_status_callback should be
1056 * called to inform the upper layers of the same. Similarly, when it becomes
1057 * available the callback should be called. This is a global state while the
1058 * UNKNOWN transition described above is per geofence.
1059 *
1060 * An important aspect to note is that users of this API (framework), will use
1061 * other subsystems like wifi, sensors, cell to handle Unknown case and
1062 * hopefully provide a definitive state transition to the third party
1063 * application. GPS Geofence will just be a signal indicating what the GPS
1064 * subsystem knows about the Geofence.
1065 *
1066 */
Jaikumar Ganesh5824b402013-02-25 11:43:33 -08001067
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001068/**
1069 * The callback associated with the geofence.
1070 * Parameters:
1071 * geofence_id - The id associated with the add_geofence_area.
1072 * location - The current GPS location.
1073 * transition - Can be one of GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED,
1074 * GPS_GEOFENCE_UNCERTAIN.
1075 * timestamp - Timestamp when the transition was detected.
1076 *
1077 * The callback should only be called when the caller is interested in that
1078 * particular transition. For instance, if the caller is interested only in
1079 * ENTERED transition, then the callback should NOT be called with the EXITED
1080 * transition.
1081 *
1082 * IMPORTANT: If a transition is triggered resulting in this callback, the GPS
1083 * subsystem will wake up the application processor, if its in suspend state.
1084 */
1085typedef void (*gps_geofence_transition_callback) (int32_t geofence_id, GpsLocation* location,
1086 int32_t transition, GpsUtcTime timestamp);
1087
1088/**
destradaa9f7c3732014-04-29 10:50:22 -07001089 * The callback associated with the availability of the GPS system for geofencing
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001090 * monitoring. If the GPS system determines that it cannot monitor geofences
1091 * because of lack of reliability or unavailability of the GPS signals, it will
1092 * call this callback with GPS_GEOFENCE_UNAVAILABLE parameter.
1093 *
1094 * Parameters:
1095 * status - GPS_GEOFENCE_UNAVAILABLE or GPS_GEOFENCE_AVAILABLE.
1096 * last_location - Last known location.
1097 */
1098typedef void (*gps_geofence_status_callback) (int32_t status, GpsLocation* last_location);
1099
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001100/**
1101 * The callback associated with the add_geofence call.
1102 *
1103 * Parameter:
1104 * geofence_id - Id of the geofence.
1105 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1106 * GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached.
1107 * GPS_GEOFENCE_ERROR_ID_EXISTS - geofence with id already exists
1108 * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - the monitorTransition contains an
1109 * invalid transition
1110 * GPS_GEOFENCE_ERROR_GENERIC - for other errors.
1111 */
1112typedef void (*gps_geofence_add_callback) (int32_t geofence_id, int32_t status);
1113
1114/**
1115 * The callback associated with the remove_geofence call.
1116 *
1117 * Parameter:
1118 * geofence_id - Id of the geofence.
1119 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1120 * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
1121 * GPS_GEOFENCE_ERROR_GENERIC for others.
1122 */
1123typedef void (*gps_geofence_remove_callback) (int32_t geofence_id, int32_t status);
1124
1125
1126/**
1127 * The callback associated with the pause_geofence call.
1128 *
1129 * Parameter:
1130 * geofence_id - Id of the geofence.
1131 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1132 * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
1133 * GPS_GEOFENCE_ERROR_INVALID_TRANSITION -
1134 * when monitor_transitions is invalid
1135 * GPS_GEOFENCE_ERROR_GENERIC for others.
1136 */
1137typedef void (*gps_geofence_pause_callback) (int32_t geofence_id, int32_t status);
1138
1139/**
1140 * The callback associated with the resume_geofence call.
1141 *
1142 * Parameter:
1143 * geofence_id - Id of the geofence.
1144 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1145 * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
1146 * GPS_GEOFENCE_ERROR_GENERIC for others.
1147 */
1148typedef void (*gps_geofence_resume_callback) (int32_t geofence_id, int32_t status);
1149
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001150typedef struct {
1151 gps_geofence_transition_callback geofence_transition_callback;
1152 gps_geofence_status_callback geofence_status_callback;
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001153 gps_geofence_add_callback geofence_add_callback;
1154 gps_geofence_remove_callback geofence_remove_callback;
1155 gps_geofence_pause_callback geofence_pause_callback;
1156 gps_geofence_resume_callback geofence_resume_callback;
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001157 gps_create_thread create_thread_cb;
1158} GpsGeofenceCallbacks;
1159
1160/** Extended interface for GPS_Geofencing support */
1161typedef struct {
1162 /** set to sizeof(GpsGeofencingInterface) */
1163 size_t size;
1164
1165 /**
1166 * Opens the geofence interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -07001167 * to the implementation of this interface.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001168 */
1169 void (*init)( GpsGeofenceCallbacks* callbacks );
1170
1171 /**
1172 * Add a geofence area. This api currently supports circular geofences.
1173 * Parameters:
1174 * geofence_id - The id for the geofence. If a geofence with this id
Jaikumar Ganesh5824b402013-02-25 11:43:33 -08001175 * already exists, an error value (GPS_GEOFENCE_ERROR_ID_EXISTS)
1176 * should be returned.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001177 * latitude, longtitude, radius_meters - The lat, long and radius
1178 * (in meters) for the geofence
1179 * last_transition - The current state of the geofence. For example, if
1180 * the system already knows that the user is inside the geofence,
1181 * this will be set to GPS_GEOFENCE_ENTERED. In most cases, it
1182 * will be GPS_GEOFENCE_UNCERTAIN.
1183 * monitor_transition - Which transitions to monitor. Bitwise OR of
1184 * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and
1185 * GPS_GEOFENCE_UNCERTAIN.
1186 * notification_responsiveness_ms - Defines the best-effort description
1187 * of how soon should the callback be called when the transition
1188 * associated with the Geofence is triggered. For instance, if set
1189 * to 1000 millseconds with GPS_GEOFENCE_ENTERED, the callback
1190 * should be called 1000 milliseconds within entering the geofence.
1191 * This parameter is defined in milliseconds.
1192 * NOTE: This is not to be confused with the rate that the GPS is
1193 * polled at. It is acceptable to dynamically vary the rate of
1194 * sampling the GPS for power-saving reasons; thus the rate of
1195 * sampling may be faster or slower than this.
1196 * unknown_timer_ms - The time limit after which the UNCERTAIN transition
destradaa9f7c3732014-04-29 10:50:22 -07001197 * should be triggered. This parameter is defined in milliseconds.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001198 * See above for a detailed explanation.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001199 */
destradaa9f7c3732014-04-29 10:50:22 -07001200 void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude,
1201 double radius_meters, int last_transition, int monitor_transitions,
1202 int notification_responsiveness_ms, int unknown_timer_ms);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001203
1204 /**
1205 * Pause monitoring a particular geofence.
1206 * Parameters:
1207 * geofence_id - The id for the geofence.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001208 */
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001209 void (*pause_geofence) (int32_t geofence_id);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001210
1211 /**
1212 * Resume monitoring a particular geofence.
1213 * Parameters:
1214 * geofence_id - The id for the geofence.
1215 * monitor_transitions - Which transitions to monitor. Bitwise OR of
1216 * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and
1217 * GPS_GEOFENCE_UNCERTAIN.
1218 * This supersedes the value associated provided in the
1219 * add_geofence_area call.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001220 */
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001221 void (*resume_geofence) (int32_t geofence_id, int monitor_transitions);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001222
1223 /**
1224 * Remove a geofence area. After the function returns, no notifications
1225 * should be sent.
1226 * Parameter:
1227 * geofence_id - The id for the geofence.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001228 */
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001229 void (*remove_geofence_area) (int32_t geofence_id);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001230} GpsGeofencingInterface;
destradaa9f7c3732014-04-29 10:50:22 -07001231
destradaa9f7c3732014-04-29 10:50:22 -07001232/**
Lifu Tang7e33bb22016-02-07 18:09:30 -08001233 * Legacy struct to represent an estimate of the GPS clock time.
1234 * Deprecated, to be removed in the next Android release.
1235 * Use GnssClock instead.
destradaa9f7c3732014-04-29 10:50:22 -07001236 */
1237typedef struct {
1238 /** set to sizeof(GpsClock) */
1239 size_t size;
Lifu Tang7e33bb22016-02-07 18:09:30 -08001240 GpsClockFlags flags;
1241 int16_t leap_second;
1242 GpsClockType type;
1243 int64_t time_ns;
1244 double time_uncertainty_ns;
1245 int64_t full_bias_ns;
1246 double bias_ns;
1247 double bias_uncertainty_ns;
1248 double drift_nsps;
1249 double drift_uncertainty_nsps;
1250} GpsClock;
1251
1252/**
1253 * Represents an estimate of the GPS clock time.
1254 */
1255typedef struct {
1256 /** set to sizeof(GnssClock) */
1257 size_t size;
destradaa9f7c3732014-04-29 10:50:22 -07001258
Lifu Tanga1ca5742016-02-16 17:42:13 -08001259 /**
1260 * A set of flags indicating the validity of the fields in this data
1261 * structure.
1262 */
1263 GnssClockFlags flags;
destradaa9f7c3732014-04-29 10:50:22 -07001264
1265 /**
1266 * Leap second data.
destradaa75843eb2014-07-17 14:04:50 -07001267 * The sign of the value is defined by the following equation:
Lifu Tangd46260a2016-04-07 19:22:12 -07001268 * utc_time_ns = time_ns - (full_bias_ns + bias_ns) - leap_second *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001269 * 1,000,000,000
destradaa75843eb2014-07-17 14:04:50 -07001270 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001271 * If the data is available 'flags' must contain GNSS_CLOCK_HAS_LEAP_SECOND.
destradaa9f7c3732014-04-29 10:50:22 -07001272 */
1273 int16_t leap_second;
1274
1275 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001276 * The GNSS receiver internal clock value. This is the local hardware clock
1277 * value.
destradaa9f7c3732014-04-29 10:50:22 -07001278 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001279 * For local hardware clock, this value is expected to be monotonically
1280 * increasing while the hardware clock remains power on. (For the case of a
1281 * HW clock that is not continuously on, see the
Lifu Tangd46260a2016-04-07 19:22:12 -07001282 * hw_clock_discontinuity_count field). The receiver's estimate of GPS time
1283 * can be derived by substracting the sum of full_bias_ns and bias_ns (when
1284 * available) from this value.
destradaa9f7c3732014-04-29 10:50:22 -07001285 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001286 * This GPS time is expected to be the best estimate of current GPS time
1287 * that GNSS receiver can achieve.
destradaa75843eb2014-07-17 14:04:50 -07001288 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001289 * Sub-nanosecond accuracy can be provided by means of the 'bias_ns' field.
destradaa9f7c3732014-04-29 10:50:22 -07001290 * The value contains the 'time uncertainty' in it.
destradaa75843eb2014-07-17 14:04:50 -07001291 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001292 * This field is mandatory.
destradaa9f7c3732014-04-29 10:50:22 -07001293 */
1294 int64_t time_ns;
1295
1296 /**
1297 * 1-Sigma uncertainty associated with the clock's time in nanoseconds.
1298 * The uncertainty is represented as an absolute (single sided) value.
1299 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001300 * If the data is available, 'flags' must contain
Lifu Tanga1ca5742016-02-16 17:42:13 -08001301 * GNSS_CLOCK_HAS_TIME_UNCERTAINTY. This value is effectively zero (it is
1302 * the reference local clock, by which all other times and time
1303 * uncertainties are measured.) (And thus this field can be not provided,
1304 * per GNSS_CLOCK_HAS_TIME_UNCERTAINTY flag, or provided & set to 0.)
destradaa9f7c3732014-04-29 10:50:22 -07001305 */
1306 double time_uncertainty_ns;
1307
1308 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001309 * The difference between hardware clock ('time' field) inside GPS receiver
1310 * and the true GPS time since 0000Z, January 6, 1980, in nanoseconds.
destradaa9f7c3732014-04-29 10:50:22 -07001311 *
destradaa75843eb2014-07-17 14:04:50 -07001312 * The sign of the value is defined by the following equation:
Lifu Tangd46260a2016-04-07 19:22:12 -07001313 * local estimate of GPS time = time_ns - (full_bias_ns + bias_ns)
destradaa75843eb2014-07-17 14:04:50 -07001314 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001315 * This value is mandatory if the receiver has estimated GPS time. If the
1316 * computed time is for a non-GPS constellation, the time offset of that
Lifu Tangd46260a2016-04-07 19:22:12 -07001317 * constellation to GPS has to be applied to fill this value. The error
1318 * estimate for the sum of this and the bias_ns is the bias_uncertainty_ns,
1319 * and the caller is responsible for using this uncertainty (it can be very
1320 * large before the GPS time has been solved for.) If the data is available
1321 * 'flags' must contain GNSS_CLOCK_HAS_FULL_BIAS.
destradaa75843eb2014-07-17 14:04:50 -07001322 */
1323 int64_t full_bias_ns;
1324
1325 /**
1326 * Sub-nanosecond bias.
Lifu Tangd46260a2016-04-07 19:22:12 -07001327 * The error estimate for the sum of this and the full_bias_ns is the
1328 * bias_uncertainty_ns
destradaa75843eb2014-07-17 14:04:50 -07001329 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001330 * If the data is available 'flags' must contain GNSS_CLOCK_HAS_BIAS. If GPS
1331 * has computed a position fix. This value is mandatory if the receiver has
1332 * estimated GPS time.
destradaa9f7c3732014-04-29 10:50:22 -07001333 */
1334 double bias_ns;
1335
1336 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001337 * 1-Sigma uncertainty associated with the local estimate of GPS time (clock
1338 * bias) in nanoseconds. The uncertainty is represented as an absolute
1339 * (single sided) value.
destradaa9f7c3732014-04-29 10:50:22 -07001340 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001341 * If the data is available 'flags' must contain
Lifu Tanga1ca5742016-02-16 17:42:13 -08001342 * GNSS_CLOCK_HAS_BIAS_UNCERTAINTY. This value is mandatory if the receiver
1343 * has estimated GPS time.
destradaa9f7c3732014-04-29 10:50:22 -07001344 */
1345 double bias_uncertainty_ns;
1346
1347 /**
1348 * The clock's drift in nanoseconds (per second).
Lifu Tanga1ca5742016-02-16 17:42:13 -08001349 *
1350 * A positive value means that the frequency is higher than the nominal
Lifu Tangd46260a2016-04-07 19:22:12 -07001351 * frequency, and that the (full_bias_ns + bias_ns) is growing more positive
1352 * over time.
destradaa9f7c3732014-04-29 10:50:22 -07001353 *
1354 * The value contains the 'drift uncertainty' in it.
Lifu Tanga1ca5742016-02-16 17:42:13 -08001355 * If the data is available 'flags' must contain GNSS_CLOCK_HAS_DRIFT.
destradaa00caa892015-04-09 18:41:46 -07001356 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001357 * This value is mandatory if the receiver has estimated GNSS time
destradaa9f7c3732014-04-29 10:50:22 -07001358 */
1359 double drift_nsps;
1360
1361 /**
1362 * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per second).
1363 * The uncertainty is represented as an absolute (single sided) value.
1364 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001365 * If the data is available 'flags' must contain
Lifu Tanga1ca5742016-02-16 17:42:13 -08001366 * GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY. If GPS has computed a position fix this
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001367 * field is mandatory and must be populated.
destradaa9f7c3732014-04-29 10:50:22 -07001368 */
1369 double drift_uncertainty_nsps;
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001370
1371 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001372 * When there are any discontinuities in the HW clock, this field is
1373 * mandatory.
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001374 *
1375 * A "discontinuity" is meant to cover the case of a switch from one source
1376 * of clock to another. A single free-running crystal oscillator (XO)
Lifu Tanga1ca5742016-02-16 17:42:13 -08001377 * should generally not have any discontinuities, and this can be set and
1378 * left at 0.
1379 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001380 * If, however, the time_ns value (HW clock) is derived from a composite of
Lifu Tanga1ca5742016-02-16 17:42:13 -08001381 * sources, that is not as smooth as a typical XO, or is otherwise stopped &
1382 * restarted, then this value shall be incremented each time a discontinuity
1383 * occurs. (E.g. this value may start at zero at device boot-up and
1384 * increment each time there is a change in clock continuity. In the
1385 * unlikely event that this value reaches full scale, rollover (not
1386 * clamping) is required, such that this value continues to change, during
1387 * subsequent discontinuity events.)
1388 *
1389 * While this number stays the same, between GnssClock reports, it can be
1390 * safely assumed that the time_ns value has been running continuously, e.g.
1391 * derived from a single, high quality clock (XO like, or better, that's
1392 * typically used during continuous GNSS signal sampling.)
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001393 *
1394 * It is expected, esp. during periods where there are few GNSS signals
1395 * available, that the HW clock be discontinuity-free as long as possible,
Lifu Tanga1ca5742016-02-16 17:42:13 -08001396 * as this avoids the need to use (waste) a GNSS measurement to fully
1397 * re-solve for the GPS clock bias and drift, when using the accompanying
1398 * measurements, from consecutive GnssData reports.
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001399 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001400 uint32_t hw_clock_discontinuity_count;
1401
Lifu Tang7e33bb22016-02-07 18:09:30 -08001402} GnssClock;
destradaa9f7c3732014-04-29 10:50:22 -07001403
1404/**
Lifu Tang7e33bb22016-02-07 18:09:30 -08001405 * Legacy struct to represent a GPS Measurement, it contains raw and computed
1406 * information.
1407 * Deprecated, to be removed in the next Android release.
1408 * Use GnssMeasurement instead.
1409 */
1410typedef struct {
1411 /** set to sizeof(GpsMeasurement) */
1412 size_t size;
1413 GpsMeasurementFlags flags;
1414 int8_t prn;
1415 double time_offset_ns;
1416 GpsMeasurementState state;
1417 int64_t received_gps_tow_ns;
1418 int64_t received_gps_tow_uncertainty_ns;
1419 double c_n0_dbhz;
1420 double pseudorange_rate_mps;
1421 double pseudorange_rate_uncertainty_mps;
1422 GpsAccumulatedDeltaRangeState accumulated_delta_range_state;
1423 double accumulated_delta_range_m;
1424 double accumulated_delta_range_uncertainty_m;
1425 double pseudorange_m;
1426 double pseudorange_uncertainty_m;
1427 double code_phase_chips;
1428 double code_phase_uncertainty_chips;
1429 float carrier_frequency_hz;
1430 int64_t carrier_cycles;
1431 double carrier_phase;
1432 double carrier_phase_uncertainty;
1433 GpsLossOfLock loss_of_lock;
1434 int32_t bit_number;
1435 int16_t time_from_last_bit_ms;
1436 double doppler_shift_hz;
1437 double doppler_shift_uncertainty_hz;
1438 GpsMultipathIndicator multipath_indicator;
1439 double snr_db;
1440 double elevation_deg;
1441 double elevation_uncertainty_deg;
1442 double azimuth_deg;
1443 double azimuth_uncertainty_deg;
1444 bool used_in_fix;
1445} GpsMeasurement;
1446
1447/**
1448 * Represents a GNSS Measurement, it contains raw and computed information.
Lifu Tang1d4183c2016-02-24 13:50:19 -08001449 *
1450 * Independence - All signal measurement information (e.g. sv_time,
1451 * pseudorange_rate, multipath_indicator) reported in this struct should be
1452 * based on GNSS signal measurements only. You may not synthesize measurements
1453 * by calculating or reporting expected measurements based on known or estimated
1454 * position, velocity, or time.
destradaa9f7c3732014-04-29 10:50:22 -07001455 */
1456typedef struct {
1457 /** set to sizeof(GpsMeasurement) */
1458 size_t size;
1459
1460 /** A set of flags indicating the validity of the fields in this data structure. */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001461 GnssMeasurementFlags flags;
destradaa9f7c3732014-04-29 10:50:22 -07001462
1463 /**
Lifu Tang7e33bb22016-02-07 18:09:30 -08001464 * Satellite vehicle ID number, as defined in GnssSvInfo::svid
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001465 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001466 */
Lifu Tang7e33bb22016-02-07 18:09:30 -08001467 int16_t svid;
destradaa9f7c3732014-04-29 10:50:22 -07001468
1469 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001470 * Defines the constellation of the given SV. Value should be one of those
1471 * GNSS_CONSTELLATION_* constants
1472 */
1473 GnssConstellationType constellation;
1474
1475 /**
destradaa75843eb2014-07-17 14:04:50 -07001476 * Time offset at which the measurement was taken in nanoseconds.
1477 * The reference receiver's time is specified by GpsData::clock::time_ns and should be
1478 * interpreted in the same way as indicated by GpsClock::type.
1479 *
destradaa9f7c3732014-04-29 10:50:22 -07001480 * The sign of time_offset_ns is given by the following equation:
1481 * measurement time = GpsClock::time_ns + time_offset_ns
1482 *
1483 * It provides an individual time-stamp for the measurement, and allows sub-nanosecond accuracy.
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001484 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001485 */
destradaa75843eb2014-07-17 14:04:50 -07001486 double time_offset_ns;
destradaa9f7c3732014-04-29 10:50:22 -07001487
1488 /**
destradaa75843eb2014-07-17 14:04:50 -07001489 * Per satellite sync state. It represents the current sync state for the associated satellite.
1490 * Based on the sync state, the 'received GPS tow' field should be interpreted accordingly.
destradaa9f7c3732014-04-29 10:50:22 -07001491 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001492 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001493 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001494 GnssMeasurementState state;
destradaa75843eb2014-07-17 14:04:50 -07001495
1496 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001497 * The received GNSS Time-of-Week at the measurement time, in nanoseconds.
Lifu Tang1d4183c2016-02-24 13:50:19 -08001498 * Ensure that this field is independent (see comment at top of
1499 * GnssMeasurement struct.)
destradaa75843eb2014-07-17 14:04:50 -07001500 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001501 * For GPS & QZSS, this is:
1502 * Received GPS Time-of-Week at the measurement time, in nanoseconds.
1503 * The value is relative to the beginning of the current GPS week.
Tsuwei Chena90cf192014-10-23 12:49:12 -07001504 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001505 * Given the highest sync state that can be achieved, per each satellite, valid range
1506 * for this field can be:
1507 * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN
1508 * C/A code lock : [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set
1509 * Bit sync : [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set
1510 * Subframe sync : [ 0 6s ] : GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set
1511 * TOW decoded : [ 0 1week ] : GNSS_MEASUREMENT_STATE_TOW_DECODED is set
destradaa00caa892015-04-09 18:41:46 -07001512 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001513 * Note well: if there is any ambiguity in integer millisecond,
1514 * GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS should be set accordingly, in the 'state' field.
1515 *
1516 * This value must be populated if 'state' != GNSS_MEASUREMENT_STATE_UNKNOWN.
1517 *
1518 * For Glonass, this is:
1519 * Received Glonass time of day, at the measurement time in nanoseconds.
1520 *
1521 * Given the highest sync state that can be achieved, per each satellite, valid range for
1522 * this field can be:
1523 * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN
1524 * C/A code lock : [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set
Lifu Tang3fc3bc82016-03-13 22:58:33 -07001525 * Symbol sync : [ 0 10ms ] : GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set
1526 * Bit sync : [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set
1527 * String sync : [ 0 2s ] : GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC is set
1528 * Time of day : [ 0 1day ] : GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED is set
Lifu Tanga1ca5742016-02-16 17:42:13 -08001529 *
1530 * For Beidou, this is:
1531 * Received Beidou time of week, at the measurement time in nanoseconds.
1532 *
1533 * Given the highest sync state that can be achieved, per each satellite, valid range for
1534 * this field can be:
1535 * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN
1536 * C/A code lock: [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set
1537 * Bit sync (D2): [ 0 2ms ] : GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC is set
1538 * Bit sync (D1): [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set
1539 * Subframe (D2): [ 0 0.6s ] : GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC is set
1540 * Subframe (D1): [ 0 6s ] : GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set
1541 * Time of week : [ 0 1week ] : GNSS_MEASUREMENT_STATE_TOW_DECODED is set
1542 *
1543 * For Galileo, this is:
1544 * Received Galileo time of week, at the measurement time in nanoseconds.
1545 *
1546 * E1BC code lock : [ 0 4ms ] : GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK is set
1547 * E1C 2nd code lock: [ 0 100ms ] :
1548 * GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK is set
1549 *
1550 * E1B page : [ 0 2s ] : GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC is set
Lifu Tang3fc3bc82016-03-13 22:58:33 -07001551 * Time of week: [ 0 1week ] : GNSS_MEASUREMENT_STATE_TOW_DECODED is set
Lifu Tanga1ca5742016-02-16 17:42:13 -08001552 *
1553 * For SBAS, this is:
1554 * Received SBAS time, at the measurement time in nanoseconds.
1555 *
1556 * Given the highest sync state that can be achieved, per each satellite,
1557 * valid range for this field can be:
1558 * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN
1559 * C/A code lock: [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set
1560 * Symbol sync : [ 0 2ms ] : GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set
1561 * Message : [ 0 1s ] : GNSS_MEASUREMENT_STATE_SBAS_SYNC is set
1562 */
1563 int64_t received_sv_time_in_ns;
destradaa9f7c3732014-04-29 10:50:22 -07001564
1565 /**
destradaa941c9282014-07-21 18:13:42 -07001566 * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds.
destradaa00caa892015-04-09 18:41:46 -07001567 *
1568 * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN.
destradaa941c9282014-07-21 18:13:42 -07001569 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001570 int64_t received_sv_time_uncertainty_in_ns;
destradaa941c9282014-07-21 18:13:42 -07001571
1572 /**
Lifu Tang1d4183c2016-02-24 13:50:19 -08001573 * Carrier-to-noise density in dB-Hz, typically in the range [0, 63].
1574 * It contains the measured C/N0 value for the signal at the antenna port.
destradaa9f7c3732014-04-29 10:50:22 -07001575 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001576 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001577 */
1578 double c_n0_dbhz;
1579
1580 /**
Lifu Tang1d4183c2016-02-24 13:50:19 -08001581 * Pseudorange rate at the timestamp in m/s. The correction of a given
1582 * Pseudorange Rate value includes corrections for receiver and satellite
1583 * clock frequency errors. Ensure that this field is independent (see
1584 * comment at top of GnssMeasurement struct.)
destradaa00caa892015-04-09 18:41:46 -07001585 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001586 * It is mandatory to provide the 'uncorrected' 'pseudorange rate', and provide GpsClock's
Lifu Tang3fc3bc82016-03-13 22:58:33 -07001587 * 'drift' field as well (When providing the uncorrected pseudorange rate, do not apply the
Lifu Tanga1ca5742016-02-16 17:42:13 -08001588 * corrections described above.)
destradaa9f7c3732014-04-29 10:50:22 -07001589 *
1590 * The value includes the 'pseudorange rate uncertainty' in it.
destradaa00caa892015-04-09 18:41:46 -07001591 * A positive 'uncorrected' value indicates that the SV is moving away from the receiver.
1592 *
destradaa357e6222015-04-14 16:30:21 -07001593 * The sign of the 'uncorrected' 'pseudorange rate' and its relation to the sign of 'doppler
destradaa00caa892015-04-09 18:41:46 -07001594 * shift' is given by the equation:
destradaa357e6222015-04-14 16:30:21 -07001595 * pseudorange rate = -k * doppler shift (where k is a constant)
destradaa9f7c3732014-04-29 10:50:22 -07001596 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001597 * This should be the most accurate pseudorange rate available, based on
1598 * fresh signal measurements from this channel.
1599 *
1600 * It is mandatory that this value be provided at typical carrier phase PRR
1601 * quality (few cm/sec per second of uncertainty, or better) - when signals
1602 * are sufficiently strong & stable, e.g. signals from a GPS simulator at >=
1603 * 35 dB-Hz.
destradaa9f7c3732014-04-29 10:50:22 -07001604 */
destradaa75843eb2014-07-17 14:04:50 -07001605 double pseudorange_rate_mps;
destradaa9f7c3732014-04-29 10:50:22 -07001606
1607 /**
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001608 * 1-Sigma uncertainty of the pseudorange_rate_mps.
destradaa9f7c3732014-04-29 10:50:22 -07001609 * The uncertainty is represented as an absolute (single sided) value.
1610 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001611 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001612 */
destradaa75843eb2014-07-17 14:04:50 -07001613 double pseudorange_rate_uncertainty_mps;
1614
1615 /**
1616 * Accumulated delta range's state. It indicates whether ADR is reset or there is a cycle slip
1617 * (indicating loss of lock).
1618 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001619 * This is a mandatory value.
destradaa75843eb2014-07-17 14:04:50 -07001620 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001621 GnssAccumulatedDeltaRangeState accumulated_delta_range_state;
destradaa9f7c3732014-04-29 10:50:22 -07001622
1623 /**
1624 * Accumulated delta range since the last channel reset in meters.
destradaa357e6222015-04-14 16:30:21 -07001625 * A positive value indicates that the SV is moving away from the receiver.
destradaa00caa892015-04-09 18:41:46 -07001626 *
destradaa357e6222015-04-14 16:30:21 -07001627 * The sign of the 'accumulated delta range' and its relation to the sign of 'carrier phase'
destradaa00caa892015-04-09 18:41:46 -07001628 * is given by the equation:
destradaa357e6222015-04-14 16:30:21 -07001629 * accumulated delta range = -k * carrier phase (where k is a constant)
destradaa00caa892015-04-09 18:41:46 -07001630 *
1631 * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN.
1632 * However, it is expected that the data is only accurate when:
1633 * 'accumulated delta range state' == GPS_ADR_STATE_VALID.
destradaa9f7c3732014-04-29 10:50:22 -07001634 */
1635 double accumulated_delta_range_m;
1636
1637 /**
1638 * 1-Sigma uncertainty of the accumulated delta range in meters.
destradaa00caa892015-04-09 18:41:46 -07001639 * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN.
destradaa9f7c3732014-04-29 10:50:22 -07001640 */
1641 double accumulated_delta_range_uncertainty_m;
1642
1643 /**
destradaa9f7c3732014-04-29 10:50:22 -07001644 * Carrier frequency at which codes and messages are modulated, it can be L1 or L2.
1645 * If the field is not set, the carrier frequency is assumed to be L1.
1646 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001647 * If the data is available, 'flags' must contain
1648 * GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY.
destradaa9f7c3732014-04-29 10:50:22 -07001649 */
1650 float carrier_frequency_hz;
1651
1652 /**
1653 * The number of full carrier cycles between the satellite and the receiver.
1654 * The reference frequency is given by the field 'carrier_frequency_hz'.
Lifu Tang3fc3bc82016-03-13 22:58:33 -07001655 * Indications of possible cycle slips and resets in the accumulation of
1656 * this value can be inferred from the accumulated_delta_range_state flags.
destradaa9f7c3732014-04-29 10:50:22 -07001657 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001658 * If the data is available, 'flags' must contain
1659 * GNSS_MEASUREMENT_HAS_CARRIER_CYCLES.
destradaa9f7c3732014-04-29 10:50:22 -07001660 */
1661 int64_t carrier_cycles;
1662
1663 /**
1664 * The RF phase detected by the receiver, in the range [0.0, 1.0].
1665 * This is usually the fractional part of the complete carrier phase measurement.
1666 *
1667 * The reference frequency is given by the field 'carrier_frequency_hz'.
1668 * The value contains the 'carrier-phase uncertainty' in it.
1669 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001670 * If the data is available, 'flags' must contain
1671 * GNSS_MEASUREMENT_HAS_CARRIER_PHASE.
destradaa9f7c3732014-04-29 10:50:22 -07001672 */
1673 double carrier_phase;
1674
1675 /**
1676 * 1-Sigma uncertainty of the carrier-phase.
Lifu Tanga1ca5742016-02-16 17:42:13 -08001677 * If the data is available, 'flags' must contain
1678 * GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY.
destradaa9f7c3732014-04-29 10:50:22 -07001679 */
1680 double carrier_phase_uncertainty;
1681
1682 /**
destradaa9f7c3732014-04-29 10:50:22 -07001683 * An enumeration that indicates the 'multipath' state of the event.
Lifu Tang1d4183c2016-02-24 13:50:19 -08001684 *
1685 * The multipath Indicator is intended to report the presence of overlapping
1686 * signals that manifest as distorted correlation peaks.
1687 *
1688 * - if there is a distorted correlation peak shape, report that multipath
1689 * is GNSS_MULTIPATH_INDICATOR_PRESENT.
1690 * - if there is not a distorted correlation peak shape, report
1691 * GNSS_MULTIPATH_INDICATOR_NOT_PRESENT
1692 * - if signals are too weak to discern this information, report
1693 * GNSS_MULTIPATH_INDICATOR_UNKNOWN
1694 *
1695 * Example: when doing the standardized overlapping Multipath Performance
1696 * test (3GPP TS 34.171) the Multipath indicator should report
1697 * GNSS_MULTIPATH_INDICATOR_PRESENT for those signals that are tracked, and
1698 * contain multipath, and GNSS_MULTIPATH_INDICATOR_NOT_PRESENT for those
1699 * signals that are tracked and do not contain multipath.
destradaa9f7c3732014-04-29 10:50:22 -07001700 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001701 GnssMultipathIndicator multipath_indicator;
destradaa9f7c3732014-04-29 10:50:22 -07001702
1703 /**
Lifu Tang1d4183c2016-02-24 13:50:19 -08001704 * Signal-to-noise ratio at correlator output in dB.
Lifu Tanga1ca5742016-02-16 17:42:13 -08001705 * If the data is available, 'flags' must contain GNSS_MEASUREMENT_HAS_SNR.
Lifu Tang1d4183c2016-02-24 13:50:19 -08001706 * This is the power ratio of the "correlation peak height above the
1707 * observed noise floor" to "the noise RMS".
destradaa9f7c3732014-04-29 10:50:22 -07001708 */
1709 double snr_db;
Lifu Tang7e33bb22016-02-07 18:09:30 -08001710} GnssMeasurement;
1711
1712/**
1713 * Legacy struct to represents a reading of GPS measurements.
1714 * Deprecated, to be removed in the next Android release.
1715 * Use GnssData instead.
1716 */
1717typedef struct {
1718 /** set to sizeof(GpsData) */
1719 size_t size;
1720 size_t measurement_count;
1721 GpsMeasurement measurements[GPS_MAX_MEASUREMENT];
1722
1723 /** The GPS clock time reading. */
1724 GpsClock clock;
1725} GpsData;
destradaa9f7c3732014-04-29 10:50:22 -07001726
Lifu Tanga1ca5742016-02-16 17:42:13 -08001727/**
1728 * Represents a reading of GNSS measurements. For devices where GnssSystemInfo's
1729 * year_of_hw is set to 2016+, it is mandatory that these be provided, on
1730 * request, when the GNSS receiver is searching/tracking signals.
1731 *
1732 * - Reporting of GPS constellation measurements is mandatory.
1733 * - Reporting of all tracked constellations are encouraged.
1734 */
destradaa9f7c3732014-04-29 10:50:22 -07001735typedef struct {
Lifu Tang7e33bb22016-02-07 18:09:30 -08001736 /** set to sizeof(GnssData) */
destradaa9f7c3732014-04-29 10:50:22 -07001737 size_t size;
1738
1739 /** Number of measurements. */
1740 size_t measurement_count;
1741
1742 /** The array of measurements. */
Lifu Tang7e33bb22016-02-07 18:09:30 -08001743 GnssMeasurement measurements[GNSS_MAX_MEASUREMENT];
destradaa9f7c3732014-04-29 10:50:22 -07001744
1745 /** The GPS clock time reading. */
Lifu Tang7e33bb22016-02-07 18:09:30 -08001746 GnssClock clock;
1747} GnssData;
destradaa9f7c3732014-04-29 10:50:22 -07001748
1749/**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001750 * The legacy callback for to report measurements from the HAL.
1751 *
1752 * This callback is deprecated, and will be removed in the next release. Use
1753 * gnss_measurement_callback() instead.
destradaa9f7c3732014-04-29 10:50:22 -07001754 *
1755 * Parameters:
1756 * data - A data structure containing the measurements.
1757 */
1758typedef void (*gps_measurement_callback) (GpsData* data);
1759
Lifu Tang7e33bb22016-02-07 18:09:30 -08001760/**
1761 * The callback for to report measurements from the HAL.
1762 *
1763 * Parameters:
1764 * data - A data structure containing the measurements.
1765 */
1766typedef void (*gnss_measurement_callback) (GnssData* data);
1767
destradaa9f7c3732014-04-29 10:50:22 -07001768typedef struct {
1769 /** set to sizeof(GpsMeasurementCallbacks) */
1770 size_t size;
1771 gps_measurement_callback measurement_callback;
Lifu Tang7e33bb22016-02-07 18:09:30 -08001772 gnss_measurement_callback gnss_measurement_callback;
destradaa9f7c3732014-04-29 10:50:22 -07001773} GpsMeasurementCallbacks;
1774
destradaa9f7c3732014-04-29 10:50:22 -07001775/**
1776 * Extended interface for GPS Measurements support.
1777 */
1778typedef struct {
1779 /** Set to sizeof(GpsMeasurementInterface) */
1780 size_t size;
1781
1782 /**
1783 * Initializes the interface and registers the callback routines with the HAL.
1784 * After a successful call to 'init' the HAL must begin to provide updates at its own phase.
1785 *
1786 * Status:
1787 * GPS_MEASUREMENT_OPERATION_SUCCESS
1788 * GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a
1789 * corresponding call to 'close'
1790 * GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL
1791 * will not generate any updates upon returning this error code.
1792 */
1793 int (*init) (GpsMeasurementCallbacks* callbacks);
1794
1795 /**
1796 * Stops updates from the HAL, and unregisters the callback routines.
1797 * After a call to stop, the previously registered callbacks must be considered invalid by the
1798 * HAL.
1799 * If stop is invoked without a previous 'init', this function should perform no work.
1800 */
1801 void (*close) ();
1802
1803} GpsMeasurementInterface;
1804
Lifu Tang7e33bb22016-02-07 18:09:30 -08001805/**
1806 * Legacy struct to represents a GPS navigation message (or a fragment of it).
1807 * Deprecated, to be removed in the next Android release.
1808 * Use GnssNavigationMessage instead.
1809 */
destradaa9f7c3732014-04-29 10:50:22 -07001810typedef struct {
1811 /** set to sizeof(GpsNavigationMessage) */
1812 size_t size;
Lifu Tang7e33bb22016-02-07 18:09:30 -08001813 int8_t prn;
1814 GpsNavigationMessageType type;
1815 NavigationMessageStatus status;
1816 int16_t message_id;
1817 int16_t submessage_id;
1818 size_t data_length;
1819 uint8_t* data;
1820} GpsNavigationMessage;
1821
1822/** Represents a GPS navigation message (or a fragment of it). */
1823typedef struct {
1824 /** set to sizeof(GnssNavigationMessage) */
1825 size_t size;
destradaa9f7c3732014-04-29 10:50:22 -07001826
1827 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001828 * Satellite vehicle ID number, as defined in GnssSvInfo::svid
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001829 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001830 */
Lifu Tang7e33bb22016-02-07 18:09:30 -08001831 int16_t svid;
destradaa9f7c3732014-04-29 10:50:22 -07001832
1833 /**
1834 * The type of message contained in the structure.
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001835 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001836 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001837 GnssNavigationMessageType type;
destradaa9f7c3732014-04-29 10:50:22 -07001838
1839 /**
Tsuwei Chena90cf192014-10-23 12:49:12 -07001840 * The status of the received navigation message.
1841 * No need to send any navigation message that contains words with parity error and cannot be
1842 * corrected.
1843 */
1844 NavigationMessageStatus status;
1845
1846 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001847 * Message identifier. It provides an index so the complete Navigation
1848 * Message can be assembled.
1849 *
1850 * - For GPS L1 C/A subframe 4 and 5, this value corresponds to the 'frame
1851 * id' of the navigation message, in the range of 1-25 (Subframe 1, 2, 3
1852 * does not contain a 'frame id' and this value can be set to -1.)
1853 *
1854 * - For Glonass L1 C/A, this refers to the frame ID, in the range of 1-5.
1855 *
1856 * - For BeiDou D1, this refers to the frame number in the range of 1-24
1857 *
1858 * - For Beidou D2, this refers to the frame number, in the range of 1-120
1859 *
Lifu Tang3fc3bc82016-03-13 22:58:33 -07001860 * - For Galileo F/NAV nominal frame structure, this refers to the subframe
1861 * number, in the range of 1-12
Lifu Tanga1ca5742016-02-16 17:42:13 -08001862 *
Lifu Tang3fc3bc82016-03-13 22:58:33 -07001863 * - For Galileo I/NAV nominal frame structure, this refers to the subframe
1864 * number in the range of 1-24
destradaa9f7c3732014-04-29 10:50:22 -07001865 */
1866 int16_t message_id;
1867
1868 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001869 * Sub-message identifier. If required by the message 'type', this value
1870 * contains a sub-index within the current message (or frame) that is being
1871 * transmitted.
1872 *
1873 * - For GPS L1 C/A, BeiDou D1 & BeiDou D2, the submessage id corresponds to
1874 * the subframe number of the navigation message, in the range of 1-5.
1875 *
1876 * - For Glonass L1 C/A, this refers to the String number, in the range from
1877 * 1-15
1878 *
Lifu Tang3fc3bc82016-03-13 22:58:33 -07001879 * - For Galileo F/NAV, this refers to the page type in the range 1-6
Lifu Tanga1ca5742016-02-16 17:42:13 -08001880 *
Lifu Tang3fc3bc82016-03-13 22:58:33 -07001881 * - For Galileo I/NAV, this refers to the word type in the range 1-10+
destradaa9f7c3732014-04-29 10:50:22 -07001882 */
1883 int16_t submessage_id;
1884
1885 /**
1886 * The length of the data (in bytes) contained in the current message.
1887 * If this value is different from zero, 'data' must point to an array of the same size.
destradaa69d5ea52014-07-31 16:34:09 -07001888 * e.g. for L1 C/A the size of the sub-frame will be 40 bytes (10 words, 30 bits/word).
destradaa9f7c3732014-04-29 10:50:22 -07001889 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001890 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001891 */
1892 size_t data_length;
1893
1894 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001895 * The data of the reported GPS message. The bytes (or words) specified
1896 * using big endian format (MSB first).
destradaa69d5ea52014-07-31 16:34:09 -07001897 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001898 * - For GPS L1 C/A, Beidou D1 & Beidou D2, each subframe contains 10 30-bit
1899 * words. Each word (30 bits) should be fit into the last 30 bits in a
1900 * 4-byte word (skip B31 and B32), with MSB first, for a total of 40
1901 * bytes, covering a time period of 6, 6, and 0.6 seconds, respectively.
1902 *
1903 * - For Glonass L1 C/A, each string contains 85 data bits, including the
1904 * checksum. These bits should be fit into 11 bytes, with MSB first (skip
1905 * B86-B88), covering a time period of 2 seconds.
1906 *
Lifu Tang3fc3bc82016-03-13 22:58:33 -07001907 * - For Galileo F/NAV, each word consists of 238-bit (sync & tail symbols
1908 * excluded). Each word should be fit into 30-bytes, with MSB first (skip
1909 * B239, B240), covering a time period of 10 seconds.
Lifu Tanga1ca5742016-02-16 17:42:13 -08001910 *
Lifu Tang3fc3bc82016-03-13 22:58:33 -07001911 * - For Galileo I/NAV, each page contains 2 page parts, even and odd, with
1912 * a total of 2x114 = 228 bits, (sync & tail excluded) that should be fit
1913 * into 29 bytes, with MSB first (skip B229-B232).
destradaa9f7c3732014-04-29 10:50:22 -07001914 */
1915 uint8_t* data;
1916
Lifu Tang7e33bb22016-02-07 18:09:30 -08001917} GnssNavigationMessage;
destradaa9f7c3732014-04-29 10:50:22 -07001918
1919/**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001920 * The legacy callback to report an available fragment of a GPS navigation
1921 * messages from the HAL.
1922 *
1923 * This callback is deprecated, and will be removed in the next release. Use
1924 * gnss_navigation_message_callback() instead.
destradaa9f7c3732014-04-29 10:50:22 -07001925 *
1926 * Parameters:
1927 * message - The GPS navigation submessage/subframe representation.
1928 */
1929typedef void (*gps_navigation_message_callback) (GpsNavigationMessage* message);
1930
Lifu Tang7e33bb22016-02-07 18:09:30 -08001931/**
1932 * The callback to report an available fragment of a GPS navigation messages from the HAL.
1933 *
1934 * Parameters:
1935 * message - The GPS navigation submessage/subframe representation.
1936 */
1937typedef void (*gnss_navigation_message_callback) (GnssNavigationMessage* message);
1938
destradaa9f7c3732014-04-29 10:50:22 -07001939typedef struct {
1940 /** set to sizeof(GpsNavigationMessageCallbacks) */
1941 size_t size;
1942 gps_navigation_message_callback navigation_message_callback;
Lifu Tang7e33bb22016-02-07 18:09:30 -08001943 gnss_navigation_message_callback gnss_navigation_message_callback;
destradaa9f7c3732014-04-29 10:50:22 -07001944} GpsNavigationMessageCallbacks;
1945
destradaa9f7c3732014-04-29 10:50:22 -07001946/**
1947 * Extended interface for GPS navigation message reporting support.
1948 */
1949typedef struct {
1950 /** Set to sizeof(GpsNavigationMessageInterface) */
1951 size_t size;
1952
1953 /**
1954 * Initializes the interface and registers the callback routines with the HAL.
1955 * After a successful call to 'init' the HAL must begin to provide updates as they become
1956 * available.
1957 *
1958 * Status:
1959 * GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS
1960 * GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT - if a callback has already been registered
1961 * without a corresponding call to 'close'.
1962 * GPS_NAVIGATION_MESSAGE_ERROR_GENERIC - if any other error occurred, it is expected that
1963 * the HAL will not generate any updates upon returning this error code.
1964 */
1965 int (*init) (GpsNavigationMessageCallbacks* callbacks);
1966
1967 /**
1968 * Stops updates from the HAL, and unregisters the callback routines.
1969 * After a call to stop, the previously registered callbacks must be considered invalid by the
1970 * HAL.
1971 * If stop is invoked without a previous 'init', this function should perform no work.
1972 */
1973 void (*close) ();
1974
1975} GpsNavigationMessageInterface;
1976
Tsuwei Chen167d31f2014-08-26 16:34:19 -07001977/**
1978 * Interface for passing GNSS configuration contents from platform to HAL.
1979 */
1980typedef struct {
1981 /** Set to sizeof(GnssConfigurationInterface) */
1982 size_t size;
1983
1984 /**
1985 * Deliver GNSS configuration contents to HAL.
1986 * Parameters:
1987 * config_data - a pointer to a char array which holds what usually is expected from
1988 file(/etc/gps.conf), i.e., a sequence of UTF8 strings separated by '\n'.
1989 * length - total number of UTF8 characters in configuraiton data.
1990 *
1991 * IMPORTANT:
1992 * GPS HAL should expect this function can be called multiple times. And it may be
1993 * called even when GpsLocationProvider is already constructed and enabled. GPS HAL
1994 * should maintain the existing requests for various callback regardless the change
1995 * in configuration data.
1996 */
1997 void (*configuration_update) (const char* config_data, int32_t length);
1998} GnssConfigurationInterface;
1999
Mike Lockwood9b0b1c32010-02-23 18:42:37 -05002000__END_DECLS
2001
2002#endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */
2003