Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ensuring correct date/time

Tags:

android

iphone

we are creating a location-enabled app where users use this app to record certain events in the field.

The important part of the event data is when an event happened. This is no issue when user is online, but we also support situations when user is offline (by remembering & later syncing events).

There could be situations when users are offline and they change the time on the phone, so that event times are wrongly recorded.

So, what would be the best way to ensure we get a correct time, independent of user actions, given that device could be offline. Some ideas:

  1. GPS time. Is it possible to acquire it?
  2. Tracking system time changes made by user?
  3. Any other idea?

Note: time does need second accuracy, approximately minute accuracy would be ok.

Note2: we are creating mobile apps for Android and iPhone, so I'm interested for generic solutions and also solutions that are specific to any of those two platforms.

like image 705
Peter Knego Avatar asked Feb 18 '11 13:02

Peter Knego


1 Answers

I, personally, wouldn't worry so much about this scenario. The liklihood of someone intentionally changing the time on their Android (which periodically throughout the day syncs to a time server automatically) while offline seems low to me. That being said, the only way I could see compensating for this is to keep a service running in the background that keeps a running tally of the seconds passed since recording the location data offline. Once uploaded to your servers you could use the elapsed seconds to calculate a time offset from current UTC time. It's an awful lot to go through, but it would work.

GPS time is an interesting idea, but Android allows users of the SDK to send mock locations to their devices. I'm not sure you could reliably track changes to system time either, and even if you could you'd be capturing them after the fact without the current real time as context.

like image 181
Mike Yockey Avatar answered Sep 22 '22 10:09

Mike Yockey