From 5f32513590444bbc4e9b1d954ec39db5c3eb44e6 Mon Sep 17 00:00:00 2001 From: sz656r Date: Thu, 28 Apr 2022 16:07:59 -0700 Subject: [PATCH] Cleanup user data when user stopped 1. During the quick user switch, the user status is changed from STATE_STOPPING to STATE_BOOTING, the process android.process.core (ContactsProvider2) was not closed, but the AccountManagerService cleanup the user in stopping stage. 2. When the user is switched back, the old ContactsProvider2 process was used, but the client doesn't have the listener registered for AccountManager any more. 3. This causes the ContactsProvider reloaded again when the phone is connected, then duplicated contacts will show on the screen. 4. Solution is cleaning up the user data in onUserStopped. Test: manual verification Bug: 224818967 Change-Id: I8fb44e0e66ff73c055a548d57ff3d45ecc213f71 Merged-In: Ic11cbd3f3d59a0165be882c2ce975a2c4d00b1a1 (cherry picked from commit 454b6c590fc76f356ed8181bb844f6dd15588c2c) --- .../com/android/server/accounts/AccountManagerService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java index b059cc7e2aa2d..7d8c19f41ae45 100644 --- a/services/core/java/com/android/server/accounts/AccountManagerService.java +++ b/services/core/java/com/android/server/accounts/AccountManagerService.java @@ -168,8 +168,8 @@ public class AccountManagerService } @Override - public void onUserStopping(@NonNull TargetUser user) { - Slog.i(TAG, "onStopUser " + user); + public void onUserStopped(@NonNull TargetUser user) { + Slog.i(TAG, "onUserStopped " + user); mService.purgeUserData(user.getUserIdentifier()); } }