Clean up USER_OWNER in AccountManager
Refactor copyAccountUser to take an explicit user handle instead of
hardcode to owner. This requires refactoring one app that uses this
Api.
Bug: 19913735
Change-Id: Ib9b11d8155bea2a58974d09ec2d70bc756d46313
diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java
index 8c84b4d..a475041 100644
--- a/core/java/android/accounts/AccountManager.java
+++ b/core/java/android/accounts/AccountManager.java
@@ -1555,9 +1555,10 @@
}
/**
- * Copies an account from the primary user to another user.
+ * Copies an account from one user to another user.
* @param account the account to copy
- * @param user the target user
+ * @param fromUser the user to copy the account from
+ * @param toUser the target user
* @param callback Callback to invoke when the request completes,
* null for no callback
* @param handler {@link Handler} identifying the callback thread,
@@ -1567,16 +1568,18 @@
* @hide
*/
public AccountManagerFuture<Boolean> copyAccountToUser(
- final Account account, final UserHandle user,
+ final Account account, final UserHandle fromUser, final UserHandle toUser,
AccountManagerCallback<Boolean> callback, Handler handler) {
if (account == null) throw new IllegalArgumentException("account is null");
- if (user == null) throw new IllegalArgumentException("user is null");
+ if (toUser == null || fromUser == null) {
+ throw new IllegalArgumentException("fromUser and toUser cannot be null");
+ }
return new Future2Task<Boolean>(handler, callback) {
@Override
public void doWork() throws RemoteException {
mService.copyAccountToUser(
- mResponse, account, UserHandle.USER_OWNER, user.getIdentifier());
+ mResponse, account, fromUser.getIdentifier(), toUser.getIdentifier());
}
@Override
public Boolean bundleToResult(Bundle bundle) throws AuthenticatorException {