[HD2 Android NAND Development] AngelDeath:
Greets All,

I finally decided to post this here in the hopes to help myself and as well as everyone else, including the Dev's of kernels. As you all know the AGPS support for the HD2 doesnt work as it should, and even the support for it isnt there. Obviously being that these are ports, there is still things that need to be fixed, even in native android, but thats a different topic.

As some of you may know or not, I created scripts taking it one step further to have our GPS's lock faster then they have, for anyone that has no idea what I am talking about: Instantaneous GPS Fixation CWR v1.1 USA & INTERNATIONAL COMPLETED!

While doing this, I ran into a script, and I have tried talking to the kernel dev's many of them and other then 1 responding and confirming my finding, no one has responded, so at this point, here is what I found to help, do what you want with it.

There seems to be a script missing in part of the kernel, its suppose to be located in include/hardware called "gps.h" which is the support for the agps. I looked thru alot of gits, did alot of searches, and have not found any that have this script. The one kernel dev that looked thru his kernel also told me that this script didnt exist, but also said that a file called "gps.c" should go with it. Being that I am NOT a genius programmer, I am limited in what I can do. I am trying to learn, but there is no concise tutorial that is new to use as a guide, they are all outdated.

So this is what I found so far. I have more info if anyone is interested in fixing this or needs more help, but I'm sure no one needs it cause you are all far superior then I am in development. Here is the script thats missing in all the kernels for agps support:

00001 /*
00002 * Copyright (C) 2010 The Android Open Source Project
00003 *
00004 * Licensed under the Apache License, Version 2.0 (the "License");
00005 * you may not use this file except in compliance with the License.
00006 * You may obtain a copy of the License at
00007 *
00008 * http://www.apache.org/licenses/LICENSE-2.0
00009 *
00010 * Unless required by applicable law or agreed to in writing, software
00011 * distributed under the License is distributed on an "AS IS" BASIS,
00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013 * See the License for the specific language governing permissions and
00014 * limitations under the License.
00015 */
00016
00017 #ifndef ANDROID_INCLUDE_HARDWARE_GPS_H
00018 #define ANDROID_INCLUDE_HARDWARE_GPS_H
00019
00020 #include <stdint.h>
00021 #include <sys/cdefs.h>
00022 #include <sys/types.h>
00023
00024 #include <hardware/hardware.h>
00025
00026 __BEGIN_DECLS
00027
00028 /**
00029 * The id of this module
00030 */
00031 #define GPS_HARDWARE_MODULE_ID "gps"
00032
00033
00034 /** Milliseconds since January 1, 1970 */
00035 typedef int64_t GpsUtcTime;
00036
00037 /** Maximum number of SVs for gps_sv_status_callback(). */
00038 #define GPS_MAX_SVS 32
00039
00040 /** Requested operational mode for GPS operation. */
00041 typedef uint32_t GpsPositionMode;
00042 // IMPORTANT: Note that the following values must match
00043 // constants in GpsLocationProvider.java.
00044 /** Mode for running GPS standalone (no assistance). */
00045 #define GPS_POSITION_MODE_STANDALONE 0
00046 /** AGPS MS-Based mode. */
00047 #define GPS_POSITION_MODE_MS_BASED 1
00048 /** AGPS MS-Assisted mode. */
00049 #define GPS_POSITION_MODE_MS_ASSISTED 2
00050
00051 /** Requested recurrence mode for GPS operation. */
00052 typedef uint32_t GpsPositionRecurrence;
00053 // IMPORTANT: Note that the following values must match
00054 // constants in GpsLocationProvider.java.
00055 /** Receive GPS fixes on a recurring basis at a specified period. */
00056 #define GPS_POSITION_RECURRENCE_PERIODIC 0
00057 /** Request a single shot GPS fix. */
00058 #define GPS_POSITION_RECURRENCE_SINGLE 1
00059
00060 /** GPS status event values. */
00061 typedef uint16_t GpsStatusValue;
00062 // IMPORTANT: Note that the following values must match
00063 // constants in GpsLocationProvider.java.
00064 /** GPS status unknown. */
00065 #define GPS_STATUS_NONE 0
00066 /** GPS has begun navigating. */
00067 #define GPS_STATUS_SESSION_BEGIN 1
00068 /** GPS has stopped navigating. */
00069 #define GPS_STATUS_SESSION_END 2
00070 /** GPS has powered on but is not navigating. */
00071 #define GPS_STATUS_ENGINE_ON 3
00072 /** GPS is powered off. */
00073 #define GPS_STATUS_ENGINE_OFF 4
00074
00075 /** Flags to indicate which values are valid in a GpsLocation. */
00076 typedef uint16_t GpsLocationFlags;
00077 // IMPORTANT: Note that the following values must match
00078 // constants in GpsLocationProvider.java.
00079 /** GpsLocation has valid latitude and longitude. */
00080 #define GPS_LOCATION_HAS_LAT_LONG 0x0001
00081 /** GpsLocation has valid altitude. */
00082 #define GPS_LOCATION_HAS_ALTITUDE 0x0002
00083 /** GpsLocation has valid speed. */
00084 #define GPS_LOCATION_HAS_SPEED 0x0004
00085 /** GpsLocation has valid bearing. */
00086 #define GPS_LOCATION_HAS_BEARING 0x0008
00087 /** GpsLocation has valid accuracy. */
00088 #define GPS_LOCATION_HAS_ACCURACY 0x0010
00089
00090 /** Flags for the gps_set_capabilities callback. */
00091
00092 /** GPS HAL schedules fixes for GPS_POSITION_RECURRENCE_PERIODIC mode.
00093 If this is not set, then the framework will use 1000ms for min_interval
00094 and will start and call start() and stop() to schedule the GPS.
00095 */
00096 #define GPS_CAPABILITY_SCHEDULING 0x0000001
00097 /** GPS supports MS-Based AGPS mode */
00098 #define GPS_CAPABILITY_MSB 0x0000002
00099 /** GPS supports MS-Assisted AGPS mode */
00100 #define GPS_CAPABILITY_MSA 0x0000004
00101 /** GPS supports single-shot fixes */
00102 #define GPS_CAPABILITY_SINGLE_SHOT 0x0000008
00103
00104 /** Flags used to specify which aiding data to delete
00105 when calling delete_aiding_data(). */
00106 typedef uint16_t GpsAidingData;
00107 // IMPORTANT: Note that the following values must match
00108 // constants in GpsLocationProvider.java.
00109 #define GPS_DELETE_EPHEMERIS 0x0001
00110 #define GPS_DELETE_ALMANAC 0x0002
00111 #define GPS_DELETE_POSITION 0x0004
00112 #define GPS_DELETE_TIME 0x0008
00113 #define GPS_DELETE_IONO 0x0010
00114 #define GPS_DELETE_UTC 0x0020
00115 #define GPS_DELETE_HEALTH 0x0040
00116 #define GPS_DELETE_SVDIR 0x0080
00117 #define GPS_DELETE_SVSTEER 0x0100
00118 #define GPS_DELETE_SADATA 0x0200
00119 #define GPS_DELETE_RTI 0x0400
00120 #define GPS_DELETE_CELLDB_INFO 0x8000
00121 #define GPS_DELETE_ALL 0xFFFF
00122
00123 /** AGPS type */
00124 typedef uint16_t AGpsType;
00125 #define AGPS_TYPE_SUPL 1
00126 #define AGPS_TYPE_C2K 2
00127
00128 /**
00129 * String length constants
00130 */
00131 #define GPS_NI_SHORT_STRING_MAXLEN 256
00132 #define GPS_NI_LONG_STRING_MAXLEN 2048
00133
00134 /**
00135 * GpsNiType constants
00136 */
00137 typedef uint32_t GpsNiType;
00138 #define GPS_NI_TYPE_VOICE 1
00139 #define GPS_NI_TYPE_UMTS_SUPL 2
00140 #define GPS_NI_TYPE_UMTS_CTRL_PLANE 3
00141
00142 /**
00143 * GpsNiNotifyFlags constants
00144 */
00145 typedef uint32_t GpsNiNotifyFlags;
00146 /** NI requires notification */
00147 #define GPS_NI_NEED_NOTIFY 0x0001
00148 /** NI requires verification */
00149 #define GPS_NI_NEED_VERIFY 0x0002
00150 /** NI requires privacy override, no notification/minimal trace */
00151 #define GPS_NI_PRIVACY_OVERRIDE 0x0004
00152
00153 /**
00154 * GPS NI responses, used to define the response in
00155 * NI structures
00156 */
00157 typedef int GpsUserResponseType;
00158 #define GPS_NI_RESPONSE_ACCEPT 1
00159 #define GPS_NI_RESPONSE_DENY 2
00160 #define GPS_NI_RESPONSE_NORESP 3
00161
00162 /**
00163 * NI data encoding scheme
00164 */
00165 typedef int GpsNiEncodingType;
00166 #define GPS_ENC_NONE 0
00167 #define GPS_ENC_SUPL_GSM_DEFAULT 1
00168 #define GPS_ENC_SUPL_UTF8 2
00169 #define GPS_ENC_SUPL_UCS2 3
00170 #define GPS_ENC_UNKNOWN -1
00171
00172 /** AGPS status event values. */
00173 typedef uint16_t AGpsStatusValue;
00174 /** GPS requests data connection for AGPS. */
00175 #define GPS_REQUEST_AGPS_DATA_CONN 1
00176 /** GPS releases the AGPS data connection. */
00177 #define GPS_RELEASE_AGPS_DATA_CONN 2
00178 /** AGPS data connection initiated */
00179 #define GPS_AGPS_DATA_CONNECTED 3
00180 /** AGPS data connection completed */
00181 #define GPS_AGPS_DATA_CONN_DONE 4
00182 /** AGPS data connection failed */
00183 #define GPS_AGPS_DATA_CONN_FAILED 5
00184
00185 /**
00186 * Name for the GPS XTRA interface.
00187 */
00188 #define GPS_XTRA_INTERFACE "gps-xtra"
00189
00190 /**
00191 * Name for the GPS DEBUG interface.
00192 */
00193 #define GPS_DEBUG_INTERFACE "gps-debug"
00194
00195 /**
00196 * Name for the AGPS interface.
00197 */
00198 #define AGPS_INTERFACE "agps"
00199
00200 /**
00201 * Name for NI interface
00202 */
00203 #define GPS_NI_INTERFACE "gps-ni"
00204
00205 /** Represents a location. */
00206 typedef struct {
00207 /** set to sizeof(GpsLocation) */
00208 size_t size;
00209 /** Contains GpsLocationFlags bits. */
00210 uint16_t flags;
00211 /** Represents latitude in degrees. */
00212 double latitude;
00213 /** Represents longitude in degrees. */
00214 double longitude;
00215 /** Represents altitude in meters above the WGS 84 reference
00216 * ellipsoid. */
00217 double altitude;
00218 /** Represents speed in meters per second. */
00219 float speed;
00220 /** Represents heading in degrees. */
00221 float bearing;
00222 /** Represents expected accuracy in meters. */
00223 float accuracy;
00224 /** Timestamp for the location fix. */
00225 GpsUtcTime timestamp;
00226 } GpsLocation;
00227
00228 /** Represents the status. */
00229 typedef struct {
00230 /** set to sizeof(GpsStatus) */
00231 size_t size;
00232 GpsStatusValue status;
00233 } GpsStatus;
00234
00235 /** Represents SV information. */
00236 typedef struct {
00237 /** set to sizeof(GpsSvInfo) */
00238 size_t size;
00239 /** Pseudo-random number for the SV. */
00240 int prn;
00241 /** Signal to noise ratio. */
00242 float snr;
00243 /** Elevation of SV in degrees. */
00244 float elevation;
00245 /** Azimuth of SV in degrees. */
00246 float azimuth;
00247 } GpsSvInfo;
00248
00249 /** Represents SV status. */
00250 typedef struct {
00251 /** set to sizeof(GpsSvStatus) */
00252 size_t size;
00253
00254 /** Number of SVs currently visible. */
00255 int num_svs;
00256
00257 /** Contains an array of SV information. */
00258 GpsSvInfo sv_list[GPS_MAX_SVS];
00259
00260 /** Represents a bit mask indicating which SVs
00261 * have ephemeris data.
00262 */
00263 uint32_t ephemeris_mask;
00264
00265 /** Represents a bit mask indicating which SVs
00266 * have almanac data.
00267 */
00268 uint32_t almanac_mask;
00269
00270 /**
00271 * Represents a bit mask indicating which SVs
00272 * were used for computing the most recent position fix.
00273 */
00274 uint32_t used_in_fix_mask;
00275 } GpsSvStatus;
00276
00277 /** Callback with location information. */
00278 typedef void (* gps_location_callback)(GpsLocation* location);
00279
00280 /** Callback with status information. */
00281 typedef void (* gps_status_callback)(GpsStatus* status);
00282
00283 /** Callback with SV status information. */
00284 typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info);
00285
00286 /** Callback for reporting NMEA sentences. */
00287 typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length);
00288
00289 /** Callback to inform framework of the GPS engine's capabilities.
00290 capability parameter is a bit field of GPS_CAPABILITY_* flags */
00291 typedef void (* gps_set_capabilities)(uint32_t capabilities);
00292
00293 /** Callback utility for acquiring the GPS wakelock.
00294 This can be used to prevent the CPU from suspending while handling GPS events. */
00295 typedef void (* gps_acquire_wakelock)();
00296
00297 /** Callback utility for releasing the GPS wakelock. */
00298 typedef void (* gps_release_wakelock)();
00299
00300 /** GPS callback structure. */
00301 typedef struct {
00302 /** set to sizeof(GpsCallbacks) */
00303 size_t size;
00304 gps_location_callback location_cb;
00305 gps_status_callback status_cb;
00306 gps_sv_status_callback sv_status_cb;
00307 gps_nmea_callback nmea_cb;
00308 gps_set_capabilities set_capabilities_cb;
00309 gps_acquire_wakelock acquire_wakelock_cb;
00310 gps_release_wakelock release_wakelock_cb;
00311 } GpsCallbacks;
00312
00313
00314 /** Represents the standard GPS interface. */
00315 typedef struct {
00316 /** set to sizeof(GpsInterface) */
00317 size_t size;
00318 /**
00319 * Opens the interface and provides the callback routines
00320 * to the implemenation of this interface.
00321 */
00322 int (*init)( GpsCallbacks* callbacks );
00323
00324 /** Starts navigating. */
00325 int (*start)( void );
00326
00327 /** Stops navigating. */
00328 int (*stop)( void );
00329
00330 /** Closes the interface. */
00331 void (*cleanup)( void );
00332
00333 /** Injects the current time. */
00334 int (*inject_time)(GpsUtcTime time, int64_t timeReference,
00335 int uncertainty);
00336
00337 /** Injects current location from another location provider
00338 * (typically cell ID).
00339 * latitude and longitude are measured in degrees
00340 * expected accuracy is measured in meters
00341 */
00342 int (*inject_location)(double latitude, double longitude, float accuracy);
00343
00344 /**
00345 * Specifies that the next call to start will not use the
00346 * information defined in the flags. GPS_DELETE_ALL is passed for
00347 * a cold start.
00348 */
00349 void (*delete_aiding_data)(GpsAidingData flags);
00350
00351 /**
00352 * min_interval represents the time between fixes in milliseconds.
00353 * preferred_accuracy represents the requested fix accuracy in meters.
00354 * preferred_time represents the requested time to first fix in milliseconds.
00355 */
00356 int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence,
00357 uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time);
00358
00359 /** Get a pointer to extension information. */
00360 const void* (*get_extension)(const char* name);
00361 } GpsInterface;
00362
00363 /** Callback to request the client to download XTRA data.
00364 The client should download XTRA data and inject it by calling
00365 inject_xtra_data(). */
00366 typedef void (* gps_xtra_download_request)();
00367
00368 /** Callback structure for the XTRA interface. */
00369 typedef struct {
00370 gps_xtra_download_request download_request_cb;
00371 } GpsXtraCallbacks;
00372
00373 /** Extended interface for XTRA support. */
00374 typedef struct {
00375 /** set to sizeof(GpsXtraInterface) */
00376 size_t size;
00377 /**
00378 * Opens the XTRA interface and provides the callback routines
00379 * to the implemenation of this interface.
00380 */
00381 int (*init)( GpsXtraCallbacks* callbacks );
00382 /** Injects XTRA data into the GPS. */
00383 int (*inject_xtra_data)( char* data, int length );
00384 } GpsXtraInterface;
00385
00386 /** Extended interface for DEBUG support. */
00387 typedef struct {
00388 /** set to sizeof(GpsDebugInterface) */
00389 size_t size;
00390
00391 /**
00392 * This function should return any information that the native
00393 * implementation wishes to include in a bugreport.
00394 */
00395 size_t (*get_internal_state)(char* buffer, size_t bufferSize);
00396 } GpsDebugInterface;
00397
00398 /** Represents the status of AGPS. */
00399 typedef struct {
00400 /** set to sizeof(AGpsStatus) */
00401 size_t size;
00402
00403 AGpsType type;
00404 AGpsStatusValue status;
00405 } AGpsStatus;
00406
00407 /** Callback with AGPS status information. */
00408 typedef void (* agps_status_callback)(AGpsStatus* status);
00409
00410 /** Callback structure for the AGPS interface. */
00411 typedef struct {
00412 agps_status_callback status_cb;
00413 } AGpsCallbacks;
00414
00415
00416 /** Extended interface for AGPS support. */
00417 typedef struct {
00418 /** set to sizeof(AGpsInterface) */
00419 size_t size;
00420
00421 /**
00422 * Opens the AGPS interface and provides the callback routines
00423 * to the implemenation of this interface.
00424 */
00425 void (*init)( AGpsCallbacks* callbacks );
00426 /**
00427 * Notifies that a data connection is available and sets
00428 * the name of the APN to be used for SUPL.
00429 */
00430 int (*data_conn_open)( const char* apn );
00431 /**
00432 * Notifies that the AGPS data connection has been closed.
00433 */
00434 int (*data_conn_closed)();
00435 /**
00436 * Notifies that a data connection is not available for AGPS.
00437 */
00438 int (*data_conn_failed)();
00439 /**
00440 * Sets the hostname and port for the AGPS server.
00441 */
00442 int (*set_server)( AGpsType type, const char* hostname, int port );
00443 } AGpsInterface;
00444
00445
00446 /** Represents an NI request */
00447 typedef struct {
00448 /** set to sizeof(GpsNiNotification) */
00449 size_t size;
00450
00451 /**
00452 * An ID generated by HAL to associate NI notifications and UI
00453 * responses
00454 */
00455 int notification_id;
00456
00457 /**
00458 * An NI type used to distinguish different categories of NI
00459 * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ...
00460 */
00461 GpsNiType ni_type;
00462
00463 /**
00464 * Notification/verification options, combinations of GpsNiNotifyFlags constants
00465 */
00466 GpsNiNotifyFlags notify_flags;
00467
00468 /**
00469 * Timeout period to wait for user response.
00470 * Set to 0 for no time out limit.
00471 */
00472 int timeout;
00473
00474 /**
00475 * Default response when time out.
00476 */
00477 GpsUserResponseType default_response;
00478
00479 /**
00480 * Requestor ID
00481 */
00482 char requestor_id[GPS_NI_SHORT_STRING_MAXLEN];
00483
00484 /**
00485 * Notification message. It can also be used to store client_id in some cases
00486 */
00487 char text[GPS_NI_LONG_STRING_MAXLEN];
00488
00489 /**
00490 * Client name decoding scheme
00491 */
00492 GpsNiEncodingType requestor_id_encoding;
00493
00494 /**
00495 * Client name decoding scheme
00496 */
00497 GpsNiEncodingType text_encoding;
00498
00499 /**
00500 * A pointer to extra data. Format:
00501 * key_1 = value_1
00502 * key_2 = value_2
00503 */
00504 char extras[GPS_NI_LONG_STRING_MAXLEN];
00505
00506 } GpsNiNotification;
00507
00508 /** Callback with NI notification. */
00509 typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification);
00510
00511 /** GPS NI callback structure. */
00512 typedef struct
00513 {
00514 /**
00515 * Sends the notification request from HAL to GPSLocationProvider.
00516 */
00517 gps_ni_notify_callback notify_cb;
00518 } GpsNiCallbacks;
00519
00520 /**
00521 * Extended interface for Network-initiated (NI) support.
00522 */
00523 typedef struct
00524 {
00525 /** set to sizeof(GpsNiInterface) */
00526 size_t size;
00527
00528 /** Registers the callbacks for HAL to use. */
00529 void (*init) (GpsNiCallbacks *callbacks);
00530
00531 /** Sends a response to HAL. */
00532 void (*respond) (int notif_id, GpsUserResponseType user_response);
00533 } GpsNiInterface;
00534
00535 struct gps_device_t {
00536 struct hw_device_t common;
00537
00538 /**
00539 * Set the provided lights to the provided values.
00540 *
00541 * Returns: 0 on succes, error code on failure.
00542 */
00543 const GpsInterface* (*get_gps_interface)(struct gps_device_t* dev);
00544 };
00545
00546 __END_DECLS
00547
00548 #endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */
00549

Also if anyone is interested, I also have a rom that has apparently agps support in the rom, the "4281-001_Huashan_Sense_21_Gingerbread.zip" has support for agps, because it also have the agps drivers located in there, obviously this is the "brother" of the HD2 in china, so you guys might want to disassemble that as well.

I hope this was helpful in getting this to work, if I can be of any help, then let me know, but I think this script is the starting point for agps, because even some "Native" Android phones dont have agps support.

Good luck, and Hope this was of some use to you.