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);
|
restoreCallingIdentity(identityToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getSyncAutomatically(Account account, String providerName) {
|
public boolean getSyncAutomatically(Account account, String providerName) {
|
||||||
mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS,
|
mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS,
|
||||||
"no permission to read the sync settings");
|
"no permission to read the sync settings");
|
||||||
@@ -318,7 +318,7 @@ public final class ContentService extends IContentService.Stub {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMasterSyncAutomatically(boolean flag) {
|
public void setMasterSyncAutomatically(boolean flag) {
|
||||||
mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS,
|
mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS,
|
||||||
"no permission to write the sync settings");
|
"no permission to write the sync settings");
|
||||||
@@ -348,7 +348,7 @@ public final class ContentService extends IContentService.Stub {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActiveSyncInfo getActiveSync() {
|
public ActiveSyncInfo getActiveSync() {
|
||||||
mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS,
|
mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS,
|
||||||
"no permission to read the sync stats");
|
"no permission to read the sync stats");
|
||||||
@@ -363,7 +363,7 @@ public final class ContentService extends IContentService.Stub {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SyncStatusInfo getSyncStatus(Account account, String authority) {
|
public SyncStatusInfo getSyncStatus(Account account, String authority) {
|
||||||
mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS,
|
mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS,
|
||||||
"no permission to read the sync stats");
|
"no permission to read the sync stats");
|
||||||
@@ -371,15 +371,15 @@ public final class ContentService extends IContentService.Stub {
|
|||||||
try {
|
try {
|
||||||
SyncManager syncManager = getSyncManager();
|
SyncManager syncManager = getSyncManager();
|
||||||
if (syncManager != null) {
|
if (syncManager != null) {
|
||||||
return syncManager.getSyncStorageEngine().getStatusByAuthority(
|
return syncManager.getSyncStorageEngine().getStatusByAccountAndAuthority(
|
||||||
authority);
|
account, authority);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
restoreCallingIdentity(identityToken);
|
restoreCallingIdentity(identityToken);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSyncPending(Account account, String authority) {
|
public boolean isSyncPending(Account account, String authority) {
|
||||||
mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS,
|
mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS,
|
||||||
"no permission to read the sync stats");
|
"no permission to read the sync stats");
|
||||||
@@ -394,7 +394,7 @@ public final class ContentService extends IContentService.Stub {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addStatusChangeListener(int mask, ISyncStatusObserver callback) {
|
public void addStatusChangeListener(int mask, ISyncStatusObserver callback) {
|
||||||
long identityToken = clearCallingIdentity();
|
long identityToken = clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
@@ -406,7 +406,7 @@ public final class ContentService extends IContentService.Stub {
|
|||||||
restoreCallingIdentity(identityToken);
|
restoreCallingIdentity(identityToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeStatusChangeListener(ISyncStatusObserver callback) {
|
public void removeStatusChangeListener(ISyncStatusObserver callback) {
|
||||||
long identityToken = clearCallingIdentity();
|
long identityToken = clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
@@ -418,7 +418,7 @@ public final class ContentService extends IContentService.Stub {
|
|||||||
restoreCallingIdentity(identityToken);
|
restoreCallingIdentity(identityToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IContentService main(Context context, boolean factoryTest) {
|
public static IContentService main(Context context, boolean factoryTest) {
|
||||||
ContentService service = new ContentService(context, factoryTest);
|
ContentService service = new ContentService(context, factoryTest);
|
||||||
ServiceManager.addService(ContentResolver.CONTENT_SERVICE_NAME, service);
|
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
|
* Returns the status that matches the authority and account.
|
||||||
* the authority, the one with the latest "lastSuccessTime" status is returned.
|
*
|
||||||
|
* @param account the account we want to check
|
||||||
* @param authority the authority whose row should be selected
|
* @param authority the authority whose row should be selected
|
||||||
* @return the SyncStatusInfo for the authority, or null if none exists
|
* @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) {
|
synchronized (mAuthorities) {
|
||||||
SyncStatusInfo best = null;
|
|
||||||
final int N = mSyncStatus.size();
|
final int N = mSyncStatus.size();
|
||||||
for (int i=0; i<N; i++) {
|
for (int i=0; i<N; i++) {
|
||||||
SyncStatusInfo cur = mSyncStatus.valueAt(i);
|
SyncStatusInfo cur = mSyncStatus.valueAt(i);
|
||||||
AuthorityInfo ainfo = mAuthorities.get(cur.authorityId);
|
AuthorityInfo ainfo = mAuthorities.get(cur.authorityId);
|
||||||
if (ainfo != null && ainfo.authority.equals(authority)) {
|
|
||||||
if (best == null) {
|
if (ainfo != null && ainfo.authority.equals(authority) &&
|
||||||
best = cur;
|
account.equals(ainfo.account)) {
|
||||||
} else if (best.lastSuccessTime > cur.lastSuccessTime) {
|
return cur;
|
||||||
best = cur;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return best;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user