summaryrefslogtreecommitdiff
path: root/core/java/android/accounts/AccountManager.java
diff options
context:
space:
mode:
authorTejas Khorana <khorana@google.com>2016-06-28 20:59:52 -0700
committerTejas Khorana <khorana@google.com>2016-08-02 14:57:06 -0700
commit5edff3b8b1085660dba4d7106a5b6498f41ccf22 (patch)
treee3e17e007eb9e178af33835c0bcafa21fe788613 /core/java/android/accounts/AccountManager.java
parent39940e2667c585e8098729bb2d871d781917712a (diff)
Account Manager Push API
Account Push API: Designed to repurpose existing Account Discovery APIs. Bug#30562311 Bug: https://b.corp.google.com/issues/30562311 Change-Id: If1b22dc96c5cff21550e93bd26942faa5bcdabbf
Diffstat (limited to 'core/java/android/accounts/AccountManager.java')
-rw-r--r--core/java/android/accounts/AccountManager.java109
1 files changed, 109 insertions, 0 deletions
diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java
index 88b12972ccc8..59d2f18c3a19 100644
--- a/core/java/android/accounts/AccountManager.java
+++ b/core/java/android/accounts/AccountManager.java
@@ -733,6 +733,115 @@ public class AccountManager {
}
/**
+ * Adds an account directly to the AccountManager. Additionally this
+ * makes the Account visible to desired UIDs of applications on the device,
+ * and sends directed broadcasts to these individual applications.
+ * <p>Normally used by sign-up wizards associated with authenticators, not
+ * directly by applications.
+ * <p>Calling this method does not update the last authenticated timestamp,
+ * referred by {@link #KEY_LAST_AUTHENTICATED_TIME}. To update it, call
+ * {@link #notifyAccountAuthenticated(Account)} after getting success.
+ * <p>It is safe to call this method from the main thread.
+ * <p>This method requires the caller to have a signature match with the
+ * authenticator that owns the specified account.
+ *
+ * @param account The {@link Account} to add
+ * @param password The password to associate with the account, null for none
+ * @param extras String values to use for the account's userdata, null for
+ * none
+ * @param selectedUids Array of uids whose associated applications can access
+ * this account without any additional user approval.
+ *
+ * @return True if the account was successfully added, false if the account
+ * already exists, the account is null, or another error occurs.
+ */
+ public boolean addAccountExplicitly(Account account, String password, Bundle extras,
+ int[] selectedUids) {
+ if (account == null) throw new IllegalArgumentException("account is null");
+ try {
+ return mService.addAccountExplicitlyWithUid(account, password, extras, selectedUids);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Returns all UIDs for applications that requested the account type.
+ * <p>This method requires the caller to have a signature match with the authenticator
+ * that owns the specified account.
+ *
+ * @param accountType The account type to be authenticated.
+ *
+ * @return array of all UIDs that support accounts of this
+ * account type that seek approval (to be used to know which accounts for
+ * the authenticator to include in addAccountExplicitly). Null if none.
+ */
+ public int[] getRequestingUidsForType(String accountType) {
+ try {
+ return mService.getRequestingUidsForType(accountType);
+ } catch (RemoteException re) {
+ throw re.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Gives a certain UID, represented a application, access to an account
+ * <p>This method requires the caller to have a signature match with the authenticator
+ * that owns the specified account.
+ *
+ * @param account Account to make visible.
+ * @param uid The UID of the application to add account access.
+ *
+ * @return True if account made visible to application and was not previously visible.
+ */
+ public boolean makeAccountVisible(Account account, int uid) {
+ try {
+ return mService.makeAccountVisible(account, uid);
+ } catch (RemoteException re) {
+ throw re.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Removes visibility of certain account of a process identified
+ * by a given UID to an application.
+ * This is called by the Authenticator.
+ * <p>This method requires the caller to have a signature match with the authenticator
+ * that owns the specified account.
+ *
+ * @param account Remove visibility of this account..
+ * @param uid The UID of the application to remove account access.
+ *
+ * @return True if application access to account removed and was previously visible.
+ */
+ public boolean removeAccountVisibility(Account account, int uid) {
+ try {
+ return mService.removeAccountVisibility(account, uid);
+ } catch (RemoteException re) {
+ throw re.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Checks visibility of certain account of a process identified
+ * by a given UID. This is called by the Authenticator.
+ * <p>This method requires the caller to have a signature match with the authenticator
+ * that owns the specified account.
+ *
+ * @param account Account to check visibility.
+ * @param uid The UID of the application to check account access.
+ *
+ * @return True if application has access to the account
+ */
+ public boolean isAccountVisible(Account account, int uid) {
+ try {
+ return mService.isAccountVisible(account, uid);
+ } catch (RemoteException re) {
+ throw re.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Notifies the system that the account has just been authenticated. This
* information may be used by other applications to verify the account. This
* should be called only when the user has entered correct credentials for