diff options
author | Esteban Talavera <etalavera@google.com> | 2014-10-31 15:41:12 +0000 |
---|---|---|
committer | Alexandra Gherghina <alexgherghina@google.com> | 2014-11-14 11:09:27 +0000 |
commit | 22dc3b7ba111e27bce99a7cce966598e7873508c (patch) | |
tree | 604c5e9ba1c602c45609d68ac34e2d8b5264c1f9 /core/java/android/accounts | |
parent | f39cec0b068abcf306eb91c304ed2eb76e60f8c0 (diff) | |
download | frameworks_base-22dc3b7ba111e27bce99a7cce966598e7873508c.zip frameworks_base-22dc3b7ba111e27bce99a7cce966598e7873508c.tar.gz frameworks_base-22dc3b7ba111e27bce99a7cce966598e7873508c.tar.bz2 |
New AccountManager method to copy accounts between users.
Adding the copyAccountToUser method which copies an account
along with its credentials to a different user.
Also an extra in the public api to identify the account to migrate
during provisioning.
Bug: 17716971
Change-Id: I2f29f1765ba0d360a3894b13ef86253b7c7d3284
Diffstat (limited to 'core/java/android/accounts')
-rw-r--r-- | core/java/android/accounts/AccountManager.java | 34 | ||||
-rw-r--r-- | core/java/android/accounts/IAccountManager.aidl | 2 |
2 files changed, 36 insertions, 0 deletions
diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java index 64c2fd0..6957435 100644 --- a/core/java/android/accounts/AccountManager.java +++ b/core/java/android/accounts/AccountManager.java @@ -1443,6 +1443,40 @@ public class AccountManager { } /** + * Copies an account from the primary user to another user. + * @param account the account to copy + * @param user the target user + * @param callback Callback to invoke when the request completes, + * null for no callback + * @param handler {@link Handler} identifying the callback thread, + * null for the main thread + * @return An {@link AccountManagerFuture} which resolves to a Boolean indicated wether it + * succeeded. + * @hide + */ + public AccountManagerFuture<Boolean> copyAccountToUser( + final Account account, final UserHandle user, + AccountManagerCallback<Boolean> callback, Handler handler) { + if (account == null) throw new IllegalArgumentException("account is null"); + if (user == null) throw new IllegalArgumentException("user is null"); + + return new Future2Task<Boolean>(handler, callback) { + @Override + public void doWork() throws RemoteException { + mService.copyAccountToUser( + mResponse, account, UserHandle.USER_OWNER, user.getIdentifier()); + } + @Override + public Boolean bundleToResult(Bundle bundle) throws AuthenticatorException { + if (!bundle.containsKey(KEY_BOOLEAN_RESULT)) { + throw new AuthenticatorException("no result in response"); + } + return bundle.getBoolean(KEY_BOOLEAN_RESULT); + } + }.start(); + } + + /** * @hide * Removes the shared account. * @param account the account to remove diff --git a/core/java/android/accounts/IAccountManager.aidl b/core/java/android/accounts/IAccountManager.aidl index bc75b9b..aa41161 100644 --- a/core/java/android/accounts/IAccountManager.aidl +++ b/core/java/android/accounts/IAccountManager.aidl @@ -42,6 +42,8 @@ interface IAccountManager { void removeAccountAsUser(in IAccountManagerResponse response, in Account account, boolean expectActivityLaunch, int userId); boolean removeAccountExplicitly(in Account account); + void copyAccountToUser(in IAccountManagerResponse response, in Account account, + int userFrom, int userTo); void invalidateAuthToken(String accountType, String authToken); String peekAuthToken(in Account account, String authTokenType); void setAuthToken(in Account account, String authTokenType, String authToken); |