[HD2 Android NAND Development] htcvidi:
I continue to study the source code of Hyperdroid to see how this behaves to update GPS time.

Much of the code is in the file GpsLocationProvider.java

My comments begin with'<===='

Parameters NTP_SERVER and SUPL_HOST are read in the Constructor of the class

Here's a part of the code

===================================

mProperties = new Properties();

try {

File file = new File(PROPERTIES_FILE);

FileInputStream stream = new FileInputStream(file); <===== open gps.conf

mProperties.load(stream); <===== load parameters from gps.conf

stream.close();

mNtpServer = mProperties.getProperty("NTP_SERVER", null); <=== get NTP_sERVEUR value

mSuplServerHost = mProperties.getProperty("SUPL_HOST"); <=== get SUPL_HOST value

String portString = mProperties.getProperty("SUPL_PORT");

if (mSuplServerHost != null && portString != null) {

try {

mSuplServerPort = Integer.parseInt(portString);

} catch (NumberFormatException e) {

Log.e(TAG, "unable to parse SUPL_PORT: " + portString);

}

}

mC2KServerHost = mProperties.getProperty("C2K_HOST"); <=== read C2K_HOST value in gps.conf

portString = mProperties.getProperty("C2K_PORT");

if (mC2KServerHost != null && portString != null) {

try {

mC2KServerPort = Integer.parseInt(portString);

} catch (NumberFormatException e) {

Log.e(TAG, "unable to parse C2K_PORT: " + portString);

}

}

} catch (IOException e) {

Log.w(TAG, "Could not open GPS configuration file " + PROPERTIES_FILE);

}

================================

Only one NTP server is recovered in the file gps.conf. Probably the first in the list.

So it is useless, on Hyperdroid, to have multiple NTP_SERVER in the gps.conf.

Use only the fastest NTP server from AngelDeath list.

The NTP time is injected into the GPS in the following function

==============================

private void handleInjectNtpTime() {

if (!mNetworkAvailable) {

// try again when network is up

mInjectNtpTimePending = true;

return;

}

mInjectNtpTimePending = false;

SntpClient client = new SntpClient();

long delay;

if (client.requestTime(mNtpServer, 10000)) { <==== mNtpServer value has been initialized from gps.conf

long time = client.getNtpTime();

long timeReference = client.getNtpTimeReference();

int certainty = (int)(client.getRoundTripTime()/2);

long now = System.currentTimeMillis();

Log.d(TAG, "NTP server returned: " <==== You can see this line if you get à look to logcat

+ time + " (" + new Date(time)

+ ") reference: " + timeReference

+ " certainty: " + certainty

+ " system time offset: " + (time - now));

native_inject_time(time, timeReference, certainty); <=== time injection in gps

delay = NTP_INTERVAL;

} else {

if (DEBUG) Log.d(TAG, "requestTime failed");

delay = RETRY_INTERVAL;

}

// send delayed message for next NTP injection

// since this is delayed and not urgent we do not hold a wake lock here

mHandler.removeMessages(INJECT_NTP_TIME);

mHandler.sendMessageDelayed(Message.obtain(mHandler, INJECT_NTP_TIME), delay);

}

==========================

The time is injected into the GPS by the function 'native_inject_time'

This feature is present in the file 'com_android_server_location_GpsLocationProvider.cpp'

==========================

static JNINativeMethod sMethods[] = {

/* name, signature, funcPtr */

{"class_init_native", "()V", (void *)android_location_GpsLocationProvider_class_init_native},

{"native_is_supported", "()Z", (void*)android_location_GpsLocationProvider_is_supported},

{"native_init", "()Z", (void*)android_location_GpsLocationProvider_init},

{"native_cleanup", "()V", (void*)android_location_GpsLocationProvider_cleanup},

{"native_set_position_mode", "(IIIII)Z", (void*)android_location_GpsLocationProvider_set_position_mode},

{"native_start", "()Z", (void*)android_location_GpsLocationProvider_start},

{"native_stop", "()Z", (void*)android_location_GpsLocationProvider_stop},

{"native_delete_aiding_data", "(I)V", (void*)android_location_GpsLocationProvider_delete_aiding_data},

{"native_read_sv_status", "([I[F[F[F[I)I", (void*)android_location_GpsLocationProvider_read_sv_status},

{"native_read_nmea", "([BI)I", (void*)android_location_GpsLocationProvider_read_nmea},

Here =====> {"native_inject_time", "(JJI)V", (void*)android_location_GpsLocationProvider_inject_time},

{"native_inject_location", "(DDF)V", (void*)android_location_GpsLocationProvider_inject_location},

{"native_supports_xtra", "()Z", (void*)android_location_GpsLocationProvider_supports_xtra},

{"native_inject_xtra_data", "([BI)V", (void*)android_location_GpsLocationProvider_inject_xtra_data},

{"native_agps_data_conn_open", "(Ljava/lang/String;)V", (void*)android_location_GpsLocationProvider_agps_data_conn_open},

{"native_agps_data_conn_closed", "()V", (void*)android_location_GpsLocationProvider_agps_data_conn_closed},

{"native_agps_data_conn_failed", "()V", (void*)android_location_GpsLocationProvider_agps_data_conn_failed},

{"native_agps_set_id","(ILjava/lang/String;)V",(void*)android_location_GpsLocationProvider_agps_set_id},

{"native_agps_set_ref_location_cellid","(IIIII)V",(void*)android_location_GpsLocationProvider_agps_set_reference_location_cellid},

{"native_set_agps_server", "(ILjava/lang/String;I)V", (void*)android_location_GpsLocationProvider_set_agps_server},

{"native_send_ni_response", "(II)V", (void*)android_location_GpsLocationProvider_send_ni_response},

{"native_agps_ni_message", "([BI)V", (void *)android_location_GpsLocationProvider_agps_send_ni_message},

{"native_get_internal_state", "()Ljava/lang/String;", (void*)android_location_GpsLocationProvider_get_internal_state},

{"native_update_network_state", "(ZIZLjava/lang/String;)V", (void*)android_location_GpsLocationProvider_update_network_state },

};

=============================

This function points to 'android_location_GpsLocationProvider_inject_time'

=============================

static void android_location_GpsLocationProvider_inject_time(JNIEnv* env, jobject obj,

jlong time, jlong timeReference, jint uncertainty)

{

const GpsInterface* interface = GetGpsInterface(env, obj); <== Get Pointer to Gps interface

if (interface)	<== If a pointer is returned

interface->inject_time(time, timeReference, uncertainty); <== call gps function in the gps module

}

===========================

As you can see, this function retrieves a pointer to the GPS interface in order to call the different methods available.

Then it calls the method 'inject_time' presents in the GPS module.

These are the sources of this module that I miss.

If anyone knows where to find them, I'm interested.

My next step will be to study how XTRA_SERVER is managed