am bb79e5fd
: Merge "Be tolerant of GPS session and engine on status messages arriving out of order." into eclair
Merge commit 'bb79e5fdb52eb86963fc688e6a455451b6e1a867' into eclair-plus-aosp * commit 'bb79e5fdb52eb86963fc688e6a455451b6e1a867': Be tolerant of GPS session and engine on status messages arriving out of order.
This commit is contained in:
@ -183,6 +183,9 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
|
|||||||
// true if GPS is navigating
|
// true if GPS is navigating
|
||||||
private boolean mNavigating;
|
private boolean mNavigating;
|
||||||
|
|
||||||
|
// true if GPS engine is on
|
||||||
|
private boolean mEngineOn;
|
||||||
|
|
||||||
// requested frequency of fixes, in seconds
|
// requested frequency of fixes, in seconds
|
||||||
private int mFixInterval = 1;
|
private int mFixInterval = 1;
|
||||||
|
|
||||||
@ -556,13 +559,17 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
|
|||||||
mNetworkThread = null;
|
mNetworkThread = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// do this before releasing wakelock
|
||||||
|
native_cleanup();
|
||||||
|
|
||||||
// The GpsEventThread does not wait for the GPS to shutdown
|
// The GpsEventThread does not wait for the GPS to shutdown
|
||||||
// so we need to report the GPS_STATUS_ENGINE_OFF event here
|
// so we need to report the GPS_STATUS_ENGINE_OFF event here
|
||||||
if (mNavigating) {
|
if (mNavigating) {
|
||||||
|
reportStatus(GPS_STATUS_SESSION_END);
|
||||||
|
}
|
||||||
|
if (mEngineOn) {
|
||||||
reportStatus(GPS_STATUS_ENGINE_OFF);
|
reportStatus(GPS_STATUS_ENGINE_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
native_cleanup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
@ -874,9 +881,24 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
|
|||||||
|
|
||||||
synchronized(mListeners) {
|
synchronized(mListeners) {
|
||||||
boolean wasNavigating = mNavigating;
|
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");
|
if (DEBUG) Log.d(TAG, "Acquiring wakelock");
|
||||||
mWakeLock.acquire();
|
mWakeLock.acquire();
|
||||||
}
|
}
|
||||||
@ -919,7 +941,8 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
|
|||||||
mContext.sendBroadcast(intent);
|
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");
|
if (DEBUG) Log.d(TAG, "Releasing wakelock");
|
||||||
mWakeLock.release();
|
mWakeLock.release();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user