summaryrefslogtreecommitdiffstats
path: root/services/java/com
diff options
context:
space:
mode:
authorMatthew Williams <mjwilliams@google.com>2013-11-14 09:27:26 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2013-11-14 09:27:26 -0800
commit72402f9de7b108d77316e3c93399b07a2f98c42a (patch)
tree71915600b082d30618247ea43e5143bbff7218b4 /services/java/com
parentd1b0af82855528c531a35d28d3c65d7a94f2228c (diff)
parent09d8e3cf4e411b016ee65d8328dd7a443c9de0ff (diff)
downloadframeworks_base-72402f9de7b108d77316e3c93399b07a2f98c42a.zip
frameworks_base-72402f9de7b108d77316e3c93399b07a2f98c42a.tar.gz
frameworks_base-72402f9de7b108d77316e3c93399b07a2f98c42a.tar.bz2
am 09d8e3cf: am c68bb182: Merge "SyncManager now returns copy on getCurrentSyncs()" into klp-dev
* commit '09d8e3cf4e411b016ee65d8328dd7a443c9de0ff': SyncManager now returns copy on getCurrentSyncs()
Diffstat (limited to 'services/java/com')
-rw-r--r--services/java/com/android/server/content/ContentService.java2
-rw-r--r--services/java/com/android/server/content/SyncStorageEngine.java36
2 files changed, 29 insertions, 9 deletions
diff --git a/services/java/com/android/server/content/ContentService.java b/services/java/com/android/server/content/ContentService.java
index cb35ef1..023bf2b 100644
--- a/services/java/com/android/server/content/ContentService.java
+++ b/services/java/com/android/server/content/ContentService.java
@@ -660,7 +660,7 @@ public final class ContentService extends IContentService.Stub {
int userId = UserHandle.getCallingUserId();
long identityToken = clearCallingIdentity();
try {
- return getSyncManager().getSyncStorageEngine().getCurrentSyncs(userId);
+ return getSyncManager().getSyncStorageEngine().getCurrentSyncsCopy(userId);
} finally {
restoreCallingIdentity(identityToken);
}
diff --git a/services/java/com/android/server/content/SyncStorageEngine.java b/services/java/com/android/server/content/SyncStorageEngine.java
index 41ef229..5ebf9ea 100644
--- a/services/java/com/android/server/content/SyncStorageEngine.java
+++ b/services/java/com/android/server/content/SyncStorageEngine.java
@@ -1295,20 +1295,40 @@ public class SyncStorageEngine extends Handler {
}
/**
- * Return a list of the currently active syncs. Note that the returned items are the
- * real, live active sync objects, so be careful what you do with it.
+ * Return a list of the currently active syncs. Note that the returned
+ * items are the real, live active sync objects, so be careful what you do
+ * with it.
*/
- public List<SyncInfo> getCurrentSyncs(int userId) {
+ private List<SyncInfo> getCurrentSyncs(int userId) {
synchronized (mAuthorities) {
- ArrayList<SyncInfo> syncs = mCurrentSyncs.get(userId);
- if (syncs == null) {
- syncs = new ArrayList<SyncInfo>();
- mCurrentSyncs.put(userId, syncs);
+ return getCurrentSyncsLocked(userId);
+ }
+ }
+
+ /**
+ * @return a copy of the current syncs data structure. Will not return
+ * null.
+ */
+ public List<SyncInfo> getCurrentSyncsCopy(int userId) {
+ synchronized (mAuthorities) {
+ final List<SyncInfo> syncs = getCurrentSyncsLocked(userId);
+ final List<SyncInfo> syncsCopy = new ArrayList<SyncInfo>();
+ for (SyncInfo sync : syncs) {
+ syncsCopy.add(new SyncInfo(sync));
}
- return syncs;
+ return syncsCopy;
}
}
+ private List<SyncInfo> getCurrentSyncsLocked(int userId) {
+ ArrayList<SyncInfo> syncs = mCurrentSyncs.get(userId);
+ if (syncs == null) {
+ syncs = new ArrayList<SyncInfo>();
+ mCurrentSyncs.put(userId, syncs);
+ }
+ return syncs;
+ }
+
/**
* Return an array of the current sync status for all authorities. Note
* that the objects inside the array are the real, live status objects,