Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef 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 Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 23 | #include <pthread.h> |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 24 | |
| 25 | #include <hardware/hardware.h> |
| 26 | |
| 27 | __BEGIN_DECLS |
| 28 | |
| 29 | /** |
| 30 | * The id of this module |
| 31 | */ |
| 32 | #define GPS_HARDWARE_MODULE_ID "gps" |
| 33 | |
| 34 | |
| 35 | /** Milliseconds since January 1, 1970 */ |
| 36 | typedef int64_t GpsUtcTime; |
| 37 | |
| 38 | /** Maximum number of SVs for gps_sv_status_callback(). */ |
| 39 | #define GPS_MAX_SVS 32 |
| 40 | |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 41 | /** Requested operational mode for GPS operation. */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 42 | typedef uint32_t GpsPositionMode; |
| 43 | // IMPORTANT: Note that the following values must match |
| 44 | // constants in GpsLocationProvider.java. |
| 45 | /** Mode for running GPS standalone (no assistance). */ |
| 46 | #define GPS_POSITION_MODE_STANDALONE 0 |
| 47 | /** AGPS MS-Based mode. */ |
| 48 | #define GPS_POSITION_MODE_MS_BASED 1 |
| 49 | /** AGPS MS-Assisted mode. */ |
| 50 | #define GPS_POSITION_MODE_MS_ASSISTED 2 |
| 51 | |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 52 | /** Requested recurrence mode for GPS operation. */ |
| 53 | typedef uint32_t GpsPositionRecurrence; |
| 54 | // IMPORTANT: Note that the following values must match |
| 55 | // constants in GpsLocationProvider.java. |
| 56 | /** Receive GPS fixes on a recurring basis at a specified period. */ |
| 57 | #define GPS_POSITION_RECURRENCE_PERIODIC 0 |
| 58 | /** Request a single shot GPS fix. */ |
| 59 | #define GPS_POSITION_RECURRENCE_SINGLE 1 |
| 60 | |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 61 | /** GPS status event values. */ |
| 62 | typedef uint16_t GpsStatusValue; |
| 63 | // IMPORTANT: Note that the following values must match |
| 64 | // constants in GpsLocationProvider.java. |
| 65 | /** GPS status unknown. */ |
| 66 | #define GPS_STATUS_NONE 0 |
| 67 | /** GPS has begun navigating. */ |
| 68 | #define GPS_STATUS_SESSION_BEGIN 1 |
| 69 | /** GPS has stopped navigating. */ |
| 70 | #define GPS_STATUS_SESSION_END 2 |
| 71 | /** GPS has powered on but is not navigating. */ |
| 72 | #define GPS_STATUS_ENGINE_ON 3 |
| 73 | /** GPS is powered off. */ |
| 74 | #define GPS_STATUS_ENGINE_OFF 4 |
| 75 | |
| 76 | /** Flags to indicate which values are valid in a GpsLocation. */ |
| 77 | typedef uint16_t GpsLocationFlags; |
| 78 | // IMPORTANT: Note that the following values must match |
| 79 | // constants in GpsLocationProvider.java. |
| 80 | /** GpsLocation has valid latitude and longitude. */ |
| 81 | #define GPS_LOCATION_HAS_LAT_LONG 0x0001 |
| 82 | /** GpsLocation has valid altitude. */ |
| 83 | #define GPS_LOCATION_HAS_ALTITUDE 0x0002 |
| 84 | /** GpsLocation has valid speed. */ |
| 85 | #define GPS_LOCATION_HAS_SPEED 0x0004 |
| 86 | /** GpsLocation has valid bearing. */ |
| 87 | #define GPS_LOCATION_HAS_BEARING 0x0008 |
| 88 | /** GpsLocation has valid accuracy. */ |
| 89 | #define GPS_LOCATION_HAS_ACCURACY 0x0010 |
| 90 | |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 91 | /** Flags for the gps_set_capabilities callback. */ |
| 92 | |
| 93 | /** GPS HAL schedules fixes for GPS_POSITION_RECURRENCE_PERIODIC mode. |
| 94 | If this is not set, then the framework will use 1000ms for min_interval |
| 95 | and will start and call start() and stop() to schedule the GPS. |
| 96 | */ |
| 97 | #define GPS_CAPABILITY_SCHEDULING 0x0000001 |
| 98 | /** GPS supports MS-Based AGPS mode */ |
| 99 | #define GPS_CAPABILITY_MSB 0x0000002 |
| 100 | /** GPS supports MS-Assisted AGPS mode */ |
| 101 | #define GPS_CAPABILITY_MSA 0x0000004 |
| 102 | /** GPS supports single-shot fixes */ |
| 103 | #define GPS_CAPABILITY_SINGLE_SHOT 0x0000008 |
| 104 | |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 105 | /** Flags used to specify which aiding data to delete |
| 106 | when calling delete_aiding_data(). */ |
| 107 | typedef uint16_t GpsAidingData; |
| 108 | // IMPORTANT: Note that the following values must match |
| 109 | // constants in GpsLocationProvider.java. |
| 110 | #define GPS_DELETE_EPHEMERIS 0x0001 |
| 111 | #define GPS_DELETE_ALMANAC 0x0002 |
| 112 | #define GPS_DELETE_POSITION 0x0004 |
| 113 | #define GPS_DELETE_TIME 0x0008 |
| 114 | #define GPS_DELETE_IONO 0x0010 |
| 115 | #define GPS_DELETE_UTC 0x0020 |
| 116 | #define GPS_DELETE_HEALTH 0x0040 |
| 117 | #define GPS_DELETE_SVDIR 0x0080 |
| 118 | #define GPS_DELETE_SVSTEER 0x0100 |
| 119 | #define GPS_DELETE_SADATA 0x0200 |
| 120 | #define GPS_DELETE_RTI 0x0400 |
| 121 | #define GPS_DELETE_CELLDB_INFO 0x8000 |
| 122 | #define GPS_DELETE_ALL 0xFFFF |
| 123 | |
| 124 | /** AGPS type */ |
| 125 | typedef uint16_t AGpsType; |
| 126 | #define AGPS_TYPE_SUPL 1 |
| 127 | #define AGPS_TYPE_C2K 2 |
| 128 | |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame^] | 129 | typedef uint16_t AGpsSetIDType; |
| 130 | #define AGPS_SETID_TYPE_NONE 0 |
| 131 | #define AGPS_SETID_TYPE_IMSI 1 |
| 132 | #define AGPS_SETID_TYPE_MSISDN 2 |
| 133 | |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 134 | /** |
| 135 | * String length constants |
| 136 | */ |
| 137 | #define GPS_NI_SHORT_STRING_MAXLEN 256 |
| 138 | #define GPS_NI_LONG_STRING_MAXLEN 2048 |
| 139 | |
| 140 | /** |
| 141 | * GpsNiType constants |
| 142 | */ |
| 143 | typedef uint32_t GpsNiType; |
| 144 | #define GPS_NI_TYPE_VOICE 1 |
| 145 | #define GPS_NI_TYPE_UMTS_SUPL 2 |
| 146 | #define GPS_NI_TYPE_UMTS_CTRL_PLANE 3 |
| 147 | |
| 148 | /** |
| 149 | * GpsNiNotifyFlags constants |
| 150 | */ |
| 151 | typedef uint32_t GpsNiNotifyFlags; |
| 152 | /** NI requires notification */ |
| 153 | #define GPS_NI_NEED_NOTIFY 0x0001 |
| 154 | /** NI requires verification */ |
| 155 | #define GPS_NI_NEED_VERIFY 0x0002 |
| 156 | /** NI requires privacy override, no notification/minimal trace */ |
| 157 | #define GPS_NI_PRIVACY_OVERRIDE 0x0004 |
| 158 | |
| 159 | /** |
| 160 | * GPS NI responses, used to define the response in |
| 161 | * NI structures |
| 162 | */ |
| 163 | typedef int GpsUserResponseType; |
| 164 | #define GPS_NI_RESPONSE_ACCEPT 1 |
| 165 | #define GPS_NI_RESPONSE_DENY 2 |
| 166 | #define GPS_NI_RESPONSE_NORESP 3 |
| 167 | |
| 168 | /** |
| 169 | * NI data encoding scheme |
| 170 | */ |
| 171 | typedef int GpsNiEncodingType; |
| 172 | #define GPS_ENC_NONE 0 |
| 173 | #define GPS_ENC_SUPL_GSM_DEFAULT 1 |
| 174 | #define GPS_ENC_SUPL_UTF8 2 |
| 175 | #define GPS_ENC_SUPL_UCS2 3 |
| 176 | #define GPS_ENC_UNKNOWN -1 |
| 177 | |
| 178 | /** AGPS status event values. */ |
| 179 | typedef uint16_t AGpsStatusValue; |
| 180 | /** GPS requests data connection for AGPS. */ |
| 181 | #define GPS_REQUEST_AGPS_DATA_CONN 1 |
| 182 | /** GPS releases the AGPS data connection. */ |
| 183 | #define GPS_RELEASE_AGPS_DATA_CONN 2 |
| 184 | /** AGPS data connection initiated */ |
| 185 | #define GPS_AGPS_DATA_CONNECTED 3 |
| 186 | /** AGPS data connection completed */ |
| 187 | #define GPS_AGPS_DATA_CONN_DONE 4 |
| 188 | /** AGPS data connection failed */ |
| 189 | #define GPS_AGPS_DATA_CONN_FAILED 5 |
| 190 | |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame^] | 191 | #define AGPS_REF_LOCATION_TYPE_GSM_CELLID 1 |
| 192 | #define AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2 |
| 193 | #define AGPS_REG_LOCATION_TYPE_MAC 3 |
| 194 | |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 195 | /** |
| 196 | * Name for the GPS XTRA interface. |
| 197 | */ |
| 198 | #define GPS_XTRA_INTERFACE "gps-xtra" |
| 199 | |
| 200 | /** |
| 201 | * Name for the GPS DEBUG interface. |
| 202 | */ |
| 203 | #define GPS_DEBUG_INTERFACE "gps-debug" |
| 204 | |
| 205 | /** |
| 206 | * Name for the AGPS interface. |
| 207 | */ |
| 208 | #define AGPS_INTERFACE "agps" |
| 209 | |
| 210 | /** |
| 211 | * Name for NI interface |
| 212 | */ |
| 213 | #define GPS_NI_INTERFACE "gps-ni" |
| 214 | |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame^] | 215 | /** |
| 216 | * Name for the AGPS-RIL interface. |
| 217 | */ |
| 218 | #define AGPS_RIL_INTERFACE "agps_ril" |
| 219 | |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 220 | /** Represents a location. */ |
| 221 | typedef struct { |
| 222 | /** set to sizeof(GpsLocation) */ |
| 223 | size_t size; |
| 224 | /** Contains GpsLocationFlags bits. */ |
| 225 | uint16_t flags; |
| 226 | /** Represents latitude in degrees. */ |
| 227 | double latitude; |
| 228 | /** Represents longitude in degrees. */ |
| 229 | double longitude; |
| 230 | /** Represents altitude in meters above the WGS 84 reference |
| 231 | * ellipsoid. */ |
| 232 | double altitude; |
| 233 | /** Represents speed in meters per second. */ |
| 234 | float speed; |
| 235 | /** Represents heading in degrees. */ |
| 236 | float bearing; |
| 237 | /** Represents expected accuracy in meters. */ |
| 238 | float accuracy; |
| 239 | /** Timestamp for the location fix. */ |
| 240 | GpsUtcTime timestamp; |
| 241 | } GpsLocation; |
| 242 | |
| 243 | /** Represents the status. */ |
| 244 | typedef struct { |
| 245 | /** set to sizeof(GpsStatus) */ |
| 246 | size_t size; |
| 247 | GpsStatusValue status; |
| 248 | } GpsStatus; |
| 249 | |
| 250 | /** Represents SV information. */ |
| 251 | typedef struct { |
| 252 | /** set to sizeof(GpsSvInfo) */ |
| 253 | size_t size; |
| 254 | /** Pseudo-random number for the SV. */ |
| 255 | int prn; |
| 256 | /** Signal to noise ratio. */ |
| 257 | float snr; |
| 258 | /** Elevation of SV in degrees. */ |
| 259 | float elevation; |
| 260 | /** Azimuth of SV in degrees. */ |
| 261 | float azimuth; |
| 262 | } GpsSvInfo; |
| 263 | |
| 264 | /** Represents SV status. */ |
| 265 | typedef struct { |
| 266 | /** set to sizeof(GpsSvStatus) */ |
| 267 | size_t size; |
| 268 | |
| 269 | /** Number of SVs currently visible. */ |
| 270 | int num_svs; |
| 271 | |
| 272 | /** Contains an array of SV information. */ |
| 273 | GpsSvInfo sv_list[GPS_MAX_SVS]; |
| 274 | |
| 275 | /** Represents a bit mask indicating which SVs |
| 276 | * have ephemeris data. |
| 277 | */ |
| 278 | uint32_t ephemeris_mask; |
| 279 | |
| 280 | /** Represents a bit mask indicating which SVs |
| 281 | * have almanac data. |
| 282 | */ |
| 283 | uint32_t almanac_mask; |
| 284 | |
| 285 | /** |
| 286 | * Represents a bit mask indicating which SVs |
| 287 | * were used for computing the most recent position fix. |
| 288 | */ |
| 289 | uint32_t used_in_fix_mask; |
| 290 | } GpsSvStatus; |
| 291 | |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame^] | 292 | /* 2G and 3G */ |
| 293 | /* In 3G lac is discarded */ |
| 294 | typedef struct { |
| 295 | uint16_t type; |
| 296 | uint16_t mcc; |
| 297 | uint16_t mnc; |
| 298 | uint16_t lac; |
| 299 | uint32_t cid; |
| 300 | } AGpsRefLocationCellID; |
| 301 | |
| 302 | typedef struct { |
| 303 | uint8_t mac[6]; |
| 304 | } AGpsRefLocationMac; |
| 305 | |
| 306 | /** Represents ref locations */ |
| 307 | typedef struct { |
| 308 | uint16_t type; |
| 309 | union { |
| 310 | AGpsRefLocationCellID cellID; |
| 311 | AGpsRefLocationMac mac; |
| 312 | } u; |
| 313 | } AGpsRefLocation; |
| 314 | |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 315 | /** Callback with location information. |
| 316 | * Can only be called from a thread created by create_thread_cb. |
| 317 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 318 | typedef void (* gps_location_callback)(GpsLocation* location); |
| 319 | |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 320 | /** Callback with status information. |
| 321 | * Can only be called from a thread created by create_thread_cb. |
| 322 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 323 | typedef void (* gps_status_callback)(GpsStatus* status); |
| 324 | |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 325 | /** Callback with SV status information. |
| 326 | * Can only be called from a thread created by create_thread_cb. |
| 327 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 328 | typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info); |
| 329 | |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 330 | /** Callback for reporting NMEA sentences. |
| 331 | * Can only be called from a thread created by create_thread_cb. |
| 332 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 333 | typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length); |
| 334 | |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 335 | /** Callback to inform framework of the GPS engine's capabilities. |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 336 | * Capability parameter is a bit field of GPS_CAPABILITY_* flags. |
| 337 | */ |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 338 | typedef void (* gps_set_capabilities)(uint32_t capabilities); |
| 339 | |
Mike Lockwood | d20bbae | 2010-04-07 09:04:25 -0400 | [diff] [blame] | 340 | /** Callback utility for acquiring the GPS wakelock. |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 341 | * This can be used to prevent the CPU from suspending while handling GPS events. |
| 342 | */ |
Mike Lockwood | d20bbae | 2010-04-07 09:04:25 -0400 | [diff] [blame] | 343 | typedef void (* gps_acquire_wakelock)(); |
| 344 | |
| 345 | /** Callback utility for releasing the GPS wakelock. */ |
| 346 | typedef void (* gps_release_wakelock)(); |
| 347 | |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 348 | /** Callback for creating a thread that can call into the Java framework code. |
| 349 | * This must be used to create any threads that report events up to the framework. |
| 350 | */ |
| 351 | typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg); |
| 352 | |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 353 | /** GPS callback structure. */ |
| 354 | typedef struct { |
Mike Lockwood | d20bbae | 2010-04-07 09:04:25 -0400 | [diff] [blame] | 355 | /** set to sizeof(GpsCallbacks) */ |
| 356 | size_t size; |
| 357 | gps_location_callback location_cb; |
| 358 | gps_status_callback status_cb; |
| 359 | gps_sv_status_callback sv_status_cb; |
| 360 | gps_nmea_callback nmea_cb; |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 361 | gps_set_capabilities set_capabilities_cb; |
Mike Lockwood | d20bbae | 2010-04-07 09:04:25 -0400 | [diff] [blame] | 362 | gps_acquire_wakelock acquire_wakelock_cb; |
| 363 | gps_release_wakelock release_wakelock_cb; |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 364 | gps_create_thread create_thread_cb; |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 365 | } GpsCallbacks; |
| 366 | |
| 367 | |
| 368 | /** Represents the standard GPS interface. */ |
| 369 | typedef struct { |
| 370 | /** set to sizeof(GpsInterface) */ |
| 371 | size_t size; |
| 372 | /** |
| 373 | * Opens the interface and provides the callback routines |
| 374 | * to the implemenation of this interface. |
| 375 | */ |
| 376 | int (*init)( GpsCallbacks* callbacks ); |
| 377 | |
| 378 | /** Starts navigating. */ |
| 379 | int (*start)( void ); |
| 380 | |
| 381 | /** Stops navigating. */ |
| 382 | int (*stop)( void ); |
| 383 | |
| 384 | /** Closes the interface. */ |
| 385 | void (*cleanup)( void ); |
| 386 | |
| 387 | /** Injects the current time. */ |
| 388 | int (*inject_time)(GpsUtcTime time, int64_t timeReference, |
| 389 | int uncertainty); |
| 390 | |
| 391 | /** Injects current location from another location provider |
| 392 | * (typically cell ID). |
| 393 | * latitude and longitude are measured in degrees |
| 394 | * expected accuracy is measured in meters |
| 395 | */ |
| 396 | int (*inject_location)(double latitude, double longitude, float accuracy); |
| 397 | |
| 398 | /** |
| 399 | * Specifies that the next call to start will not use the |
| 400 | * information defined in the flags. GPS_DELETE_ALL is passed for |
| 401 | * a cold start. |
| 402 | */ |
| 403 | void (*delete_aiding_data)(GpsAidingData flags); |
| 404 | |
| 405 | /** |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 406 | * min_interval represents the time between fixes in milliseconds. |
| 407 | * preferred_accuracy represents the requested fix accuracy in meters. |
| 408 | * preferred_time represents the requested time to first fix in milliseconds. |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 409 | */ |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 410 | int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence, |
| 411 | uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time); |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 412 | |
| 413 | /** Get a pointer to extension information. */ |
| 414 | const void* (*get_extension)(const char* name); |
| 415 | } GpsInterface; |
| 416 | |
| 417 | /** Callback to request the client to download XTRA data. |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 418 | * The client should download XTRA data and inject it by calling inject_xtra_data(). |
| 419 | * Can only be called from a thread created by create_thread_cb. |
| 420 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 421 | typedef void (* gps_xtra_download_request)(); |
| 422 | |
| 423 | /** Callback structure for the XTRA interface. */ |
| 424 | typedef struct { |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 425 | gps_xtra_download_request download_request_cb; |
| 426 | gps_create_thread create_thread_cb; |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 427 | } GpsXtraCallbacks; |
| 428 | |
| 429 | /** Extended interface for XTRA support. */ |
| 430 | typedef struct { |
| 431 | /** set to sizeof(GpsXtraInterface) */ |
| 432 | size_t size; |
| 433 | /** |
| 434 | * Opens the XTRA interface and provides the callback routines |
| 435 | * to the implemenation of this interface. |
| 436 | */ |
| 437 | int (*init)( GpsXtraCallbacks* callbacks ); |
| 438 | /** Injects XTRA data into the GPS. */ |
| 439 | int (*inject_xtra_data)( char* data, int length ); |
| 440 | } GpsXtraInterface; |
| 441 | |
| 442 | /** Extended interface for DEBUG support. */ |
| 443 | typedef struct { |
| 444 | /** set to sizeof(GpsDebugInterface) */ |
| 445 | size_t size; |
| 446 | |
| 447 | /** |
| 448 | * This function should return any information that the native |
| 449 | * implementation wishes to include in a bugreport. |
| 450 | */ |
| 451 | size_t (*get_internal_state)(char* buffer, size_t bufferSize); |
| 452 | } GpsDebugInterface; |
| 453 | |
| 454 | /** Represents the status of AGPS. */ |
| 455 | typedef struct { |
| 456 | /** set to sizeof(AGpsStatus) */ |
| 457 | size_t size; |
| 458 | |
| 459 | AGpsType type; |
| 460 | AGpsStatusValue status; |
| 461 | } AGpsStatus; |
| 462 | |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 463 | /** Callback with AGPS status information. |
| 464 | * Can only be called from a thread created by create_thread_cb. |
| 465 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 466 | typedef void (* agps_status_callback)(AGpsStatus* status); |
| 467 | |
| 468 | /** Callback structure for the AGPS interface. */ |
| 469 | typedef struct { |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 470 | agps_status_callback status_cb; |
| 471 | gps_create_thread create_thread_cb; |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 472 | } AGpsCallbacks; |
| 473 | |
| 474 | |
| 475 | /** Extended interface for AGPS support. */ |
| 476 | typedef struct { |
| 477 | /** set to sizeof(AGpsInterface) */ |
| 478 | size_t size; |
| 479 | |
| 480 | /** |
| 481 | * Opens the AGPS interface and provides the callback routines |
| 482 | * to the implemenation of this interface. |
| 483 | */ |
| 484 | void (*init)( AGpsCallbacks* callbacks ); |
| 485 | /** |
| 486 | * Notifies that a data connection is available and sets |
| 487 | * the name of the APN to be used for SUPL. |
| 488 | */ |
| 489 | int (*data_conn_open)( const char* apn ); |
| 490 | /** |
| 491 | * Notifies that the AGPS data connection has been closed. |
| 492 | */ |
| 493 | int (*data_conn_closed)(); |
| 494 | /** |
| 495 | * Notifies that a data connection is not available for AGPS. |
| 496 | */ |
| 497 | int (*data_conn_failed)(); |
| 498 | /** |
| 499 | * Sets the hostname and port for the AGPS server. |
| 500 | */ |
| 501 | int (*set_server)( AGpsType type, const char* hostname, int port ); |
| 502 | } AGpsInterface; |
| 503 | |
| 504 | |
| 505 | /** Represents an NI request */ |
| 506 | typedef struct { |
| 507 | /** set to sizeof(GpsNiNotification) */ |
| 508 | size_t size; |
| 509 | |
| 510 | /** |
| 511 | * An ID generated by HAL to associate NI notifications and UI |
| 512 | * responses |
| 513 | */ |
| 514 | int notification_id; |
| 515 | |
| 516 | /** |
| 517 | * An NI type used to distinguish different categories of NI |
| 518 | * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ... |
| 519 | */ |
| 520 | GpsNiType ni_type; |
| 521 | |
| 522 | /** |
| 523 | * Notification/verification options, combinations of GpsNiNotifyFlags constants |
| 524 | */ |
| 525 | GpsNiNotifyFlags notify_flags; |
| 526 | |
| 527 | /** |
| 528 | * Timeout period to wait for user response. |
| 529 | * Set to 0 for no time out limit. |
| 530 | */ |
| 531 | int timeout; |
| 532 | |
| 533 | /** |
| 534 | * Default response when time out. |
| 535 | */ |
| 536 | GpsUserResponseType default_response; |
| 537 | |
| 538 | /** |
| 539 | * Requestor ID |
| 540 | */ |
| 541 | char requestor_id[GPS_NI_SHORT_STRING_MAXLEN]; |
| 542 | |
| 543 | /** |
| 544 | * Notification message. It can also be used to store client_id in some cases |
| 545 | */ |
| 546 | char text[GPS_NI_LONG_STRING_MAXLEN]; |
| 547 | |
| 548 | /** |
| 549 | * Client name decoding scheme |
| 550 | */ |
| 551 | GpsNiEncodingType requestor_id_encoding; |
| 552 | |
| 553 | /** |
| 554 | * Client name decoding scheme |
| 555 | */ |
| 556 | GpsNiEncodingType text_encoding; |
| 557 | |
| 558 | /** |
| 559 | * A pointer to extra data. Format: |
| 560 | * key_1 = value_1 |
| 561 | * key_2 = value_2 |
| 562 | */ |
| 563 | char extras[GPS_NI_LONG_STRING_MAXLEN]; |
| 564 | |
| 565 | } GpsNiNotification; |
| 566 | |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 567 | /** Callback with NI notification. |
| 568 | * Can only be called from a thread created by create_thread_cb. |
| 569 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 570 | typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification); |
| 571 | |
| 572 | /** GPS NI callback structure. */ |
| 573 | typedef struct |
| 574 | { |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame] | 575 | /** |
| 576 | * Sends the notification request from HAL to GPSLocationProvider. |
| 577 | */ |
| 578 | gps_ni_notify_callback notify_cb; |
| 579 | gps_create_thread create_thread_cb; |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 580 | } GpsNiCallbacks; |
| 581 | |
| 582 | /** |
| 583 | * Extended interface for Network-initiated (NI) support. |
| 584 | */ |
| 585 | typedef struct |
| 586 | { |
| 587 | /** set to sizeof(GpsNiInterface) */ |
| 588 | size_t size; |
| 589 | |
| 590 | /** Registers the callbacks for HAL to use. */ |
| 591 | void (*init) (GpsNiCallbacks *callbacks); |
| 592 | |
| 593 | /** Sends a response to HAL. */ |
| 594 | void (*respond) (int notif_id, GpsUserResponseType user_response); |
| 595 | } GpsNiInterface; |
| 596 | |
| 597 | struct gps_device_t { |
| 598 | struct hw_device_t common; |
| 599 | |
| 600 | /** |
| 601 | * Set the provided lights to the provided values. |
| 602 | * |
| 603 | * Returns: 0 on succes, error code on failure. |
| 604 | */ |
| 605 | const GpsInterface* (*get_gps_interface)(struct gps_device_t* dev); |
| 606 | }; |
| 607 | |
Miguel Torroja | 5f404f5 | 2010-07-27 06:34:15 +0200 | [diff] [blame^] | 608 | #define AGPS_RIL_REQUEST_SETID_IMSI (1<<0L) |
| 609 | #define AGPS_RIL_REQUEST_SETID_MSISDN (1<<1L) |
| 610 | |
| 611 | #define AGPS_RIL_REQUEST_REFLOC_CELLID (1<<0L) |
| 612 | #define AGPS_RIL_REQUEST_REFLOC_MAC (1<<1L) |
| 613 | |
| 614 | typedef void (*agps_ril_request_set_id)(uint32_t flags); |
| 615 | typedef void (*agps_ril_request_ref_loc)(uint32_t flags); |
| 616 | |
| 617 | typedef struct { |
| 618 | agps_ril_request_set_id request_setid; |
| 619 | agps_ril_request_ref_loc request_refloc; |
| 620 | gps_create_thread create_thread_cb; |
| 621 | } AGpsRilCallbacks; |
| 622 | |
| 623 | /** Extended interface for AGPS_RIL support. */ |
| 624 | typedef struct { |
| 625 | /** set to sizeof(AGpsRilInterface) */ |
| 626 | size_t size; |
| 627 | /** |
| 628 | * Opens the AGPS interface and provides the callback routines |
| 629 | * to the implemenation of this interface. |
| 630 | */ |
| 631 | void (*init)( AGpsRilCallbacks* callbacks ); |
| 632 | |
| 633 | /** |
| 634 | * Sets the reference location. |
| 635 | */ |
| 636 | void (*set_ref_location) (const AGpsRefLocation *agps_reflocation, size_t sz_struct); |
| 637 | /** |
| 638 | * Sets the set ID. |
| 639 | */ |
| 640 | void (*set_set_id) (AGpsSetIDType type, const char* setid); |
| 641 | |
| 642 | /** |
| 643 | * Send network initiated message. |
| 644 | */ |
| 645 | void (*ni_message) (uint8_t *msg, size_t len); |
| 646 | } AGpsRilInterface; |
| 647 | |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 648 | __END_DECLS |
| 649 | |
| 650 | #endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */ |
| 651 | |