summaryrefslogtreecommitdiffstats
path: root/core/java/android/accounts/AccountManager.java
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2012-12-14 12:09:36 -0800
committerAmith Yamasani <yamasani@google.com>2013-03-06 09:49:44 -0800
commit67df64b3a48a8157d08a98fa90135d0ac0ee621c (patch)
treed390d5c537c976a14688e24c1f9a8a213840ff29 /core/java/android/accounts/AccountManager.java
parent0ffc81c1ada65b4ef4febaacf044e9fa62309b87 (diff)
downloadframeworks_base-67df64b3a48a8157d08a98fa90135d0ac0ee621c.zip
frameworks_base-67df64b3a48a8157d08a98fa90135d0ac0ee621c.tar.gz
frameworks_base-67df64b3a48a8157d08a98fa90135d0ac0ee621c.tar.bz2
Shared accounts and sharing of apps
API and preliminary implementation for sharing primary user accounts with a secondary user. AbstractAccountAuthenticator has new methods to retrieve and apply a bundle of credentials to clone an account from the primary to a restricted secondary user. The AccountManagerService initiates the account clone when it starts up the user and detects that the user has a shared account registered that hasn't been converted to a real account. AccountManager also has new hidden APIs to add/remove/get shared accounts. There might be further improvements to this API to make shared accounts hidden/visible to select apps. AccountManagerService has a new table to store the shared account information. Added ability in PackageManager to install and uninstall packages for a secondary user. This is required when the primary user selects a few apps to share with a restricted user. Remove shared accounts from secondary users when primary user removes the account. Change-Id: I9378ed0d8c1cc66baf150a4bec0ede56f6f8b06b
Diffstat (limited to 'core/java/android/accounts/AccountManager.java')
-rw-r--r--core/java/android/accounts/AccountManager.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java
index 6d9bb1d..6aac723 100644
--- a/core/java/android/accounts/AccountManager.java
+++ b/core/java/android/accounts/AccountManager.java
@@ -1123,6 +1123,57 @@ public class AccountManager {
}
/**
+ * Adds a shared account from the primary user to a secondary user. Adding the shared account
+ * doesn't take effect immediately. When the target user starts up, any pending shared accounts
+ * are attempted to be copied to the target user from the primary via calls to the
+ * authenticator.
+ * @param account the account to share
+ * @param user the target user
+ * @return
+ * @hide
+ */
+ public boolean addSharedAccount(final Account account, UserHandle user) {
+ try {
+ boolean val = mService.addSharedAccountAsUser(account, user.getIdentifier());
+ return val;
+ } catch (RemoteException re) {
+ // won't ever happen
+ throw new RuntimeException(re);
+ }
+ }
+
+ /**
+ * @hide
+ * Removes the shared account.
+ * @param account the account to remove
+ * @param user the user to remove the account from
+ * @return
+ */
+ public boolean removeSharedAccount(final Account account, UserHandle user) {
+ try {
+ boolean val = mService.removeSharedAccountAsUser(account, user.getIdentifier());
+ return val;
+ } catch (RemoteException re) {
+ // won't ever happen
+ throw new RuntimeException(re);
+ }
+ }
+
+ /**
+ * @hide
+ * @param user
+ * @return
+ */
+ public Account[] getSharedAccounts(UserHandle user) {
+ try {
+ return mService.getSharedAccountsAsUser(user.getIdentifier());
+ } catch (RemoteException re) {
+ // won't ever happen
+ throw new RuntimeException(re);
+ }
+ }
+
+ /**
* Confirms that the user knows the password for an account to make extra
* sure they are the owner of the account. The user-entered password can
* be supplied directly, otherwise the authenticator for this account type