summaryrefslogtreecommitdiffstats
path: root/location
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2010-01-20 10:14:54 -0500
committerMike Lockwood <lockwood@android.com>2010-02-02 13:26:33 -0500
commitc2a6738215af95bc50639e43c8f9291a0d521b37 (patch)
tree64b91ac50e1ca2dfd16d7abad2d5bf54ed68fa40 /location
parent2f3a615feaa1286612576bc15f6bd8cae011301f (diff)
downloadframeworks_base-c2a6738215af95bc50639e43c8f9291a0d521b37.zip
frameworks_base-c2a6738215af95bc50639e43c8f9291a0d521b37.tar.gz
frameworks_base-c2a6738215af95bc50639e43c8f9291a0d521b37.tar.bz2
Be tolerant of GPS session and engine on status messages arriving out of order.
BUG: 2366194 Change-Id: Iac152cc46f3647e12c9077f1bfa4183f19ac94b6 Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'location')
-rwxr-xr-xlocation/java/com/android/internal/location/GpsLocationProvider.java33
1 files changed, 28 insertions, 5 deletions
diff --git a/location/java/com/android/internal/location/GpsLocationProvider.java b/location/java/com/android/internal/location/GpsLocationProvider.java
index 7763549..134756e 100755
--- a/location/java/com/android/internal/location/GpsLocationProvider.java
+++ b/location/java/com/android/internal/location/GpsLocationProvider.java
@@ -182,6 +182,9 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
// true if GPS is navigating
private boolean mNavigating;
+
+ // true if GPS engine is on
+ private boolean mEngineOn;
// requested frequency of fixes, in seconds
private int mFixInterval = 1;
@@ -556,13 +559,17 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
mNetworkThread = null;
}
+ // do this before releasing wakelock
+ native_cleanup();
+
// The GpsEventThread does not wait for the GPS to shutdown
// so we need to report the GPS_STATUS_ENGINE_OFF event here
if (mNavigating) {
+ reportStatus(GPS_STATUS_SESSION_END);
+ }
+ if (mEngineOn) {
reportStatus(GPS_STATUS_ENGINE_OFF);
}
-
- native_cleanup();
}
public boolean isEnabled() {
@@ -874,9 +881,24 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
synchronized(mListeners) {
boolean wasNavigating = mNavigating;
- mNavigating = (status == GPS_STATUS_SESSION_BEGIN);
- if (mNavigating && !mWakeLock.isHeld()) {
+ switch (status) {
+ case GPS_STATUS_SESSION_BEGIN:
+ mNavigating = true;
+ break;
+ case GPS_STATUS_SESSION_END:
+ mNavigating = false;
+ break;
+ case GPS_STATUS_ENGINE_ON:
+ mEngineOn = true;
+ break;
+ case GPS_STATUS_ENGINE_OFF:
+ mEngineOn = false;
+ break;
+ }
+
+ // beware, the events can come out of order
+ if ((mNavigating || mEngineOn) && !mWakeLock.isHeld()) {
if (DEBUG) Log.d(TAG, "Acquiring wakelock");
mWakeLock.acquire();
}
@@ -919,7 +941,8 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
mContext.sendBroadcast(intent);
}
- if (status == GPS_STATUS_ENGINE_OFF && mWakeLock.isHeld()) {
+ // beware, the events can come out of order
+ if (!mNavigating && !mEngineOn && mWakeLock.isHeld()) {
if (DEBUG) Log.d(TAG, "Releasing wakelock");
mWakeLock.release();
}