diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-05-07 08:24:05 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-05-07 08:24:05 -0700 |
commit | 158b2129cfd50105305ca0c170163d59e9804106 (patch) | |
tree | bbaa37e9186d5a1b22c3332f75867debccfe0e85 /location | |
parent | 7c6b6fbe4c2cf621844aba0c9b409f067f574ef0 (diff) | |
parent | f792fc59c18aa470eb44cc596d5774115e2d9d02 (diff) | |
download | frameworks_base-158b2129cfd50105305ca0c170163d59e9804106.zip frameworks_base-158b2129cfd50105305ca0c170163d59e9804106.tar.gz frameworks_base-158b2129cfd50105305ca0c170163d59e9804106.tar.bz2 |
am f792fc5: Merge change 1150 into donut
Merge commit 'f792fc59c18aa470eb44cc596d5774115e2d9d02'
* commit 'f792fc59c18aa470eb44cc596d5774115e2d9d02':
location: Location Manager wakelock cleanup
Diffstat (limited to 'location')
4 files changed, 18 insertions, 30 deletions
diff --git a/location/java/android/location/ILocationProvider.aidl b/location/java/android/location/ILocationProvider.aidl index e3e374d..6c23f83 100644 --- a/location/java/android/location/ILocationProvider.aidl +++ b/location/java/android/location/ILocationProvider.aidl @@ -44,6 +44,4 @@ interface ILocationProvider { boolean sendExtraCommand(String command, inout Bundle extras); void addListener(int uid); void removeListener(int uid); - void wakeLockAcquired(); - void wakeLockReleased(); } diff --git a/location/java/com/android/internal/location/GpsLocationProvider.java b/location/java/com/android/internal/location/GpsLocationProvider.java index 97b6a62..21c7adb 100644 --- a/location/java/com/android/internal/location/GpsLocationProvider.java +++ b/location/java/com/android/internal/location/GpsLocationProvider.java @@ -34,6 +34,7 @@ import android.net.ConnectivityManager; import android.net.SntpClient; import android.os.Bundle; import android.os.IBinder; +import android.os.PowerManager; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; @@ -207,6 +208,10 @@ public class GpsLocationProvider extends ILocationProvider.Stub { private int mSuplDataConnectionState; private final ConnectivityManager mConnMgr; + // Wakelocks + private final static String WAKELOCK_KEY = "GpsLocationProvider"; + private final PowerManager.WakeLock mWakeLock; + // Alarms private final static String ALARM_WAKEUP = "com.android.internal.location.ALARM_WAKEUP"; private final AlarmManager mAlarmManager; @@ -307,6 +312,10 @@ public class GpsLocationProvider extends ILocationProvider.Stub { mContext = context; mLocationManager = locationManager; + // Create a wake lock + PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); + mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_KEY); + mAlarmManager = (AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE); mWakeupIntent = PendingIntent.getBroadcast(mContext, 0, new Intent(ALARM_WAKEUP), 0); @@ -574,12 +583,6 @@ public class GpsLocationProvider extends ILocationProvider.Stub { } } - public void wakeLockAcquired() { - } - - public void wakeLockReleased() { - } - public void addListener(int uid) { mClientUids.put(uid, 0); if (mNavigating) { @@ -767,6 +770,10 @@ public class GpsLocationProvider extends ILocationProvider.Stub { mNavigating = (status == GPS_STATUS_SESSION_BEGIN); if (wasNavigating != mNavigating) { + if (mNavigating) { + if (DEBUG) Log.d(TAG, "Acquiring wakelock"); + mWakeLock.acquire(); + } synchronized(mListeners) { int size = mListeners.size(); for (int i = 0; i < size; i++) { @@ -804,6 +811,11 @@ public class GpsLocationProvider extends ILocationProvider.Stub { 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"); + mWakeLock.release(); + } } } diff --git a/location/java/com/android/internal/location/LocationProviderProxy.java b/location/java/com/android/internal/location/LocationProviderProxy.java index abca28f..80303f4 100644 --- a/location/java/com/android/internal/location/LocationProviderProxy.java +++ b/location/java/com/android/internal/location/LocationProviderProxy.java @@ -231,20 +231,4 @@ public class LocationProviderProxy { Log.e(TAG, "removeListener failed", e); } } - - public void wakeLockAcquired() { - try { - mProvider.wakeLockAcquired(); - } catch (RemoteException e) { - Log.e(TAG, "wakeLockAcquired failed", e); - } - } - - public void wakeLockReleased() { - try { - mProvider.wakeLockReleased(); - } catch (RemoteException e) { - Log.e(TAG, "wakeLockReleased failed", e); - } - } } diff --git a/location/java/com/android/internal/location/MockProvider.java b/location/java/com/android/internal/location/MockProvider.java index d81d0ab..f167a44 100644 --- a/location/java/com/android/internal/location/MockProvider.java +++ b/location/java/com/android/internal/location/MockProvider.java @@ -182,12 +182,6 @@ public class MockProvider extends ILocationProvider.Stub { public void removeListener(int uid) { } - public void wakeLockAcquired() { - } - - public void wakeLockReleased() { - } - public void dump(PrintWriter pw, String prefix) { pw.println(prefix + mName); pw.println(prefix + "mHasLocation=" + mHasLocation); |