I just double checked.  It works for me too.  You may have hit it
earlier when I was updating the web page.

To answer the question:
How are you handling the overhead of IPC in your time calculations?


When you connect to the service, you register a callback.  The service
updates your callback object with calls to two methods, onTimeUpdate
and onClockStateChange.

The service passes to void onTimeUpdate(long atomicTime, long
localTime); two parameters:

1. atomicTime: the milliseconds since epoch of the atomic time.
2. localTime: the milliseconds since epoch of the local phone time
that the atomic time was recorded.


So, your client always knows the current atomic time and the local
time at which the atomic time was recorded.

You adjust for the latency that IPC adds using the following math in
your client:

long currentTime = System.currentTimeMillis();
long delta = currentTime - localTime; // currentTime will always be
equal to or greater than localTime.
long currentAtomicTime = atomicTime + delta;


There's a full client in the sample code file:
http://www.timekeepersite.com/download/HelloClock.zip


AIDL code below:



package com.cognition.navyclock;

interface iNavyClockCallback{

        /*
         * Called frequently to notify the callback of the current atomic
time.
         *
         * atomicTime is the actual atomic time.
         * localTime is the time on the phone that the atomicTime was
measured.
         *
         * The difference between atomicTime and localTime can be interpreted
as the offset
         * or skew of the local clock from the atomic clock.
         */
        void onTimeUpdate(long atomicTime, long localTime);

        /*
          * Notifies the callback of the current atomic clock state.  Will be
one of the
          * states defined in the class AtomicClockState
          *
          * newState - the identifier of the new state
          * server   - the name of the server that the service is currently
talking to.
          * location - the common name/description of the server
          */
         void onClockStateChange(int newState, String server, String
location);



}


On Mar 5, 10:04 am, Greg Donald <gdon...@gmail.com> wrote:
> On Fri, Mar 5, 2010 at 12:00 PM, Mark Murphy <mmur...@commonsware.com> wrote:
> >>http://www.timekeepersite.com/dev.html
>
> > FYI, that's a 404.
>
> Works for me.
>
> --
> Greg Donald
> destiney.com | gregdonald.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to