Add ACTION_ACCOUNT_REMOVED to Account Manager.
AccountManagerService sends an intent with the action when account of any type is removed or renamed.
Test: manual, APCT.
Bug: 37280078
Change-Id: I53b1bb9d6cde1edba5c37ecf3e4e13d748b19005
diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java
index 5f585cc..eb58e4c 100644
--- a/services/core/java/com/android/server/accounts/AccountManagerService.java
+++ b/services/core/java/com/android/server/accounts/AccountManagerService.java
@@ -959,6 +959,12 @@
mContext.sendBroadcastAsUser(ACCOUNTS_CHANGED_INTENT, new UserHandle(userId));
}
+ private void sendAccountRemovedBroadcast(int userId) {
+ Intent intent = new Intent(AccountManager.ACTION_ACCOUNT_REMOVED);
+ intent.setFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
+ mContext.sendBroadcastAsUser(intent, new UserHandle(userId));
+ }
+
@Override
public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
throws RemoteException {
@@ -1111,6 +1117,7 @@
notifyPackage(packageToVisibility.getKey(), accounts);
}
}
+ sendAccountRemovedBroadcast(accounts.userId);
} else {
ArrayList<String> accountNames = accountNamesByType.get(account.type);
if (accountNames == null) {
@@ -1971,6 +1978,7 @@
sendNotificationAccountUpdated(resultAccount, accounts);
sendAccountsChangedBroadcast(accounts.userId);
+ sendAccountRemovedBroadcast(accounts.userId);
}
}
return resultAccount;
@@ -2206,6 +2214,7 @@
// Only broadcast LOGIN_ACCOUNTS_CHANGED if a change occurred.
sendAccountsChangedBroadcast(accounts.userId);
+ sendAccountRemovedBroadcast(accounts.userId);
String action = userUnlocked ? AccountsDb.DEBUG_ACTION_ACCOUNT_REMOVE
: AccountsDb.DEBUG_ACTION_ACCOUNT_REMOVE_DE;
logRecord(action, AccountsDb.TABLE_ACCOUNTS, accountId, accounts);