Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong tests in LegacyLastLocationFinder.getLastBestLocation() #6

Open
GoogleCodeExporter opened this issue Jun 29, 2015 · 3 comments
Open

Comments

@GoogleCodeExporter
Copy link

In the LegacyLastLocationFinder.getLastBestLocation() method, the tests on the 
fix time are inverted!

if ((time < minTime && accuracy < bestAccuracy))
should be:
if ((time > minTime && accuracy < bestAccuracy))

if (time > minTime && bestAccuracy == Float.MAX_VALUE && time < bestTime)
should be:
if (time < minTime && bestAccuracy == Float.MAX_VALUE && time > bestTime)

and
if (locationListener != null && (bestTime > minTime || bestAccuracy > 
minDistance))
should be:
if (locationListener != null && (bestTime < minTime || bestAccuracy > 
minDistance))

It is less important but the comment for the minTime is misleading.

I also think the test to get the latest fix no matter its accuracy in both 
LegacyLastLocationFinder and GingerbreadLastLocationFinder should not include a 
check on minTime. Then,
if (time < minTime && bestAccuracy == Float.MAX_VALUE && time > bestTime)
should actually be:
if (bestAccuracy == Float.MAX_VALUE && time > bestTime)

Original issue reported on code.google.com by pbp...@gmail.com on 16 Aug 2011 at 5:17

@GoogleCodeExporter
Copy link
Author

I thought it over and the last part of my report should be ignored.

Original comment by pbp...@gmail.com on 16 Aug 2011 at 5:52

@GoogleCodeExporter
Copy link
Author

Worse yet. minTime is defined as "Minimum time required between location 
updates" but it is being compared with Location.getTime() which is defined as 
"Returns the UTC time of this fix, in milliseconds since January 1, 1970".

We shouldn't be comparing minTime with Location.getTime(). We should be 
comparing it with timeElapsed (System.currentTimeMillis() - Location.getTime()).

This bug applies to GingerbreadLastLocationFinder as well.

Original comment by cow...@bbs.darktech.org on 7 May 2012 at 3:58

@GoogleCodeExporter
Copy link
Author

Actually, the correct and simple fix would be to just edit the line
long time = location.getTime();
to
long time = System.currentTimeMillis() - location.getTime();
That will solve all issues.
Also minTime should be defined something like "Minimum time since last location 
update"

Original comment by lionscr...@gmail.com on 27 Dec 2012 at 10:36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant