am f307ec5d: Merge change Iafa92b8f into eclair-mr2

Merge commit 'f307ec5d82ce75112eb60118db89dbfee6819e90' into eclair-mr2-plus-aosp

* commit 'f307ec5d82ce75112eb60118db89dbfee6819e90':
  remove accounts for authenticators that are uninstalled
This commit is contained in:
Fred Quintana
2009-12-02 11:38:29 -08:00
committed by Android Git Automerger

View File

@@ -225,6 +225,35 @@ public class AccountManagerService
mSimWatcher = new SimWatcher(mContext);
sThis.set(this);
validateAccounts();
}
private void validateAccounts() {
boolean accountDeleted = false;
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
Cursor cursor = db.query(TABLE_ACCOUNTS,
new String[]{ACCOUNTS_ID, ACCOUNTS_TYPE, ACCOUNTS_NAME},
null, null, null, null, null);
try {
while (cursor.moveToNext()) {
final long accountId = cursor.getLong(0);
final String accountType = cursor.getString(1);
final String accountName = cursor.getString(2);
if (mAuthenticatorCache.getServiceInfo(AuthenticatorDescription.newKey(accountType))
== null) {
Log.d(TAG, "deleting account " + accountName + " because type "
+ accountType + " no longer has a registered authenticator");
db.delete(TABLE_ACCOUNTS, ACCOUNTS_ID + "=" + accountId, null);
accountDeleted = true;
}
}
} finally {
cursor.close();
if (accountDeleted) {
sendAccountsChangedBroadcast();
}
}
}
public void onServiceChanged(AuthenticatorDescription desc, boolean removed) {