Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 81f7c4b6 authored by Tejas Khorana's avatar Tejas Khorana Committed by Android (Google) Code Review
Browse files

Merge "Account Manager Push API"

parents 909f6c48 5edff3b8
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2844,6 +2844,7 @@ package android.accounts {
  public class AccountManager {
    method public android.accounts.AccountManagerFuture<android.os.Bundle> addAccount(java.lang.String, java.lang.String, java.lang.String[], android.os.Bundle, android.app.Activity, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler);
    method public boolean addAccountExplicitly(android.accounts.Account, java.lang.String, android.os.Bundle);
    method public boolean addAccountExplicitly(android.accounts.Account, java.lang.String, android.os.Bundle, int[]);
    method public void addOnAccountsUpdatedListener(android.accounts.OnAccountsUpdateListener, android.os.Handler, boolean);
    method public java.lang.String blockingGetAuthToken(android.accounts.Account, java.lang.String, boolean) throws android.accounts.AuthenticatorException, java.io.IOException, android.accounts.OperationCanceledException;
    method public void clearPassword(android.accounts.Account);
@@ -2862,10 +2863,13 @@ package android.accounts {
    method public android.accounts.AuthenticatorDescription[] getAuthenticatorTypes();
    method public java.lang.String getPassword(android.accounts.Account);
    method public java.lang.String getPreviousName(android.accounts.Account);
    method public int[] getRequestingUidsForType(java.lang.String);
    method public java.lang.String getUserData(android.accounts.Account, java.lang.String);
    method public android.accounts.AccountManagerFuture<java.lang.Boolean> hasFeatures(android.accounts.Account, java.lang.String[], android.accounts.AccountManagerCallback<java.lang.Boolean>, android.os.Handler);
    method public void invalidateAuthToken(java.lang.String, java.lang.String);
    method public boolean isAccountVisible(android.accounts.Account, int);
    method public android.accounts.AccountManagerFuture<java.lang.Boolean> isCredentialsUpdateSuggested(android.accounts.Account, java.lang.String, android.accounts.AccountManagerCallback<java.lang.Boolean>, android.os.Handler);
    method public boolean makeAccountVisible(android.accounts.Account, int);
    method public static deprecated android.content.Intent newChooseAccountIntent(android.accounts.Account, java.util.ArrayList<android.accounts.Account>, java.lang.String[], boolean, java.lang.String, java.lang.String, java.lang.String[], android.os.Bundle);
    method public static android.content.Intent newChooseAccountIntent(android.accounts.Account, java.util.List<android.accounts.Account>, java.lang.String[], java.lang.String, java.lang.String, java.lang.String[], android.os.Bundle);
    method public boolean notifyAccountAuthenticated(android.accounts.Account);
@@ -2873,6 +2877,7 @@ package android.accounts {
    method public deprecated android.accounts.AccountManagerFuture<java.lang.Boolean> removeAccount(android.accounts.Account, android.accounts.AccountManagerCallback<java.lang.Boolean>, android.os.Handler);
    method public android.accounts.AccountManagerFuture<android.os.Bundle> removeAccount(android.accounts.Account, android.app.Activity, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler);
    method public boolean removeAccountExplicitly(android.accounts.Account);
    method public boolean removeAccountVisibility(android.accounts.Account, int);
    method public void removeOnAccountsUpdatedListener(android.accounts.OnAccountsUpdateListener);
    method public android.accounts.AccountManagerFuture<android.accounts.Account> renameAccount(android.accounts.Account, java.lang.String, android.accounts.AccountManagerCallback<android.accounts.Account>, android.os.Handler);
    method public void setAuthToken(android.accounts.Account, java.lang.String, java.lang.String);
+5 −0
Original line number Diff line number Diff line
@@ -2958,6 +2958,7 @@ package android.accounts {
  public class AccountManager {
    method public android.accounts.AccountManagerFuture<android.os.Bundle> addAccount(java.lang.String, java.lang.String, java.lang.String[], android.os.Bundle, android.app.Activity, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler);
    method public boolean addAccountExplicitly(android.accounts.Account, java.lang.String, android.os.Bundle);
    method public boolean addAccountExplicitly(android.accounts.Account, java.lang.String, android.os.Bundle, int[]);
    method public void addOnAccountsUpdatedListener(android.accounts.OnAccountsUpdateListener, android.os.Handler, boolean);
    method public java.lang.String blockingGetAuthToken(android.accounts.Account, java.lang.String, boolean) throws android.accounts.AuthenticatorException, java.io.IOException, android.accounts.OperationCanceledException;
    method public void clearPassword(android.accounts.Account);
@@ -2977,10 +2978,13 @@ package android.accounts {
    method public android.accounts.AuthenticatorDescription[] getAuthenticatorTypes();
    method public java.lang.String getPassword(android.accounts.Account);
    method public java.lang.String getPreviousName(android.accounts.Account);
    method public int[] getRequestingUidsForType(java.lang.String);
    method public java.lang.String getUserData(android.accounts.Account, java.lang.String);
    method public android.accounts.AccountManagerFuture<java.lang.Boolean> hasFeatures(android.accounts.Account, java.lang.String[], android.accounts.AccountManagerCallback<java.lang.Boolean>, android.os.Handler);
    method public void invalidateAuthToken(java.lang.String, java.lang.String);
    method public boolean isAccountVisible(android.accounts.Account, int);
    method public android.accounts.AccountManagerFuture<java.lang.Boolean> isCredentialsUpdateSuggested(android.accounts.Account, java.lang.String, android.accounts.AccountManagerCallback<java.lang.Boolean>, android.os.Handler);
    method public boolean makeAccountVisible(android.accounts.Account, int);
    method public static deprecated android.content.Intent newChooseAccountIntent(android.accounts.Account, java.util.ArrayList<android.accounts.Account>, java.lang.String[], boolean, java.lang.String, java.lang.String, java.lang.String[], android.os.Bundle);
    method public static android.content.Intent newChooseAccountIntent(android.accounts.Account, java.util.List<android.accounts.Account>, java.lang.String[], java.lang.String, java.lang.String, java.lang.String[], android.os.Bundle);
    method public boolean notifyAccountAuthenticated(android.accounts.Account);
@@ -2988,6 +2992,7 @@ package android.accounts {
    method public deprecated android.accounts.AccountManagerFuture<java.lang.Boolean> removeAccount(android.accounts.Account, android.accounts.AccountManagerCallback<java.lang.Boolean>, android.os.Handler);
    method public android.accounts.AccountManagerFuture<android.os.Bundle> removeAccount(android.accounts.Account, android.app.Activity, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler);
    method public boolean removeAccountExplicitly(android.accounts.Account);
    method public boolean removeAccountVisibility(android.accounts.Account, int);
    method public void removeOnAccountsUpdatedListener(android.accounts.OnAccountsUpdateListener);
    method public android.accounts.AccountManagerFuture<android.accounts.Account> renameAccount(android.accounts.Account, java.lang.String, android.accounts.AccountManagerCallback<android.accounts.Account>, android.os.Handler);
    method public void setAuthToken(android.accounts.Account, java.lang.String, java.lang.String);
+5 −0
Original line number Diff line number Diff line
@@ -2844,6 +2844,7 @@ package android.accounts {
  public class AccountManager {
    method public android.accounts.AccountManagerFuture<android.os.Bundle> addAccount(java.lang.String, java.lang.String, java.lang.String[], android.os.Bundle, android.app.Activity, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler);
    method public boolean addAccountExplicitly(android.accounts.Account, java.lang.String, android.os.Bundle);
    method public boolean addAccountExplicitly(android.accounts.Account, java.lang.String, android.os.Bundle, int[]);
    method public void addOnAccountsUpdatedListener(android.accounts.OnAccountsUpdateListener, android.os.Handler, boolean);
    method public java.lang.String blockingGetAuthToken(android.accounts.Account, java.lang.String, boolean) throws android.accounts.AuthenticatorException, java.io.IOException, android.accounts.OperationCanceledException;
    method public void clearPassword(android.accounts.Account);
@@ -2862,10 +2863,13 @@ package android.accounts {
    method public android.accounts.AuthenticatorDescription[] getAuthenticatorTypes();
    method public java.lang.String getPassword(android.accounts.Account);
    method public java.lang.String getPreviousName(android.accounts.Account);
    method public int[] getRequestingUidsForType(java.lang.String);
    method public java.lang.String getUserData(android.accounts.Account, java.lang.String);
    method public android.accounts.AccountManagerFuture<java.lang.Boolean> hasFeatures(android.accounts.Account, java.lang.String[], android.accounts.AccountManagerCallback<java.lang.Boolean>, android.os.Handler);
    method public void invalidateAuthToken(java.lang.String, java.lang.String);
    method public boolean isAccountVisible(android.accounts.Account, int);
    method public android.accounts.AccountManagerFuture<java.lang.Boolean> isCredentialsUpdateSuggested(android.accounts.Account, java.lang.String, android.accounts.AccountManagerCallback<java.lang.Boolean>, android.os.Handler);
    method public boolean makeAccountVisible(android.accounts.Account, int);
    method public static deprecated android.content.Intent newChooseAccountIntent(android.accounts.Account, java.util.ArrayList<android.accounts.Account>, java.lang.String[], boolean, java.lang.String, java.lang.String, java.lang.String[], android.os.Bundle);
    method public static android.content.Intent newChooseAccountIntent(android.accounts.Account, java.util.List<android.accounts.Account>, java.lang.String[], java.lang.String, java.lang.String, java.lang.String[], android.os.Bundle);
    method public boolean notifyAccountAuthenticated(android.accounts.Account);
@@ -2873,6 +2877,7 @@ package android.accounts {
    method public deprecated android.accounts.AccountManagerFuture<java.lang.Boolean> removeAccount(android.accounts.Account, android.accounts.AccountManagerCallback<java.lang.Boolean>, android.os.Handler);
    method public android.accounts.AccountManagerFuture<android.os.Bundle> removeAccount(android.accounts.Account, android.app.Activity, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler);
    method public boolean removeAccountExplicitly(android.accounts.Account);
    method public boolean removeAccountVisibility(android.accounts.Account, int);
    method public void removeOnAccountsUpdatedListener(android.accounts.OnAccountsUpdateListener);
    method public android.accounts.AccountManagerFuture<android.accounts.Account> renameAccount(android.accounts.Account, java.lang.String, android.accounts.AccountManagerCallback<android.accounts.Account>, android.os.Handler);
    method public void setAuthToken(android.accounts.Account, java.lang.String, java.lang.String);
+109 −0
Original line number Diff line number Diff line
@@ -732,6 +732,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
+15 −2
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.accounts.Account;
import android.accounts.AuthenticatorDescription;
import android.os.Bundle;


/**
 * Central application service that provides account management.
 * @hide
@@ -92,7 +91,8 @@ interface IAccountManager {
    void startUpdateCredentialsSession(in IAccountManagerResponse response, in Account account,
        String authTokenType, boolean expectActivityLaunch, in Bundle options);

    /* Finish session started by startAddAccountSession(...) or startUpdateCredentialsSession(...) for user */
    /* Finish session started by startAddAccountSession(...) or startUpdateCredentialsSession(...)
    for user */
    void finishSessionAsUser(in IAccountManagerResponse response, in Bundle sessionBundle,
        boolean expectActivityLaunch, in Bundle appInfo, int userId);

@@ -102,4 +102,17 @@ interface IAccountManager {
    /* Check if credentials update is suggested */
    void isCredentialsUpdateSuggested(in IAccountManagerResponse response, in Account account,
        String statusToken);

    /* Allows Authenticator to view what packages or UIDs on phone have requested it. */
    int[] getRequestingUidsForType(String accountType);

    /* Allows authenticator to add an account explicitly that is only visible to
     certain uids; the authenticator learns of these UIDs */
    boolean addAccountExplicitlyWithUid(in Account account, String password, in Bundle extras,
            in int[] selectedUids);

    /* Controls visibility of UIDs of applications to Accounts */
    boolean removeAccountVisibility(in Account a, in int uid);
    boolean makeAccountVisible(in Account a, in int uid);
    boolean isAccountVisible(in Account a, in int uid);
}
Loading