am 7e90005f: Merge change I705b1d33 into eclair
Merge commit '7e90005fcb95d4c20c92e915f4418b94341dda36' into eclair-mr2 * commit '7e90005fcb95d4c20c92e915f4418b94341dda36': GpsLocationProvider: Do not release wakelock until the GPS engine is fully off
This commit is contained in:
@@ -875,53 +875,51 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
|
|||||||
synchronized(mListeners) {
|
synchronized(mListeners) {
|
||||||
boolean wasNavigating = mNavigating;
|
boolean wasNavigating = mNavigating;
|
||||||
mNavigating = (status == GPS_STATUS_SESSION_BEGIN);
|
mNavigating = (status == GPS_STATUS_SESSION_BEGIN);
|
||||||
|
|
||||||
if (wasNavigating == mNavigating) {
|
if (mNavigating && !mWakeLock.isHeld()) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mNavigating) {
|
|
||||||
if (DEBUG) Log.d(TAG, "Acquiring wakelock");
|
if (DEBUG) Log.d(TAG, "Acquiring wakelock");
|
||||||
mWakeLock.acquire();
|
mWakeLock.acquire();
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = mListeners.size();
|
if (wasNavigating != mNavigating) {
|
||||||
for (int i = 0; i < size; i++) {
|
int size = mListeners.size();
|
||||||
Listener listener = mListeners.get(i);
|
for (int i = 0; i < size; i++) {
|
||||||
|
Listener listener = mListeners.get(i);
|
||||||
|
try {
|
||||||
|
if (mNavigating) {
|
||||||
|
listener.mListener.onGpsStarted();
|
||||||
|
} else {
|
||||||
|
listener.mListener.onGpsStopped();
|
||||||
|
}
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.w(TAG, "RemoteException in reportStatus");
|
||||||
|
mListeners.remove(listener);
|
||||||
|
// adjust for size of list changing
|
||||||
|
size--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mNavigating) {
|
// update battery stats
|
||||||
listener.mListener.onGpsStarted();
|
for (int i=mClientUids.size() - 1; i >= 0; i--) {
|
||||||
} else {
|
int uid = mClientUids.keyAt(i);
|
||||||
listener.mListener.onGpsStopped();
|
if (mNavigating) {
|
||||||
|
mBatteryStats.noteStartGps(uid);
|
||||||
|
} else {
|
||||||
|
mBatteryStats.noteStopGps(uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.w(TAG, "RemoteException in reportStatus");
|
Log.w(TAG, "RemoteException in reportStatus");
|
||||||
mListeners.remove(listener);
|
|
||||||
// adjust for size of list changing
|
|
||||||
size--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// send an intent to notify that the GPS has been enabled or disabled.
|
||||||
|
Intent intent = new Intent(GPS_ENABLED_CHANGE_ACTION);
|
||||||
|
intent.putExtra(EXTRA_ENABLED, mNavigating);
|
||||||
|
mContext.sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (status == GPS_STATUS_ENGINE_OFF && mWakeLock.isHeld()) {
|
||||||
// update battery stats
|
|
||||||
for (int i=mClientUids.size() - 1; i >= 0; i--) {
|
|
||||||
int uid = mClientUids.keyAt(i);
|
|
||||||
if (mNavigating) {
|
|
||||||
mBatteryStats.noteStartGps(uid);
|
|
||||||
} else {
|
|
||||||
mBatteryStats.noteStopGps(uid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
Log.w(TAG, "RemoteException in reportStatus");
|
|
||||||
}
|
|
||||||
|
|
||||||
// send an intent to notify that the GPS has been enabled or disabled.
|
|
||||||
Intent intent = new Intent(GPS_ENABLED_CHANGE_ACTION);
|
|
||||||
intent.putExtra(EXTRA_ENABLED, mNavigating);
|
|
||||||
mContext.sendBroadcast(intent);
|
|
||||||
|
|
||||||
if (!mNavigating) {
|
|
||||||
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