diff options
| author | 2023-04-25 17:40:52 +0000 | |
|---|---|---|
| committer | 2023-04-25 17:40:52 +0000 | |
| commit | 3d87229f038ab038b28f4be56c38ca9e37e4b4a4 (patch) | |
| tree | fd1ef6e0fa246a7a2e60b5006690b99eb30bbed0 | |
| parent | 744c5eee8f111397814f976b2c48d2c3c0be7889 (diff) | |
| parent | a72a8dab0648ef2eef820327b2d993a92acc12aa (diff) | |
Merge "Migrate and remove account from calling user in headless mode" into udc-dev
| -rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 22f684bea73d..ebe7e0cbac06 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -21613,7 +21613,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } copyAccount(targetUser, sourceUser, accountToMigrate, callerPackage); if (!keepAccountMigrated) { - removeAccount(accountToMigrate); + removeAccount(accountToMigrate, sourceUserId); } } @@ -21657,9 +21657,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { .write(); } - private void removeAccount(Account account) { - final AccountManager accountManager = - mContext.getSystemService(AccountManager.class); + private void removeAccount(Account account, @UserIdInt int sourceUserId) { + final AccountManager accountManager = mContext.createContextAsUser( + UserHandle.of(sourceUserId), /* flags= */ 0) + .getSystemService(AccountManager.class); final AccountManagerFuture<Bundle> bundle = accountManager.removeAccount(account, null, null /* callback */, null /* handler */); try { |