diff options
author | Hakan Gustavsson <hakan.gustavsson@sonyericsson.com> | 2010-02-23 09:12:38 +0100 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2010-04-19 16:16:23 -0700 |
commit | fa94ff074d3200fae2f5d14a6d0f454e2ad23cfa (patch) | |
tree | cb29be3fc592830ef4ae34c2e93cfcd6eee0bdfe /location/java | |
parent | 69acb6b746c82f88607b3365795ebb3279188eed (diff) | |
download | frameworks_base-fa94ff074d3200fae2f5d14a6d0f454e2ad23cfa.zip frameworks_base-fa94ff074d3200fae2f5d14a6d0f454e2ad23cfa.tar.gz frameworks_base-fa94ff074d3200fae2f5d14a6d0f454e2ad23cfa.tar.bz2 |
GpsLocationProvider: Store new Location before onGpsStatusChanged is sent
In reportLocation() the new location is now stored before the callback
onGpsStatusChanged(GPS_EVENT_FIRST_FIX) is sent. This will prevent users
from getting a faulty location from LocationManager.getLastKnownLocation()
after receiving onGpsStatusChanged(GPS_EVENT_FIRST_FIX).
Change-Id: I6c654b2acbf2e216c99058a20f068bf4721a1c7a
Diffstat (limited to 'location/java')
-rwxr-xr-x | location/java/com/android/internal/location/GpsLocationProvider.java | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/location/java/com/android/internal/location/GpsLocationProvider.java b/location/java/com/android/internal/location/GpsLocationProvider.java index 9233ea9..ed3fdde 100755 --- a/location/java/com/android/internal/location/GpsLocationProvider.java +++ b/location/java/com/android/internal/location/GpsLocationProvider.java @@ -805,29 +805,6 @@ public class GpsLocationProvider extends ILocationProvider.Stub { if (VERBOSE) Log.v(TAG, "reportLocation lat: " + latitude + " long: " + longitude + " timestamp: " + timestamp); - mLastFixTime = System.currentTimeMillis(); - // report time to first fix - if (mTTFF == 0 && (flags & LOCATION_HAS_LAT_LONG) == LOCATION_HAS_LAT_LONG) { - mTTFF = (int)(mLastFixTime - mFixRequestTime); - if (Config.LOGD) Log.d(TAG, "TTFF: " + mTTFF); - - // notify status listeners - synchronized(mListeners) { - int size = mListeners.size(); - for (int i = 0; i < size; i++) { - Listener listener = mListeners.get(i); - try { - listener.mListener.onFirstFix(mTTFF); - } catch (RemoteException e) { - Log.w(TAG, "RemoteException in stopNavigating"); - mListeners.remove(listener); - // adjust for size of list changing - size--; - } - } - } - } - synchronized (mLocation) { mLocationFlags = flags; if ((flags & LOCATION_HAS_LAT_LONG) == LOCATION_HAS_LAT_LONG) { @@ -863,6 +840,29 @@ public class GpsLocationProvider extends ILocationProvider.Stub { } } + mLastFixTime = System.currentTimeMillis(); + // report time to first fix + if (mTTFF == 0 && (flags & LOCATION_HAS_LAT_LONG) == LOCATION_HAS_LAT_LONG) { + mTTFF = (int)(mLastFixTime - mFixRequestTime); + if (Config.LOGD) Log.d(TAG, "TTFF: " + mTTFF); + + // notify status listeners + synchronized(mListeners) { + int size = mListeners.size(); + for (int i = 0; i < size; i++) { + Listener listener = mListeners.get(i); + try { + listener.mListener.onFirstFix(mTTFF); + } catch (RemoteException e) { + Log.w(TAG, "RemoteException in stopNavigating"); + mListeners.remove(listener); + // adjust for size of list changing + size--; + } + } + } + } + if (mStarted && mStatus != LocationProvider.AVAILABLE) { mAlarmManager.cancel(mTimeoutIntent); // send an intent to notify that the GPS is receiving fixes. |