blob: c8395595025cba234f27701039528494b8bd1d61 [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
29__BEGIN_DECLS
30
31/**
32 * The id of this module
33 */
34#define GPS_HARDWARE_MODULE_ID "gps"
35
36
37/** Milliseconds since January 1, 1970 */
38typedef int64_t GpsUtcTime;
39
40/** Maximum number of SVs for gps_sv_status_callback(). */
41#define GPS_MAX_SVS 32
Lifu Tang7e33bb22016-02-07 18:09:30 -080042/** Maximum number of SVs for gps_sv_status_callback(). */
43#define GNSS_MAX_SVS 64
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050044
destradaa9f7c3732014-04-29 10:50:22 -070045/** Maximum number of Measurements in gps_measurement_callback(). */
46#define GPS_MAX_MEASUREMENT 32
47
Lifu Tang7e33bb22016-02-07 18:09:30 -080048/** Maximum number of Measurements in gnss_measurement_callback(). */
49#define GNSS_MAX_MEASUREMENT 64
50
Mike Lockwoodb15879a2010-04-14 15:36:34 -040051/** Requested operational mode for GPS operation. */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050052typedef uint32_t GpsPositionMode;
Lifu Tanga1ca5742016-02-16 17:42:13 -080053/* IMPORTANT: Note that the following values must match
54 * constants in GpsLocationProvider.java. */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050055/** Mode for running GPS standalone (no assistance). */
56#define GPS_POSITION_MODE_STANDALONE 0
57/** AGPS MS-Based mode. */
58#define GPS_POSITION_MODE_MS_BASED 1
destradaa81534882015-04-28 13:10:56 -070059/**
60 * AGPS MS-Assisted mode. This mode is not maintained by the platform anymore.
Lifu Tangdf0fcf72015-10-27 14:58:25 -070061 * It is strongly recommended to use GPS_POSITION_MODE_MS_BASED instead.
destradaa81534882015-04-28 13:10:56 -070062 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050063#define GPS_POSITION_MODE_MS_ASSISTED 2
64
Mike Lockwoodb15879a2010-04-14 15:36:34 -040065/** Requested recurrence mode for GPS operation. */
66typedef uint32_t GpsPositionRecurrence;
Lifu Tanga1ca5742016-02-16 17:42:13 -080067/* IMPORTANT: Note that the following values must match
68 * constants in GpsLocationProvider.java. */
Mike Lockwoodb15879a2010-04-14 15:36:34 -040069/** Receive GPS fixes on a recurring basis at a specified period. */
70#define GPS_POSITION_RECURRENCE_PERIODIC 0
71/** Request a single shot GPS fix. */
72#define GPS_POSITION_RECURRENCE_SINGLE 1
73
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050074/** GPS status event values. */
75typedef uint16_t GpsStatusValue;
Lifu Tanga1ca5742016-02-16 17:42:13 -080076/* IMPORTANT: Note that the following values must match
77 * constants in GpsLocationProvider.java. */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050078/** GPS status unknown. */
79#define GPS_STATUS_NONE 0
80/** GPS has begun navigating. */
81#define GPS_STATUS_SESSION_BEGIN 1
82/** GPS has stopped navigating. */
83#define GPS_STATUS_SESSION_END 2
84/** GPS has powered on but is not navigating. */
85#define GPS_STATUS_ENGINE_ON 3
86/** GPS is powered off. */
87#define GPS_STATUS_ENGINE_OFF 4
88
89/** Flags to indicate which values are valid in a GpsLocation. */
90typedef uint16_t GpsLocationFlags;
Lifu Tanga1ca5742016-02-16 17:42:13 -080091/* IMPORTANT: Note that the following values must match
92 * constants in GpsLocationProvider.java. */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -050093/** GpsLocation has valid latitude and longitude. */
94#define GPS_LOCATION_HAS_LAT_LONG 0x0001
95/** GpsLocation has valid altitude. */
96#define GPS_LOCATION_HAS_ALTITUDE 0x0002
97/** GpsLocation has valid speed. */
98#define GPS_LOCATION_HAS_SPEED 0x0004
99/** GpsLocation has valid bearing. */
100#define GPS_LOCATION_HAS_BEARING 0x0008
101/** GpsLocation has valid accuracy. */
102#define GPS_LOCATION_HAS_ACCURACY 0x0010
103
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400104/** Flags for the gps_set_capabilities callback. */
105
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700106/**
107 * GPS HAL schedules fixes for GPS_POSITION_RECURRENCE_PERIODIC mode. If this is
108 * not set, then the framework will use 1000ms for min_interval and will start
109 * and call start() and stop() to schedule the GPS.
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400110 */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700111#define GPS_CAPABILITY_SCHEDULING (1 << 0)
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400112/** GPS supports MS-Based AGPS mode */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700113#define GPS_CAPABILITY_MSB (1 << 1)
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400114/** GPS supports MS-Assisted AGPS mode */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700115#define GPS_CAPABILITY_MSA (1 << 2)
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400116/** GPS supports single-shot fixes */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700117#define GPS_CAPABILITY_SINGLE_SHOT (1 << 3)
Mike Lockwood8aac5912011-06-29 15:10:36 -0400118/** GPS supports on demand time injection */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700119#define GPS_CAPABILITY_ON_DEMAND_TIME (1 << 4)
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -0800120/** GPS supports Geofencing */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700121#define GPS_CAPABILITY_GEOFENCING (1 << 5)
Lifu Tang1d4183c2016-02-24 13:50:19 -0800122/** GPS supports Measurements. */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700123#define GPS_CAPABILITY_MEASUREMENTS (1 << 6)
destradaa69d5ea52014-07-31 16:34:09 -0700124/** GPS supports Navigation Messages */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700125#define GPS_CAPABILITY_NAV_MESSAGES (1 << 7)
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400126
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700127/**
128 * Flags used to specify which aiding data to delete when calling
129 * delete_aiding_data().
130 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500131typedef uint16_t GpsAidingData;
Lifu Tanga1ca5742016-02-16 17:42:13 -0800132/* IMPORTANT: Note that the following values must match
133 * constants in GpsLocationProvider.java. */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500134#define GPS_DELETE_EPHEMERIS 0x0001
135#define GPS_DELETE_ALMANAC 0x0002
136#define GPS_DELETE_POSITION 0x0004
137#define GPS_DELETE_TIME 0x0008
138#define GPS_DELETE_IONO 0x0010
139#define GPS_DELETE_UTC 0x0020
140#define GPS_DELETE_HEALTH 0x0040
141#define GPS_DELETE_SVDIR 0x0080
142#define GPS_DELETE_SVSTEER 0x0100
143#define GPS_DELETE_SADATA 0x0200
144#define GPS_DELETE_RTI 0x0400
145#define GPS_DELETE_CELLDB_INFO 0x8000
146#define GPS_DELETE_ALL 0xFFFF
147
148/** AGPS type */
149typedef uint16_t AGpsType;
150#define AGPS_TYPE_SUPL 1
151#define AGPS_TYPE_C2K 2
152
Miguel Torroja5f404f52010-07-27 06:34:15 +0200153typedef uint16_t AGpsSetIDType;
154#define AGPS_SETID_TYPE_NONE 0
155#define AGPS_SETID_TYPE_IMSI 1
156#define AGPS_SETID_TYPE_MSISDN 2
157
destradaaf48cc672014-06-05 11:07:09 -0700158typedef uint16_t ApnIpType;
159#define APN_IP_INVALID 0
160#define APN_IP_IPV4 1
161#define APN_IP_IPV6 2
162#define APN_IP_IPV4V6 3
163
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500164/**
165 * String length constants
166 */
167#define GPS_NI_SHORT_STRING_MAXLEN 256
168#define GPS_NI_LONG_STRING_MAXLEN 2048
169
170/**
171 * GpsNiType constants
172 */
173typedef uint32_t GpsNiType;
174#define GPS_NI_TYPE_VOICE 1
175#define GPS_NI_TYPE_UMTS_SUPL 2
176#define GPS_NI_TYPE_UMTS_CTRL_PLANE 3
177
178/**
179 * GpsNiNotifyFlags constants
180 */
181typedef uint32_t GpsNiNotifyFlags;
182/** NI requires notification */
183#define GPS_NI_NEED_NOTIFY 0x0001
184/** NI requires verification */
185#define GPS_NI_NEED_VERIFY 0x0002
186/** NI requires privacy override, no notification/minimal trace */
187#define GPS_NI_PRIVACY_OVERRIDE 0x0004
188
189/**
190 * GPS NI responses, used to define the response in
191 * NI structures
192 */
193typedef int GpsUserResponseType;
194#define GPS_NI_RESPONSE_ACCEPT 1
195#define GPS_NI_RESPONSE_DENY 2
196#define GPS_NI_RESPONSE_NORESP 3
197
198/**
199 * NI data encoding scheme
200 */
201typedef int GpsNiEncodingType;
202#define GPS_ENC_NONE 0
203#define GPS_ENC_SUPL_GSM_DEFAULT 1
204#define GPS_ENC_SUPL_UTF8 2
205#define GPS_ENC_SUPL_UCS2 3
206#define GPS_ENC_UNKNOWN -1
207
208/** AGPS status event values. */
209typedef uint16_t AGpsStatusValue;
210/** GPS requests data connection for AGPS. */
211#define GPS_REQUEST_AGPS_DATA_CONN 1
212/** GPS releases the AGPS data connection. */
213#define GPS_RELEASE_AGPS_DATA_CONN 2
214/** AGPS data connection initiated */
215#define GPS_AGPS_DATA_CONNECTED 3
216/** AGPS data connection completed */
217#define GPS_AGPS_DATA_CONN_DONE 4
218/** AGPS data connection failed */
219#define GPS_AGPS_DATA_CONN_FAILED 5
220
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700221typedef uint16_t AGpsRefLocationType;
Miguel Torroja5f404f52010-07-27 06:34:15 +0200222#define AGPS_REF_LOCATION_TYPE_GSM_CELLID 1
223#define AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2
224#define AGPS_REG_LOCATION_TYPE_MAC 3
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700225#define AGPS_REF_LOCATION_TYPE_LTE_CELLID 4
Miguel Torroja5f404f52010-07-27 06:34:15 +0200226
Mike Lockwood455e83b2010-10-11 06:16:57 -0400227/** Network types for update_network_state "type" parameter */
228#define AGPS_RIL_NETWORK_TYPE_MOBILE 0
229#define AGPS_RIL_NETWORK_TYPE_WIFI 1
230#define AGPS_RIL_NETWORK_TYPE_MOBILE_MMS 2
231#define AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL 3
232#define AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN 4
233#define AGPS_RIL_NETWORK_TTYPE_MOBILE_HIPRI 5
234#define AGPS_RIL_NETWORK_TTYPE_WIMAX 6
235
Lifu Tanga1ca5742016-02-16 17:42:13 -0800236/* The following typedef together with its constants below are deprecated, and
237 * will be removed in the next release. */
destradaa9f7c3732014-04-29 10:50:22 -0700238typedef uint16_t GpsClockFlags;
destradaa9f7c3732014-04-29 10:50:22 -0700239#define GPS_CLOCK_HAS_LEAP_SECOND (1<<0)
destradaa9f7c3732014-04-29 10:50:22 -0700240#define GPS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1)
destradaa75843eb2014-07-17 14:04:50 -0700241#define GPS_CLOCK_HAS_FULL_BIAS (1<<2)
destradaa75843eb2014-07-17 14:04:50 -0700242#define GPS_CLOCK_HAS_BIAS (1<<3)
destradaa75843eb2014-07-17 14:04:50 -0700243#define GPS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4)
destradaa75843eb2014-07-17 14:04:50 -0700244#define GPS_CLOCK_HAS_DRIFT (1<<5)
destradaa75843eb2014-07-17 14:04:50 -0700245#define GPS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6)
246
247/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800248 * Flags to indicate what fields in GnssClock are valid.
destradaa75843eb2014-07-17 14:04:50 -0700249 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800250typedef uint16_t GnssClockFlags;
251/** A valid 'leap second' is stored in the data structure. */
252#define GNSS_CLOCK_HAS_LEAP_SECOND (1<<0)
253/** A valid 'time uncertainty' is stored in the data structure. */
254#define GNSS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1)
255/** A valid 'full bias' is stored in the data structure. */
256#define GNSS_CLOCK_HAS_FULL_BIAS (1<<2)
257/** A valid 'bias' is stored in the data structure. */
258#define GNSS_CLOCK_HAS_BIAS (1<<3)
259/** A valid 'bias uncertainty' is stored in the data structure. */
260#define GNSS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4)
261/** A valid 'drift' is stored in the data structure. */
262#define GNSS_CLOCK_HAS_DRIFT (1<<5)
263/** A valid 'drift uncertainty' is stored in the data structure. */
264#define GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6)
265
266/* The following typedef together with its constants below are deprecated, and
267 * will be removed in the next release. */
destradaa75843eb2014-07-17 14:04:50 -0700268typedef uint8_t GpsClockType;
destradaa75843eb2014-07-17 14:04:50 -0700269#define GPS_CLOCK_TYPE_UNKNOWN 0
destradaa75843eb2014-07-17 14:04:50 -0700270#define GPS_CLOCK_TYPE_LOCAL_HW_TIME 1
destradaa75843eb2014-07-17 14:04:50 -0700271#define GPS_CLOCK_TYPE_GPS_TIME 2
destradaa9f7c3732014-04-29 10:50:22 -0700272
Lifu Tanga1ca5742016-02-16 17:42:13 -0800273/* The following typedef together with its constants below are deprecated, and
274 * will be removed in the next release. */
destradaa9f7c3732014-04-29 10:50:22 -0700275typedef uint32_t GpsMeasurementFlags;
destradaa9f7c3732014-04-29 10:50:22 -0700276#define GPS_MEASUREMENT_HAS_SNR (1<<0)
destradaa9f7c3732014-04-29 10:50:22 -0700277#define GPS_MEASUREMENT_HAS_ELEVATION (1<<1)
destradaa9f7c3732014-04-29 10:50:22 -0700278#define GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY (1<<2)
destradaa9f7c3732014-04-29 10:50:22 -0700279#define GPS_MEASUREMENT_HAS_AZIMUTH (1<<3)
destradaa9f7c3732014-04-29 10:50:22 -0700280#define GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY (1<<4)
destradaa9f7c3732014-04-29 10:50:22 -0700281#define GPS_MEASUREMENT_HAS_PSEUDORANGE (1<<5)
destradaa9f7c3732014-04-29 10:50:22 -0700282#define GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY (1<<6)
destradaa9f7c3732014-04-29 10:50:22 -0700283#define GPS_MEASUREMENT_HAS_CODE_PHASE (1<<7)
destradaa9f7c3732014-04-29 10:50:22 -0700284#define GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY (1<<8)
destradaa9f7c3732014-04-29 10:50:22 -0700285#define GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9)
destradaa9f7c3732014-04-29 10:50:22 -0700286#define GPS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10)
destradaa9f7c3732014-04-29 10:50:22 -0700287#define GPS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11)
destradaa9f7c3732014-04-29 10:50:22 -0700288#define GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12)
destradaa9f7c3732014-04-29 10:50:22 -0700289#define GPS_MEASUREMENT_HAS_BIT_NUMBER (1<<13)
destradaa9f7c3732014-04-29 10:50:22 -0700290#define GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT (1<<14)
destradaa9f7c3732014-04-29 10:50:22 -0700291#define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT (1<<15)
destradaa9f7c3732014-04-29 10:50:22 -0700292#define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY (1<<16)
destradaa9f7c3732014-04-29 10:50:22 -0700293#define GPS_MEASUREMENT_HAS_USED_IN_FIX (1<<17)
destradaa00caa892015-04-09 18:41:46 -0700294#define GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE (1<<18)
destradaa9f7c3732014-04-29 10:50:22 -0700295
296/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800297 * Flags to indicate what fields in GnssMeasurement are valid.
destradaa9f7c3732014-04-29 10:50:22 -0700298 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800299typedef uint32_t GnssMeasurementFlags;
300/** A valid 'snr' is stored in the data structure. */
301#define GNSS_MEASUREMENT_HAS_SNR (1<<0)
Lifu Tanga1ca5742016-02-16 17:42:13 -0800302/** A valid 'carrier frequency' is stored in the data structure. */
303#define GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9)
304/** A valid 'carrier cycles' is stored in the data structure. */
305#define GNSS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10)
306/** A valid 'carrier phase' is stored in the data structure. */
307#define GNSS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11)
308/** A valid 'carrier phase uncertainty' is stored in the data structure. */
309#define GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12)
Lifu Tanga1ca5742016-02-16 17:42:13 -0800310/**
311 * The value of 'pseudorange rate' is uncorrected.
312 * This is a mandatory flag. See comments of
313 * GpsMeasurement::pseudorange_rate_mps for more details.
314 */
315#define GNSS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE (1<<18)
316
317/* The following typedef together with its constants below are deprecated, and
318 * will be removed in the next release. */
destradaa9f7c3732014-04-29 10:50:22 -0700319typedef uint8_t GpsLossOfLock;
destradaa9f7c3732014-04-29 10:50:22 -0700320#define GPS_LOSS_OF_LOCK_UNKNOWN 0
destradaa9f7c3732014-04-29 10:50:22 -0700321#define GPS_LOSS_OF_LOCK_OK 1
destradaa9f7c3732014-04-29 10:50:22 -0700322#define GPS_LOSS_OF_LOCK_CYCLE_SLIP 2
323
Lifu Tanga1ca5742016-02-16 17:42:13 -0800324/* The following typedef together with its constants below are deprecated, and
Lifu Tang1d4183c2016-02-24 13:50:19 -0800325 * will be removed in the next release. Use GnssMultipathIndicator instead.
326 */
destradaa9f7c3732014-04-29 10:50:22 -0700327typedef uint8_t GpsMultipathIndicator;
destradaa9f7c3732014-04-29 10:50:22 -0700328#define GPS_MULTIPATH_INDICATOR_UNKNOWN 0
destradaa9f7c3732014-04-29 10:50:22 -0700329#define GPS_MULTIPATH_INDICATOR_DETECTED 1
destradaa9f7c3732014-04-29 10:50:22 -0700330#define GPS_MULTIPATH_INDICATOR_NOT_USED 2
331
332/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800333 * Enumeration of available values for the GNSS Measurement's multipath
334 * indicator.
destradaa75843eb2014-07-17 14:04:50 -0700335 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800336typedef uint8_t GnssMultipathIndicator;
337/** The indicator is not available or unknown. */
338#define GNSS_MULTIPATH_INDICATOR_UNKNOWN 0
339/** The measurement is indicated to be affected by multipath. */
Lifu Tang1d4183c2016-02-24 13:50:19 -0800340#define GNSS_MULTIPATH_INDICATOR_PRESENT 1
Lifu Tanga1ca5742016-02-16 17:42:13 -0800341/** The measurement is indicated to be not affected by multipath. */
Lifu Tang1d4183c2016-02-24 13:50:19 -0800342#define GNSS_MULTIPATH_INDICATOR_NOT_PRESENT 2
Lifu Tanga1ca5742016-02-16 17:42:13 -0800343
344/* The following typedef together with its constants below are deprecated, and
345 * will be removed in the next release. */
destradaa75843eb2014-07-17 14:04:50 -0700346typedef uint16_t GpsMeasurementState;
347#define GPS_MEASUREMENT_STATE_UNKNOWN 0
348#define GPS_MEASUREMENT_STATE_CODE_LOCK (1<<0)
349#define GPS_MEASUREMENT_STATE_BIT_SYNC (1<<1)
350#define GPS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2)
351#define GPS_MEASUREMENT_STATE_TOW_DECODED (1<<3)
Tsuwei Chena90cf192014-10-23 12:49:12 -0700352#define GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4)
destradaa75843eb2014-07-17 14:04:50 -0700353
354/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800355 * Flags indicating the GNSS measurement state.
356 *
357 * The expected behavior here is for GPS HAL to set all the flags that applies.
358 * For example, if the state for a satellite is only C/A code locked and bit
359 * synchronized, and there is still millisecond ambiguity, the state should be
360 * set as:
361 *
362 * GNSS_MEASUREMENT_STATE_CODE_LOCK | GNSS_MEASUREMENT_STATE_BIT_SYNC |
363 * GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS
364 *
365 * If GNSS is still searching for a satellite, the corresponding state should be
366 * set to GNSS_MEASUREMENT_STATE_UNKNOWN(0).
destradaa75843eb2014-07-17 14:04:50 -0700367 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800368typedef uint16_t GnssMeasurementState;
369#define GNSS_MEASUREMENT_STATE_UNKNOWN 0
370#define GNSS_MEASUREMENT_STATE_CODE_LOCK (1<<0)
371#define GNSS_MEASUREMENT_STATE_BIT_SYNC (1<<1)
372#define GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2)
373#define GNSS_MEASUREMENT_STATE_TOW_DECODED (1<<3)
374#define GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4)
Lifu Tang1d4183c2016-02-24 13:50:19 -0800375#define GNSS_MEASUREMENT_STATE_SYMBOL_SYNC (1<<5)
Lifu Tanga1ca5742016-02-16 17:42:13 -0800376
377/* The following typedef together with its constants below are deprecated, and
378 * will be removed in the next release. */
destradaa75843eb2014-07-17 14:04:50 -0700379typedef uint16_t GpsAccumulatedDeltaRangeState;
380#define GPS_ADR_STATE_UNKNOWN 0
381#define GPS_ADR_STATE_VALID (1<<0)
382#define GPS_ADR_STATE_RESET (1<<1)
383#define GPS_ADR_STATE_CYCLE_SLIP (1<<2)
384
385/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800386 * Flags indicating the Accumulated Delta Range's states.
destradaa9f7c3732014-04-29 10:50:22 -0700387 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800388typedef uint16_t GnssAccumulatedDeltaRangeState;
389#define GNSS_ADR_STATE_UNKNOWN 0
390#define GNSS_ADR_STATE_VALID (1<<0)
391#define GNSS_ADR_STATE_RESET (1<<1)
392#define GNSS_ADR_STATE_CYCLE_SLIP (1<<2)
393
394/* The following typedef together with its constants below are deprecated, and
395 * will be removed in the next release. */
destradaa9f7c3732014-04-29 10:50:22 -0700396typedef uint8_t GpsNavigationMessageType;
destradaa9f7c3732014-04-29 10:50:22 -0700397#define GPS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0
destradaa9f7c3732014-04-29 10:50:22 -0700398#define GPS_NAVIGATION_MESSAGE_TYPE_L1CA 1
destradaa9f7c3732014-04-29 10:50:22 -0700399#define GPS_NAVIGATION_MESSAGE_TYPE_L2CNAV 2
destradaa9f7c3732014-04-29 10:50:22 -0700400#define GPS_NAVIGATION_MESSAGE_TYPE_L5CNAV 3
destradaa9f7c3732014-04-29 10:50:22 -0700401#define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2 4
402
Tsuwei Chena90cf192014-10-23 12:49:12 -0700403/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800404 * Enumeration of available values to indicate the GNSS Navigation message
405 * types.
406 *
407 * For convenience, first byte is the GnssConstellationType on which that signal
408 * is typically transmitted
409 */
410typedef int16_t GnssNavigationMessageType;
411
412#define GNSS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0
413/** GPS L1 C/A message contained in the structure. */
414#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L1CA 0x0101
415/** GPS L2-CNAV message contained in the structure. */
416#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L2CNAV 0x0102
417/** GPS L5-CNAV message contained in the structure. */
418#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L5CNAV 0x0103
419/** GPS CNAV-2 message contained in the structure. */
420#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_CNAV2 0x0104
421/** Glonass L1 CA message contained in the structure. */
422#define GNSS_NAVIGATION_MESSAGE_TYPE_GLO_L1CA 0x0301
423/** Beidou D1 message contained in the structure. */
424#define GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D1 0x0501
425/** Beidou D2 message contained in the structure. */
426#define GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D2 0x0502
427/** Galileo I/NAV message contained in the structure. */
428#define GNSS_NAVIGATION_MESSAGE_TYPE_GAL_I 0x0601
429/** Galileo F/NAV message contained in the structure. */
430#define GNSS_NAVIGATION_MESSAGE_TYPE_GAL_F 0x0602
431
432/**
Tsuwei Chena90cf192014-10-23 12:49:12 -0700433 * Status of Navigation Message
434 * When a message is received properly without any parity error in its navigation words, the
435 * status should be set to NAV_MESSAGE_STATUS_PARITY_PASSED. But if a message is received
436 * with words that failed parity check, but GPS is able to correct those words, the status
437 * should be set to NAV_MESSAGE_STATUS_PARITY_REBUILT.
438 * No need to send any navigation message that contains words with parity error and cannot be
439 * corrected.
440 */
441typedef uint16_t NavigationMessageStatus;
Lifu Tang1d4183c2016-02-24 13:50:19 -0800442#define NAV_MESSAGE_STATUS_UNKNOWN 0
Tsuwei Chena90cf192014-10-23 12:49:12 -0700443#define NAV_MESSAGE_STATUS_PARITY_PASSED (1<<0)
444#define NAV_MESSAGE_STATUS_PARITY_REBUILT (1<<1)
destradaa9f7c3732014-04-29 10:50:22 -0700445
Lifu Tang1d4183c2016-02-24 13:50:19 -0800446/* This constant is deprecated, and will be removed in the next release. */
447#define NAV_MESSAGE_STATUS_UNKONW 0
448
destradaa9f7c3732014-04-29 10:50:22 -0700449/**
Lifu Tang1d4183c2016-02-24 13:50:19 -0800450 * Flags that indicate information about the satellite
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700451 */
452typedef uint8_t GnssSvFlags;
453#define GNSS_SV_FLAGS_NONE 0
454#define GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA (1 << 0)
455#define GNSS_SV_FLAGS_HAS_ALMANAC_DATA (1 << 1)
456#define GNSS_SV_FLAGS_USED_IN_FIX (1 << 2)
457
458/**
459 * Constellation type of GnssSvInfo
460 */
461typedef uint8_t GnssConstellationType;
462#define GNSS_CONSTELLATION_UNKNOWN 0
463#define GNSS_CONSTELLATION_GPS 1
464#define GNSS_CONSTELLATION_SBAS 2
465#define GNSS_CONSTELLATION_GLONASS 3
466#define GNSS_CONSTELLATION_QZSS 4
467#define GNSS_CONSTELLATION_BEIDOU 5
468#define GNSS_CONSTELLATION_GALILEO 6
469
470/**
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500471 * Name for the GPS XTRA interface.
472 */
473#define GPS_XTRA_INTERFACE "gps-xtra"
474
475/**
476 * Name for the GPS DEBUG interface.
477 */
478#define GPS_DEBUG_INTERFACE "gps-debug"
479
480/**
481 * Name for the AGPS interface.
482 */
483#define AGPS_INTERFACE "agps"
484
485/**
destradaaa1f4c0a2013-09-13 15:45:03 -0700486 * Name of the Supl Certificate interface.
487 */
488#define SUPL_CERTIFICATE_INTERFACE "supl-certificate"
489
490/**
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500491 * Name for NI interface
492 */
493#define GPS_NI_INTERFACE "gps-ni"
494
Miguel Torroja5f404f52010-07-27 06:34:15 +0200495/**
496 * Name for the AGPS-RIL interface.
497 */
498#define AGPS_RIL_INTERFACE "agps_ril"
499
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -0800500/**
501 * Name for the GPS_Geofencing interface.
502 */
503#define GPS_GEOFENCING_INTERFACE "gps_geofencing"
504
destradaa9f7c3732014-04-29 10:50:22 -0700505/**
506 * Name of the GPS Measurements interface.
507 */
508#define GPS_MEASUREMENT_INTERFACE "gps_measurement"
509
510/**
511 * Name of the GPS navigation message interface.
512 */
Tsuwei Chen167d31f2014-08-26 16:34:19 -0700513#define GPS_NAVIGATION_MESSAGE_INTERFACE "gps_navigation_message"
514
515/**
516 * Name of the GNSS/GPS configuration interface.
517 */
518#define GNSS_CONFIGURATION_INTERFACE "gnss_configuration"
destradaa9f7c3732014-04-29 10:50:22 -0700519
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -0800520
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500521/** Represents a location. */
522typedef struct {
523 /** set to sizeof(GpsLocation) */
524 size_t size;
525 /** Contains GpsLocationFlags bits. */
526 uint16_t flags;
527 /** Represents latitude in degrees. */
528 double latitude;
529 /** Represents longitude in degrees. */
530 double longitude;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700531 /**
532 * Represents altitude in meters above the WGS 84 reference ellipsoid.
533 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500534 double altitude;
535 /** Represents speed in meters per second. */
536 float speed;
537 /** Represents heading in degrees. */
538 float bearing;
539 /** Represents expected accuracy in meters. */
540 float accuracy;
541 /** Timestamp for the location fix. */
542 GpsUtcTime timestamp;
543} GpsLocation;
544
545/** Represents the status. */
546typedef struct {
547 /** set to sizeof(GpsStatus) */
548 size_t size;
549 GpsStatusValue status;
550} GpsStatus;
551
Lifu Tanga1ca5742016-02-16 17:42:13 -0800552/**
553 * Legacy struct to represents SV information.
554 * Deprecated, to be removed in the next Android release.
555 * Use GnssSvInfo instead.
556 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500557typedef struct {
558 /** set to sizeof(GpsSvInfo) */
559 size_t size;
560 /** Pseudo-random number for the SV. */
561 int prn;
562 /** Signal to noise ratio. */
563 float snr;
564 /** Elevation of SV in degrees. */
565 float elevation;
566 /** Azimuth of SV in degrees. */
567 float azimuth;
568} GpsSvInfo;
569
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500570typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700571 /** set to sizeof(GnssSvInfo) */
572 size_t size;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500573
574 /**
Lifu Tang1d4183c2016-02-24 13:50:19 -0800575 * Pseudo-random number for the SV, or FCN/OSN number for Glonass. The
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700576 * distinction is made by looking at constellation field. Values should be
577 * in the range of:
578 *
579 * - GPS: 1-32
580 * - SBAS: 120-151, 183-192
Lifu Tang1d4183c2016-02-24 13:50:19 -0800581 * - GLONASS: Set the upper 8 bits, signed, to the frequency channel number
582 * (FCN) in the range from -7 to +6, if known, and -127, if
583 * unknown
584 * Set the lower 8 bits, signed, to the orbital slot number (OSN)
585 * in the range from 1-24, if known, or -127 if unknown
586 * At least one of the two (FCN & OSN) must be set to a known
587 * value
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700588 * - QZSS: 193-200
Lifu Tang1d4183c2016-02-24 13:50:19 -0800589 * - Galileo: 1-36
590 * - Beidou: 1-37
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500591 */
Lifu Tang7e33bb22016-02-07 18:09:30 -0800592 int16_t svid;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700593
Lifu Tanga1ca5742016-02-16 17:42:13 -0800594 /**
595 * Defines the constellation of the given SV. Value should be one of those
596 * GNSS_CONSTELLATION_* constants
597 */
598 GnssConstellationType constellation;
599
Lifu Tang1d4183c2016-02-24 13:50:19 -0800600 /**
601 * Carrier-to-noise density in dB-Hz, typically in the range [0, 63].
602 * It contains the measured C/N0 value for the signal at the antenna port.
603 *
604 * This is a mandatory value.
605 */
606 float c_n0_dbhz;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700607
608 /** Elevation of SV in degrees. */
609 float elevation;
610
611 /** Azimuth of SV in degrees. */
612 float azimuth;
613
614 /**
615 * Contains additional data about the given SV. Value should be one of those
616 * GNSS_SV_FLAGS_* constants
617 */
618 GnssSvFlags flags;
619
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700620} GnssSvInfo;
621
622/**
Lifu Tang7e33bb22016-02-07 18:09:30 -0800623 * Legacy struct to represents SV status.
624 * Deprecated, to be removed in the next Android release.
625 * Use GnssSvStatus instead.
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700626 */
627typedef struct {
628 /** set to sizeof(GpsSvStatus) */
629 size_t size;
Lifu Tang7e33bb22016-02-07 18:09:30 -0800630 int num_svs;
631 GpsSvInfo sv_list[GPS_MAX_SVS];
632 uint32_t ephemeris_mask;
633 uint32_t almanac_mask;
634 uint32_t used_in_fix_mask;
635} GpsSvStatus;
636
637/**
638 * Represents SV status.
639 */
640typedef struct {
641 /** set to sizeof(GnssSvStatus) */
642 size_t size;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700643
644 /** Number of GPS SVs currently visible, refers to the SVs stored in sv_list */
645 int num_svs;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700646 /**
647 * Pointer to an array of SVs information for all GNSS constellations,
648 * except GPS, which is reported using sv_list
649 */
Lifu Tang7e33bb22016-02-07 18:09:30 -0800650 GnssSvInfo gnss_sv_list[GNSS_MAX_SVS];
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700651
Lifu Tang7e33bb22016-02-07 18:09:30 -0800652} GnssSvStatus;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500653
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700654/* CellID for 2G, 3G and LTE, used in AGPS. */
Miguel Torroja5f404f52010-07-27 06:34:15 +0200655typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700656 AGpsRefLocationType type;
657 /** Mobile Country Code. */
Miguel Torroja5f404f52010-07-27 06:34:15 +0200658 uint16_t mcc;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700659 /** Mobile Network Code .*/
Miguel Torroja5f404f52010-07-27 06:34:15 +0200660 uint16_t mnc;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700661 /** Location Area Code in 2G, 3G and LTE. In 3G lac is discarded. In LTE,
662 * lac is populated with tac, to ensure that we don't break old clients that
663 * might rely in the old (wrong) behavior.
664 */
Miguel Torroja5f404f52010-07-27 06:34:15 +0200665 uint16_t lac;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700666 /** Cell id in 2G. Utran Cell id in 3G. Cell Global Id EUTRA in LTE. */
Miguel Torroja5f404f52010-07-27 06:34:15 +0200667 uint32_t cid;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700668 /** Tracking Area Code in LTE. */
669 uint16_t tac;
670 /** Physical Cell id in LTE (not used in 2G and 3G) */
671 uint16_t pcid;
Miguel Torroja5f404f52010-07-27 06:34:15 +0200672} AGpsRefLocationCellID;
673
674typedef struct {
675 uint8_t mac[6];
676} AGpsRefLocationMac;
677
678/** Represents ref locations */
679typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700680 AGpsRefLocationType type;
Miguel Torroja5f404f52010-07-27 06:34:15 +0200681 union {
682 AGpsRefLocationCellID cellID;
683 AGpsRefLocationMac mac;
684 } u;
685} AGpsRefLocation;
686
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700687/**
688 * Callback with location information. Can only be called from a thread created
689 * by create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700690 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500691typedef void (* gps_location_callback)(GpsLocation* location);
692
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700693/**
694 * Callback with status information. Can only be called from a thread created by
695 * create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700696 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500697typedef void (* gps_status_callback)(GpsStatus* status);
698
destradaa9f7c3732014-04-29 10:50:22 -0700699/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800700 * Legacy callback with SV status information.
destradaa9f7c3732014-04-29 10:50:22 -0700701 * Can only be called from a thread created by create_thread_cb.
Lifu Tanga1ca5742016-02-16 17:42:13 -0800702 *
703 * This callback is deprecated, and will be removed in the next release. Use
704 * gnss_sv_status_callback() instead.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700705 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500706typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info);
707
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700708/**
Lifu Tang7e33bb22016-02-07 18:09:30 -0800709 * Callback with SV status information.
710 * Can only be called from a thread created by create_thread_cb.
711 */
712typedef void (* gnss_sv_status_callback)(GnssSvStatus* sv_info);
713
714/**
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700715 * Callback for reporting NMEA sentences. Can only be called from a thread
716 * created by create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700717 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500718typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length);
719
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700720/**
721 * Callback to inform framework of the GPS engine's capabilities. Capability
722 * parameter is a bit field of GPS_CAPABILITY_* flags.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700723 */
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400724typedef void (* gps_set_capabilities)(uint32_t capabilities);
725
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700726/**
727 * Callback utility for acquiring the GPS wakelock. This can be used to prevent
728 * the CPU from suspending while handling GPS events.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700729 */
Mike Lockwoodd20bbae2010-04-07 09:04:25 -0400730typedef void (* gps_acquire_wakelock)();
731
732/** Callback utility for releasing the GPS wakelock. */
733typedef void (* gps_release_wakelock)();
734
Mike Lockwood8aac5912011-06-29 15:10:36 -0400735/** Callback for requesting NTP time */
736typedef void (* gps_request_utc_time)();
737
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700738/**
739 * Callback for creating a thread that can call into the Java framework code.
740 * This must be used to create any threads that report events up to the
741 * framework.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700742 */
743typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg);
744
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700745/**
746 * Provides information about how new the underlying GPS/GNSS hardware and
747 * software is.
748 *
749 * This information will be available for Android Test Applications. If a GPS
750 * HAL does not provide this information, it will be considered "2015 or
751 * earlier".
752 *
753 * If a GPS HAL does provide this information, then newer years will need to
754 * meet newer CTS standards. E.g. if the date are 2016 or above, then N+ level
755 * GpsMeasurement support will be verified.
756 */
757typedef struct {
Lifu Tanga1ca5742016-02-16 17:42:13 -0800758 /** Set to sizeof(GnssSystemInfo) */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700759 size_t size;
760 /* year in which the last update was made to the underlying hardware/firmware
761 * used to capture GNSS signals, e.g. 2016 */
762 uint16_t year_of_hw;
Lifu Tanga1ca5742016-02-16 17:42:13 -0800763} GnssSystemInfo;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700764
765/**
766 * Callback to inform framework of the engine's hardware version information.
767 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800768typedef void (*gnss_set_system_info)(const GnssSystemInfo* info);
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700769
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700770/** New GPS callback structure. */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500771typedef struct {
Mike Lockwoodd20bbae2010-04-07 09:04:25 -0400772 /** set to sizeof(GpsCallbacks) */
773 size_t size;
774 gps_location_callback location_cb;
775 gps_status_callback status_cb;
776 gps_sv_status_callback sv_status_cb;
777 gps_nmea_callback nmea_cb;
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400778 gps_set_capabilities set_capabilities_cb;
Mike Lockwoodd20bbae2010-04-07 09:04:25 -0400779 gps_acquire_wakelock acquire_wakelock_cb;
780 gps_release_wakelock release_wakelock_cb;
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700781 gps_create_thread create_thread_cb;
Mike Lockwood8aac5912011-06-29 15:10:36 -0400782 gps_request_utc_time request_utc_time_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500783
Lifu Tanga1ca5742016-02-16 17:42:13 -0800784 gnss_set_system_info set_system_info_cb;
Lifu Tang7e33bb22016-02-07 18:09:30 -0800785 gnss_sv_status_callback gnss_sv_status_cb;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700786} GpsCallbacks;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500787
788/** Represents the standard GPS interface. */
789typedef struct {
790 /** set to sizeof(GpsInterface) */
791 size_t size;
792 /**
793 * Opens the interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -0700794 * to the implementation of this interface.
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500795 */
796 int (*init)( GpsCallbacks* callbacks );
797
798 /** Starts navigating. */
799 int (*start)( void );
800
801 /** Stops navigating. */
802 int (*stop)( void );
803
804 /** Closes the interface. */
805 void (*cleanup)( void );
806
807 /** Injects the current time. */
808 int (*inject_time)(GpsUtcTime time, int64_t timeReference,
809 int uncertainty);
810
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700811 /**
812 * Injects current location from another location provider (typically cell
813 * ID). Latitude and longitude are measured in degrees expected accuracy is
814 * measured in meters
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500815 */
816 int (*inject_location)(double latitude, double longitude, float accuracy);
817
818 /**
819 * Specifies that the next call to start will not use the
820 * information defined in the flags. GPS_DELETE_ALL is passed for
821 * a cold start.
822 */
823 void (*delete_aiding_data)(GpsAidingData flags);
824
825 /**
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400826 * min_interval represents the time between fixes in milliseconds.
827 * preferred_accuracy represents the requested fix accuracy in meters.
828 * preferred_time represents the requested time to first fix in milliseconds.
destradaa81534882015-04-28 13:10:56 -0700829 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700830 * 'mode' parameter should be one of GPS_POSITION_MODE_MS_BASED
destradaa81534882015-04-28 13:10:56 -0700831 * or GPS_POSITION_MODE_STANDALONE.
832 * It is allowed by the platform (and it is recommended) to fallback to
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700833 * GPS_POSITION_MODE_MS_BASED if GPS_POSITION_MODE_MS_ASSISTED is passed in, and
destradaa81534882015-04-28 13:10:56 -0700834 * GPS_POSITION_MODE_MS_BASED is supported.
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500835 */
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400836 int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence,
837 uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time);
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500838
839 /** Get a pointer to extension information. */
840 const void* (*get_extension)(const char* name);
841} GpsInterface;
842
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700843/**
844 * Callback to request the client to download XTRA data. The client should
845 * download XTRA data and inject it by calling inject_xtra_data(). Can only be
846 * called from a thread created by create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700847 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500848typedef void (* gps_xtra_download_request)();
849
850/** Callback structure for the XTRA interface. */
851typedef struct {
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700852 gps_xtra_download_request download_request_cb;
853 gps_create_thread create_thread_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500854} GpsXtraCallbacks;
855
856/** Extended interface for XTRA support. */
857typedef struct {
858 /** set to sizeof(GpsXtraInterface) */
859 size_t size;
860 /**
861 * Opens the XTRA interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -0700862 * to the implementation of this interface.
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500863 */
864 int (*init)( GpsXtraCallbacks* callbacks );
865 /** Injects XTRA data into the GPS. */
866 int (*inject_xtra_data)( char* data, int length );
867} GpsXtraInterface;
868
869/** Extended interface for DEBUG support. */
870typedef struct {
871 /** set to sizeof(GpsDebugInterface) */
872 size_t size;
873
874 /**
875 * This function should return any information that the native
876 * implementation wishes to include in a bugreport.
877 */
878 size_t (*get_internal_state)(char* buffer, size_t bufferSize);
879} GpsDebugInterface;
880
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700881/*
882 * Represents the status of AGPS augmented to support IPv4 and IPv6.
883 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500884typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700885 /** set to sizeof(AGpsStatus) */
destradaaf48cc672014-06-05 11:07:09 -0700886 size_t size;
887
888 AGpsType type;
889 AGpsStatusValue status;
890
891 /**
892 * Must be set to a valid IPv4 address if the field 'addr' contains an IPv4
893 * address, or set to INADDR_NONE otherwise.
894 */
895 uint32_t ipaddr;
896
897 /**
898 * Must contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report.
899 * Any other value of addr.ss_family will be rejected.
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700900 */
destradaaf48cc672014-06-05 11:07:09 -0700901 struct sockaddr_storage addr;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700902} AGpsStatus;
destradaaf48cc672014-06-05 11:07:09 -0700903
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700904/**
905 * Callback with AGPS status information. Can only be called from a thread
906 * created by create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700907 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500908typedef void (* agps_status_callback)(AGpsStatus* status);
909
910/** Callback structure for the AGPS interface. */
911typedef struct {
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700912 agps_status_callback status_cb;
913 gps_create_thread create_thread_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500914} AGpsCallbacks;
915
destradaaf48cc672014-06-05 11:07:09 -0700916/**
917 * Extended interface for AGPS support, it is augmented to enable to pass
918 * extra APN data.
919 */
920typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700921 /** set to sizeof(AGpsInterface) */
destradaaf48cc672014-06-05 11:07:09 -0700922 size_t size;
923
924 /**
925 * Opens the AGPS interface and provides the callback routines to the
926 * implementation of this interface.
927 */
928 void (*init)(AGpsCallbacks* callbacks);
929 /**
930 * Deprecated.
931 * If the HAL supports AGpsInterface_v2 this API will not be used, see
932 * data_conn_open_with_apn_ip_type for more information.
933 */
934 int (*data_conn_open)(const char* apn);
935 /**
936 * Notifies that the AGPS data connection has been closed.
937 */
938 int (*data_conn_closed)();
939 /**
940 * Notifies that a data connection is not available for AGPS.
941 */
942 int (*data_conn_failed)();
943 /**
944 * Sets the hostname and port for the AGPS server.
945 */
946 int (*set_server)(AGpsType type, const char* hostname, int port);
947
948 /**
949 * Notifies that a data connection is available and sets the name of the
950 * APN, and its IP type, to be used for SUPL connections.
951 */
952 int (*data_conn_open_with_apn_ip_type)(
953 const char* apn,
954 ApnIpType apnIpType);
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700955} AGpsInterface;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500956
destradaaa1f4c0a2013-09-13 15:45:03 -0700957/** Error codes associated with certificate operations */
958#define AGPS_CERTIFICATE_OPERATION_SUCCESS 0
959#define AGPS_CERTIFICATE_ERROR_GENERIC -100
960#define AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES -101
961
962/** A data structure that represents an X.509 certificate using DER encoding */
963typedef struct {
964 size_t length;
965 u_char* data;
966} DerEncodedCertificate;
967
968/**
969 * A type definition for SHA1 Fingerprints used to identify X.509 Certificates
970 * The Fingerprint is a digest of the DER Certificate that uniquely identifies it.
971 */
972typedef struct {
973 u_char data[20];
974} Sha1CertificateFingerprint;
975
destradaa9f7c3732014-04-29 10:50:22 -0700976/** AGPS Interface to handle SUPL certificate operations */
destradaaa1f4c0a2013-09-13 15:45:03 -0700977typedef struct {
978 /** set to sizeof(SuplCertificateInterface) */
979 size_t size;
980
981 /**
982 * Installs a set of Certificates used for SUPL connections to the AGPS server.
983 * If needed the HAL should find out internally any certificates that need to be removed to
984 * accommodate the certificates to install.
985 * The certificates installed represent a full set of valid certificates needed to connect to
986 * AGPS SUPL servers.
987 * The list of certificates is required, and all must be available at the same time, when trying
988 * to establish a connection with the AGPS Server.
989 *
990 * Parameters:
991 * certificates - A pointer to an array of DER encoded certificates that are need to be
992 * installed in the HAL.
993 * length - The number of certificates to install.
994 * Returns:
995 * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully
996 * AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES if the HAL cannot store the number of
997 * certificates attempted to be installed, the state of the certificates stored should
998 * remain the same as before on this error case.
999 *
1000 * IMPORTANT:
1001 * If needed the HAL should find out internally the set of certificates that need to be
1002 * removed to accommodate the certificates to install.
1003 */
1004 int (*install_certificates) ( const DerEncodedCertificate* certificates, size_t length );
1005
1006 /**
1007 * Notifies the HAL that a list of certificates used for SUPL connections are revoked. It is
1008 * expected that the given set of certificates is removed from the internal store of the HAL.
1009 *
1010 * Parameters:
1011 * fingerprints - A pointer to an array of SHA1 Fingerprints to identify the set of
1012 * certificates to revoke.
1013 * length - The number of fingerprints provided.
1014 * Returns:
1015 * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully.
1016 *
1017 * IMPORTANT:
1018 * If any of the certificates provided (through its fingerprint) is not known by the HAL,
1019 * it should be ignored and continue revoking/deleting the rest of them.
1020 */
1021 int (*revoke_certificates) ( const Sha1CertificateFingerprint* fingerprints, size_t length );
destradaa7ddd4d72013-11-07 13:47:59 -08001022} SuplCertificateInterface;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -05001023
1024/** Represents an NI request */
1025typedef struct {
1026 /** set to sizeof(GpsNiNotification) */
1027 size_t size;
1028
1029 /**
1030 * An ID generated by HAL to associate NI notifications and UI
1031 * responses
1032 */
1033 int notification_id;
1034
1035 /**
1036 * An NI type used to distinguish different categories of NI
1037 * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ...
1038 */
1039 GpsNiType ni_type;
1040
1041 /**
1042 * Notification/verification options, combinations of GpsNiNotifyFlags constants
1043 */
1044 GpsNiNotifyFlags notify_flags;
1045
1046 /**
1047 * Timeout period to wait for user response.
1048 * Set to 0 for no time out limit.
1049 */
1050 int timeout;
1051
1052 /**
1053 * Default response when time out.
1054 */
1055 GpsUserResponseType default_response;
1056
1057 /**
1058 * Requestor ID
1059 */
1060 char requestor_id[GPS_NI_SHORT_STRING_MAXLEN];
1061
1062 /**
1063 * Notification message. It can also be used to store client_id in some cases
1064 */
1065 char text[GPS_NI_LONG_STRING_MAXLEN];
1066
1067 /**
1068 * Client name decoding scheme
1069 */
1070 GpsNiEncodingType requestor_id_encoding;
1071
1072 /**
1073 * Client name decoding scheme
1074 */
1075 GpsNiEncodingType text_encoding;
1076
1077 /**
1078 * A pointer to extra data. Format:
1079 * key_1 = value_1
1080 * key_2 = value_2
1081 */
1082 char extras[GPS_NI_LONG_STRING_MAXLEN];
1083
1084} GpsNiNotification;
1085
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001086/**
1087 * Callback with NI notification. Can only be called from a thread created by
1088 * create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -07001089 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -05001090typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification);
1091
1092/** GPS NI callback structure. */
1093typedef struct
1094{
Mike Lockwood4453b5b2010-06-20 14:23:10 -07001095 /**
1096 * Sends the notification request from HAL to GPSLocationProvider.
1097 */
1098 gps_ni_notify_callback notify_cb;
1099 gps_create_thread create_thread_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -05001100} GpsNiCallbacks;
1101
1102/**
1103 * Extended interface for Network-initiated (NI) support.
1104 */
1105typedef struct
1106{
1107 /** set to sizeof(GpsNiInterface) */
1108 size_t size;
1109
1110 /** Registers the callbacks for HAL to use. */
1111 void (*init) (GpsNiCallbacks *callbacks);
1112
1113 /** Sends a response to HAL. */
1114 void (*respond) (int notif_id, GpsUserResponseType user_response);
1115} GpsNiInterface;
1116
1117struct gps_device_t {
1118 struct hw_device_t common;
1119
1120 /**
1121 * Set the provided lights to the provided values.
1122 *
1123 * Returns: 0 on succes, error code on failure.
1124 */
1125 const GpsInterface* (*get_gps_interface)(struct gps_device_t* dev);
1126};
1127
Miguel Torroja5f404f52010-07-27 06:34:15 +02001128#define AGPS_RIL_REQUEST_SETID_IMSI (1<<0L)
1129#define AGPS_RIL_REQUEST_SETID_MSISDN (1<<1L)
1130
1131#define AGPS_RIL_REQUEST_REFLOC_CELLID (1<<0L)
1132#define AGPS_RIL_REQUEST_REFLOC_MAC (1<<1L)
1133
1134typedef void (*agps_ril_request_set_id)(uint32_t flags);
1135typedef void (*agps_ril_request_ref_loc)(uint32_t flags);
1136
1137typedef struct {
1138 agps_ril_request_set_id request_setid;
1139 agps_ril_request_ref_loc request_refloc;
1140 gps_create_thread create_thread_cb;
1141} AGpsRilCallbacks;
1142
1143/** Extended interface for AGPS_RIL support. */
1144typedef struct {
1145 /** set to sizeof(AGpsRilInterface) */
1146 size_t size;
1147 /**
1148 * Opens the AGPS interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -07001149 * to the implementation of this interface.
Miguel Torroja5f404f52010-07-27 06:34:15 +02001150 */
1151 void (*init)( AGpsRilCallbacks* callbacks );
1152
1153 /**
1154 * Sets the reference location.
1155 */
1156 void (*set_ref_location) (const AGpsRefLocation *agps_reflocation, size_t sz_struct);
1157 /**
1158 * Sets the set ID.
1159 */
1160 void (*set_set_id) (AGpsSetIDType type, const char* setid);
1161
1162 /**
1163 * Send network initiated message.
1164 */
1165 void (*ni_message) (uint8_t *msg, size_t len);
Mike Lockwood455e83b2010-10-11 06:16:57 -04001166
1167 /**
1168 * Notify GPS of network status changes.
1169 * These parameters match values in the android.net.NetworkInfo class.
1170 */
1171 void (*update_network_state) (int connected, int type, int roaming, const char* extra_info);
Kevin Tangb82c2db2011-04-13 17:15:55 -07001172
1173 /**
1174 * Notify GPS of network status changes.
1175 * These parameters match values in the android.net.NetworkInfo class.
1176 */
1177 void (*update_network_availability) (int avaiable, const char* apn);
Miguel Torroja5f404f52010-07-27 06:34:15 +02001178} AGpsRilInterface;
1179
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001180/**
1181 * GPS Geofence.
1182 * There are 3 states associated with a Geofence: Inside, Outside, Unknown.
1183 * There are 3 transitions: ENTERED, EXITED, UNCERTAIN.
1184 *
1185 * An example state diagram with confidence level: 95% and Unknown time limit
1186 * set as 30 secs is shown below. (confidence level and Unknown time limit are
1187 * explained latter)
1188 * ____________________________
1189 * | Unknown (30 secs) |
1190 * """"""""""""""""""""""""""""
1191 * ^ | | ^
1192 * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN
1193 * | v v |
1194 * ________ EXITED _________
1195 * | Inside | -----------> | Outside |
1196 * | | <----------- | |
1197 * """""""" ENTERED """""""""
1198 *
1199 * Inside state: We are 95% confident that the user is inside the geofence.
1200 * Outside state: We are 95% confident that the user is outside the geofence
1201 * Unknown state: Rest of the time.
1202 *
1203 * The Unknown state is better explained with an example:
1204 *
1205 * __________
1206 * | c|
1207 * | ___ | _______
1208 * | |a| | | b |
1209 * | """ | """""""
1210 * | |
1211 * """"""""""
1212 * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy
1213 * circle reported by the GPS subsystem. Now with regard to "b", the system is
1214 * confident that the user is outside. But with regard to "a" is not confident
1215 * whether it is inside or outside the geofence. If the accuracy remains the
1216 * same for a sufficient period of time, the UNCERTAIN transition would be
1217 * triggered with the state set to Unknown. If the accuracy improves later, an
1218 * appropriate transition should be triggered. This "sufficient period of time"
1219 * is defined by the parameter in the add_geofence_area API.
1220 * In other words, Unknown state can be interpreted as a state in which the
1221 * GPS subsystem isn't confident enough that the user is either inside or
1222 * outside the Geofence. It moves to Unknown state only after the expiry of the
1223 * timeout.
1224 *
1225 * The geofence callback needs to be triggered for the ENTERED and EXITED
1226 * transitions, when the GPS system is confident that the user has entered
1227 * (Inside state) or exited (Outside state) the Geofence. An implementation
1228 * which uses a value of 95% as the confidence is recommended. The callback
1229 * should be triggered only for the transitions requested by the
1230 * add_geofence_area call.
1231 *
1232 * Even though the diagram and explanation talks about states and transitions,
1233 * the callee is only interested in the transistions. The states are mentioned
1234 * here for illustrative purposes.
1235 *
1236 * Startup Scenario: When the device boots up, if an application adds geofences,
1237 * and then we get an accurate GPS location fix, it needs to trigger the
1238 * appropriate (ENTERED or EXITED) transition for every Geofence it knows about.
1239 * By default, all the Geofences will be in the Unknown state.
1240 *
1241 * When the GPS system is unavailable, gps_geofence_status_callback should be
1242 * called to inform the upper layers of the same. Similarly, when it becomes
1243 * available the callback should be called. This is a global state while the
1244 * UNKNOWN transition described above is per geofence.
1245 *
1246 * An important aspect to note is that users of this API (framework), will use
1247 * other subsystems like wifi, sensors, cell to handle Unknown case and
1248 * hopefully provide a definitive state transition to the third party
1249 * application. GPS Geofence will just be a signal indicating what the GPS
1250 * subsystem knows about the Geofence.
1251 *
1252 */
1253#define GPS_GEOFENCE_ENTERED (1<<0L)
1254#define GPS_GEOFENCE_EXITED (1<<1L)
1255#define GPS_GEOFENCE_UNCERTAIN (1<<2L)
1256
1257#define GPS_GEOFENCE_UNAVAILABLE (1<<0L)
1258#define GPS_GEOFENCE_AVAILABLE (1<<1L)
1259
Jaikumar Ganesh5824b402013-02-25 11:43:33 -08001260#define GPS_GEOFENCE_OPERATION_SUCCESS 0
1261#define GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES -100
1262#define GPS_GEOFENCE_ERROR_ID_EXISTS -101
1263#define GPS_GEOFENCE_ERROR_ID_UNKNOWN -102
1264#define GPS_GEOFENCE_ERROR_INVALID_TRANSITION -103
1265#define GPS_GEOFENCE_ERROR_GENERIC -149
1266
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001267/**
1268 * The callback associated with the geofence.
1269 * Parameters:
1270 * geofence_id - The id associated with the add_geofence_area.
1271 * location - The current GPS location.
1272 * transition - Can be one of GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED,
1273 * GPS_GEOFENCE_UNCERTAIN.
1274 * timestamp - Timestamp when the transition was detected.
1275 *
1276 * The callback should only be called when the caller is interested in that
1277 * particular transition. For instance, if the caller is interested only in
1278 * ENTERED transition, then the callback should NOT be called with the EXITED
1279 * transition.
1280 *
1281 * IMPORTANT: If a transition is triggered resulting in this callback, the GPS
1282 * subsystem will wake up the application processor, if its in suspend state.
1283 */
1284typedef void (*gps_geofence_transition_callback) (int32_t geofence_id, GpsLocation* location,
1285 int32_t transition, GpsUtcTime timestamp);
1286
1287/**
destradaa9f7c3732014-04-29 10:50:22 -07001288 * The callback associated with the availability of the GPS system for geofencing
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001289 * monitoring. If the GPS system determines that it cannot monitor geofences
1290 * because of lack of reliability or unavailability of the GPS signals, it will
1291 * call this callback with GPS_GEOFENCE_UNAVAILABLE parameter.
1292 *
1293 * Parameters:
1294 * status - GPS_GEOFENCE_UNAVAILABLE or GPS_GEOFENCE_AVAILABLE.
1295 * last_location - Last known location.
1296 */
1297typedef void (*gps_geofence_status_callback) (int32_t status, GpsLocation* last_location);
1298
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001299/**
1300 * The callback associated with the add_geofence call.
1301 *
1302 * Parameter:
1303 * geofence_id - Id of the geofence.
1304 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1305 * GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached.
1306 * GPS_GEOFENCE_ERROR_ID_EXISTS - geofence with id already exists
1307 * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - the monitorTransition contains an
1308 * invalid transition
1309 * GPS_GEOFENCE_ERROR_GENERIC - for other errors.
1310 */
1311typedef void (*gps_geofence_add_callback) (int32_t geofence_id, int32_t status);
1312
1313/**
1314 * The callback associated with the remove_geofence call.
1315 *
1316 * Parameter:
1317 * geofence_id - Id of the geofence.
1318 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1319 * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
1320 * GPS_GEOFENCE_ERROR_GENERIC for others.
1321 */
1322typedef void (*gps_geofence_remove_callback) (int32_t geofence_id, int32_t status);
1323
1324
1325/**
1326 * The callback associated with the pause_geofence call.
1327 *
1328 * Parameter:
1329 * geofence_id - Id of the geofence.
1330 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1331 * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
1332 * GPS_GEOFENCE_ERROR_INVALID_TRANSITION -
1333 * when monitor_transitions is invalid
1334 * GPS_GEOFENCE_ERROR_GENERIC for others.
1335 */
1336typedef void (*gps_geofence_pause_callback) (int32_t geofence_id, int32_t status);
1337
1338/**
1339 * The callback associated with the resume_geofence call.
1340 *
1341 * Parameter:
1342 * geofence_id - Id of the geofence.
1343 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1344 * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
1345 * GPS_GEOFENCE_ERROR_GENERIC for others.
1346 */
1347typedef void (*gps_geofence_resume_callback) (int32_t geofence_id, int32_t status);
1348
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001349typedef struct {
1350 gps_geofence_transition_callback geofence_transition_callback;
1351 gps_geofence_status_callback geofence_status_callback;
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001352 gps_geofence_add_callback geofence_add_callback;
1353 gps_geofence_remove_callback geofence_remove_callback;
1354 gps_geofence_pause_callback geofence_pause_callback;
1355 gps_geofence_resume_callback geofence_resume_callback;
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001356 gps_create_thread create_thread_cb;
1357} GpsGeofenceCallbacks;
1358
1359/** Extended interface for GPS_Geofencing support */
1360typedef struct {
1361 /** set to sizeof(GpsGeofencingInterface) */
1362 size_t size;
1363
1364 /**
1365 * Opens the geofence interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -07001366 * to the implementation of this interface.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001367 */
1368 void (*init)( GpsGeofenceCallbacks* callbacks );
1369
1370 /**
1371 * Add a geofence area. This api currently supports circular geofences.
1372 * Parameters:
1373 * geofence_id - The id for the geofence. If a geofence with this id
Jaikumar Ganesh5824b402013-02-25 11:43:33 -08001374 * already exists, an error value (GPS_GEOFENCE_ERROR_ID_EXISTS)
1375 * should be returned.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001376 * latitude, longtitude, radius_meters - The lat, long and radius
1377 * (in meters) for the geofence
1378 * last_transition - The current state of the geofence. For example, if
1379 * the system already knows that the user is inside the geofence,
1380 * this will be set to GPS_GEOFENCE_ENTERED. In most cases, it
1381 * will be GPS_GEOFENCE_UNCERTAIN.
1382 * monitor_transition - Which transitions to monitor. Bitwise OR of
1383 * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and
1384 * GPS_GEOFENCE_UNCERTAIN.
1385 * notification_responsiveness_ms - Defines the best-effort description
1386 * of how soon should the callback be called when the transition
1387 * associated with the Geofence is triggered. For instance, if set
1388 * to 1000 millseconds with GPS_GEOFENCE_ENTERED, the callback
1389 * should be called 1000 milliseconds within entering the geofence.
1390 * This parameter is defined in milliseconds.
1391 * NOTE: This is not to be confused with the rate that the GPS is
1392 * polled at. It is acceptable to dynamically vary the rate of
1393 * sampling the GPS for power-saving reasons; thus the rate of
1394 * sampling may be faster or slower than this.
1395 * unknown_timer_ms - The time limit after which the UNCERTAIN transition
destradaa9f7c3732014-04-29 10:50:22 -07001396 * should be triggered. This parameter is defined in milliseconds.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001397 * See above for a detailed explanation.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001398 */
destradaa9f7c3732014-04-29 10:50:22 -07001399 void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude,
1400 double radius_meters, int last_transition, int monitor_transitions,
1401 int notification_responsiveness_ms, int unknown_timer_ms);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001402
1403 /**
1404 * Pause monitoring a particular geofence.
1405 * Parameters:
1406 * geofence_id - The id for the geofence.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001407 */
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001408 void (*pause_geofence) (int32_t geofence_id);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001409
1410 /**
1411 * Resume monitoring a particular geofence.
1412 * Parameters:
1413 * geofence_id - The id for the geofence.
1414 * monitor_transitions - Which transitions to monitor. Bitwise OR of
1415 * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and
1416 * GPS_GEOFENCE_UNCERTAIN.
1417 * This supersedes the value associated provided in the
1418 * add_geofence_area call.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001419 */
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001420 void (*resume_geofence) (int32_t geofence_id, int monitor_transitions);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001421
1422 /**
1423 * Remove a geofence area. After the function returns, no notifications
1424 * should be sent.
1425 * Parameter:
1426 * geofence_id - The id for the geofence.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001427 */
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001428 void (*remove_geofence_area) (int32_t geofence_id);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001429} GpsGeofencingInterface;
destradaa9f7c3732014-04-29 10:50:22 -07001430
destradaa9f7c3732014-04-29 10:50:22 -07001431/**
Lifu Tang7e33bb22016-02-07 18:09:30 -08001432 * Legacy struct to represent an estimate of the GPS clock time.
1433 * Deprecated, to be removed in the next Android release.
1434 * Use GnssClock instead.
destradaa9f7c3732014-04-29 10:50:22 -07001435 */
1436typedef struct {
1437 /** set to sizeof(GpsClock) */
1438 size_t size;
Lifu Tang7e33bb22016-02-07 18:09:30 -08001439 GpsClockFlags flags;
1440 int16_t leap_second;
1441 GpsClockType type;
1442 int64_t time_ns;
1443 double time_uncertainty_ns;
1444 int64_t full_bias_ns;
1445 double bias_ns;
1446 double bias_uncertainty_ns;
1447 double drift_nsps;
1448 double drift_uncertainty_nsps;
1449} GpsClock;
1450
1451/**
1452 * Represents an estimate of the GPS clock time.
1453 */
1454typedef struct {
1455 /** set to sizeof(GnssClock) */
1456 size_t size;
destradaa9f7c3732014-04-29 10:50:22 -07001457
Lifu Tanga1ca5742016-02-16 17:42:13 -08001458 /**
1459 * A set of flags indicating the validity of the fields in this data
1460 * structure.
1461 */
1462 GnssClockFlags flags;
destradaa9f7c3732014-04-29 10:50:22 -07001463
1464 /**
1465 * Leap second data.
destradaa75843eb2014-07-17 14:04:50 -07001466 * The sign of the value is defined by the following equation:
Lifu Tanga1ca5742016-02-16 17:42:13 -08001467 * utc_time_ns = time_ns + (full_bias_ns + bias_ns) - leap_second *
1468 * 1,000,000,000
destradaa75843eb2014-07-17 14:04:50 -07001469 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001470 * If the data is available 'flags' must contain GNSS_CLOCK_HAS_LEAP_SECOND.
destradaa9f7c3732014-04-29 10:50:22 -07001471 */
1472 int16_t leap_second;
1473
1474 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001475 * The GNSS receiver internal clock value. This is the local hardware clock
1476 * value.
destradaa9f7c3732014-04-29 10:50:22 -07001477 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001478 * For local hardware clock, this value is expected to be monotonically
1479 * increasing while the hardware clock remains power on. (For the case of a
1480 * HW clock that is not continuously on, see the
1481 * hw_clock_discontinuity_count field). The real GPS time can be derived by
1482 * adding the 'full_bias_ns + bias_ns' (when it is available) to this value.
destradaa9f7c3732014-04-29 10:50:22 -07001483 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001484 * This GPS time is expected to be the best estimate of current GPS time
1485 * that GNSS receiver can achieve.
destradaa75843eb2014-07-17 14:04:50 -07001486 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001487 * Sub-nanosecond accuracy can be provided by means of the 'bias_ns' field.
destradaa9f7c3732014-04-29 10:50:22 -07001488 * The value contains the 'time uncertainty' in it.
destradaa75843eb2014-07-17 14:04:50 -07001489 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001490 * This field is mandatory.
destradaa9f7c3732014-04-29 10:50:22 -07001491 */
1492 int64_t time_ns;
1493
1494 /**
1495 * 1-Sigma uncertainty associated with the clock's time in nanoseconds.
1496 * The uncertainty is represented as an absolute (single sided) value.
1497 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001498 * If the data is available, 'flags' must contain
Lifu Tanga1ca5742016-02-16 17:42:13 -08001499 * GNSS_CLOCK_HAS_TIME_UNCERTAINTY. This value is effectively zero (it is
1500 * the reference local clock, by which all other times and time
1501 * uncertainties are measured.) (And thus this field can be not provided,
1502 * per GNSS_CLOCK_HAS_TIME_UNCERTAINTY flag, or provided & set to 0.)
destradaa9f7c3732014-04-29 10:50:22 -07001503 */
1504 double time_uncertainty_ns;
1505
1506 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001507 * The difference between hardware clock ('time' field) inside GPS receiver
1508 * and the true GPS time since 0000Z, January 6, 1980, in nanoseconds.
destradaa9f7c3732014-04-29 10:50:22 -07001509 *
destradaa75843eb2014-07-17 14:04:50 -07001510 * The sign of the value is defined by the following equation:
Lifu Tanga1ca5742016-02-16 17:42:13 -08001511 * local estimate of GPS time = time_ns + (full_bias_ns + bias_ns)
destradaa75843eb2014-07-17 14:04:50 -07001512 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001513 * This value is mandatory if the receiver has estimated GPS time. If the
1514 * computed time is for a non-GPS constellation, the time offset of that
1515 * constellation to GPS has to be applied to fill this value. The value
1516 * contains the 'bias uncertainty' in it, and the caller is responsible of
1517 * using the uncertainty. If the data is available 'flags' must contain
1518 * GNSS_CLOCK_HAS_FULL_BIAS.
destradaa75843eb2014-07-17 14:04:50 -07001519 */
1520 int64_t full_bias_ns;
1521
1522 /**
1523 * Sub-nanosecond bias.
destradaa9f7c3732014-04-29 10:50:22 -07001524 * The value contains the 'bias uncertainty' in it.
destradaa75843eb2014-07-17 14:04:50 -07001525 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001526 * If the data is available 'flags' must contain GNSS_CLOCK_HAS_BIAS. If GPS
1527 * has computed a position fix. This value is mandatory if the receiver has
1528 * estimated GPS time.
destradaa9f7c3732014-04-29 10:50:22 -07001529 */
1530 double bias_ns;
1531
1532 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001533 * 1-Sigma uncertainty associated with the local estimate of GPS time (clock
1534 * bias) in nanoseconds. The uncertainty is represented as an absolute
1535 * (single sided) value.
destradaa9f7c3732014-04-29 10:50:22 -07001536 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001537 * If the data is available 'flags' must contain
Lifu Tanga1ca5742016-02-16 17:42:13 -08001538 * GNSS_CLOCK_HAS_BIAS_UNCERTAINTY. This value is mandatory if the receiver
1539 * has estimated GPS time.
destradaa9f7c3732014-04-29 10:50:22 -07001540 */
1541 double bias_uncertainty_ns;
1542
1543 /**
1544 * The clock's drift in nanoseconds (per second).
Lifu Tanga1ca5742016-02-16 17:42:13 -08001545 *
1546 * A positive value means that the frequency is higher than the nominal
1547 * frequency.
destradaa9f7c3732014-04-29 10:50:22 -07001548 *
1549 * The value contains the 'drift uncertainty' in it.
Lifu Tanga1ca5742016-02-16 17:42:13 -08001550 * If the data is available 'flags' must contain GNSS_CLOCK_HAS_DRIFT.
destradaa00caa892015-04-09 18:41:46 -07001551 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001552 * This value is mandatory if the receiver has estimated GNSS time
destradaa9f7c3732014-04-29 10:50:22 -07001553 */
1554 double drift_nsps;
1555
1556 /**
1557 * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per second).
1558 * The uncertainty is represented as an absolute (single sided) value.
1559 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001560 * If the data is available 'flags' must contain
Lifu Tanga1ca5742016-02-16 17:42:13 -08001561 * GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY. If GPS has computed a position fix this
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001562 * field is mandatory and must be populated.
destradaa9f7c3732014-04-29 10:50:22 -07001563 */
1564 double drift_uncertainty_nsps;
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001565
1566 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001567 * When there are any discontinuities in the HW clock, this field is
1568 * mandatory.
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001569 *
1570 * A "discontinuity" is meant to cover the case of a switch from one source
1571 * of clock to another. A single free-running crystal oscillator (XO)
Lifu Tanga1ca5742016-02-16 17:42:13 -08001572 * should generally not have any discontinuities, and this can be set and
1573 * left at 0.
1574 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001575 * If, however, the time_ns value (HW clock) is derived from a composite of
Lifu Tanga1ca5742016-02-16 17:42:13 -08001576 * sources, that is not as smooth as a typical XO, or is otherwise stopped &
1577 * restarted, then this value shall be incremented each time a discontinuity
1578 * occurs. (E.g. this value may start at zero at device boot-up and
1579 * increment each time there is a change in clock continuity. In the
1580 * unlikely event that this value reaches full scale, rollover (not
1581 * clamping) is required, such that this value continues to change, during
1582 * subsequent discontinuity events.)
1583 *
1584 * While this number stays the same, between GnssClock reports, it can be
1585 * safely assumed that the time_ns value has been running continuously, e.g.
1586 * derived from a single, high quality clock (XO like, or better, that's
1587 * typically used during continuous GNSS signal sampling.)
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001588 *
1589 * It is expected, esp. during periods where there are few GNSS signals
1590 * available, that the HW clock be discontinuity-free as long as possible,
Lifu Tanga1ca5742016-02-16 17:42:13 -08001591 * as this avoids the need to use (waste) a GNSS measurement to fully
1592 * re-solve for the GPS clock bias and drift, when using the accompanying
1593 * measurements, from consecutive GnssData reports.
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001594 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001595 uint32_t hw_clock_discontinuity_count;
1596
Lifu Tang7e33bb22016-02-07 18:09:30 -08001597} GnssClock;
destradaa9f7c3732014-04-29 10:50:22 -07001598
1599/**
Lifu Tang7e33bb22016-02-07 18:09:30 -08001600 * Legacy struct to represent a GPS Measurement, it contains raw and computed
1601 * information.
1602 * Deprecated, to be removed in the next Android release.
1603 * Use GnssMeasurement instead.
1604 */
1605typedef struct {
1606 /** set to sizeof(GpsMeasurement) */
1607 size_t size;
1608 GpsMeasurementFlags flags;
1609 int8_t prn;
1610 double time_offset_ns;
1611 GpsMeasurementState state;
1612 int64_t received_gps_tow_ns;
1613 int64_t received_gps_tow_uncertainty_ns;
1614 double c_n0_dbhz;
1615 double pseudorange_rate_mps;
1616 double pseudorange_rate_uncertainty_mps;
1617 GpsAccumulatedDeltaRangeState accumulated_delta_range_state;
1618 double accumulated_delta_range_m;
1619 double accumulated_delta_range_uncertainty_m;
1620 double pseudorange_m;
1621 double pseudorange_uncertainty_m;
1622 double code_phase_chips;
1623 double code_phase_uncertainty_chips;
1624 float carrier_frequency_hz;
1625 int64_t carrier_cycles;
1626 double carrier_phase;
1627 double carrier_phase_uncertainty;
1628 GpsLossOfLock loss_of_lock;
1629 int32_t bit_number;
1630 int16_t time_from_last_bit_ms;
1631 double doppler_shift_hz;
1632 double doppler_shift_uncertainty_hz;
1633 GpsMultipathIndicator multipath_indicator;
1634 double snr_db;
1635 double elevation_deg;
1636 double elevation_uncertainty_deg;
1637 double azimuth_deg;
1638 double azimuth_uncertainty_deg;
1639 bool used_in_fix;
1640} GpsMeasurement;
1641
1642/**
1643 * Represents a GNSS Measurement, it contains raw and computed information.
Lifu Tang1d4183c2016-02-24 13:50:19 -08001644 *
1645 * Independence - All signal measurement information (e.g. sv_time,
1646 * pseudorange_rate, multipath_indicator) reported in this struct should be
1647 * based on GNSS signal measurements only. You may not synthesize measurements
1648 * by calculating or reporting expected measurements based on known or estimated
1649 * position, velocity, or time.
destradaa9f7c3732014-04-29 10:50:22 -07001650 */
1651typedef struct {
1652 /** set to sizeof(GpsMeasurement) */
1653 size_t size;
1654
1655 /** A set of flags indicating the validity of the fields in this data structure. */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001656 GnssMeasurementFlags flags;
destradaa9f7c3732014-04-29 10:50:22 -07001657
1658 /**
Lifu Tang7e33bb22016-02-07 18:09:30 -08001659 * Satellite vehicle ID number, as defined in GnssSvInfo::svid
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001660 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001661 */
Lifu Tang7e33bb22016-02-07 18:09:30 -08001662 int16_t svid;
destradaa9f7c3732014-04-29 10:50:22 -07001663
1664 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001665 * Defines the constellation of the given SV. Value should be one of those
1666 * GNSS_CONSTELLATION_* constants
1667 */
1668 GnssConstellationType constellation;
1669
1670 /**
destradaa75843eb2014-07-17 14:04:50 -07001671 * Time offset at which the measurement was taken in nanoseconds.
1672 * The reference receiver's time is specified by GpsData::clock::time_ns and should be
1673 * interpreted in the same way as indicated by GpsClock::type.
1674 *
destradaa9f7c3732014-04-29 10:50:22 -07001675 * The sign of time_offset_ns is given by the following equation:
1676 * measurement time = GpsClock::time_ns + time_offset_ns
1677 *
1678 * It provides an individual time-stamp for the measurement, and allows sub-nanosecond accuracy.
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001679 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001680 */
destradaa75843eb2014-07-17 14:04:50 -07001681 double time_offset_ns;
destradaa9f7c3732014-04-29 10:50:22 -07001682
1683 /**
destradaa75843eb2014-07-17 14:04:50 -07001684 * Per satellite sync state. It represents the current sync state for the associated satellite.
1685 * Based on the sync state, the 'received GPS tow' field should be interpreted accordingly.
destradaa9f7c3732014-04-29 10:50:22 -07001686 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001687 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001688 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001689 GnssMeasurementState state;
destradaa75843eb2014-07-17 14:04:50 -07001690
1691 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001692 * The received GNSS Time-of-Week at the measurement time, in nanoseconds.
Lifu Tang1d4183c2016-02-24 13:50:19 -08001693 * Ensure that this field is independent (see comment at top of
1694 * GnssMeasurement struct.)
destradaa75843eb2014-07-17 14:04:50 -07001695 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001696 * For GPS & QZSS, this is:
1697 * Received GPS Time-of-Week at the measurement time, in nanoseconds.
1698 * The value is relative to the beginning of the current GPS week.
Tsuwei Chena90cf192014-10-23 12:49:12 -07001699 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001700 * Given the highest sync state that can be achieved, per each satellite, valid range
1701 * for this field can be:
1702 * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN
1703 * C/A code lock : [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set
1704 * Bit sync : [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set
1705 * Subframe sync : [ 0 6s ] : GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set
1706 * TOW decoded : [ 0 1week ] : GNSS_MEASUREMENT_STATE_TOW_DECODED is set
destradaa00caa892015-04-09 18:41:46 -07001707 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001708 * Note well: if there is any ambiguity in integer millisecond,
1709 * GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS should be set accordingly, in the 'state' field.
1710 *
1711 * This value must be populated if 'state' != GNSS_MEASUREMENT_STATE_UNKNOWN.
1712 *
1713 * For Glonass, this is:
1714 * Received Glonass time of day, at the measurement time in nanoseconds.
1715 *
1716 * Given the highest sync state that can be achieved, per each satellite, valid range for
1717 * this field can be:
1718 * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN
1719 * C/A code lock : [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set
1720 * Symbol sync : [ 0 10ms ] : GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set
1721 * Bit sync : [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set
1722 * String sync : [ 0 2s ] : GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC is set
1723 * Time of day : [ 0 1day ] : GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED is set
1724 *
1725 * For Beidou, this is:
1726 * Received Beidou time of week, at the measurement time in nanoseconds.
1727 *
1728 * Given the highest sync state that can be achieved, per each satellite, valid range for
1729 * this field can be:
1730 * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN
1731 * C/A code lock: [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set
1732 * Bit sync (D2): [ 0 2ms ] : GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC is set
1733 * Bit sync (D1): [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set
1734 * Subframe (D2): [ 0 0.6s ] : GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC is set
1735 * Subframe (D1): [ 0 6s ] : GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set
1736 * Time of week : [ 0 1week ] : GNSS_MEASUREMENT_STATE_TOW_DECODED is set
1737 *
1738 * For Galileo, this is:
1739 * Received Galileo time of week, at the measurement time in nanoseconds.
1740 *
1741 * E1BC code lock : [ 0 4ms ] : GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK is set
1742 * E1C 2nd code lock: [ 0 100ms ] :
1743 * GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK is set
1744 *
1745 * E1B page : [ 0 2s ] : GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC is set
1746 * Time of week: [ 0 1week ] : GNSS_MEASUREMENT_STATE_GAL_TOW_DECODED is set
1747 *
1748 * For SBAS, this is:
1749 * Received SBAS time, at the measurement time in nanoseconds.
1750 *
1751 * Given the highest sync state that can be achieved, per each satellite,
1752 * valid range for this field can be:
1753 * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN
1754 * C/A code lock: [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set
1755 * Symbol sync : [ 0 2ms ] : GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set
1756 * Message : [ 0 1s ] : GNSS_MEASUREMENT_STATE_SBAS_SYNC is set
1757 */
1758 int64_t received_sv_time_in_ns;
destradaa9f7c3732014-04-29 10:50:22 -07001759
1760 /**
destradaa941c9282014-07-21 18:13:42 -07001761 * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds.
destradaa00caa892015-04-09 18:41:46 -07001762 *
1763 * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN.
destradaa941c9282014-07-21 18:13:42 -07001764 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001765 int64_t received_sv_time_uncertainty_in_ns;
destradaa941c9282014-07-21 18:13:42 -07001766
1767 /**
Lifu Tang1d4183c2016-02-24 13:50:19 -08001768 * Carrier-to-noise density in dB-Hz, typically in the range [0, 63].
1769 * It contains the measured C/N0 value for the signal at the antenna port.
destradaa9f7c3732014-04-29 10:50:22 -07001770 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001771 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001772 */
1773 double c_n0_dbhz;
1774
1775 /**
Lifu Tang1d4183c2016-02-24 13:50:19 -08001776 * Pseudorange rate at the timestamp in m/s. The correction of a given
1777 * Pseudorange Rate value includes corrections for receiver and satellite
1778 * clock frequency errors. Ensure that this field is independent (see
1779 * comment at top of GnssMeasurement struct.)
destradaa00caa892015-04-09 18:41:46 -07001780 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001781 * It is mandatory to provide the 'uncorrected' 'pseudorange rate', and provide GpsClock's
1782 * 'drift' field as well, and
1783 * GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE must be set in 'flags'
1784 * field. (When providing the uncorrected pseudorange rate, do not apply the
1785 * corrections described above.)
destradaa9f7c3732014-04-29 10:50:22 -07001786 *
1787 * The value includes the 'pseudorange rate uncertainty' in it.
destradaa00caa892015-04-09 18:41:46 -07001788 * A positive 'uncorrected' value indicates that the SV is moving away from the receiver.
1789 *
destradaa357e6222015-04-14 16:30:21 -07001790 * The sign of the 'uncorrected' 'pseudorange rate' and its relation to the sign of 'doppler
destradaa00caa892015-04-09 18:41:46 -07001791 * shift' is given by the equation:
destradaa357e6222015-04-14 16:30:21 -07001792 * pseudorange rate = -k * doppler shift (where k is a constant)
destradaa9f7c3732014-04-29 10:50:22 -07001793 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001794 * This should be the most accurate pseudorange rate available, based on
1795 * fresh signal measurements from this channel.
1796 *
1797 * It is mandatory that this value be provided at typical carrier phase PRR
1798 * quality (few cm/sec per second of uncertainty, or better) - when signals
1799 * are sufficiently strong & stable, e.g. signals from a GPS simulator at >=
1800 * 35 dB-Hz.
destradaa9f7c3732014-04-29 10:50:22 -07001801 */
destradaa75843eb2014-07-17 14:04:50 -07001802 double pseudorange_rate_mps;
destradaa9f7c3732014-04-29 10:50:22 -07001803
1804 /**
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001805 * 1-Sigma uncertainty of the pseudorange_rate_mps.
destradaa9f7c3732014-04-29 10:50:22 -07001806 * The uncertainty is represented as an absolute (single sided) value.
1807 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001808 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001809 */
destradaa75843eb2014-07-17 14:04:50 -07001810 double pseudorange_rate_uncertainty_mps;
1811
1812 /**
1813 * Accumulated delta range's state. It indicates whether ADR is reset or there is a cycle slip
1814 * (indicating loss of lock).
1815 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001816 * This is a mandatory value.
destradaa75843eb2014-07-17 14:04:50 -07001817 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001818 GnssAccumulatedDeltaRangeState accumulated_delta_range_state;
destradaa9f7c3732014-04-29 10:50:22 -07001819
1820 /**
1821 * Accumulated delta range since the last channel reset in meters.
destradaa357e6222015-04-14 16:30:21 -07001822 * A positive value indicates that the SV is moving away from the receiver.
destradaa00caa892015-04-09 18:41:46 -07001823 *
destradaa357e6222015-04-14 16:30:21 -07001824 * The sign of the 'accumulated delta range' and its relation to the sign of 'carrier phase'
destradaa00caa892015-04-09 18:41:46 -07001825 * is given by the equation:
destradaa357e6222015-04-14 16:30:21 -07001826 * accumulated delta range = -k * carrier phase (where k is a constant)
destradaa00caa892015-04-09 18:41:46 -07001827 *
1828 * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN.
1829 * However, it is expected that the data is only accurate when:
1830 * 'accumulated delta range state' == GPS_ADR_STATE_VALID.
destradaa9f7c3732014-04-29 10:50:22 -07001831 */
1832 double accumulated_delta_range_m;
1833
1834 /**
1835 * 1-Sigma uncertainty of the accumulated delta range in meters.
destradaa00caa892015-04-09 18:41:46 -07001836 * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN.
destradaa9f7c3732014-04-29 10:50:22 -07001837 */
1838 double accumulated_delta_range_uncertainty_m;
1839
1840 /**
destradaa9f7c3732014-04-29 10:50:22 -07001841 * Carrier frequency at which codes and messages are modulated, it can be L1 or L2.
1842 * If the field is not set, the carrier frequency is assumed to be L1.
1843 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001844 * If the data is available, 'flags' must contain
1845 * GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY.
destradaa9f7c3732014-04-29 10:50:22 -07001846 */
1847 float carrier_frequency_hz;
1848
1849 /**
1850 * The number of full carrier cycles between the satellite and the receiver.
1851 * The reference frequency is given by the field 'carrier_frequency_hz'.
1852 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001853 * If the data is available, 'flags' must contain
1854 * GNSS_MEASUREMENT_HAS_CARRIER_CYCLES.
destradaa9f7c3732014-04-29 10:50:22 -07001855 */
1856 int64_t carrier_cycles;
1857
1858 /**
1859 * The RF phase detected by the receiver, in the range [0.0, 1.0].
1860 * This is usually the fractional part of the complete carrier phase measurement.
1861 *
1862 * The reference frequency is given by the field 'carrier_frequency_hz'.
1863 * The value contains the 'carrier-phase uncertainty' in it.
1864 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001865 * If the data is available, 'flags' must contain
1866 * GNSS_MEASUREMENT_HAS_CARRIER_PHASE.
destradaa9f7c3732014-04-29 10:50:22 -07001867 */
1868 double carrier_phase;
1869
1870 /**
1871 * 1-Sigma uncertainty of the carrier-phase.
Lifu Tanga1ca5742016-02-16 17:42:13 -08001872 * If the data is available, 'flags' must contain
1873 * GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY.
destradaa9f7c3732014-04-29 10:50:22 -07001874 */
1875 double carrier_phase_uncertainty;
1876
1877 /**
destradaa9f7c3732014-04-29 10:50:22 -07001878 * An enumeration that indicates the 'multipath' state of the event.
Lifu Tang1d4183c2016-02-24 13:50:19 -08001879 *
1880 * The multipath Indicator is intended to report the presence of overlapping
1881 * signals that manifest as distorted correlation peaks.
1882 *
1883 * - if there is a distorted correlation peak shape, report that multipath
1884 * is GNSS_MULTIPATH_INDICATOR_PRESENT.
1885 * - if there is not a distorted correlation peak shape, report
1886 * GNSS_MULTIPATH_INDICATOR_NOT_PRESENT
1887 * - if signals are too weak to discern this information, report
1888 * GNSS_MULTIPATH_INDICATOR_UNKNOWN
1889 *
1890 * Example: when doing the standardized overlapping Multipath Performance
1891 * test (3GPP TS 34.171) the Multipath indicator should report
1892 * GNSS_MULTIPATH_INDICATOR_PRESENT for those signals that are tracked, and
1893 * contain multipath, and GNSS_MULTIPATH_INDICATOR_NOT_PRESENT for those
1894 * signals that are tracked and do not contain multipath.
destradaa9f7c3732014-04-29 10:50:22 -07001895 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001896 GnssMultipathIndicator multipath_indicator;
destradaa9f7c3732014-04-29 10:50:22 -07001897
1898 /**
Lifu Tang1d4183c2016-02-24 13:50:19 -08001899 * Signal-to-noise ratio at correlator output in dB.
Lifu Tanga1ca5742016-02-16 17:42:13 -08001900 * If the data is available, 'flags' must contain GNSS_MEASUREMENT_HAS_SNR.
Lifu Tang1d4183c2016-02-24 13:50:19 -08001901 * This is the power ratio of the "correlation peak height above the
1902 * observed noise floor" to "the noise RMS".
destradaa9f7c3732014-04-29 10:50:22 -07001903 */
1904 double snr_db;
Lifu Tang7e33bb22016-02-07 18:09:30 -08001905} GnssMeasurement;
1906
1907/**
1908 * Legacy struct to represents a reading of GPS measurements.
1909 * Deprecated, to be removed in the next Android release.
1910 * Use GnssData instead.
1911 */
1912typedef struct {
1913 /** set to sizeof(GpsData) */
1914 size_t size;
1915 size_t measurement_count;
1916 GpsMeasurement measurements[GPS_MAX_MEASUREMENT];
1917
1918 /** The GPS clock time reading. */
1919 GpsClock clock;
1920} GpsData;
destradaa9f7c3732014-04-29 10:50:22 -07001921
Lifu Tanga1ca5742016-02-16 17:42:13 -08001922/**
1923 * Represents a reading of GNSS measurements. For devices where GnssSystemInfo's
1924 * year_of_hw is set to 2016+, it is mandatory that these be provided, on
1925 * request, when the GNSS receiver is searching/tracking signals.
1926 *
1927 * - Reporting of GPS constellation measurements is mandatory.
1928 * - Reporting of all tracked constellations are encouraged.
1929 */
destradaa9f7c3732014-04-29 10:50:22 -07001930typedef struct {
Lifu Tang7e33bb22016-02-07 18:09:30 -08001931 /** set to sizeof(GnssData) */
destradaa9f7c3732014-04-29 10:50:22 -07001932 size_t size;
1933
1934 /** Number of measurements. */
1935 size_t measurement_count;
1936
1937 /** The array of measurements. */
Lifu Tang7e33bb22016-02-07 18:09:30 -08001938 GnssMeasurement measurements[GNSS_MAX_MEASUREMENT];
destradaa9f7c3732014-04-29 10:50:22 -07001939
1940 /** The GPS clock time reading. */
Lifu Tang7e33bb22016-02-07 18:09:30 -08001941 GnssClock clock;
1942} GnssData;
destradaa9f7c3732014-04-29 10:50:22 -07001943
1944/**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001945 * The legacy callback for to report measurements from the HAL.
1946 *
1947 * This callback is deprecated, and will be removed in the next release. Use
1948 * gnss_measurement_callback() instead.
destradaa9f7c3732014-04-29 10:50:22 -07001949 *
1950 * Parameters:
1951 * data - A data structure containing the measurements.
1952 */
1953typedef void (*gps_measurement_callback) (GpsData* data);
1954
Lifu Tang7e33bb22016-02-07 18:09:30 -08001955/**
1956 * The callback for to report measurements from the HAL.
1957 *
1958 * Parameters:
1959 * data - A data structure containing the measurements.
1960 */
1961typedef void (*gnss_measurement_callback) (GnssData* data);
1962
destradaa9f7c3732014-04-29 10:50:22 -07001963typedef struct {
1964 /** set to sizeof(GpsMeasurementCallbacks) */
1965 size_t size;
1966 gps_measurement_callback measurement_callback;
Lifu Tang7e33bb22016-02-07 18:09:30 -08001967 gnss_measurement_callback gnss_measurement_callback;
destradaa9f7c3732014-04-29 10:50:22 -07001968} GpsMeasurementCallbacks;
1969
1970#define GPS_MEASUREMENT_OPERATION_SUCCESS 0
1971#define GPS_MEASUREMENT_ERROR_ALREADY_INIT -100
1972#define GPS_MEASUREMENT_ERROR_GENERIC -101
1973
1974/**
1975 * Extended interface for GPS Measurements support.
1976 */
1977typedef struct {
1978 /** Set to sizeof(GpsMeasurementInterface) */
1979 size_t size;
1980
1981 /**
1982 * Initializes the interface and registers the callback routines with the HAL.
1983 * After a successful call to 'init' the HAL must begin to provide updates at its own phase.
1984 *
1985 * Status:
1986 * GPS_MEASUREMENT_OPERATION_SUCCESS
1987 * GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a
1988 * corresponding call to 'close'
1989 * GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL
1990 * will not generate any updates upon returning this error code.
1991 */
1992 int (*init) (GpsMeasurementCallbacks* callbacks);
1993
1994 /**
1995 * Stops updates from the HAL, and unregisters the callback routines.
1996 * After a call to stop, the previously registered callbacks must be considered invalid by the
1997 * HAL.
1998 * If stop is invoked without a previous 'init', this function should perform no work.
1999 */
2000 void (*close) ();
2001
2002} GpsMeasurementInterface;
2003
Lifu Tang7e33bb22016-02-07 18:09:30 -08002004/**
2005 * Legacy struct to represents a GPS navigation message (or a fragment of it).
2006 * Deprecated, to be removed in the next Android release.
2007 * Use GnssNavigationMessage instead.
2008 */
destradaa9f7c3732014-04-29 10:50:22 -07002009typedef struct {
2010 /** set to sizeof(GpsNavigationMessage) */
2011 size_t size;
Lifu Tang7e33bb22016-02-07 18:09:30 -08002012 int8_t prn;
2013 GpsNavigationMessageType type;
2014 NavigationMessageStatus status;
2015 int16_t message_id;
2016 int16_t submessage_id;
2017 size_t data_length;
2018 uint8_t* data;
2019} GpsNavigationMessage;
2020
2021/** Represents a GPS navigation message (or a fragment of it). */
2022typedef struct {
2023 /** set to sizeof(GnssNavigationMessage) */
2024 size_t size;
destradaa9f7c3732014-04-29 10:50:22 -07002025
2026 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08002027 * Satellite vehicle ID number, as defined in GnssSvInfo::svid
Lifu Tangdf0fcf72015-10-27 14:58:25 -07002028 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07002029 */
Lifu Tang7e33bb22016-02-07 18:09:30 -08002030 int16_t svid;
destradaa9f7c3732014-04-29 10:50:22 -07002031
2032 /**
2033 * The type of message contained in the structure.
Lifu Tangdf0fcf72015-10-27 14:58:25 -07002034 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07002035 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08002036 GnssNavigationMessageType type;
destradaa9f7c3732014-04-29 10:50:22 -07002037
2038 /**
Tsuwei Chena90cf192014-10-23 12:49:12 -07002039 * The status of the received navigation message.
2040 * No need to send any navigation message that contains words with parity error and cannot be
2041 * corrected.
2042 */
2043 NavigationMessageStatus status;
2044
2045 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08002046 * Message identifier. It provides an index so the complete Navigation
2047 * Message can be assembled.
2048 *
2049 * - For GPS L1 C/A subframe 4 and 5, this value corresponds to the 'frame
2050 * id' of the navigation message, in the range of 1-25 (Subframe 1, 2, 3
2051 * does not contain a 'frame id' and this value can be set to -1.)
2052 *
2053 * - For Glonass L1 C/A, this refers to the frame ID, in the range of 1-5.
2054 *
2055 * - For BeiDou D1, this refers to the frame number in the range of 1-24
2056 *
2057 * - For Beidou D2, this refers to the frame number, in the range of 1-120
2058 *
2059 * - For Galileo F/NAV, this refers to the frame number, in the range of 1-N
2060 *
2061 * - For Galileo I/NAV, this refers to the frame number in the range of 1-N
destradaa9f7c3732014-04-29 10:50:22 -07002062 */
2063 int16_t message_id;
2064
2065 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08002066 * Sub-message identifier. If required by the message 'type', this value
2067 * contains a sub-index within the current message (or frame) that is being
2068 * transmitted.
2069 *
2070 * - For GPS L1 C/A, BeiDou D1 & BeiDou D2, the submessage id corresponds to
2071 * the subframe number of the navigation message, in the range of 1-5.
2072 *
2073 * - For Glonass L1 C/A, this refers to the String number, in the range from
2074 * 1-15
2075 *
2076 * - For Galileo F/NAV, this refers to the subframe number in the range 1-12
2077 *
2078 * - For Galileo I/NAV, this refers to the subframe number in the range 1-24
destradaa9f7c3732014-04-29 10:50:22 -07002079 */
2080 int16_t submessage_id;
2081
2082 /**
2083 * The length of the data (in bytes) contained in the current message.
2084 * If this value is different from zero, 'data' must point to an array of the same size.
destradaa69d5ea52014-07-31 16:34:09 -07002085 * 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 -07002086 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07002087 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07002088 */
2089 size_t data_length;
2090
2091 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08002092 * The data of the reported GPS message. The bytes (or words) specified
2093 * using big endian format (MSB first).
destradaa69d5ea52014-07-31 16:34:09 -07002094 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08002095 * - For GPS L1 C/A, Beidou D1 & Beidou D2, each subframe contains 10 30-bit
2096 * words. Each word (30 bits) should be fit into the last 30 bits in a
2097 * 4-byte word (skip B31 and B32), with MSB first, for a total of 40
2098 * bytes, covering a time period of 6, 6, and 0.6 seconds, respectively.
2099 *
2100 * - For Glonass L1 C/A, each string contains 85 data bits, including the
2101 * checksum. These bits should be fit into 11 bytes, with MSB first (skip
2102 * B86-B88), covering a time period of 2 seconds.
2103 *
2104 * - For Galileo F/NAV, each subframe contains 5 238-bit word (sync & tail
2105 * symbols excluded). Each word should be fit into 30-bytes, with MSB
2106 * first (skip B239, B240), covering a time period of 10 seconds.
2107 *
2108 * - For Galileo I/NAV, each subframe contains 15 114-bit word (sync & tail
2109 * symbols excluded). Each word should be fit into 15-bytes, with MSB
2110 * first (skip B115-B120), covering a time period of 2 seconds.
destradaa9f7c3732014-04-29 10:50:22 -07002111 */
2112 uint8_t* data;
2113
Lifu Tang7e33bb22016-02-07 18:09:30 -08002114} GnssNavigationMessage;
destradaa9f7c3732014-04-29 10:50:22 -07002115
2116/**
Lifu Tanga1ca5742016-02-16 17:42:13 -08002117 * The legacy callback to report an available fragment of a GPS navigation
2118 * messages from the HAL.
2119 *
2120 * This callback is deprecated, and will be removed in the next release. Use
2121 * gnss_navigation_message_callback() instead.
destradaa9f7c3732014-04-29 10:50:22 -07002122 *
2123 * Parameters:
2124 * message - The GPS navigation submessage/subframe representation.
2125 */
2126typedef void (*gps_navigation_message_callback) (GpsNavigationMessage* message);
2127
Lifu Tang7e33bb22016-02-07 18:09:30 -08002128/**
2129 * The callback to report an available fragment of a GPS navigation messages from the HAL.
2130 *
2131 * Parameters:
2132 * message - The GPS navigation submessage/subframe representation.
2133 */
2134typedef void (*gnss_navigation_message_callback) (GnssNavigationMessage* message);
2135
destradaa9f7c3732014-04-29 10:50:22 -07002136typedef struct {
2137 /** set to sizeof(GpsNavigationMessageCallbacks) */
2138 size_t size;
2139 gps_navigation_message_callback navigation_message_callback;
Lifu Tang7e33bb22016-02-07 18:09:30 -08002140 gnss_navigation_message_callback gnss_navigation_message_callback;
destradaa9f7c3732014-04-29 10:50:22 -07002141} GpsNavigationMessageCallbacks;
2142
2143#define GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS 0
2144#define GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT -100
2145#define GPS_NAVIGATION_MESSAGE_ERROR_GENERIC -101
2146
2147/**
2148 * Extended interface for GPS navigation message reporting support.
2149 */
2150typedef struct {
2151 /** Set to sizeof(GpsNavigationMessageInterface) */
2152 size_t size;
2153
2154 /**
2155 * Initializes the interface and registers the callback routines with the HAL.
2156 * After a successful call to 'init' the HAL must begin to provide updates as they become
2157 * available.
2158 *
2159 * Status:
2160 * GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS
2161 * GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT - if a callback has already been registered
2162 * without a corresponding call to 'close'.
2163 * GPS_NAVIGATION_MESSAGE_ERROR_GENERIC - if any other error occurred, it is expected that
2164 * the HAL will not generate any updates upon returning this error code.
2165 */
2166 int (*init) (GpsNavigationMessageCallbacks* callbacks);
2167
2168 /**
2169 * Stops updates from the HAL, and unregisters the callback routines.
2170 * After a call to stop, the previously registered callbacks must be considered invalid by the
2171 * HAL.
2172 * If stop is invoked without a previous 'init', this function should perform no work.
2173 */
2174 void (*close) ();
2175
2176} GpsNavigationMessageInterface;
2177
Tsuwei Chen167d31f2014-08-26 16:34:19 -07002178/**
2179 * Interface for passing GNSS configuration contents from platform to HAL.
2180 */
2181typedef struct {
2182 /** Set to sizeof(GnssConfigurationInterface) */
2183 size_t size;
2184
2185 /**
2186 * Deliver GNSS configuration contents to HAL.
2187 * Parameters:
2188 * config_data - a pointer to a char array which holds what usually is expected from
2189 file(/etc/gps.conf), i.e., a sequence of UTF8 strings separated by '\n'.
2190 * length - total number of UTF8 characters in configuraiton data.
2191 *
2192 * IMPORTANT:
2193 * GPS HAL should expect this function can be called multiple times. And it may be
2194 * called even when GpsLocationProvider is already constructed and enabled. GPS HAL
2195 * should maintain the existing requests for various callback regardless the change
2196 * in configuration data.
2197 */
2198 void (*configuration_update) (const char* config_data, int32_t length);
2199} GnssConfigurationInterface;
2200
Mike Lockwood9b0b1c32010-02-23 18:42:37 -05002201__END_DECLS
2202
2203#endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */
2204