blob: 354d343135610dc7aea7b793dd90c0957c50d47b [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 following typedef together with its constants below are deprecated, and
312 * will be removed in the next release. */
destradaa9f7c3732014-04-29 10:50:22 -0700313typedef uint8_t GpsLossOfLock;
destradaa9f7c3732014-04-29 10:50:22 -0700314#define GPS_LOSS_OF_LOCK_UNKNOWN 0
destradaa9f7c3732014-04-29 10:50:22 -0700315#define GPS_LOSS_OF_LOCK_OK 1
destradaa9f7c3732014-04-29 10:50:22 -0700316#define GPS_LOSS_OF_LOCK_CYCLE_SLIP 2
317
Lifu Tanga1ca5742016-02-16 17:42:13 -0800318/* The following typedef together with its constants below are deprecated, and
Lifu Tang1d4183c2016-02-24 13:50:19 -0800319 * will be removed in the next release. Use GnssMultipathIndicator instead.
320 */
destradaa9f7c3732014-04-29 10:50:22 -0700321typedef uint8_t GpsMultipathIndicator;
destradaa9f7c3732014-04-29 10:50:22 -0700322#define GPS_MULTIPATH_INDICATOR_UNKNOWN 0
destradaa9f7c3732014-04-29 10:50:22 -0700323#define GPS_MULTIPATH_INDICATOR_DETECTED 1
destradaa9f7c3732014-04-29 10:50:22 -0700324#define GPS_MULTIPATH_INDICATOR_NOT_USED 2
325
326/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800327 * Enumeration of available values for the GNSS Measurement's multipath
328 * indicator.
destradaa75843eb2014-07-17 14:04:50 -0700329 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800330typedef uint8_t GnssMultipathIndicator;
331/** The indicator is not available or unknown. */
332#define GNSS_MULTIPATH_INDICATOR_UNKNOWN 0
333/** The measurement is indicated to be affected by multipath. */
Lifu Tang1d4183c2016-02-24 13:50:19 -0800334#define GNSS_MULTIPATH_INDICATOR_PRESENT 1
Lifu Tanga1ca5742016-02-16 17:42:13 -0800335/** The measurement is indicated to be not affected by multipath. */
Lifu Tang1d4183c2016-02-24 13:50:19 -0800336#define GNSS_MULTIPATH_INDICATOR_NOT_PRESENT 2
Lifu Tanga1ca5742016-02-16 17:42:13 -0800337
338/* The following typedef together with its constants below are deprecated, and
339 * will be removed in the next release. */
destradaa75843eb2014-07-17 14:04:50 -0700340typedef uint16_t GpsMeasurementState;
341#define GPS_MEASUREMENT_STATE_UNKNOWN 0
342#define GPS_MEASUREMENT_STATE_CODE_LOCK (1<<0)
343#define GPS_MEASUREMENT_STATE_BIT_SYNC (1<<1)
344#define GPS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2)
345#define GPS_MEASUREMENT_STATE_TOW_DECODED (1<<3)
Tsuwei Chena90cf192014-10-23 12:49:12 -0700346#define GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4)
destradaa75843eb2014-07-17 14:04:50 -0700347
348/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800349 * Flags indicating the GNSS measurement state.
350 *
351 * The expected behavior here is for GPS HAL to set all the flags that applies.
352 * For example, if the state for a satellite is only C/A code locked and bit
353 * synchronized, and there is still millisecond ambiguity, the state should be
354 * set as:
355 *
356 * GNSS_MEASUREMENT_STATE_CODE_LOCK | GNSS_MEASUREMENT_STATE_BIT_SYNC |
357 * GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS
358 *
359 * If GNSS is still searching for a satellite, the corresponding state should be
360 * set to GNSS_MEASUREMENT_STATE_UNKNOWN(0).
destradaa75843eb2014-07-17 14:04:50 -0700361 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800362typedef uint16_t GnssMeasurementState;
363#define GNSS_MEASUREMENT_STATE_UNKNOWN 0
364#define GNSS_MEASUREMENT_STATE_CODE_LOCK (1<<0)
365#define GNSS_MEASUREMENT_STATE_BIT_SYNC (1<<1)
366#define GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2)
367#define GNSS_MEASUREMENT_STATE_TOW_DECODED (1<<3)
368#define GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4)
Lifu Tang1d4183c2016-02-24 13:50:19 -0800369#define GNSS_MEASUREMENT_STATE_SYMBOL_SYNC (1<<5)
Lifu Tanga1ca5742016-02-16 17:42:13 -0800370
371/* The following typedef together with its constants below are deprecated, and
372 * will be removed in the next release. */
destradaa75843eb2014-07-17 14:04:50 -0700373typedef uint16_t GpsAccumulatedDeltaRangeState;
374#define GPS_ADR_STATE_UNKNOWN 0
375#define GPS_ADR_STATE_VALID (1<<0)
376#define GPS_ADR_STATE_RESET (1<<1)
377#define GPS_ADR_STATE_CYCLE_SLIP (1<<2)
378
379/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800380 * Flags indicating the Accumulated Delta Range's states.
destradaa9f7c3732014-04-29 10:50:22 -0700381 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800382typedef uint16_t GnssAccumulatedDeltaRangeState;
383#define GNSS_ADR_STATE_UNKNOWN 0
384#define GNSS_ADR_STATE_VALID (1<<0)
385#define GNSS_ADR_STATE_RESET (1<<1)
386#define GNSS_ADR_STATE_CYCLE_SLIP (1<<2)
387
388/* The following typedef together with its constants below are deprecated, and
389 * will be removed in the next release. */
destradaa9f7c3732014-04-29 10:50:22 -0700390typedef uint8_t GpsNavigationMessageType;
destradaa9f7c3732014-04-29 10:50:22 -0700391#define GPS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0
destradaa9f7c3732014-04-29 10:50:22 -0700392#define GPS_NAVIGATION_MESSAGE_TYPE_L1CA 1
destradaa9f7c3732014-04-29 10:50:22 -0700393#define GPS_NAVIGATION_MESSAGE_TYPE_L2CNAV 2
destradaa9f7c3732014-04-29 10:50:22 -0700394#define GPS_NAVIGATION_MESSAGE_TYPE_L5CNAV 3
destradaa9f7c3732014-04-29 10:50:22 -0700395#define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2 4
396
Tsuwei Chena90cf192014-10-23 12:49:12 -0700397/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800398 * Enumeration of available values to indicate the GNSS Navigation message
399 * types.
400 *
401 * For convenience, first byte is the GnssConstellationType on which that signal
402 * is typically transmitted
403 */
404typedef int16_t GnssNavigationMessageType;
405
406#define GNSS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0
407/** GPS L1 C/A message contained in the structure. */
408#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L1CA 0x0101
409/** GPS L2-CNAV message contained in the structure. */
410#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L2CNAV 0x0102
411/** GPS L5-CNAV message contained in the structure. */
412#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L5CNAV 0x0103
413/** GPS CNAV-2 message contained in the structure. */
414#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_CNAV2 0x0104
415/** Glonass L1 CA message contained in the structure. */
416#define GNSS_NAVIGATION_MESSAGE_TYPE_GLO_L1CA 0x0301
417/** Beidou D1 message contained in the structure. */
418#define GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D1 0x0501
419/** Beidou D2 message contained in the structure. */
420#define GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D2 0x0502
421/** Galileo I/NAV message contained in the structure. */
422#define GNSS_NAVIGATION_MESSAGE_TYPE_GAL_I 0x0601
423/** Galileo F/NAV message contained in the structure. */
424#define GNSS_NAVIGATION_MESSAGE_TYPE_GAL_F 0x0602
425
426/**
Tsuwei Chena90cf192014-10-23 12:49:12 -0700427 * Status of Navigation Message
428 * When a message is received properly without any parity error in its navigation words, the
429 * status should be set to NAV_MESSAGE_STATUS_PARITY_PASSED. But if a message is received
430 * with words that failed parity check, but GPS is able to correct those words, the status
431 * should be set to NAV_MESSAGE_STATUS_PARITY_REBUILT.
432 * No need to send any navigation message that contains words with parity error and cannot be
433 * corrected.
434 */
435typedef uint16_t NavigationMessageStatus;
Lifu Tang1d4183c2016-02-24 13:50:19 -0800436#define NAV_MESSAGE_STATUS_UNKNOWN 0
Tsuwei Chena90cf192014-10-23 12:49:12 -0700437#define NAV_MESSAGE_STATUS_PARITY_PASSED (1<<0)
438#define NAV_MESSAGE_STATUS_PARITY_REBUILT (1<<1)
destradaa9f7c3732014-04-29 10:50:22 -0700439
Lifu Tang1d4183c2016-02-24 13:50:19 -0800440/* This constant is deprecated, and will be removed in the next release. */
441#define NAV_MESSAGE_STATUS_UNKONW 0
442
destradaa9f7c3732014-04-29 10:50:22 -0700443/**
Lifu Tang1d4183c2016-02-24 13:50:19 -0800444 * Flags that indicate information about the satellite
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700445 */
446typedef uint8_t GnssSvFlags;
447#define GNSS_SV_FLAGS_NONE 0
448#define GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA (1 << 0)
449#define GNSS_SV_FLAGS_HAS_ALMANAC_DATA (1 << 1)
450#define GNSS_SV_FLAGS_USED_IN_FIX (1 << 2)
451
452/**
453 * Constellation type of GnssSvInfo
454 */
455typedef uint8_t GnssConstellationType;
456#define GNSS_CONSTELLATION_UNKNOWN 0
457#define GNSS_CONSTELLATION_GPS 1
458#define GNSS_CONSTELLATION_SBAS 2
459#define GNSS_CONSTELLATION_GLONASS 3
460#define GNSS_CONSTELLATION_QZSS 4
461#define GNSS_CONSTELLATION_BEIDOU 5
462#define GNSS_CONSTELLATION_GALILEO 6
463
464/**
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500465 * Name for the GPS XTRA interface.
466 */
467#define GPS_XTRA_INTERFACE "gps-xtra"
468
469/**
470 * Name for the GPS DEBUG interface.
471 */
472#define GPS_DEBUG_INTERFACE "gps-debug"
473
474/**
475 * Name for the AGPS interface.
476 */
477#define AGPS_INTERFACE "agps"
478
479/**
destradaaa1f4c0a2013-09-13 15:45:03 -0700480 * Name of the Supl Certificate interface.
481 */
482#define SUPL_CERTIFICATE_INTERFACE "supl-certificate"
483
484/**
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500485 * Name for NI interface
486 */
487#define GPS_NI_INTERFACE "gps-ni"
488
Miguel Torroja5f404f52010-07-27 06:34:15 +0200489/**
490 * Name for the AGPS-RIL interface.
491 */
492#define AGPS_RIL_INTERFACE "agps_ril"
493
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -0800494/**
495 * Name for the GPS_Geofencing interface.
496 */
497#define GPS_GEOFENCING_INTERFACE "gps_geofencing"
498
destradaa9f7c3732014-04-29 10:50:22 -0700499/**
500 * Name of the GPS Measurements interface.
501 */
502#define GPS_MEASUREMENT_INTERFACE "gps_measurement"
503
504/**
505 * Name of the GPS navigation message interface.
506 */
Tsuwei Chen167d31f2014-08-26 16:34:19 -0700507#define GPS_NAVIGATION_MESSAGE_INTERFACE "gps_navigation_message"
508
509/**
510 * Name of the GNSS/GPS configuration interface.
511 */
512#define GNSS_CONFIGURATION_INTERFACE "gnss_configuration"
destradaa9f7c3732014-04-29 10:50:22 -0700513
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -0800514
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500515/** Represents a location. */
516typedef struct {
517 /** set to sizeof(GpsLocation) */
518 size_t size;
519 /** Contains GpsLocationFlags bits. */
520 uint16_t flags;
521 /** Represents latitude in degrees. */
522 double latitude;
523 /** Represents longitude in degrees. */
524 double longitude;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700525 /**
526 * Represents altitude in meters above the WGS 84 reference ellipsoid.
527 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500528 double altitude;
529 /** Represents speed in meters per second. */
530 float speed;
531 /** Represents heading in degrees. */
532 float bearing;
533 /** Represents expected accuracy in meters. */
534 float accuracy;
535 /** Timestamp for the location fix. */
536 GpsUtcTime timestamp;
537} GpsLocation;
538
539/** Represents the status. */
540typedef struct {
541 /** set to sizeof(GpsStatus) */
542 size_t size;
543 GpsStatusValue status;
544} GpsStatus;
545
Lifu Tanga1ca5742016-02-16 17:42:13 -0800546/**
547 * Legacy struct to represents SV information.
548 * Deprecated, to be removed in the next Android release.
549 * Use GnssSvInfo instead.
550 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500551typedef struct {
552 /** set to sizeof(GpsSvInfo) */
553 size_t size;
554 /** Pseudo-random number for the SV. */
555 int prn;
556 /** Signal to noise ratio. */
557 float snr;
558 /** Elevation of SV in degrees. */
559 float elevation;
560 /** Azimuth of SV in degrees. */
561 float azimuth;
562} GpsSvInfo;
563
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500564typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700565 /** set to sizeof(GnssSvInfo) */
566 size_t size;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500567
568 /**
Lifu Tang1d4183c2016-02-24 13:50:19 -0800569 * Pseudo-random number for the SV, or FCN/OSN number for Glonass. The
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700570 * distinction is made by looking at constellation field. Values should be
571 * in the range of:
572 *
573 * - GPS: 1-32
574 * - SBAS: 120-151, 183-192
Lifu Tang1d4183c2016-02-24 13:50:19 -0800575 * - GLONASS: Set the upper 8 bits, signed, to the frequency channel number
576 * (FCN) in the range from -7 to +6, if known, and -127, if
577 * unknown
578 * Set the lower 8 bits, signed, to the orbital slot number (OSN)
579 * in the range from 1-24, if known, or -127 if unknown
580 * At least one of the two (FCN & OSN) must be set to a known
581 * value
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700582 * - QZSS: 193-200
Lifu Tang1d4183c2016-02-24 13:50:19 -0800583 * - Galileo: 1-36
584 * - Beidou: 1-37
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500585 */
Lifu Tang7e33bb22016-02-07 18:09:30 -0800586 int16_t svid;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700587
Lifu Tanga1ca5742016-02-16 17:42:13 -0800588 /**
589 * Defines the constellation of the given SV. Value should be one of those
590 * GNSS_CONSTELLATION_* constants
591 */
592 GnssConstellationType constellation;
593
Lifu Tang1d4183c2016-02-24 13:50:19 -0800594 /**
595 * Carrier-to-noise density in dB-Hz, typically in the range [0, 63].
596 * It contains the measured C/N0 value for the signal at the antenna port.
597 *
598 * This is a mandatory value.
599 */
600 float c_n0_dbhz;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700601
602 /** Elevation of SV in degrees. */
603 float elevation;
604
605 /** Azimuth of SV in degrees. */
606 float azimuth;
607
608 /**
609 * Contains additional data about the given SV. Value should be one of those
610 * GNSS_SV_FLAGS_* constants
611 */
612 GnssSvFlags flags;
613
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700614} GnssSvInfo;
615
616/**
Lifu Tang7e33bb22016-02-07 18:09:30 -0800617 * Legacy struct to represents SV status.
618 * Deprecated, to be removed in the next Android release.
619 * Use GnssSvStatus instead.
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700620 */
621typedef struct {
622 /** set to sizeof(GpsSvStatus) */
623 size_t size;
Lifu Tang7e33bb22016-02-07 18:09:30 -0800624 int num_svs;
625 GpsSvInfo sv_list[GPS_MAX_SVS];
626 uint32_t ephemeris_mask;
627 uint32_t almanac_mask;
628 uint32_t used_in_fix_mask;
629} GpsSvStatus;
630
631/**
632 * Represents SV status.
633 */
634typedef struct {
635 /** set to sizeof(GnssSvStatus) */
636 size_t size;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700637
638 /** Number of GPS SVs currently visible, refers to the SVs stored in sv_list */
639 int num_svs;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700640 /**
641 * Pointer to an array of SVs information for all GNSS constellations,
642 * except GPS, which is reported using sv_list
643 */
Lifu Tang7e33bb22016-02-07 18:09:30 -0800644 GnssSvInfo gnss_sv_list[GNSS_MAX_SVS];
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700645
Lifu Tang7e33bb22016-02-07 18:09:30 -0800646} GnssSvStatus;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500647
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700648/* CellID for 2G, 3G and LTE, used in AGPS. */
Miguel Torroja5f404f52010-07-27 06:34:15 +0200649typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700650 AGpsRefLocationType type;
651 /** Mobile Country Code. */
Miguel Torroja5f404f52010-07-27 06:34:15 +0200652 uint16_t mcc;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700653 /** Mobile Network Code .*/
Miguel Torroja5f404f52010-07-27 06:34:15 +0200654 uint16_t mnc;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700655 /** Location Area Code in 2G, 3G and LTE. In 3G lac is discarded. In LTE,
656 * lac is populated with tac, to ensure that we don't break old clients that
657 * might rely in the old (wrong) behavior.
658 */
Miguel Torroja5f404f52010-07-27 06:34:15 +0200659 uint16_t lac;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700660 /** Cell id in 2G. Utran Cell id in 3G. Cell Global Id EUTRA in LTE. */
Miguel Torroja5f404f52010-07-27 06:34:15 +0200661 uint32_t cid;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700662 /** Tracking Area Code in LTE. */
663 uint16_t tac;
664 /** Physical Cell id in LTE (not used in 2G and 3G) */
665 uint16_t pcid;
Miguel Torroja5f404f52010-07-27 06:34:15 +0200666} AGpsRefLocationCellID;
667
668typedef struct {
669 uint8_t mac[6];
670} AGpsRefLocationMac;
671
672/** Represents ref locations */
673typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700674 AGpsRefLocationType type;
Miguel Torroja5f404f52010-07-27 06:34:15 +0200675 union {
676 AGpsRefLocationCellID cellID;
677 AGpsRefLocationMac mac;
678 } u;
679} AGpsRefLocation;
680
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700681/**
682 * Callback with location information. Can only be called from a thread created
683 * by create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700684 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500685typedef void (* gps_location_callback)(GpsLocation* location);
686
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700687/**
688 * Callback with status information. Can only be called from a thread created by
689 * create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700690 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500691typedef void (* gps_status_callback)(GpsStatus* status);
692
destradaa9f7c3732014-04-29 10:50:22 -0700693/**
Lifu Tanga1ca5742016-02-16 17:42:13 -0800694 * Legacy callback with SV status information.
destradaa9f7c3732014-04-29 10:50:22 -0700695 * Can only be called from a thread created by create_thread_cb.
Lifu Tanga1ca5742016-02-16 17:42:13 -0800696 *
697 * This callback is deprecated, and will be removed in the next release. Use
698 * gnss_sv_status_callback() instead.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700699 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500700typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info);
701
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700702/**
Lifu Tang7e33bb22016-02-07 18:09:30 -0800703 * Callback with SV status information.
704 * Can only be called from a thread created by create_thread_cb.
705 */
706typedef void (* gnss_sv_status_callback)(GnssSvStatus* sv_info);
707
708/**
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700709 * Callback for reporting NMEA sentences. Can only be called from a thread
710 * created by create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700711 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500712typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length);
713
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700714/**
715 * Callback to inform framework of the GPS engine's capabilities. Capability
716 * parameter is a bit field of GPS_CAPABILITY_* flags.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700717 */
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400718typedef void (* gps_set_capabilities)(uint32_t capabilities);
719
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700720/**
721 * Callback utility for acquiring the GPS wakelock. This can be used to prevent
722 * the CPU from suspending while handling GPS events.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700723 */
Mike Lockwoodd20bbae2010-04-07 09:04:25 -0400724typedef void (* gps_acquire_wakelock)();
725
726/** Callback utility for releasing the GPS wakelock. */
727typedef void (* gps_release_wakelock)();
728
Mike Lockwood8aac5912011-06-29 15:10:36 -0400729/** Callback for requesting NTP time */
730typedef void (* gps_request_utc_time)();
731
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700732/**
733 * Callback for creating a thread that can call into the Java framework code.
734 * This must be used to create any threads that report events up to the
735 * framework.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700736 */
737typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg);
738
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700739/**
740 * Provides information about how new the underlying GPS/GNSS hardware and
741 * software is.
742 *
743 * This information will be available for Android Test Applications. If a GPS
744 * HAL does not provide this information, it will be considered "2015 or
745 * earlier".
746 *
747 * If a GPS HAL does provide this information, then newer years will need to
748 * meet newer CTS standards. E.g. if the date are 2016 or above, then N+ level
749 * GpsMeasurement support will be verified.
750 */
751typedef struct {
Lifu Tanga1ca5742016-02-16 17:42:13 -0800752 /** Set to sizeof(GnssSystemInfo) */
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700753 size_t size;
754 /* year in which the last update was made to the underlying hardware/firmware
755 * used to capture GNSS signals, e.g. 2016 */
756 uint16_t year_of_hw;
Lifu Tanga1ca5742016-02-16 17:42:13 -0800757} GnssSystemInfo;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700758
759/**
760 * Callback to inform framework of the engine's hardware version information.
761 */
Lifu Tanga1ca5742016-02-16 17:42:13 -0800762typedef void (*gnss_set_system_info)(const GnssSystemInfo* info);
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700763
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700764/** New GPS callback structure. */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500765typedef struct {
Mike Lockwoodd20bbae2010-04-07 09:04:25 -0400766 /** set to sizeof(GpsCallbacks) */
767 size_t size;
768 gps_location_callback location_cb;
769 gps_status_callback status_cb;
770 gps_sv_status_callback sv_status_cb;
771 gps_nmea_callback nmea_cb;
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400772 gps_set_capabilities set_capabilities_cb;
Mike Lockwoodd20bbae2010-04-07 09:04:25 -0400773 gps_acquire_wakelock acquire_wakelock_cb;
774 gps_release_wakelock release_wakelock_cb;
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700775 gps_create_thread create_thread_cb;
Mike Lockwood8aac5912011-06-29 15:10:36 -0400776 gps_request_utc_time request_utc_time_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500777
Lifu Tanga1ca5742016-02-16 17:42:13 -0800778 gnss_set_system_info set_system_info_cb;
Lifu Tang7e33bb22016-02-07 18:09:30 -0800779 gnss_sv_status_callback gnss_sv_status_cb;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700780} GpsCallbacks;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500781
782/** Represents the standard GPS interface. */
783typedef struct {
784 /** set to sizeof(GpsInterface) */
785 size_t size;
786 /**
787 * Opens the interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -0700788 * to the implementation of this interface.
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500789 */
790 int (*init)( GpsCallbacks* callbacks );
791
792 /** Starts navigating. */
793 int (*start)( void );
794
795 /** Stops navigating. */
796 int (*stop)( void );
797
798 /** Closes the interface. */
799 void (*cleanup)( void );
800
801 /** Injects the current time. */
802 int (*inject_time)(GpsUtcTime time, int64_t timeReference,
803 int uncertainty);
804
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700805 /**
806 * Injects current location from another location provider (typically cell
807 * ID). Latitude and longitude are measured in degrees expected accuracy is
808 * measured in meters
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500809 */
810 int (*inject_location)(double latitude, double longitude, float accuracy);
811
812 /**
813 * Specifies that the next call to start will not use the
814 * information defined in the flags. GPS_DELETE_ALL is passed for
815 * a cold start.
816 */
817 void (*delete_aiding_data)(GpsAidingData flags);
818
819 /**
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400820 * min_interval represents the time between fixes in milliseconds.
821 * preferred_accuracy represents the requested fix accuracy in meters.
822 * preferred_time represents the requested time to first fix in milliseconds.
destradaa81534882015-04-28 13:10:56 -0700823 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700824 * 'mode' parameter should be one of GPS_POSITION_MODE_MS_BASED
destradaa81534882015-04-28 13:10:56 -0700825 * or GPS_POSITION_MODE_STANDALONE.
826 * It is allowed by the platform (and it is recommended) to fallback to
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700827 * GPS_POSITION_MODE_MS_BASED if GPS_POSITION_MODE_MS_ASSISTED is passed in, and
destradaa81534882015-04-28 13:10:56 -0700828 * GPS_POSITION_MODE_MS_BASED is supported.
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500829 */
Mike Lockwoodb15879a2010-04-14 15:36:34 -0400830 int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence,
831 uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time);
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500832
833 /** Get a pointer to extension information. */
834 const void* (*get_extension)(const char* name);
835} GpsInterface;
836
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700837/**
838 * Callback to request the client to download XTRA data. The client should
839 * download XTRA data and inject it by calling inject_xtra_data(). Can only be
840 * called from a thread created by create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700841 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500842typedef void (* gps_xtra_download_request)();
843
844/** Callback structure for the XTRA interface. */
845typedef struct {
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700846 gps_xtra_download_request download_request_cb;
847 gps_create_thread create_thread_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500848} GpsXtraCallbacks;
849
850/** Extended interface for XTRA support. */
851typedef struct {
852 /** set to sizeof(GpsXtraInterface) */
853 size_t size;
854 /**
855 * Opens the XTRA interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -0700856 * to the implementation of this interface.
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500857 */
858 int (*init)( GpsXtraCallbacks* callbacks );
859 /** Injects XTRA data into the GPS. */
860 int (*inject_xtra_data)( char* data, int length );
861} GpsXtraInterface;
862
863/** Extended interface for DEBUG support. */
864typedef struct {
865 /** set to sizeof(GpsDebugInterface) */
866 size_t size;
867
868 /**
869 * This function should return any information that the native
870 * implementation wishes to include in a bugreport.
871 */
872 size_t (*get_internal_state)(char* buffer, size_t bufferSize);
873} GpsDebugInterface;
874
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700875/*
876 * Represents the status of AGPS augmented to support IPv4 and IPv6.
877 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500878typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700879 /** set to sizeof(AGpsStatus) */
destradaaf48cc672014-06-05 11:07:09 -0700880 size_t size;
881
882 AGpsType type;
883 AGpsStatusValue status;
884
885 /**
886 * Must be set to a valid IPv4 address if the field 'addr' contains an IPv4
887 * address, or set to INADDR_NONE otherwise.
888 */
889 uint32_t ipaddr;
890
891 /**
892 * Must contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report.
893 * Any other value of addr.ss_family will be rejected.
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700894 */
destradaaf48cc672014-06-05 11:07:09 -0700895 struct sockaddr_storage addr;
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700896} AGpsStatus;
destradaaf48cc672014-06-05 11:07:09 -0700897
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700898/**
899 * Callback with AGPS status information. Can only be called from a thread
900 * created by create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700901 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500902typedef void (* agps_status_callback)(AGpsStatus* status);
903
904/** Callback structure for the AGPS interface. */
905typedef struct {
Mike Lockwood4453b5b2010-06-20 14:23:10 -0700906 agps_status_callback status_cb;
907 gps_create_thread create_thread_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500908} AGpsCallbacks;
909
destradaaf48cc672014-06-05 11:07:09 -0700910/**
911 * Extended interface for AGPS support, it is augmented to enable to pass
912 * extra APN data.
913 */
914typedef struct {
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700915 /** set to sizeof(AGpsInterface) */
destradaaf48cc672014-06-05 11:07:09 -0700916 size_t size;
917
918 /**
919 * Opens the AGPS interface and provides the callback routines to the
920 * implementation of this interface.
921 */
922 void (*init)(AGpsCallbacks* callbacks);
923 /**
924 * Deprecated.
925 * If the HAL supports AGpsInterface_v2 this API will not be used, see
926 * data_conn_open_with_apn_ip_type for more information.
927 */
928 int (*data_conn_open)(const char* apn);
929 /**
930 * Notifies that the AGPS data connection has been closed.
931 */
932 int (*data_conn_closed)();
933 /**
934 * Notifies that a data connection is not available for AGPS.
935 */
936 int (*data_conn_failed)();
937 /**
938 * Sets the hostname and port for the AGPS server.
939 */
940 int (*set_server)(AGpsType type, const char* hostname, int port);
941
942 /**
943 * Notifies that a data connection is available and sets the name of the
944 * APN, and its IP type, to be used for SUPL connections.
945 */
946 int (*data_conn_open_with_apn_ip_type)(
947 const char* apn,
948 ApnIpType apnIpType);
Lifu Tangdf0fcf72015-10-27 14:58:25 -0700949} AGpsInterface;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -0500950
destradaaa1f4c0a2013-09-13 15:45:03 -0700951/** Error codes associated with certificate operations */
952#define AGPS_CERTIFICATE_OPERATION_SUCCESS 0
953#define AGPS_CERTIFICATE_ERROR_GENERIC -100
954#define AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES -101
955
956/** A data structure that represents an X.509 certificate using DER encoding */
957typedef struct {
958 size_t length;
959 u_char* data;
960} DerEncodedCertificate;
961
962/**
963 * A type definition for SHA1 Fingerprints used to identify X.509 Certificates
964 * The Fingerprint is a digest of the DER Certificate that uniquely identifies it.
965 */
966typedef struct {
967 u_char data[20];
968} Sha1CertificateFingerprint;
969
destradaa9f7c3732014-04-29 10:50:22 -0700970/** AGPS Interface to handle SUPL certificate operations */
destradaaa1f4c0a2013-09-13 15:45:03 -0700971typedef struct {
972 /** set to sizeof(SuplCertificateInterface) */
973 size_t size;
974
975 /**
976 * Installs a set of Certificates used for SUPL connections to the AGPS server.
977 * If needed the HAL should find out internally any certificates that need to be removed to
978 * accommodate the certificates to install.
979 * The certificates installed represent a full set of valid certificates needed to connect to
980 * AGPS SUPL servers.
981 * The list of certificates is required, and all must be available at the same time, when trying
982 * to establish a connection with the AGPS Server.
983 *
984 * Parameters:
985 * certificates - A pointer to an array of DER encoded certificates that are need to be
986 * installed in the HAL.
987 * length - The number of certificates to install.
988 * Returns:
989 * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully
990 * AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES if the HAL cannot store the number of
991 * certificates attempted to be installed, the state of the certificates stored should
992 * remain the same as before on this error case.
993 *
994 * IMPORTANT:
995 * If needed the HAL should find out internally the set of certificates that need to be
996 * removed to accommodate the certificates to install.
997 */
998 int (*install_certificates) ( const DerEncodedCertificate* certificates, size_t length );
999
1000 /**
1001 * Notifies the HAL that a list of certificates used for SUPL connections are revoked. It is
1002 * expected that the given set of certificates is removed from the internal store of the HAL.
1003 *
1004 * Parameters:
1005 * fingerprints - A pointer to an array of SHA1 Fingerprints to identify the set of
1006 * certificates to revoke.
1007 * length - The number of fingerprints provided.
1008 * Returns:
1009 * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully.
1010 *
1011 * IMPORTANT:
1012 * If any of the certificates provided (through its fingerprint) is not known by the HAL,
1013 * it should be ignored and continue revoking/deleting the rest of them.
1014 */
1015 int (*revoke_certificates) ( const Sha1CertificateFingerprint* fingerprints, size_t length );
destradaa7ddd4d72013-11-07 13:47:59 -08001016} SuplCertificateInterface;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -05001017
1018/** Represents an NI request */
1019typedef struct {
1020 /** set to sizeof(GpsNiNotification) */
1021 size_t size;
1022
1023 /**
1024 * An ID generated by HAL to associate NI notifications and UI
1025 * responses
1026 */
1027 int notification_id;
1028
1029 /**
1030 * An NI type used to distinguish different categories of NI
1031 * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ...
1032 */
1033 GpsNiType ni_type;
1034
1035 /**
1036 * Notification/verification options, combinations of GpsNiNotifyFlags constants
1037 */
1038 GpsNiNotifyFlags notify_flags;
1039
1040 /**
1041 * Timeout period to wait for user response.
1042 * Set to 0 for no time out limit.
1043 */
1044 int timeout;
1045
1046 /**
1047 * Default response when time out.
1048 */
1049 GpsUserResponseType default_response;
1050
1051 /**
1052 * Requestor ID
1053 */
1054 char requestor_id[GPS_NI_SHORT_STRING_MAXLEN];
1055
1056 /**
1057 * Notification message. It can also be used to store client_id in some cases
1058 */
1059 char text[GPS_NI_LONG_STRING_MAXLEN];
1060
1061 /**
1062 * Client name decoding scheme
1063 */
1064 GpsNiEncodingType requestor_id_encoding;
1065
1066 /**
1067 * Client name decoding scheme
1068 */
1069 GpsNiEncodingType text_encoding;
1070
1071 /**
1072 * A pointer to extra data. Format:
1073 * key_1 = value_1
1074 * key_2 = value_2
1075 */
1076 char extras[GPS_NI_LONG_STRING_MAXLEN];
1077
1078} GpsNiNotification;
1079
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001080/**
1081 * Callback with NI notification. Can only be called from a thread created by
1082 * create_thread_cb.
Mike Lockwood4453b5b2010-06-20 14:23:10 -07001083 */
Mike Lockwood9b0b1c32010-02-23 18:42:37 -05001084typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification);
1085
1086/** GPS NI callback structure. */
1087typedef struct
1088{
Mike Lockwood4453b5b2010-06-20 14:23:10 -07001089 /**
1090 * Sends the notification request from HAL to GPSLocationProvider.
1091 */
1092 gps_ni_notify_callback notify_cb;
1093 gps_create_thread create_thread_cb;
Mike Lockwood9b0b1c32010-02-23 18:42:37 -05001094} GpsNiCallbacks;
1095
1096/**
1097 * Extended interface for Network-initiated (NI) support.
1098 */
1099typedef struct
1100{
1101 /** set to sizeof(GpsNiInterface) */
1102 size_t size;
1103
1104 /** Registers the callbacks for HAL to use. */
1105 void (*init) (GpsNiCallbacks *callbacks);
1106
1107 /** Sends a response to HAL. */
1108 void (*respond) (int notif_id, GpsUserResponseType user_response);
1109} GpsNiInterface;
1110
1111struct gps_device_t {
1112 struct hw_device_t common;
1113
1114 /**
1115 * Set the provided lights to the provided values.
1116 *
1117 * Returns: 0 on succes, error code on failure.
1118 */
1119 const GpsInterface* (*get_gps_interface)(struct gps_device_t* dev);
1120};
1121
Miguel Torroja5f404f52010-07-27 06:34:15 +02001122#define AGPS_RIL_REQUEST_SETID_IMSI (1<<0L)
1123#define AGPS_RIL_REQUEST_SETID_MSISDN (1<<1L)
1124
1125#define AGPS_RIL_REQUEST_REFLOC_CELLID (1<<0L)
1126#define AGPS_RIL_REQUEST_REFLOC_MAC (1<<1L)
1127
1128typedef void (*agps_ril_request_set_id)(uint32_t flags);
1129typedef void (*agps_ril_request_ref_loc)(uint32_t flags);
1130
1131typedef struct {
1132 agps_ril_request_set_id request_setid;
1133 agps_ril_request_ref_loc request_refloc;
1134 gps_create_thread create_thread_cb;
1135} AGpsRilCallbacks;
1136
1137/** Extended interface for AGPS_RIL support. */
1138typedef struct {
1139 /** set to sizeof(AGpsRilInterface) */
1140 size_t size;
1141 /**
1142 * Opens the AGPS interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -07001143 * to the implementation of this interface.
Miguel Torroja5f404f52010-07-27 06:34:15 +02001144 */
1145 void (*init)( AGpsRilCallbacks* callbacks );
1146
1147 /**
1148 * Sets the reference location.
1149 */
1150 void (*set_ref_location) (const AGpsRefLocation *agps_reflocation, size_t sz_struct);
1151 /**
1152 * Sets the set ID.
1153 */
1154 void (*set_set_id) (AGpsSetIDType type, const char* setid);
1155
1156 /**
1157 * Send network initiated message.
1158 */
1159 void (*ni_message) (uint8_t *msg, size_t len);
Mike Lockwood455e83b2010-10-11 06:16:57 -04001160
1161 /**
1162 * Notify GPS of network status changes.
1163 * These parameters match values in the android.net.NetworkInfo class.
1164 */
1165 void (*update_network_state) (int connected, int type, int roaming, const char* extra_info);
Kevin Tangb82c2db2011-04-13 17:15:55 -07001166
1167 /**
1168 * Notify GPS of network status changes.
1169 * These parameters match values in the android.net.NetworkInfo class.
1170 */
1171 void (*update_network_availability) (int avaiable, const char* apn);
Miguel Torroja5f404f52010-07-27 06:34:15 +02001172} AGpsRilInterface;
1173
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001174/**
1175 * GPS Geofence.
1176 * There are 3 states associated with a Geofence: Inside, Outside, Unknown.
1177 * There are 3 transitions: ENTERED, EXITED, UNCERTAIN.
1178 *
1179 * An example state diagram with confidence level: 95% and Unknown time limit
1180 * set as 30 secs is shown below. (confidence level and Unknown time limit are
1181 * explained latter)
1182 * ____________________________
1183 * | Unknown (30 secs) |
1184 * """"""""""""""""""""""""""""
1185 * ^ | | ^
1186 * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN
1187 * | v v |
1188 * ________ EXITED _________
1189 * | Inside | -----------> | Outside |
1190 * | | <----------- | |
1191 * """""""" ENTERED """""""""
1192 *
1193 * Inside state: We are 95% confident that the user is inside the geofence.
1194 * Outside state: We are 95% confident that the user is outside the geofence
1195 * Unknown state: Rest of the time.
1196 *
1197 * The Unknown state is better explained with an example:
1198 *
1199 * __________
1200 * | c|
1201 * | ___ | _______
1202 * | |a| | | b |
1203 * | """ | """""""
1204 * | |
1205 * """"""""""
1206 * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy
1207 * circle reported by the GPS subsystem. Now with regard to "b", the system is
1208 * confident that the user is outside. But with regard to "a" is not confident
1209 * whether it is inside or outside the geofence. If the accuracy remains the
1210 * same for a sufficient period of time, the UNCERTAIN transition would be
1211 * triggered with the state set to Unknown. If the accuracy improves later, an
1212 * appropriate transition should be triggered. This "sufficient period of time"
1213 * is defined by the parameter in the add_geofence_area API.
1214 * In other words, Unknown state can be interpreted as a state in which the
1215 * GPS subsystem isn't confident enough that the user is either inside or
1216 * outside the Geofence. It moves to Unknown state only after the expiry of the
1217 * timeout.
1218 *
1219 * The geofence callback needs to be triggered for the ENTERED and EXITED
1220 * transitions, when the GPS system is confident that the user has entered
1221 * (Inside state) or exited (Outside state) the Geofence. An implementation
1222 * which uses a value of 95% as the confidence is recommended. The callback
1223 * should be triggered only for the transitions requested by the
1224 * add_geofence_area call.
1225 *
1226 * Even though the diagram and explanation talks about states and transitions,
1227 * the callee is only interested in the transistions. The states are mentioned
1228 * here for illustrative purposes.
1229 *
1230 * Startup Scenario: When the device boots up, if an application adds geofences,
1231 * and then we get an accurate GPS location fix, it needs to trigger the
1232 * appropriate (ENTERED or EXITED) transition for every Geofence it knows about.
1233 * By default, all the Geofences will be in the Unknown state.
1234 *
1235 * When the GPS system is unavailable, gps_geofence_status_callback should be
1236 * called to inform the upper layers of the same. Similarly, when it becomes
1237 * available the callback should be called. This is a global state while the
1238 * UNKNOWN transition described above is per geofence.
1239 *
1240 * An important aspect to note is that users of this API (framework), will use
1241 * other subsystems like wifi, sensors, cell to handle Unknown case and
1242 * hopefully provide a definitive state transition to the third party
1243 * application. GPS Geofence will just be a signal indicating what the GPS
1244 * subsystem knows about the Geofence.
1245 *
1246 */
1247#define GPS_GEOFENCE_ENTERED (1<<0L)
1248#define GPS_GEOFENCE_EXITED (1<<1L)
1249#define GPS_GEOFENCE_UNCERTAIN (1<<2L)
1250
1251#define GPS_GEOFENCE_UNAVAILABLE (1<<0L)
1252#define GPS_GEOFENCE_AVAILABLE (1<<1L)
1253
Jaikumar Ganesh5824b402013-02-25 11:43:33 -08001254#define GPS_GEOFENCE_OPERATION_SUCCESS 0
1255#define GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES -100
1256#define GPS_GEOFENCE_ERROR_ID_EXISTS -101
1257#define GPS_GEOFENCE_ERROR_ID_UNKNOWN -102
1258#define GPS_GEOFENCE_ERROR_INVALID_TRANSITION -103
1259#define GPS_GEOFENCE_ERROR_GENERIC -149
1260
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001261/**
1262 * The callback associated with the geofence.
1263 * Parameters:
1264 * geofence_id - The id associated with the add_geofence_area.
1265 * location - The current GPS location.
1266 * transition - Can be one of GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED,
1267 * GPS_GEOFENCE_UNCERTAIN.
1268 * timestamp - Timestamp when the transition was detected.
1269 *
1270 * The callback should only be called when the caller is interested in that
1271 * particular transition. For instance, if the caller is interested only in
1272 * ENTERED transition, then the callback should NOT be called with the EXITED
1273 * transition.
1274 *
1275 * IMPORTANT: If a transition is triggered resulting in this callback, the GPS
1276 * subsystem will wake up the application processor, if its in suspend state.
1277 */
1278typedef void (*gps_geofence_transition_callback) (int32_t geofence_id, GpsLocation* location,
1279 int32_t transition, GpsUtcTime timestamp);
1280
1281/**
destradaa9f7c3732014-04-29 10:50:22 -07001282 * The callback associated with the availability of the GPS system for geofencing
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001283 * monitoring. If the GPS system determines that it cannot monitor geofences
1284 * because of lack of reliability or unavailability of the GPS signals, it will
1285 * call this callback with GPS_GEOFENCE_UNAVAILABLE parameter.
1286 *
1287 * Parameters:
1288 * status - GPS_GEOFENCE_UNAVAILABLE or GPS_GEOFENCE_AVAILABLE.
1289 * last_location - Last known location.
1290 */
1291typedef void (*gps_geofence_status_callback) (int32_t status, GpsLocation* last_location);
1292
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001293/**
1294 * The callback associated with the add_geofence call.
1295 *
1296 * Parameter:
1297 * geofence_id - Id of the geofence.
1298 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1299 * GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached.
1300 * GPS_GEOFENCE_ERROR_ID_EXISTS - geofence with id already exists
1301 * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - the monitorTransition contains an
1302 * invalid transition
1303 * GPS_GEOFENCE_ERROR_GENERIC - for other errors.
1304 */
1305typedef void (*gps_geofence_add_callback) (int32_t geofence_id, int32_t status);
1306
1307/**
1308 * The callback associated with the remove_geofence call.
1309 *
1310 * Parameter:
1311 * geofence_id - Id of the geofence.
1312 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1313 * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
1314 * GPS_GEOFENCE_ERROR_GENERIC for others.
1315 */
1316typedef void (*gps_geofence_remove_callback) (int32_t geofence_id, int32_t status);
1317
1318
1319/**
1320 * The callback associated with the pause_geofence call.
1321 *
1322 * Parameter:
1323 * geofence_id - Id of the geofence.
1324 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1325 * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
1326 * GPS_GEOFENCE_ERROR_INVALID_TRANSITION -
1327 * when monitor_transitions is invalid
1328 * GPS_GEOFENCE_ERROR_GENERIC for others.
1329 */
1330typedef void (*gps_geofence_pause_callback) (int32_t geofence_id, int32_t status);
1331
1332/**
1333 * The callback associated with the resume_geofence call.
1334 *
1335 * Parameter:
1336 * geofence_id - Id of the geofence.
1337 * status - GPS_GEOFENCE_OPERATION_SUCCESS
1338 * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id
1339 * GPS_GEOFENCE_ERROR_GENERIC for others.
1340 */
1341typedef void (*gps_geofence_resume_callback) (int32_t geofence_id, int32_t status);
1342
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001343typedef struct {
1344 gps_geofence_transition_callback geofence_transition_callback;
1345 gps_geofence_status_callback geofence_status_callback;
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001346 gps_geofence_add_callback geofence_add_callback;
1347 gps_geofence_remove_callback geofence_remove_callback;
1348 gps_geofence_pause_callback geofence_pause_callback;
1349 gps_geofence_resume_callback geofence_resume_callback;
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001350 gps_create_thread create_thread_cb;
1351} GpsGeofenceCallbacks;
1352
1353/** Extended interface for GPS_Geofencing support */
1354typedef struct {
1355 /** set to sizeof(GpsGeofencingInterface) */
1356 size_t size;
1357
1358 /**
1359 * Opens the geofence interface and provides the callback routines
destradaa9f7c3732014-04-29 10:50:22 -07001360 * to the implementation of this interface.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001361 */
1362 void (*init)( GpsGeofenceCallbacks* callbacks );
1363
1364 /**
1365 * Add a geofence area. This api currently supports circular geofences.
1366 * Parameters:
1367 * geofence_id - The id for the geofence. If a geofence with this id
Jaikumar Ganesh5824b402013-02-25 11:43:33 -08001368 * already exists, an error value (GPS_GEOFENCE_ERROR_ID_EXISTS)
1369 * should be returned.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001370 * latitude, longtitude, radius_meters - The lat, long and radius
1371 * (in meters) for the geofence
1372 * last_transition - The current state of the geofence. For example, if
1373 * the system already knows that the user is inside the geofence,
1374 * this will be set to GPS_GEOFENCE_ENTERED. In most cases, it
1375 * will be GPS_GEOFENCE_UNCERTAIN.
1376 * monitor_transition - Which transitions to monitor. Bitwise OR of
1377 * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and
1378 * GPS_GEOFENCE_UNCERTAIN.
1379 * notification_responsiveness_ms - Defines the best-effort description
1380 * of how soon should the callback be called when the transition
1381 * associated with the Geofence is triggered. For instance, if set
1382 * to 1000 millseconds with GPS_GEOFENCE_ENTERED, the callback
1383 * should be called 1000 milliseconds within entering the geofence.
1384 * This parameter is defined in milliseconds.
1385 * NOTE: This is not to be confused with the rate that the GPS is
1386 * polled at. It is acceptable to dynamically vary the rate of
1387 * sampling the GPS for power-saving reasons; thus the rate of
1388 * sampling may be faster or slower than this.
1389 * unknown_timer_ms - The time limit after which the UNCERTAIN transition
destradaa9f7c3732014-04-29 10:50:22 -07001390 * should be triggered. This parameter is defined in milliseconds.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001391 * See above for a detailed explanation.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001392 */
destradaa9f7c3732014-04-29 10:50:22 -07001393 void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude,
1394 double radius_meters, int last_transition, int monitor_transitions,
1395 int notification_responsiveness_ms, int unknown_timer_ms);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001396
1397 /**
1398 * Pause monitoring a particular geofence.
1399 * Parameters:
1400 * geofence_id - The id for the geofence.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001401 */
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001402 void (*pause_geofence) (int32_t geofence_id);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001403
1404 /**
1405 * Resume monitoring a particular geofence.
1406 * Parameters:
1407 * geofence_id - The id for the geofence.
1408 * monitor_transitions - Which transitions to monitor. Bitwise OR of
1409 * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and
1410 * GPS_GEOFENCE_UNCERTAIN.
1411 * This supersedes the value associated provided in the
1412 * add_geofence_area call.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001413 */
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001414 void (*resume_geofence) (int32_t geofence_id, int monitor_transitions);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001415
1416 /**
1417 * Remove a geofence area. After the function returns, no notifications
1418 * should be sent.
1419 * Parameter:
1420 * geofence_id - The id for the geofence.
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001421 */
Jaikumar Ganesh3e39c492013-03-29 11:56:36 -07001422 void (*remove_geofence_area) (int32_t geofence_id);
Jaikumar Ganesh052a20a2013-02-04 17:22:04 -08001423} GpsGeofencingInterface;
destradaa9f7c3732014-04-29 10:50:22 -07001424
destradaa9f7c3732014-04-29 10:50:22 -07001425/**
Lifu Tang7e33bb22016-02-07 18:09:30 -08001426 * Legacy struct to represent an estimate of the GPS clock time.
1427 * Deprecated, to be removed in the next Android release.
1428 * Use GnssClock instead.
destradaa9f7c3732014-04-29 10:50:22 -07001429 */
1430typedef struct {
1431 /** set to sizeof(GpsClock) */
1432 size_t size;
Lifu Tang7e33bb22016-02-07 18:09:30 -08001433 GpsClockFlags flags;
1434 int16_t leap_second;
1435 GpsClockType type;
1436 int64_t time_ns;
1437 double time_uncertainty_ns;
1438 int64_t full_bias_ns;
1439 double bias_ns;
1440 double bias_uncertainty_ns;
1441 double drift_nsps;
1442 double drift_uncertainty_nsps;
1443} GpsClock;
1444
1445/**
1446 * Represents an estimate of the GPS clock time.
1447 */
1448typedef struct {
1449 /** set to sizeof(GnssClock) */
1450 size_t size;
destradaa9f7c3732014-04-29 10:50:22 -07001451
Lifu Tanga1ca5742016-02-16 17:42:13 -08001452 /**
1453 * A set of flags indicating the validity of the fields in this data
1454 * structure.
1455 */
1456 GnssClockFlags flags;
destradaa9f7c3732014-04-29 10:50:22 -07001457
1458 /**
1459 * Leap second data.
destradaa75843eb2014-07-17 14:04:50 -07001460 * The sign of the value is defined by the following equation:
Lifu Tanga1ca5742016-02-16 17:42:13 -08001461 * utc_time_ns = time_ns + (full_bias_ns + bias_ns) - leap_second *
1462 * 1,000,000,000
destradaa75843eb2014-07-17 14:04:50 -07001463 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001464 * If the data is available 'flags' must contain GNSS_CLOCK_HAS_LEAP_SECOND.
destradaa9f7c3732014-04-29 10:50:22 -07001465 */
1466 int16_t leap_second;
1467
1468 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001469 * The GNSS receiver internal clock value. This is the local hardware clock
1470 * value.
destradaa9f7c3732014-04-29 10:50:22 -07001471 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001472 * For local hardware clock, this value is expected to be monotonically
1473 * increasing while the hardware clock remains power on. (For the case of a
1474 * HW clock that is not continuously on, see the
1475 * hw_clock_discontinuity_count field). The real GPS time can be derived by
1476 * adding the 'full_bias_ns + bias_ns' (when it is available) to this value.
destradaa9f7c3732014-04-29 10:50:22 -07001477 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001478 * This GPS time is expected to be the best estimate of current GPS time
1479 * that GNSS receiver can achieve.
destradaa75843eb2014-07-17 14:04:50 -07001480 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001481 * Sub-nanosecond accuracy can be provided by means of the 'bias_ns' field.
destradaa9f7c3732014-04-29 10:50:22 -07001482 * The value contains the 'time uncertainty' in it.
destradaa75843eb2014-07-17 14:04:50 -07001483 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001484 * This field is mandatory.
destradaa9f7c3732014-04-29 10:50:22 -07001485 */
1486 int64_t time_ns;
1487
1488 /**
1489 * 1-Sigma uncertainty associated with the clock's time in nanoseconds.
1490 * The uncertainty is represented as an absolute (single sided) value.
1491 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001492 * If the data is available, 'flags' must contain
Lifu Tanga1ca5742016-02-16 17:42:13 -08001493 * GNSS_CLOCK_HAS_TIME_UNCERTAINTY. This value is effectively zero (it is
1494 * the reference local clock, by which all other times and time
1495 * uncertainties are measured.) (And thus this field can be not provided,
1496 * per GNSS_CLOCK_HAS_TIME_UNCERTAINTY flag, or provided & set to 0.)
destradaa9f7c3732014-04-29 10:50:22 -07001497 */
1498 double time_uncertainty_ns;
1499
1500 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001501 * The difference between hardware clock ('time' field) inside GPS receiver
1502 * and the true GPS time since 0000Z, January 6, 1980, in nanoseconds.
destradaa9f7c3732014-04-29 10:50:22 -07001503 *
destradaa75843eb2014-07-17 14:04:50 -07001504 * The sign of the value is defined by the following equation:
Lifu Tanga1ca5742016-02-16 17:42:13 -08001505 * local estimate of GPS time = time_ns + (full_bias_ns + bias_ns)
destradaa75843eb2014-07-17 14:04:50 -07001506 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001507 * This value is mandatory if the receiver has estimated GPS time. If the
1508 * computed time is for a non-GPS constellation, the time offset of that
1509 * constellation to GPS has to be applied to fill this value. The value
1510 * contains the 'bias uncertainty' in it, and the caller is responsible of
1511 * using the uncertainty. If the data is available 'flags' must contain
1512 * GNSS_CLOCK_HAS_FULL_BIAS.
destradaa75843eb2014-07-17 14:04:50 -07001513 */
1514 int64_t full_bias_ns;
1515
1516 /**
1517 * Sub-nanosecond bias.
destradaa9f7c3732014-04-29 10:50:22 -07001518 * The value contains the 'bias uncertainty' in it.
destradaa75843eb2014-07-17 14:04:50 -07001519 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001520 * If the data is available 'flags' must contain GNSS_CLOCK_HAS_BIAS. If GPS
1521 * has computed a position fix. This value is mandatory if the receiver has
1522 * estimated GPS time.
destradaa9f7c3732014-04-29 10:50:22 -07001523 */
1524 double bias_ns;
1525
1526 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001527 * 1-Sigma uncertainty associated with the local estimate of GPS time (clock
1528 * bias) in nanoseconds. The uncertainty is represented as an absolute
1529 * (single sided) value.
destradaa9f7c3732014-04-29 10:50:22 -07001530 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001531 * If the data is available 'flags' must contain
Lifu Tanga1ca5742016-02-16 17:42:13 -08001532 * GNSS_CLOCK_HAS_BIAS_UNCERTAINTY. This value is mandatory if the receiver
1533 * has estimated GPS time.
destradaa9f7c3732014-04-29 10:50:22 -07001534 */
1535 double bias_uncertainty_ns;
1536
1537 /**
1538 * The clock's drift in nanoseconds (per second).
Lifu Tanga1ca5742016-02-16 17:42:13 -08001539 *
1540 * A positive value means that the frequency is higher than the nominal
1541 * frequency.
destradaa9f7c3732014-04-29 10:50:22 -07001542 *
1543 * The value contains the 'drift uncertainty' in it.
Lifu Tanga1ca5742016-02-16 17:42:13 -08001544 * If the data is available 'flags' must contain GNSS_CLOCK_HAS_DRIFT.
destradaa00caa892015-04-09 18:41:46 -07001545 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001546 * This value is mandatory if the receiver has estimated GNSS time
destradaa9f7c3732014-04-29 10:50:22 -07001547 */
1548 double drift_nsps;
1549
1550 /**
1551 * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per second).
1552 * The uncertainty is represented as an absolute (single sided) value.
1553 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001554 * If the data is available 'flags' must contain
Lifu Tanga1ca5742016-02-16 17:42:13 -08001555 * GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY. If GPS has computed a position fix this
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001556 * field is mandatory and must be populated.
destradaa9f7c3732014-04-29 10:50:22 -07001557 */
1558 double drift_uncertainty_nsps;
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001559
1560 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001561 * When there are any discontinuities in the HW clock, this field is
1562 * mandatory.
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001563 *
1564 * A "discontinuity" is meant to cover the case of a switch from one source
1565 * of clock to another. A single free-running crystal oscillator (XO)
Lifu Tanga1ca5742016-02-16 17:42:13 -08001566 * should generally not have any discontinuities, and this can be set and
1567 * left at 0.
1568 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001569 * If, however, the time_ns value (HW clock) is derived from a composite of
Lifu Tanga1ca5742016-02-16 17:42:13 -08001570 * sources, that is not as smooth as a typical XO, or is otherwise stopped &
1571 * restarted, then this value shall be incremented each time a discontinuity
1572 * occurs. (E.g. this value may start at zero at device boot-up and
1573 * increment each time there is a change in clock continuity. In the
1574 * unlikely event that this value reaches full scale, rollover (not
1575 * clamping) is required, such that this value continues to change, during
1576 * subsequent discontinuity events.)
1577 *
1578 * While this number stays the same, between GnssClock reports, it can be
1579 * safely assumed that the time_ns value has been running continuously, e.g.
1580 * derived from a single, high quality clock (XO like, or better, that's
1581 * typically used during continuous GNSS signal sampling.)
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001582 *
1583 * It is expected, esp. during periods where there are few GNSS signals
1584 * available, that the HW clock be discontinuity-free as long as possible,
Lifu Tanga1ca5742016-02-16 17:42:13 -08001585 * as this avoids the need to use (waste) a GNSS measurement to fully
1586 * re-solve for the GPS clock bias and drift, when using the accompanying
1587 * measurements, from consecutive GnssData reports.
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001588 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001589 uint32_t hw_clock_discontinuity_count;
1590
Lifu Tang7e33bb22016-02-07 18:09:30 -08001591} GnssClock;
destradaa9f7c3732014-04-29 10:50:22 -07001592
1593/**
Lifu Tang7e33bb22016-02-07 18:09:30 -08001594 * Legacy struct to represent a GPS Measurement, it contains raw and computed
1595 * information.
1596 * Deprecated, to be removed in the next Android release.
1597 * Use GnssMeasurement instead.
1598 */
1599typedef struct {
1600 /** set to sizeof(GpsMeasurement) */
1601 size_t size;
1602 GpsMeasurementFlags flags;
1603 int8_t prn;
1604 double time_offset_ns;
1605 GpsMeasurementState state;
1606 int64_t received_gps_tow_ns;
1607 int64_t received_gps_tow_uncertainty_ns;
1608 double c_n0_dbhz;
1609 double pseudorange_rate_mps;
1610 double pseudorange_rate_uncertainty_mps;
1611 GpsAccumulatedDeltaRangeState accumulated_delta_range_state;
1612 double accumulated_delta_range_m;
1613 double accumulated_delta_range_uncertainty_m;
1614 double pseudorange_m;
1615 double pseudorange_uncertainty_m;
1616 double code_phase_chips;
1617 double code_phase_uncertainty_chips;
1618 float carrier_frequency_hz;
1619 int64_t carrier_cycles;
1620 double carrier_phase;
1621 double carrier_phase_uncertainty;
1622 GpsLossOfLock loss_of_lock;
1623 int32_t bit_number;
1624 int16_t time_from_last_bit_ms;
1625 double doppler_shift_hz;
1626 double doppler_shift_uncertainty_hz;
1627 GpsMultipathIndicator multipath_indicator;
1628 double snr_db;
1629 double elevation_deg;
1630 double elevation_uncertainty_deg;
1631 double azimuth_deg;
1632 double azimuth_uncertainty_deg;
1633 bool used_in_fix;
1634} GpsMeasurement;
1635
1636/**
1637 * Represents a GNSS Measurement, it contains raw and computed information.
Lifu Tang1d4183c2016-02-24 13:50:19 -08001638 *
1639 * Independence - All signal measurement information (e.g. sv_time,
1640 * pseudorange_rate, multipath_indicator) reported in this struct should be
1641 * based on GNSS signal measurements only. You may not synthesize measurements
1642 * by calculating or reporting expected measurements based on known or estimated
1643 * position, velocity, or time.
destradaa9f7c3732014-04-29 10:50:22 -07001644 */
1645typedef struct {
1646 /** set to sizeof(GpsMeasurement) */
1647 size_t size;
1648
1649 /** A set of flags indicating the validity of the fields in this data structure. */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001650 GnssMeasurementFlags flags;
destradaa9f7c3732014-04-29 10:50:22 -07001651
1652 /**
Lifu Tang7e33bb22016-02-07 18:09:30 -08001653 * Satellite vehicle ID number, as defined in GnssSvInfo::svid
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001654 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001655 */
Lifu Tang7e33bb22016-02-07 18:09:30 -08001656 int16_t svid;
destradaa9f7c3732014-04-29 10:50:22 -07001657
1658 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001659 * Defines the constellation of the given SV. Value should be one of those
1660 * GNSS_CONSTELLATION_* constants
1661 */
1662 GnssConstellationType constellation;
1663
1664 /**
destradaa75843eb2014-07-17 14:04:50 -07001665 * Time offset at which the measurement was taken in nanoseconds.
1666 * The reference receiver's time is specified by GpsData::clock::time_ns and should be
1667 * interpreted in the same way as indicated by GpsClock::type.
1668 *
destradaa9f7c3732014-04-29 10:50:22 -07001669 * The sign of time_offset_ns is given by the following equation:
1670 * measurement time = GpsClock::time_ns + time_offset_ns
1671 *
1672 * It provides an individual time-stamp for the measurement, and allows sub-nanosecond accuracy.
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001673 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001674 */
destradaa75843eb2014-07-17 14:04:50 -07001675 double time_offset_ns;
destradaa9f7c3732014-04-29 10:50:22 -07001676
1677 /**
destradaa75843eb2014-07-17 14:04:50 -07001678 * Per satellite sync state. It represents the current sync state for the associated satellite.
1679 * Based on the sync state, the 'received GPS tow' field should be interpreted accordingly.
destradaa9f7c3732014-04-29 10:50:22 -07001680 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001681 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001682 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001683 GnssMeasurementState state;
destradaa75843eb2014-07-17 14:04:50 -07001684
1685 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001686 * The received GNSS Time-of-Week at the measurement time, in nanoseconds.
Lifu Tang1d4183c2016-02-24 13:50:19 -08001687 * Ensure that this field is independent (see comment at top of
1688 * GnssMeasurement struct.)
destradaa75843eb2014-07-17 14:04:50 -07001689 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001690 * For GPS & QZSS, this is:
1691 * Received GPS Time-of-Week at the measurement time, in nanoseconds.
1692 * The value is relative to the beginning of the current GPS week.
Tsuwei Chena90cf192014-10-23 12:49:12 -07001693 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001694 * Given the highest sync state that can be achieved, per each satellite, valid range
1695 * for this field can be:
1696 * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN
1697 * C/A code lock : [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set
1698 * Bit sync : [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set
1699 * Subframe sync : [ 0 6s ] : GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set
1700 * TOW decoded : [ 0 1week ] : GNSS_MEASUREMENT_STATE_TOW_DECODED is set
destradaa00caa892015-04-09 18:41:46 -07001701 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001702 * Note well: if there is any ambiguity in integer millisecond,
1703 * GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS should be set accordingly, in the 'state' field.
1704 *
1705 * This value must be populated if 'state' != GNSS_MEASUREMENT_STATE_UNKNOWN.
1706 *
1707 * For Glonass, this is:
1708 * Received Glonass time of day, at the measurement time in nanoseconds.
1709 *
1710 * Given the highest sync state that can be achieved, per each satellite, valid range for
1711 * this field can be:
1712 * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN
1713 * C/A code lock : [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set
1714 * Symbol sync : [ 0 10ms ] : GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set
1715 * Bit sync : [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set
1716 * String sync : [ 0 2s ] : GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC is set
1717 * Time of day : [ 0 1day ] : GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED is set
1718 *
1719 * For Beidou, this is:
1720 * Received Beidou time of week, at the measurement time in nanoseconds.
1721 *
1722 * Given the highest sync state that can be achieved, per each satellite, valid range for
1723 * this field can be:
1724 * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN
1725 * C/A code lock: [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set
1726 * Bit sync (D2): [ 0 2ms ] : GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC is set
1727 * Bit sync (D1): [ 0 20ms ] : GNSS_MEASUREMENT_STATE_BIT_SYNC is set
1728 * Subframe (D2): [ 0 0.6s ] : GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC is set
1729 * Subframe (D1): [ 0 6s ] : GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC is set
1730 * Time of week : [ 0 1week ] : GNSS_MEASUREMENT_STATE_TOW_DECODED is set
1731 *
1732 * For Galileo, this is:
1733 * Received Galileo time of week, at the measurement time in nanoseconds.
1734 *
1735 * E1BC code lock : [ 0 4ms ] : GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK is set
1736 * E1C 2nd code lock: [ 0 100ms ] :
1737 * GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK is set
1738 *
1739 * E1B page : [ 0 2s ] : GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC is set
1740 * Time of week: [ 0 1week ] : GNSS_MEASUREMENT_STATE_GAL_TOW_DECODED is set
1741 *
1742 * For SBAS, this is:
1743 * Received SBAS time, at the measurement time in nanoseconds.
1744 *
1745 * Given the highest sync state that can be achieved, per each satellite,
1746 * valid range for this field can be:
1747 * Searching : [ 0 ] : GNSS_MEASUREMENT_STATE_UNKNOWN
1748 * C/A code lock: [ 0 1ms ] : GNSS_MEASUREMENT_STATE_CODE_LOCK is set
1749 * Symbol sync : [ 0 2ms ] : GNSS_MEASUREMENT_STATE_SYMBOL_SYNC is set
1750 * Message : [ 0 1s ] : GNSS_MEASUREMENT_STATE_SBAS_SYNC is set
1751 */
1752 int64_t received_sv_time_in_ns;
destradaa9f7c3732014-04-29 10:50:22 -07001753
1754 /**
destradaa941c9282014-07-21 18:13:42 -07001755 * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds.
destradaa00caa892015-04-09 18:41:46 -07001756 *
1757 * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN.
destradaa941c9282014-07-21 18:13:42 -07001758 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001759 int64_t received_sv_time_uncertainty_in_ns;
destradaa941c9282014-07-21 18:13:42 -07001760
1761 /**
Lifu Tang1d4183c2016-02-24 13:50:19 -08001762 * Carrier-to-noise density in dB-Hz, typically in the range [0, 63].
1763 * It contains the measured C/N0 value for the signal at the antenna port.
destradaa9f7c3732014-04-29 10:50:22 -07001764 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001765 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001766 */
1767 double c_n0_dbhz;
1768
1769 /**
Lifu Tang1d4183c2016-02-24 13:50:19 -08001770 * Pseudorange rate at the timestamp in m/s. The correction of a given
1771 * Pseudorange Rate value includes corrections for receiver and satellite
1772 * clock frequency errors. Ensure that this field is independent (see
1773 * comment at top of GnssMeasurement struct.)
destradaa00caa892015-04-09 18:41:46 -07001774 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001775 * It is mandatory to provide the 'uncorrected' 'pseudorange rate', and provide GpsClock's
1776 * 'drift' field as well, and
1777 * GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE must be set in 'flags'
1778 * field. (When providing the uncorrected pseudorange rate, do not apply the
1779 * corrections described above.)
destradaa9f7c3732014-04-29 10:50:22 -07001780 *
1781 * The value includes the 'pseudorange rate uncertainty' in it.
destradaa00caa892015-04-09 18:41:46 -07001782 * A positive 'uncorrected' value indicates that the SV is moving away from the receiver.
1783 *
destradaa357e6222015-04-14 16:30:21 -07001784 * The sign of the 'uncorrected' 'pseudorange rate' and its relation to the sign of 'doppler
destradaa00caa892015-04-09 18:41:46 -07001785 * shift' is given by the equation:
destradaa357e6222015-04-14 16:30:21 -07001786 * pseudorange rate = -k * doppler shift (where k is a constant)
destradaa9f7c3732014-04-29 10:50:22 -07001787 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001788 * This should be the most accurate pseudorange rate available, based on
1789 * fresh signal measurements from this channel.
1790 *
1791 * It is mandatory that this value be provided at typical carrier phase PRR
1792 * quality (few cm/sec per second of uncertainty, or better) - when signals
1793 * are sufficiently strong & stable, e.g. signals from a GPS simulator at >=
1794 * 35 dB-Hz.
destradaa9f7c3732014-04-29 10:50:22 -07001795 */
destradaa75843eb2014-07-17 14:04:50 -07001796 double pseudorange_rate_mps;
destradaa9f7c3732014-04-29 10:50:22 -07001797
1798 /**
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001799 * 1-Sigma uncertainty of the pseudorange_rate_mps.
destradaa9f7c3732014-04-29 10:50:22 -07001800 * The uncertainty is represented as an absolute (single sided) value.
1801 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001802 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07001803 */
destradaa75843eb2014-07-17 14:04:50 -07001804 double pseudorange_rate_uncertainty_mps;
1805
1806 /**
1807 * Accumulated delta range's state. It indicates whether ADR is reset or there is a cycle slip
1808 * (indicating loss of lock).
1809 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07001810 * This is a mandatory value.
destradaa75843eb2014-07-17 14:04:50 -07001811 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001812 GnssAccumulatedDeltaRangeState accumulated_delta_range_state;
destradaa9f7c3732014-04-29 10:50:22 -07001813
1814 /**
1815 * Accumulated delta range since the last channel reset in meters.
destradaa357e6222015-04-14 16:30:21 -07001816 * A positive value indicates that the SV is moving away from the receiver.
destradaa00caa892015-04-09 18:41:46 -07001817 *
destradaa357e6222015-04-14 16:30:21 -07001818 * The sign of the 'accumulated delta range' and its relation to the sign of 'carrier phase'
destradaa00caa892015-04-09 18:41:46 -07001819 * is given by the equation:
destradaa357e6222015-04-14 16:30:21 -07001820 * accumulated delta range = -k * carrier phase (where k is a constant)
destradaa00caa892015-04-09 18:41:46 -07001821 *
1822 * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN.
1823 * However, it is expected that the data is only accurate when:
1824 * 'accumulated delta range state' == GPS_ADR_STATE_VALID.
destradaa9f7c3732014-04-29 10:50:22 -07001825 */
1826 double accumulated_delta_range_m;
1827
1828 /**
1829 * 1-Sigma uncertainty of the accumulated delta range in meters.
destradaa00caa892015-04-09 18:41:46 -07001830 * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN.
destradaa9f7c3732014-04-29 10:50:22 -07001831 */
1832 double accumulated_delta_range_uncertainty_m;
1833
1834 /**
destradaa9f7c3732014-04-29 10:50:22 -07001835 * Carrier frequency at which codes and messages are modulated, it can be L1 or L2.
1836 * If the field is not set, the carrier frequency is assumed to be L1.
1837 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001838 * If the data is available, 'flags' must contain
1839 * GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY.
destradaa9f7c3732014-04-29 10:50:22 -07001840 */
1841 float carrier_frequency_hz;
1842
1843 /**
1844 * The number of full carrier cycles between the satellite and the receiver.
1845 * The reference frequency is given by the field 'carrier_frequency_hz'.
1846 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001847 * If the data is available, 'flags' must contain
1848 * GNSS_MEASUREMENT_HAS_CARRIER_CYCLES.
destradaa9f7c3732014-04-29 10:50:22 -07001849 */
1850 int64_t carrier_cycles;
1851
1852 /**
1853 * The RF phase detected by the receiver, in the range [0.0, 1.0].
1854 * This is usually the fractional part of the complete carrier phase measurement.
1855 *
1856 * The reference frequency is given by the field 'carrier_frequency_hz'.
1857 * The value contains the 'carrier-phase uncertainty' in it.
1858 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08001859 * If the data is available, 'flags' must contain
1860 * GNSS_MEASUREMENT_HAS_CARRIER_PHASE.
destradaa9f7c3732014-04-29 10:50:22 -07001861 */
1862 double carrier_phase;
1863
1864 /**
1865 * 1-Sigma uncertainty of the carrier-phase.
Lifu Tanga1ca5742016-02-16 17:42:13 -08001866 * If the data is available, 'flags' must contain
1867 * GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY.
destradaa9f7c3732014-04-29 10:50:22 -07001868 */
1869 double carrier_phase_uncertainty;
1870
1871 /**
destradaa9f7c3732014-04-29 10:50:22 -07001872 * An enumeration that indicates the 'multipath' state of the event.
Lifu Tang1d4183c2016-02-24 13:50:19 -08001873 *
1874 * The multipath Indicator is intended to report the presence of overlapping
1875 * signals that manifest as distorted correlation peaks.
1876 *
1877 * - if there is a distorted correlation peak shape, report that multipath
1878 * is GNSS_MULTIPATH_INDICATOR_PRESENT.
1879 * - if there is not a distorted correlation peak shape, report
1880 * GNSS_MULTIPATH_INDICATOR_NOT_PRESENT
1881 * - if signals are too weak to discern this information, report
1882 * GNSS_MULTIPATH_INDICATOR_UNKNOWN
1883 *
1884 * Example: when doing the standardized overlapping Multipath Performance
1885 * test (3GPP TS 34.171) the Multipath indicator should report
1886 * GNSS_MULTIPATH_INDICATOR_PRESENT for those signals that are tracked, and
1887 * contain multipath, and GNSS_MULTIPATH_INDICATOR_NOT_PRESENT for those
1888 * signals that are tracked and do not contain multipath.
destradaa9f7c3732014-04-29 10:50:22 -07001889 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08001890 GnssMultipathIndicator multipath_indicator;
destradaa9f7c3732014-04-29 10:50:22 -07001891
1892 /**
Lifu Tang1d4183c2016-02-24 13:50:19 -08001893 * Signal-to-noise ratio at correlator output in dB.
Lifu Tanga1ca5742016-02-16 17:42:13 -08001894 * If the data is available, 'flags' must contain GNSS_MEASUREMENT_HAS_SNR.
Lifu Tang1d4183c2016-02-24 13:50:19 -08001895 * This is the power ratio of the "correlation peak height above the
1896 * observed noise floor" to "the noise RMS".
destradaa9f7c3732014-04-29 10:50:22 -07001897 */
1898 double snr_db;
Lifu Tang7e33bb22016-02-07 18:09:30 -08001899} GnssMeasurement;
1900
1901/**
1902 * Legacy struct to represents a reading of GPS measurements.
1903 * Deprecated, to be removed in the next Android release.
1904 * Use GnssData instead.
1905 */
1906typedef struct {
1907 /** set to sizeof(GpsData) */
1908 size_t size;
1909 size_t measurement_count;
1910 GpsMeasurement measurements[GPS_MAX_MEASUREMENT];
1911
1912 /** The GPS clock time reading. */
1913 GpsClock clock;
1914} GpsData;
destradaa9f7c3732014-04-29 10:50:22 -07001915
Lifu Tanga1ca5742016-02-16 17:42:13 -08001916/**
1917 * Represents a reading of GNSS measurements. For devices where GnssSystemInfo's
1918 * year_of_hw is set to 2016+, it is mandatory that these be provided, on
1919 * request, when the GNSS receiver is searching/tracking signals.
1920 *
1921 * - Reporting of GPS constellation measurements is mandatory.
1922 * - Reporting of all tracked constellations are encouraged.
1923 */
destradaa9f7c3732014-04-29 10:50:22 -07001924typedef struct {
Lifu Tang7e33bb22016-02-07 18:09:30 -08001925 /** set to sizeof(GnssData) */
destradaa9f7c3732014-04-29 10:50:22 -07001926 size_t size;
1927
1928 /** Number of measurements. */
1929 size_t measurement_count;
1930
1931 /** The array of measurements. */
Lifu Tang7e33bb22016-02-07 18:09:30 -08001932 GnssMeasurement measurements[GNSS_MAX_MEASUREMENT];
destradaa9f7c3732014-04-29 10:50:22 -07001933
1934 /** The GPS clock time reading. */
Lifu Tang7e33bb22016-02-07 18:09:30 -08001935 GnssClock clock;
1936} GnssData;
destradaa9f7c3732014-04-29 10:50:22 -07001937
1938/**
Lifu Tanga1ca5742016-02-16 17:42:13 -08001939 * The legacy callback for to report measurements from the HAL.
1940 *
1941 * This callback is deprecated, and will be removed in the next release. Use
1942 * gnss_measurement_callback() instead.
destradaa9f7c3732014-04-29 10:50:22 -07001943 *
1944 * Parameters:
1945 * data - A data structure containing the measurements.
1946 */
1947typedef void (*gps_measurement_callback) (GpsData* data);
1948
Lifu Tang7e33bb22016-02-07 18:09:30 -08001949/**
1950 * The callback for to report measurements from the HAL.
1951 *
1952 * Parameters:
1953 * data - A data structure containing the measurements.
1954 */
1955typedef void (*gnss_measurement_callback) (GnssData* data);
1956
destradaa9f7c3732014-04-29 10:50:22 -07001957typedef struct {
1958 /** set to sizeof(GpsMeasurementCallbacks) */
1959 size_t size;
1960 gps_measurement_callback measurement_callback;
Lifu Tang7e33bb22016-02-07 18:09:30 -08001961 gnss_measurement_callback gnss_measurement_callback;
destradaa9f7c3732014-04-29 10:50:22 -07001962} GpsMeasurementCallbacks;
1963
1964#define GPS_MEASUREMENT_OPERATION_SUCCESS 0
1965#define GPS_MEASUREMENT_ERROR_ALREADY_INIT -100
1966#define GPS_MEASUREMENT_ERROR_GENERIC -101
1967
1968/**
1969 * Extended interface for GPS Measurements support.
1970 */
1971typedef struct {
1972 /** Set to sizeof(GpsMeasurementInterface) */
1973 size_t size;
1974
1975 /**
1976 * Initializes the interface and registers the callback routines with the HAL.
1977 * After a successful call to 'init' the HAL must begin to provide updates at its own phase.
1978 *
1979 * Status:
1980 * GPS_MEASUREMENT_OPERATION_SUCCESS
1981 * GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a
1982 * corresponding call to 'close'
1983 * GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL
1984 * will not generate any updates upon returning this error code.
1985 */
1986 int (*init) (GpsMeasurementCallbacks* callbacks);
1987
1988 /**
1989 * Stops updates from the HAL, and unregisters the callback routines.
1990 * After a call to stop, the previously registered callbacks must be considered invalid by the
1991 * HAL.
1992 * If stop is invoked without a previous 'init', this function should perform no work.
1993 */
1994 void (*close) ();
1995
1996} GpsMeasurementInterface;
1997
Lifu Tang7e33bb22016-02-07 18:09:30 -08001998/**
1999 * Legacy struct to represents a GPS navigation message (or a fragment of it).
2000 * Deprecated, to be removed in the next Android release.
2001 * Use GnssNavigationMessage instead.
2002 */
destradaa9f7c3732014-04-29 10:50:22 -07002003typedef struct {
2004 /** set to sizeof(GpsNavigationMessage) */
2005 size_t size;
Lifu Tang7e33bb22016-02-07 18:09:30 -08002006 int8_t prn;
2007 GpsNavigationMessageType type;
2008 NavigationMessageStatus status;
2009 int16_t message_id;
2010 int16_t submessage_id;
2011 size_t data_length;
2012 uint8_t* data;
2013} GpsNavigationMessage;
2014
2015/** Represents a GPS navigation message (or a fragment of it). */
2016typedef struct {
2017 /** set to sizeof(GnssNavigationMessage) */
2018 size_t size;
destradaa9f7c3732014-04-29 10:50:22 -07002019
2020 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08002021 * Satellite vehicle ID number, as defined in GnssSvInfo::svid
Lifu Tangdf0fcf72015-10-27 14:58:25 -07002022 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07002023 */
Lifu Tang7e33bb22016-02-07 18:09:30 -08002024 int16_t svid;
destradaa9f7c3732014-04-29 10:50:22 -07002025
2026 /**
2027 * The type of message contained in the structure.
Lifu Tangdf0fcf72015-10-27 14:58:25 -07002028 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07002029 */
Lifu Tanga1ca5742016-02-16 17:42:13 -08002030 GnssNavigationMessageType type;
destradaa9f7c3732014-04-29 10:50:22 -07002031
2032 /**
Tsuwei Chena90cf192014-10-23 12:49:12 -07002033 * The status of the received navigation message.
2034 * No need to send any navigation message that contains words with parity error and cannot be
2035 * corrected.
2036 */
2037 NavigationMessageStatus status;
2038
2039 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08002040 * Message identifier. It provides an index so the complete Navigation
2041 * Message can be assembled.
2042 *
2043 * - For GPS L1 C/A subframe 4 and 5, this value corresponds to the 'frame
2044 * id' of the navigation message, in the range of 1-25 (Subframe 1, 2, 3
2045 * does not contain a 'frame id' and this value can be set to -1.)
2046 *
2047 * - For Glonass L1 C/A, this refers to the frame ID, in the range of 1-5.
2048 *
2049 * - For BeiDou D1, this refers to the frame number in the range of 1-24
2050 *
2051 * - For Beidou D2, this refers to the frame number, in the range of 1-120
2052 *
2053 * - For Galileo F/NAV, this refers to the frame number, in the range of 1-N
2054 *
2055 * - For Galileo I/NAV, this refers to the frame number in the range of 1-N
destradaa9f7c3732014-04-29 10:50:22 -07002056 */
2057 int16_t message_id;
2058
2059 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08002060 * Sub-message identifier. If required by the message 'type', this value
2061 * contains a sub-index within the current message (or frame) that is being
2062 * transmitted.
2063 *
2064 * - For GPS L1 C/A, BeiDou D1 & BeiDou D2, the submessage id corresponds to
2065 * the subframe number of the navigation message, in the range of 1-5.
2066 *
2067 * - For Glonass L1 C/A, this refers to the String number, in the range from
2068 * 1-15
2069 *
2070 * - For Galileo F/NAV, this refers to the subframe number in the range 1-12
2071 *
2072 * - For Galileo I/NAV, this refers to the subframe number in the range 1-24
destradaa9f7c3732014-04-29 10:50:22 -07002073 */
2074 int16_t submessage_id;
2075
2076 /**
2077 * The length of the data (in bytes) contained in the current message.
2078 * If this value is different from zero, 'data' must point to an array of the same size.
destradaa69d5ea52014-07-31 16:34:09 -07002079 * 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 -07002080 *
Lifu Tangdf0fcf72015-10-27 14:58:25 -07002081 * This is a mandatory value.
destradaa9f7c3732014-04-29 10:50:22 -07002082 */
2083 size_t data_length;
2084
2085 /**
Lifu Tanga1ca5742016-02-16 17:42:13 -08002086 * The data of the reported GPS message. The bytes (or words) specified
2087 * using big endian format (MSB first).
destradaa69d5ea52014-07-31 16:34:09 -07002088 *
Lifu Tanga1ca5742016-02-16 17:42:13 -08002089 * - For GPS L1 C/A, Beidou D1 & Beidou D2, each subframe contains 10 30-bit
2090 * words. Each word (30 bits) should be fit into the last 30 bits in a
2091 * 4-byte word (skip B31 and B32), with MSB first, for a total of 40
2092 * bytes, covering a time period of 6, 6, and 0.6 seconds, respectively.
2093 *
2094 * - For Glonass L1 C/A, each string contains 85 data bits, including the
2095 * checksum. These bits should be fit into 11 bytes, with MSB first (skip
2096 * B86-B88), covering a time period of 2 seconds.
2097 *
2098 * - For Galileo F/NAV, each subframe contains 5 238-bit word (sync & tail
2099 * symbols excluded). Each word should be fit into 30-bytes, with MSB
2100 * first (skip B239, B240), covering a time period of 10 seconds.
2101 *
2102 * - For Galileo I/NAV, each subframe contains 15 114-bit word (sync & tail
2103 * symbols excluded). Each word should be fit into 15-bytes, with MSB
2104 * first (skip B115-B120), covering a time period of 2 seconds.
destradaa9f7c3732014-04-29 10:50:22 -07002105 */
2106 uint8_t* data;
2107
Lifu Tang7e33bb22016-02-07 18:09:30 -08002108} GnssNavigationMessage;
destradaa9f7c3732014-04-29 10:50:22 -07002109
2110/**
Lifu Tanga1ca5742016-02-16 17:42:13 -08002111 * The legacy callback to report an available fragment of a GPS navigation
2112 * messages from the HAL.
2113 *
2114 * This callback is deprecated, and will be removed in the next release. Use
2115 * gnss_navigation_message_callback() instead.
destradaa9f7c3732014-04-29 10:50:22 -07002116 *
2117 * Parameters:
2118 * message - The GPS navigation submessage/subframe representation.
2119 */
2120typedef void (*gps_navigation_message_callback) (GpsNavigationMessage* message);
2121
Lifu Tang7e33bb22016-02-07 18:09:30 -08002122/**
2123 * The callback to report an available fragment of a GPS navigation messages from the HAL.
2124 *
2125 * Parameters:
2126 * message - The GPS navigation submessage/subframe representation.
2127 */
2128typedef void (*gnss_navigation_message_callback) (GnssNavigationMessage* message);
2129
destradaa9f7c3732014-04-29 10:50:22 -07002130typedef struct {
2131 /** set to sizeof(GpsNavigationMessageCallbacks) */
2132 size_t size;
2133 gps_navigation_message_callback navigation_message_callback;
Lifu Tang7e33bb22016-02-07 18:09:30 -08002134 gnss_navigation_message_callback gnss_navigation_message_callback;
destradaa9f7c3732014-04-29 10:50:22 -07002135} GpsNavigationMessageCallbacks;
2136
2137#define GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS 0
2138#define GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT -100
2139#define GPS_NAVIGATION_MESSAGE_ERROR_GENERIC -101
2140
2141/**
2142 * Extended interface for GPS navigation message reporting support.
2143 */
2144typedef struct {
2145 /** Set to sizeof(GpsNavigationMessageInterface) */
2146 size_t size;
2147
2148 /**
2149 * Initializes the interface and registers the callback routines with the HAL.
2150 * After a successful call to 'init' the HAL must begin to provide updates as they become
2151 * available.
2152 *
2153 * Status:
2154 * GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS
2155 * GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT - if a callback has already been registered
2156 * without a corresponding call to 'close'.
2157 * GPS_NAVIGATION_MESSAGE_ERROR_GENERIC - if any other error occurred, it is expected that
2158 * the HAL will not generate any updates upon returning this error code.
2159 */
2160 int (*init) (GpsNavigationMessageCallbacks* callbacks);
2161
2162 /**
2163 * Stops updates from the HAL, and unregisters the callback routines.
2164 * After a call to stop, the previously registered callbacks must be considered invalid by the
2165 * HAL.
2166 * If stop is invoked without a previous 'init', this function should perform no work.
2167 */
2168 void (*close) ();
2169
2170} GpsNavigationMessageInterface;
2171
Tsuwei Chen167d31f2014-08-26 16:34:19 -07002172/**
2173 * Interface for passing GNSS configuration contents from platform to HAL.
2174 */
2175typedef struct {
2176 /** Set to sizeof(GnssConfigurationInterface) */
2177 size_t size;
2178
2179 /**
2180 * Deliver GNSS configuration contents to HAL.
2181 * Parameters:
2182 * config_data - a pointer to a char array which holds what usually is expected from
2183 file(/etc/gps.conf), i.e., a sequence of UTF8 strings separated by '\n'.
2184 * length - total number of UTF8 characters in configuraiton data.
2185 *
2186 * IMPORTANT:
2187 * GPS HAL should expect this function can be called multiple times. And it may be
2188 * called even when GpsLocationProvider is already constructed and enabled. GPS HAL
2189 * should maintain the existing requests for various callback regardless the change
2190 * in configuration data.
2191 */
2192 void (*configuration_update) (const char* config_data, int32_t length);
2193} GnssConfigurationInterface;
2194
Mike Lockwood9b0b1c32010-02-23 18:42:37 -05002195__END_DECLS
2196
2197#endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */
2198