diff options
| author | Mike Lockwood <lockwood@android.com> | 2009-12-07 17:22:54 -0800 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2009-12-07 17:22:54 -0800 |
| commit | 259e3384face72ea8e30696d7bae492d37d44e8b (patch) | |
| tree | d368beb56c288b30f38c78586ca0c0a54c14bb46 | |
| parent | 18ff0e329b314e033e4bfb92b24ecab961f0eb99 (diff) | |
| parent | 7e90005fcb95d4c20c92e915f4418b94341dda36 (diff) | |
| download | frameworks_base-259e3384face72ea8e30696d7bae492d37d44e8b.zip frameworks_base-259e3384face72ea8e30696d7bae492d37d44e8b.tar.gz frameworks_base-259e3384face72ea8e30696d7bae492d37d44e8b.tar.bz2 | |
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
| -rwxr-xr-x | location/java/com/android/internal/location/GpsLocationProvider.java | 70 |
1 files changed, 34 insertions, 36 deletions
diff --git a/location/java/com/android/internal/location/GpsLocationProvider.java b/location/java/com/android/internal/location/GpsLocationProvider.java index cd62ed1..7763549 100755 --- a/location/java/com/android/internal/location/GpsLocationProvider.java +++ b/location/java/com/android/internal/location/GpsLocationProvider.java @@ -875,53 +875,51 @@ public class GpsLocationProvider extends ILocationProvider.Stub { synchronized(mListeners) { boolean wasNavigating = mNavigating; mNavigating = (status == GPS_STATUS_SESSION_BEGIN); - - if (wasNavigating == mNavigating) { - return; - } - - if (mNavigating) { + + if (mNavigating && !mWakeLock.isHeld()) { if (DEBUG) Log.d(TAG, "Acquiring wakelock"); mWakeLock.acquire(); } - - int size = mListeners.size(); - for (int i = 0; i < size; i++) { - Listener listener = mListeners.get(i); + + if (wasNavigating != mNavigating) { + int size = mListeners.size(); + 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 { - if (mNavigating) { - listener.mListener.onGpsStarted(); - } else { - listener.mListener.onGpsStopped(); + // 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"); - mListeners.remove(listener); - // adjust for size of list changing - size--; } - } - try { - // 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); } - // 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 (status == GPS_STATUS_ENGINE_OFF && mWakeLock.isHeld()) { if (DEBUG) Log.d(TAG, "Releasing wakelock"); mWakeLock.release(); } |
