Don't purge *all* sync information when a user is deleted.
Bug: 132869699
Test: Manual:
1. Add two accounts
(Wait for a while)
2. Remove one
(Wait for a while)
3. Make sure the other account's sync adapter states are intact using
"dumpsys content".
4. Add a guest user
(Wait for a while)
5. Remove the guest user
(Wait for a while)
3. Make sure user-0's sync adapter states are intact using
"dumpsys content".
Change-Id: I1fc11a37d6b4672ecd4c62f338d75a7381a2df6b
diff --git a/services/core/java/com/android/server/content/SyncStorageEngine.java b/services/core/java/com/android/server/content/SyncStorageEngine.java
index c7a3f4b..e09c661 100644
--- a/services/core/java/com/android/server/content/SyncStorageEngine.java
+++ b/services/core/java/com/android/server/content/SyncStorageEngine.java
@@ -1027,7 +1027,7 @@
* Called when the set of account has changed, given the new array of
* active accounts.
*/
- public void removeStaleAccounts(@Nullable Account[] accounts, int userId) {
+ public void removeStaleAccounts(@Nullable Account[] currentAccounts, int userId) {
synchronized (mAuthorities) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Slog.v(TAG, "Updating for new accounts...");
@@ -1036,9 +1036,11 @@
Iterator<AccountInfo> accIt = mAccounts.values().iterator();
while (accIt.hasNext()) {
AccountInfo acc = accIt.next();
- if ((accounts == null) || (
- (acc.accountAndUser.userId == userId)
- && !ArrayUtils.contains(accounts, acc.accountAndUser.account))) {
+ if (acc.accountAndUser.userId != userId) {
+ continue; // Irrelevant user.
+ }
+ if ((currentAccounts == null)
+ || !ArrayUtils.contains(currentAccounts, acc.accountAndUser.account)) {
// This account no longer exists...
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Slog.v(TAG, "Account removed: " + acc.accountAndUser);