I find my droid doesn't update its clock itself, even if I ask it to
automatically update it from network, I am still 2 min late since I
ask it to automatically use network values (15 days ago). I need a
better time for some data synchronization. So I dove into the Android
API and I found the SntpClient class declared as internal, it seems to
be used during the GPS localisation protocol. I extracted it.
First, I was (and i'm still) unable to set up my Android device clock,
the method SystemClock.setCurrentTimeMillis() is locked as described
in the doc. Is there a way to unlock it or get round this to set the
current time myself ?
Second, when I was using the SntpClient class and doing some simple
tests with it by getting time from a NTP server, I found that there
was a difference between the real time and the received time (2 or
3s). It appears that the implementation of SntpClient doesn't look in
accordance with the RFC 2030, after changing the SntpClient as
described in the RFC, the time obtained was correct.
long originateTime = readTimeStamp(buffer,
ORIGINATE_TIME_OFFSET);
long receiveTime = readTimeStamp(buffer,
RECEIVE_TIME_OFFSET);
long transmitTime = readTimeStamp(buffer,
TRANSMIT_TIME_OFFSET);
long destinationTime = requestTime + (responseTicks -
requestTicks);
long clockOffset = (receiveTime - originateTime +
transmitTime - destinationTime)/2;
long roundTripTime = destinationTime - originateTime -
transmitTime + receiveTime;
Only the clock offset value and the round-trip time where changed, the
destination time was added as the time of arrival according to the
device clock.
I don't know which way the phone uses to update the time but I would
be grateful to know.
Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---