summaryrefslogtreecommitdiffstats
path: root/core/java/android/content/SyncManager.java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2010-09-10 18:43:00 -0700
committerDianne Hackborn <hackbod@google.com>2010-09-13 14:20:48 -0700
commit7e9f4eb2608148436cef36c9969bf8a599b39e72 (patch)
tree16351bff3017f948792a6308f4f6698e0a9d769c /core/java/android/content/SyncManager.java
parentcc5494c9996f809e36539b24e8b6b67683383d29 (diff)
downloadframeworks_base-7e9f4eb2608148436cef36c9969bf8a599b39e72.zip
frameworks_base-7e9f4eb2608148436cef36c9969bf8a599b39e72.tar.gz
frameworks_base-7e9f4eb2608148436cef36c9969bf8a599b39e72.tar.bz2
Track client requests through location manager.
This fixes a problem where applications could ask the location manager to do very heavy-weight things (like... say... update location every minute), which would get accounted against the system instead of the application because ultimately it is the system making the heavy calls (wake locks, etc). To solve this, we introduce a new class WorkSource representing the source of some work. Wake locks and Wifi locks allow you to set the source to use (but only if you are system code and thus can get the permission to do so), which is what will be reported to the battery stats until the actual caller. For the initial implementation, the location manager keeps track of all clients requesting periodic updates, and tells its providers about them as a WorkSource param when setting their min update time. The network location provider uses this to set the source on the wake and wifi locks it acquires, when doing work because of the update period. This should also be used elsewhere, such as in the GPS provider, but this is a good start. Change-Id: I2b6ffafad9e90ecf15d7c502e2db675fd52ae3cf
Diffstat (limited to 'core/java/android/content/SyncManager.java')
-rw-r--r--core/java/android/content/SyncManager.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java
index d0b67cc..3e44fcf 100644
--- a/core/java/android/content/SyncManager.java
+++ b/core/java/android/content/SyncManager.java
@@ -45,6 +45,7 @@ import android.os.Process;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
+import android.os.WorkSource;
import android.provider.Settings;
import android.text.format.DateUtils;
import android.text.format.Time;
@@ -126,8 +127,8 @@ public class SyncManager implements OnAccountsUpdateListener {
private static final int INITIALIZATION_UNBIND_DELAY_MS = 5000;
- private static final String SYNC_WAKE_LOCK = "SyncManagerSyncWakeLock";
- private static final String HANDLE_SYNC_ALARM_WAKE_LOCK = "SyncManagerHandleSyncAlarmWakeLock";
+ private static final String SYNC_WAKE_LOCK = "*sync*";
+ private static final String HANDLE_SYNC_ALARM_WAKE_LOCK = "SyncManagerHandleSyncAlarm";
private Context mContext;
@@ -1695,6 +1696,7 @@ public class SyncManager implements OnAccountsUpdateListener {
Log.v(TAG, "runStateIdle: setting mActiveSyncContext to " + mActiveSyncContext);
}
mSyncStorageEngine.setActiveSync(mActiveSyncContext);
+ mSyncWakeLock.setWorkSource(new WorkSource(syncAdapterInfo.uid));
if (!activeSyncContext.bindToSyncAdapter(syncAdapterInfo)) {
Log.e(TAG, "Bind attempt failed to " + syncAdapterInfo);
mActiveSyncContext.close();