Clean the settings for the account/authority when trying to sync an

adapter that is not installed.

Change-Id: Id4a804615b9546155948797f9dd9a0f03fbe4b2f
http://b/issue?id=2520175
This commit is contained in:
Fred Quintana
2010-03-16 15:58:44 -07:00
parent ea579c7d73
commit 7620f1ae49
2 changed files with 19 additions and 2 deletions

View File

@@ -1610,7 +1610,9 @@ public class SyncManager implements OnAccountsUpdateListener {
RegisteredServicesCache.ServiceInfo<SyncAdapterType> syncAdapterInfo =
mSyncAdapters.getServiceInfo(syncAdapterType);
if (syncAdapterInfo == null) {
Log.d(TAG, "can't find a sync adapter for " + syncAdapterType);
Log.d(TAG, "can't find a sync adapter for " + syncAdapterType
+ ", removing settings for it");
mSyncStorageEngine.removeAuthority(op.account, op.authority);
runStateIdle();
return;
}

View File

@@ -643,6 +643,12 @@ public class SyncStorageEngine extends Handler {
}
}
public void removeAuthority(Account account, String authority) {
synchronized (mAuthorities) {
removeAuthorityLocked(account, authority);
}
}
public AuthorityInfo getAuthority(int authorityId) {
synchronized (mAuthorities) {
return mAuthorities.get(authorityId);
@@ -1272,6 +1278,15 @@ public class SyncStorageEngine extends Handler {
return authority;
}
private void removeAuthorityLocked(Account account, String authorityName) {
AccountInfo accountInfo = mAccounts.get(account);
if (accountInfo != null) {
if (accountInfo.authorities.remove(authorityName) != null) {
writeAccountInfoLocked();
}
}
}
public SyncStatusInfo getOrCreateSyncStatus(AuthorityInfo authority) {
synchronized (mAuthorities) {
return getOrCreateSyncStatusLocked(authority.ident);
@@ -1533,7 +1548,7 @@ public class SyncStorageEngine extends Handler {
out.attribute(null, "authority", authority.authority);
if (!authority.enabled) {
out.attribute(null, "enabled", "false");
}
}
if (authority.syncable < 0) {
out.attribute(null, "syncable", "unknown");
} else if (authority.syncable == 0) {