summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server/content/SyncStorageEngine.java
diff options
context:
space:
mode:
Diffstat (limited to 'services/java/com/android/server/content/SyncStorageEngine.java')
-rw-r--r--services/java/com/android/server/content/SyncStorageEngine.java36
1 files changed, 28 insertions, 8 deletions
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,