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 | |
| 129 | /** |
| 130 | * String length constants |
| 131 | */ |
| 132 | #define GPS_NI_SHORT_STRING_MAXLEN 256 |
| 133 | #define GPS_NI_LONG_STRING_MAXLEN 2048 |
| 134 | |
| 135 | /** |
| 136 | * GpsNiType constants |
| 137 | */ |
| 138 | typedef uint32_t GpsNiType; |
| 139 | #define GPS_NI_TYPE_VOICE 1 |
| 140 | #define GPS_NI_TYPE_UMTS_SUPL 2 |
| 141 | #define GPS_NI_TYPE_UMTS_CTRL_PLANE 3 |
| 142 | |
| 143 | /** |
| 144 | * GpsNiNotifyFlags constants |
| 145 | */ |
| 146 | typedef uint32_t GpsNiNotifyFlags; |
| 147 | /** NI requires notification */ |
| 148 | #define GPS_NI_NEED_NOTIFY 0x0001 |
| 149 | /** NI requires verification */ |
| 150 | #define GPS_NI_NEED_VERIFY 0x0002 |
| 151 | /** NI requires privacy override, no notification/minimal trace */ |
| 152 | #define GPS_NI_PRIVACY_OVERRIDE 0x0004 |
| 153 | |
| 154 | /** |
| 155 | * GPS NI responses, used to define the response in |
| 156 | * NI structures |
| 157 | */ |
| 158 | typedef int GpsUserResponseType; |
| 159 | #define GPS_NI_RESPONSE_ACCEPT 1 |
| 160 | #define GPS_NI_RESPONSE_DENY 2 |
| 161 | #define GPS_NI_RESPONSE_NORESP 3 |
| 162 | |
| 163 | /** |
| 164 | * NI data encoding scheme |
| 165 | */ |
| 166 | typedef int GpsNiEncodingType; |
| 167 | #define GPS_ENC_NONE 0 |
| 168 | #define GPS_ENC_SUPL_GSM_DEFAULT 1 |
| 169 | #define GPS_ENC_SUPL_UTF8 2 |
| 170 | #define GPS_ENC_SUPL_UCS2 3 |
| 171 | #define GPS_ENC_UNKNOWN -1 |
| 172 | |
| 173 | /** AGPS status event values. */ |
| 174 | typedef uint16_t AGpsStatusValue; |
| 175 | /** GPS requests data connection for AGPS. */ |
| 176 | #define GPS_REQUEST_AGPS_DATA_CONN 1 |
| 177 | /** GPS releases the AGPS data connection. */ |
| 178 | #define GPS_RELEASE_AGPS_DATA_CONN 2 |
| 179 | /** AGPS data connection initiated */ |
| 180 | #define GPS_AGPS_DATA_CONNECTED 3 |
| 181 | /** AGPS data connection completed */ |
| 182 | #define GPS_AGPS_DATA_CONN_DONE 4 |
| 183 | /** AGPS data connection failed */ |
| 184 | #define GPS_AGPS_DATA_CONN_FAILED 5 |
| 185 | |
| 186 | /** |
| 187 | * Name for the GPS XTRA interface. |
| 188 | */ |
| 189 | #define GPS_XTRA_INTERFACE "gps-xtra" |
| 190 | |
| 191 | /** |
| 192 | * Name for the GPS DEBUG interface. |
| 193 | */ |
| 194 | #define GPS_DEBUG_INTERFACE "gps-debug" |
| 195 | |
| 196 | /** |
| 197 | * Name for the AGPS interface. |
| 198 | */ |
| 199 | #define AGPS_INTERFACE "agps" |
| 200 | |
| 201 | /** |
| 202 | * Name for NI interface |
| 203 | */ |
| 204 | #define GPS_NI_INTERFACE "gps-ni" |
| 205 | |
| 206 | /** Represents a location. */ |
| 207 | typedef struct { |
| 208 | /** set to sizeof(GpsLocation) */ |
| 209 | size_t size; |
| 210 | /** Contains GpsLocationFlags bits. */ |
| 211 | uint16_t flags; |
| 212 | /** Represents latitude in degrees. */ |
| 213 | double latitude; |
| 214 | /** Represents longitude in degrees. */ |
| 215 | double longitude; |
| 216 | /** Represents altitude in meters above the WGS 84 reference |
| 217 | * ellipsoid. */ |
| 218 | double altitude; |
| 219 | /** Represents speed in meters per second. */ |
| 220 | float speed; |
| 221 | /** Represents heading in degrees. */ |
| 222 | float bearing; |
| 223 | /** Represents expected accuracy in meters. */ |
| 224 | float accuracy; |
| 225 | /** Timestamp for the location fix. */ |
| 226 | GpsUtcTime timestamp; |
| 227 | } GpsLocation; |
| 228 | |
| 229 | /** Represents the status. */ |
| 230 | typedef struct { |
| 231 | /** set to sizeof(GpsStatus) */ |
| 232 | size_t size; |
| 233 | GpsStatusValue status; |
| 234 | } GpsStatus; |
| 235 | |
| 236 | /** Represents SV information. */ |
| 237 | typedef struct { |
| 238 | /** set to sizeof(GpsSvInfo) */ |
| 239 | size_t size; |
| 240 | /** Pseudo-random number for the SV. */ |
| 241 | int prn; |
| 242 | /** Signal to noise ratio. */ |
| 243 | float snr; |
| 244 | /** Elevation of SV in degrees. */ |
| 245 | float elevation; |
| 246 | /** Azimuth of SV in degrees. */ |
| 247 | float azimuth; |
| 248 | } GpsSvInfo; |
| 249 | |
| 250 | /** Represents SV status. */ |
| 251 | typedef struct { |
| 252 | /** set to sizeof(GpsSvStatus) */ |
| 253 | size_t size; |
| 254 | |
| 255 | /** Number of SVs currently visible. */ |
| 256 | int num_svs; |
| 257 | |
| 258 | /** Contains an array of SV information. */ |
| 259 | GpsSvInfo sv_list[GPS_MAX_SVS]; |
| 260 | |
| 261 | /** Represents a bit mask indicating which SVs |
| 262 | * have ephemeris data. |
| 263 | */ |
| 264 | uint32_t ephemeris_mask; |
| 265 | |
| 266 | /** Represents a bit mask indicating which SVs |
| 267 | * have almanac data. |
| 268 | */ |
| 269 | uint32_t almanac_mask; |
| 270 | |
| 271 | /** |
| 272 | * Represents a bit mask indicating which SVs |
| 273 | * were used for computing the most recent position fix. |
| 274 | */ |
| 275 | uint32_t used_in_fix_mask; |
| 276 | } GpsSvStatus; |
| 277 | |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame^] | 278 | /** Callback with location information. |
| 279 | * Can only be called from a thread created by create_thread_cb. |
| 280 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 281 | typedef void (* gps_location_callback)(GpsLocation* location); |
| 282 | |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame^] | 283 | /** Callback with status information. |
| 284 | * Can only be called from a thread created by create_thread_cb. |
| 285 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 286 | typedef void (* gps_status_callback)(GpsStatus* status); |
| 287 | |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame^] | 288 | /** Callback with SV status information. |
| 289 | * Can only be called from a thread created by create_thread_cb. |
| 290 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 291 | typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info); |
| 292 | |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame^] | 293 | /** Callback for reporting NMEA sentences. |
| 294 | * Can only be called from a thread created by create_thread_cb. |
| 295 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 296 | typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length); |
| 297 | |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 298 | /** Callback to inform framework of the GPS engine's capabilities. |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame^] | 299 | * Capability parameter is a bit field of GPS_CAPABILITY_* flags. |
| 300 | */ |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 301 | typedef void (* gps_set_capabilities)(uint32_t capabilities); |
| 302 | |
Mike Lockwood | d20bbae | 2010-04-07 09:04:25 -0400 | [diff] [blame] | 303 | /** Callback utility for acquiring the GPS wakelock. |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame^] | 304 | * This can be used to prevent the CPU from suspending while handling GPS events. |
| 305 | */ |
Mike Lockwood | d20bbae | 2010-04-07 09:04:25 -0400 | [diff] [blame] | 306 | typedef void (* gps_acquire_wakelock)(); |
| 307 | |
| 308 | /** Callback utility for releasing the GPS wakelock. */ |
| 309 | typedef void (* gps_release_wakelock)(); |
| 310 | |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame^] | 311 | /** Callback for creating a thread that can call into the Java framework code. |
| 312 | * This must be used to create any threads that report events up to the framework. |
| 313 | */ |
| 314 | typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg); |
| 315 | |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 316 | /** GPS callback structure. */ |
| 317 | typedef struct { |
Mike Lockwood | d20bbae | 2010-04-07 09:04:25 -0400 | [diff] [blame] | 318 | /** set to sizeof(GpsCallbacks) */ |
| 319 | size_t size; |
| 320 | gps_location_callback location_cb; |
| 321 | gps_status_callback status_cb; |
| 322 | gps_sv_status_callback sv_status_cb; |
| 323 | gps_nmea_callback nmea_cb; |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 324 | gps_set_capabilities set_capabilities_cb; |
Mike Lockwood | d20bbae | 2010-04-07 09:04:25 -0400 | [diff] [blame] | 325 | gps_acquire_wakelock acquire_wakelock_cb; |
| 326 | gps_release_wakelock release_wakelock_cb; |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame^] | 327 | gps_create_thread create_thread_cb; |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 328 | } GpsCallbacks; |
| 329 | |
| 330 | |
| 331 | /** Represents the standard GPS interface. */ |
| 332 | typedef struct { |
| 333 | /** set to sizeof(GpsInterface) */ |
| 334 | size_t size; |
| 335 | /** |
| 336 | * Opens the interface and provides the callback routines |
| 337 | * to the implemenation of this interface. |
| 338 | */ |
| 339 | int (*init)( GpsCallbacks* callbacks ); |
| 340 | |
| 341 | /** Starts navigating. */ |
| 342 | int (*start)( void ); |
| 343 | |
| 344 | /** Stops navigating. */ |
| 345 | int (*stop)( void ); |
| 346 | |
| 347 | /** Closes the interface. */ |
| 348 | void (*cleanup)( void ); |
| 349 | |
| 350 | /** Injects the current time. */ |
| 351 | int (*inject_time)(GpsUtcTime time, int64_t timeReference, |
| 352 | int uncertainty); |
| 353 | |
| 354 | /** Injects current location from another location provider |
| 355 | * (typically cell ID). |
| 356 | * latitude and longitude are measured in degrees |
| 357 | * expected accuracy is measured in meters |
| 358 | */ |
| 359 | int (*inject_location)(double latitude, double longitude, float accuracy); |
| 360 | |
| 361 | /** |
| 362 | * Specifies that the next call to start will not use the |
| 363 | * information defined in the flags. GPS_DELETE_ALL is passed for |
| 364 | * a cold start. |
| 365 | */ |
| 366 | void (*delete_aiding_data)(GpsAidingData flags); |
| 367 | |
| 368 | /** |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 369 | * min_interval represents the time between fixes in milliseconds. |
| 370 | * preferred_accuracy represents the requested fix accuracy in meters. |
| 371 | * preferred_time represents the requested time to first fix in milliseconds. |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 372 | */ |
Mike Lockwood | b15879a | 2010-04-14 15:36:34 -0400 | [diff] [blame] | 373 | int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence, |
| 374 | uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time); |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 375 | |
| 376 | /** Get a pointer to extension information. */ |
| 377 | const void* (*get_extension)(const char* name); |
| 378 | } GpsInterface; |
| 379 | |
| 380 | /** Callback to request the client to download XTRA data. |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame^] | 381 | * The client should download XTRA data and inject it by calling inject_xtra_data(). |
| 382 | * Can only be called from a thread created by create_thread_cb. |
| 383 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 384 | typedef void (* gps_xtra_download_request)(); |
| 385 | |
| 386 | /** Callback structure for the XTRA interface. */ |
| 387 | typedef struct { |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame^] | 388 | gps_xtra_download_request download_request_cb; |
| 389 | gps_create_thread create_thread_cb; |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 390 | } GpsXtraCallbacks; |
| 391 | |
| 392 | /** Extended interface for XTRA support. */ |
| 393 | typedef struct { |
| 394 | /** set to sizeof(GpsXtraInterface) */ |
| 395 | size_t size; |
| 396 | /** |
| 397 | * Opens the XTRA interface and provides the callback routines |
| 398 | * to the implemenation of this interface. |
| 399 | */ |
| 400 | int (*init)( GpsXtraCallbacks* callbacks ); |
| 401 | /** Injects XTRA data into the GPS. */ |
| 402 | int (*inject_xtra_data)( char* data, int length ); |
| 403 | } GpsXtraInterface; |
| 404 | |
| 405 | /** Extended interface for DEBUG support. */ |
| 406 | typedef struct { |
| 407 | /** set to sizeof(GpsDebugInterface) */ |
| 408 | size_t size; |
| 409 | |
| 410 | /** |
| 411 | * This function should return any information that the native |
| 412 | * implementation wishes to include in a bugreport. |
| 413 | */ |
| 414 | size_t (*get_internal_state)(char* buffer, size_t bufferSize); |
| 415 | } GpsDebugInterface; |
| 416 | |
| 417 | /** Represents the status of AGPS. */ |
| 418 | typedef struct { |
| 419 | /** set to sizeof(AGpsStatus) */ |
| 420 | size_t size; |
| 421 | |
| 422 | AGpsType type; |
| 423 | AGpsStatusValue status; |
| 424 | } AGpsStatus; |
| 425 | |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame^] | 426 | /** Callback with AGPS status information. |
| 427 | * Can only be called from a thread created by create_thread_cb. |
| 428 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 429 | typedef void (* agps_status_callback)(AGpsStatus* status); |
| 430 | |
| 431 | /** Callback structure for the AGPS interface. */ |
| 432 | typedef struct { |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame^] | 433 | agps_status_callback status_cb; |
| 434 | gps_create_thread create_thread_cb; |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 435 | } AGpsCallbacks; |
| 436 | |
| 437 | |
| 438 | /** Extended interface for AGPS support. */ |
| 439 | typedef struct { |
| 440 | /** set to sizeof(AGpsInterface) */ |
| 441 | size_t size; |
| 442 | |
| 443 | /** |
| 444 | * Opens the AGPS interface and provides the callback routines |
| 445 | * to the implemenation of this interface. |
| 446 | */ |
| 447 | void (*init)( AGpsCallbacks* callbacks ); |
| 448 | /** |
| 449 | * Notifies that a data connection is available and sets |
| 450 | * the name of the APN to be used for SUPL. |
| 451 | */ |
| 452 | int (*data_conn_open)( const char* apn ); |
| 453 | /** |
| 454 | * Notifies that the AGPS data connection has been closed. |
| 455 | */ |
| 456 | int (*data_conn_closed)(); |
| 457 | /** |
| 458 | * Notifies that a data connection is not available for AGPS. |
| 459 | */ |
| 460 | int (*data_conn_failed)(); |
| 461 | /** |
| 462 | * Sets the hostname and port for the AGPS server. |
| 463 | */ |
| 464 | int (*set_server)( AGpsType type, const char* hostname, int port ); |
| 465 | } AGpsInterface; |
| 466 | |
| 467 | |
| 468 | /** Represents an NI request */ |
| 469 | typedef struct { |
| 470 | /** set to sizeof(GpsNiNotification) */ |
| 471 | size_t size; |
| 472 | |
| 473 | /** |
| 474 | * An ID generated by HAL to associate NI notifications and UI |
| 475 | * responses |
| 476 | */ |
| 477 | int notification_id; |
| 478 | |
| 479 | /** |
| 480 | * An NI type used to distinguish different categories of NI |
| 481 | * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ... |
| 482 | */ |
| 483 | GpsNiType ni_type; |
| 484 | |
| 485 | /** |
| 486 | * Notification/verification options, combinations of GpsNiNotifyFlags constants |
| 487 | */ |
| 488 | GpsNiNotifyFlags notify_flags; |
| 489 | |
| 490 | /** |
| 491 | * Timeout period to wait for user response. |
| 492 | * Set to 0 for no time out limit. |
| 493 | */ |
| 494 | int timeout; |
| 495 | |
| 496 | /** |
| 497 | * Default response when time out. |
| 498 | */ |
| 499 | GpsUserResponseType default_response; |
| 500 | |
| 501 | /** |
| 502 | * Requestor ID |
| 503 | */ |
| 504 | char requestor_id[GPS_NI_SHORT_STRING_MAXLEN]; |
| 505 | |
| 506 | /** |
| 507 | * Notification message. It can also be used to store client_id in some cases |
| 508 | */ |
| 509 | char text[GPS_NI_LONG_STRING_MAXLEN]; |
| 510 | |
| 511 | /** |
| 512 | * Client name decoding scheme |
| 513 | */ |
| 514 | GpsNiEncodingType requestor_id_encoding; |
| 515 | |
| 516 | /** |
| 517 | * Client name decoding scheme |
| 518 | */ |
| 519 | GpsNiEncodingType text_encoding; |
| 520 | |
| 521 | /** |
| 522 | * A pointer to extra data. Format: |
| 523 | * key_1 = value_1 |
| 524 | * key_2 = value_2 |
| 525 | */ |
| 526 | char extras[GPS_NI_LONG_STRING_MAXLEN]; |
| 527 | |
| 528 | } GpsNiNotification; |
| 529 | |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame^] | 530 | /** Callback with NI notification. |
| 531 | * Can only be called from a thread created by create_thread_cb. |
| 532 | */ |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 533 | typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification); |
| 534 | |
| 535 | /** GPS NI callback structure. */ |
| 536 | typedef struct |
| 537 | { |
Mike Lockwood | 4453b5b | 2010-06-20 14:23:10 -0700 | [diff] [blame^] | 538 | /** |
| 539 | * Sends the notification request from HAL to GPSLocationProvider. |
| 540 | */ |
| 541 | gps_ni_notify_callback notify_cb; |
| 542 | gps_create_thread create_thread_cb; |
Mike Lockwood | 9b0b1c3 | 2010-02-23 18:42:37 -0500 | [diff] [blame] | 543 | } GpsNiCallbacks; |
| 544 | |
| 545 | /** |
| 546 | * Extended interface for Network-initiated (NI) support. |
| 547 | */ |
| 548 | typedef struct |
| 549 | { |
| 550 | /** set to sizeof(GpsNiInterface) */ |
| 551 | size_t size; |
| 552 | |
| 553 | /** Registers the callbacks for HAL to use. */ |
| 554 | void (*init) (GpsNiCallbacks *callbacks); |
| 555 | |
| 556 | /** Sends a response to HAL. */ |
| 557 | void (*respond) (int notif_id, GpsUserResponseType user_response); |
| 558 | } GpsNiInterface; |
| 559 | |
| 560 | struct gps_device_t { |
| 561 | struct hw_device_t common; |
| 562 | |
| 563 | /** |
| 564 | * Set the provided lights to the provided values. |
| 565 | * |
| 566 | * Returns: 0 on succes, error code on failure. |
| 567 | */ |
| 568 | const GpsInterface* (*get_gps_interface)(struct gps_device_t* dev); |
| 569 | }; |
| 570 | |
| 571 | __END_DECLS |
| 572 | |
| 573 | #endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */ |
| 574 | |