Merge "SyncManager now returns copy on getCurrentSyncs()" into klp-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c68bb18244
@@ -54,6 +54,14 @@ public class SyncInfo implements Parcelable {
|
|||||||
this.startTime = startTime;
|
this.startTime = startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public SyncInfo(SyncInfo other) {
|
||||||
|
this.authorityId = other.authorityId;
|
||||||
|
this.account = new Account(other.account.name, other.account.type);
|
||||||
|
this.authority = other.authority;
|
||||||
|
this.startTime = other.startTime;
|
||||||
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -660,7 +660,7 @@ public final class ContentService extends IContentService.Stub {
|
|||||||
int userId = UserHandle.getCallingUserId();
|
int userId = UserHandle.getCallingUserId();
|
||||||
long identityToken = clearCallingIdentity();
|
long identityToken = clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
return getSyncManager().getSyncStorageEngine().getCurrentSyncs(userId);
|
return getSyncManager().getSyncStorageEngine().getCurrentSyncsCopy(userId);
|
||||||
} finally {
|
} finally {
|
||||||
restoreCallingIdentity(identityToken);
|
restoreCallingIdentity(identityToken);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1295,11 +1295,32 @@ public class SyncStorageEngine extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of the currently active syncs. Note that the returned items are the
|
* Return a list of the currently active syncs. Note that the returned
|
||||||
* real, live active sync objects, so be careful what you do with it.
|
* 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) {
|
synchronized (mAuthorities) {
|
||||||
|
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 syncsCopy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SyncInfo> getCurrentSyncsLocked(int userId) {
|
||||||
ArrayList<SyncInfo> syncs = mCurrentSyncs.get(userId);
|
ArrayList<SyncInfo> syncs = mCurrentSyncs.get(userId);
|
||||||
if (syncs == null) {
|
if (syncs == null) {
|
||||||
syncs = new ArrayList<SyncInfo>();
|
syncs = new ArrayList<SyncInfo>();
|
||||||
@@ -1307,7 +1328,6 @@ public class SyncStorageEngine extends Handler {
|
|||||||
}
|
}
|
||||||
return syncs;
|
return syncs;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an array of the current sync status for all authorities. Note
|
* Return an array of the current sync status for all authorities. Note
|
||||||
|
|||||||
Reference in New Issue
Block a user