am b752098e: Sync status was ignoring account - the new UI has specific sync status for each account, so we need to use it.
Merge commit 'b752098e8d12d6e7925d97458078dbb896ca8a05' into eclair-plus-aosp * commit 'b752098e8d12d6e7925d97458078dbb896ca8a05': Sync status was ignoring account - the new UI has specific sync status for each account, so we need to use it.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user