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
diff --git a/core/java/android/accounts/AccountManagerService.java b/core/java/android/accounts/AccountManagerService.java
index 1a8d9b6..de01153 100644
--- a/core/java/android/accounts/AccountManagerService.java
+++ b/core/java/android/accounts/AccountManagerService.java
@@ -225,6 +225,35 @@
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) {