summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/content/ContentService.java20
-rw-r--r--core/java/android/content/SyncStorageEngine.java23
2 files changed, 22 insertions, 21 deletions
diff --git a/core/java/android/content/ContentService.java b/core/java/android/content/ContentService.java
index f742448..974a667 100644
--- a/core/java/android/content/ContentService.java
+++ b/core/java/android/content/ContentService.java
@@ -241,7 +241,7 @@ public final class ContentService extends IContentService.Stub {
restoreCallingIdentity(identityToken);
}
}
-
+
public boolean getSyncAutomatically(Account account, String providerName) {
mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS,
"no permission to read the sync settings");
@@ -318,7 +318,7 @@ public final class ContentService extends IContentService.Stub {
}
return false;
}
-
+
public void setMasterSyncAutomatically(boolean flag) {
mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS,
"no permission to write the sync settings");
@@ -348,7 +348,7 @@ public final class ContentService extends IContentService.Stub {
}
return false;
}
-
+
public ActiveSyncInfo getActiveSync() {
mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS,
"no permission to read the sync stats");
@@ -363,7 +363,7 @@ public final class ContentService extends IContentService.Stub {
}
return null;
}
-
+
public SyncStatusInfo getSyncStatus(Account account, String authority) {
mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS,
"no permission to read the sync stats");
@@ -371,15 +371,15 @@ public final class ContentService extends IContentService.Stub {
try {
SyncManager syncManager = getSyncManager();
if (syncManager != null) {
- return syncManager.getSyncStorageEngine().getStatusByAuthority(
- authority);
+ return syncManager.getSyncStorageEngine().getStatusByAccountAndAuthority(
+ account, authority);
}
} finally {
restoreCallingIdentity(identityToken);
}
return null;
}
-
+
public boolean isSyncPending(Account account, String authority) {
mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS,
"no permission to read the sync stats");
@@ -394,7 +394,7 @@ public final class ContentService extends IContentService.Stub {
}
return false;
}
-
+
public void addStatusChangeListener(int mask, ISyncStatusObserver callback) {
long identityToken = clearCallingIdentity();
try {
@@ -406,7 +406,7 @@ public final class ContentService extends IContentService.Stub {
restoreCallingIdentity(identityToken);
}
}
-
+
public void removeStatusChangeListener(ISyncStatusObserver callback) {
long identityToken = clearCallingIdentity();
try {
@@ -418,7 +418,7 @@ public final class ContentService extends IContentService.Stub {
restoreCallingIdentity(identityToken);
}
}
-
+
public static IContentService main(Context context, boolean factoryTest) {
ContentService service = new ContentService(context, factoryTest);
ServiceManager.addService(ContentResolver.CONTENT_SERVICE_NAME, service);
diff --git a/core/java/android/content/SyncStorageEngine.java b/core/java/android/content/SyncStorageEngine.java
index df3d241..f251984 100644
--- a/core/java/android/content/SyncStorageEngine.java
+++ b/core/java/android/content/SyncStorageEngine.java
@@ -866,27 +866,28 @@ public class SyncStorageEngine extends Handler {
}
/**
- * Returns the status that matches the authority. If there are multiples accounts for
- * the authority, the one with the latest "lastSuccessTime" status is returned.
+ * Returns the status that matches the authority and account.
+ *
+ * @param account the account we want to check
* @param authority the authority whose row should be selected
* @return the SyncStatusInfo for the authority, or null if none exists
*/
- public SyncStatusInfo getStatusByAuthority(String authority) {
+ public SyncStatusInfo getStatusByAccountAndAuthority(Account account, String authority) {
+ if (account == null || authority == null) {
+ throw new IllegalArgumentException();
+ }
synchronized (mAuthorities) {
- SyncStatusInfo best = null;
final int N = mSyncStatus.size();
for (int i=0; i<N; i++) {
SyncStatusInfo cur = mSyncStatus.valueAt(i);
AuthorityInfo ainfo = mAuthorities.get(cur.authorityId);
- if (ainfo != null && ainfo.authority.equals(authority)) {
- if (best == null) {
- best = cur;
- } else if (best.lastSuccessTime > cur.lastSuccessTime) {
- best = cur;
- }
+
+ if (ainfo != null && ainfo.authority.equals(authority) &&
+ account.equals(ainfo.account)) {
+ return cur;
}
}
- return best;
+ return null;
}
}