Search in sources :

Example 76 with SystemApi

use of android.annotation.SystemApi in project android_frameworks_base by AOSPA.

the class AbstractAccountAuthenticator method startAddAccountSession.

/**
     * Starts the add account session to authenticate user to an account of the
     * specified accountType. No file I/O should be performed in this call.
     * Account should be added to device only when {@link #finishSession} is
     * called after this.
     * <p>
     * Note: when overriding this method, {@link #finishSession} should be
     * overridden too.
     * </p>
     *
     * @param response to send the result back to the AccountManager, will never
     *            be null
     * @param accountType the type of account to authenticate with, will never
     *            be null
     * @param authTokenType the type of auth token to retrieve after
     *            authenticating with the account, may be null
     * @param requiredFeatures a String array of authenticator-specific features
     *            that the account authenticated with must support, may be null
     * @param options a Bundle of authenticator-specific options, may be null
     * @return a Bundle result or null if the result is to be returned via the
     *         response. The result will contain either:
     *         <ul>
     *         <li>{@link AccountManager#KEY_INTENT}, or
     *         <li>{@link AccountManager#KEY_ACCOUNT_SESSION_BUNDLE} for adding
     *         the account to device later, and if account is authenticated,
     *         optional {@link AccountManager#KEY_PASSWORD} and
     *         {@link AccountManager#KEY_ACCOUNT_STATUS_TOKEN} for checking the
     *         status of the account, or
     *         <li>{@link AccountManager#KEY_ERROR_CODE} and
     *         {@link AccountManager#KEY_ERROR_MESSAGE} to indicate an error
     *         </ul>
     * @throws NetworkErrorException if the authenticator could not honor the
     *             request due to a network error
     * @see #finishSession(AccountAuthenticatorResponse, String, Bundle)
     * @hide
     */
@SystemApi
public Bundle startAddAccountSession(final AccountAuthenticatorResponse response, final String accountType, final String authTokenType, final String[] requiredFeatures, final Bundle options) throws NetworkErrorException {
    new Thread(new Runnable() {

        @Override
        public void run() {
            Bundle sessionBundle = new Bundle();
            sessionBundle.putString(KEY_AUTH_TOKEN_TYPE, authTokenType);
            sessionBundle.putStringArray(KEY_REQUIRED_FEATURES, requiredFeatures);
            sessionBundle.putBundle(KEY_OPTIONS, options);
            Bundle result = new Bundle();
            result.putBundle(AccountManager.KEY_ACCOUNT_SESSION_BUNDLE, sessionBundle);
            response.onResult(result);
        }
    }).start();
    return null;
}
Also used : Bundle(android.os.Bundle) SystemApi(android.annotation.SystemApi)

Example 77 with SystemApi

use of android.annotation.SystemApi in project android_frameworks_base by AOSPA.

the class AccountManager method finishSessionAsUser.

/**
     * @see #finishSession
     * @hide
     */
@SystemApi
public AccountManagerFuture<Bundle> finishSessionAsUser(final Bundle sessionBundle, final Activity activity, final UserHandle userHandle, AccountManagerCallback<Bundle> callback, Handler handler) {
    if (sessionBundle == null) {
        throw new IllegalArgumentException("sessionBundle is null");
    }
    /* Add information required by add account flow */
    final Bundle appInfo = new Bundle();
    appInfo.putString(KEY_ANDROID_PACKAGE_NAME, mContext.getPackageName());
    return new AmsTask(activity, handler, callback) {

        @Override
        public void doWork() throws RemoteException {
            mService.finishSessionAsUser(mResponse, sessionBundle, activity != null, appInfo, userHandle.getIdentifier());
        }
    }.start();
}
Also used : Bundle(android.os.Bundle) RemoteException(android.os.RemoteException) SystemApi(android.annotation.SystemApi)

Example 78 with SystemApi

use of android.annotation.SystemApi in project android_frameworks_base by ResurrectionRemix.

the class AbstractAccountAuthenticator method finishSession.

/**
     * Finishes the session started by #startAddAccountSession or
     * #startUpdateCredentials by installing the account to device with
     * AccountManager, or updating the local credentials. File I/O may be
     * performed in this call.
     * <p>
     * Note: when overriding this method, {@link #startAddAccountSession} and
     * {@link #startUpdateCredentialsSession} should be overridden too.
     * </p>
     *
     * @param response to send the result back to the AccountManager, will never
     *            be null
     * @param accountType the type of account to authenticate with, will never
     *            be null
     * @param sessionBundle a bundle of session data created by
     *            {@link #startAddAccountSession} used for adding account to
     *            device, or by {@link #startUpdateCredentialsSession} used for
     *            updating local credentials.
     * @return a Bundle result or null if the result is to be returned via the
     *         response. The result will contain either:
     *         <ul>
     *         <li>{@link AccountManager#KEY_INTENT}, or
     *         <li>{@link AccountManager#KEY_ACCOUNT_NAME} and
     *         {@link AccountManager#KEY_ACCOUNT_TYPE} of the account that was
     *         added or local credentials were updated, or
     *         <li>{@link AccountManager#KEY_ERROR_CODE} and
     *         {@link AccountManager#KEY_ERROR_MESSAGE} to indicate an error
     *         </ul>
     * @throws NetworkErrorException if the authenticator could not honor the request due to a
     *             network error
     * @see #startAddAccountSession and #startUpdateCredentialsSession
     * @hide
     */
@SystemApi
public Bundle finishSession(final AccountAuthenticatorResponse response, final String accountType, final Bundle sessionBundle) throws NetworkErrorException {
    if (TextUtils.isEmpty(accountType)) {
        Log.e(TAG, "Account type cannot be empty.");
        Bundle result = new Bundle();
        result.putInt(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_BAD_ARGUMENTS);
        result.putString(AccountManager.KEY_ERROR_MESSAGE, "accountType cannot be empty.");
        return result;
    }
    if (sessionBundle == null) {
        Log.e(TAG, "Session bundle cannot be null.");
        Bundle result = new Bundle();
        result.putInt(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_BAD_ARGUMENTS);
        result.putString(AccountManager.KEY_ERROR_MESSAGE, "sessionBundle cannot be null.");
        return result;
    }
    if (!sessionBundle.containsKey(KEY_AUTH_TOKEN_TYPE)) {
        // We cannot handle Session bundle not created by default startAddAccountSession(...)
        // nor startUpdateCredentialsSession(...) implementation. Return error.
        Bundle result = new Bundle();
        result.putInt(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION);
        result.putString(AccountManager.KEY_ERROR_MESSAGE, "Authenticator must override finishSession if startAddAccountSession" + " or startUpdateCredentialsSession is overridden.");
        response.onResult(result);
        return result;
    }
    String authTokenType = sessionBundle.getString(KEY_AUTH_TOKEN_TYPE);
    Bundle options = sessionBundle.getBundle(KEY_OPTIONS);
    String[] requiredFeatures = sessionBundle.getStringArray(KEY_REQUIRED_FEATURES);
    Account account = sessionBundle.getParcelable(KEY_ACCOUNT);
    boolean containsKeyAccount = sessionBundle.containsKey(KEY_ACCOUNT);
    // Actual options passed to add account or update credentials flow.
    Bundle sessionOptions = new Bundle(sessionBundle);
    // Remove redundant extras in session bundle before passing it to addAccount(...) or
    // updateCredentials(...).
    sessionOptions.remove(KEY_AUTH_TOKEN_TYPE);
    sessionOptions.remove(KEY_REQUIRED_FEATURES);
    sessionOptions.remove(KEY_OPTIONS);
    sessionOptions.remove(KEY_ACCOUNT);
    if (options != null) {
        // options may contains old system info such as
        // AccountManager.KEY_ANDROID_PACKAGE_NAME required by the add account flow or update
        // credentials flow, we should replace with the new values of the current call added
        // to sessionBundle by AccountManager or AccountManagerService.
        options.putAll(sessionOptions);
        sessionOptions = options;
    }
    // contain KEY_ACCOUNT.
    if (containsKeyAccount) {
        return updateCredentials(response, account, authTokenType, options);
    }
    // Otherwise, session bundle was created by startAddAccountSession default implementation.
    return addAccount(response, accountType, authTokenType, requiredFeatures, sessionOptions);
}
Also used : Bundle(android.os.Bundle) SystemApi(android.annotation.SystemApi)

Example 79 with SystemApi

use of android.annotation.SystemApi in project android_frameworks_base by ResurrectionRemix.

the class AccountManager method finishSessionAsUser.

/**
     * @see #finishSession
     * @hide
     */
@SystemApi
public AccountManagerFuture<Bundle> finishSessionAsUser(final Bundle sessionBundle, final Activity activity, final UserHandle userHandle, AccountManagerCallback<Bundle> callback, Handler handler) {
    if (sessionBundle == null) {
        throw new IllegalArgumentException("sessionBundle is null");
    }
    /* Add information required by add account flow */
    final Bundle appInfo = new Bundle();
    appInfo.putString(KEY_ANDROID_PACKAGE_NAME, mContext.getPackageName());
    return new AmsTask(activity, handler, callback) {

        @Override
        public void doWork() throws RemoteException {
            mService.finishSessionAsUser(mResponse, sessionBundle, activity != null, appInfo, userHandle.getIdentifier());
        }
    }.start();
}
Also used : Bundle(android.os.Bundle) RemoteException(android.os.RemoteException) SystemApi(android.annotation.SystemApi)

Example 80 with SystemApi

use of android.annotation.SystemApi in project android_frameworks_base by ResurrectionRemix.

the class AccountManager method startAddAccountSession.

/**
     * Asks the user to authenticate with an account of a specified type. The
     * authenticator for this account type processes this request with the
     * appropriate user interface. If the user does elect to authenticate with a
     * new account, a bundle of session data for installing the account later is
     * returned with optional account password and account status token.
     * <p>
     * This method may be called from any thread, but the returned
     * {@link AccountManagerFuture} must not be used on the main thread.
     * <p>
     * <p>
     * <b>NOTE:</b> The account will not be installed to the device by calling
     * this api alone. #finishSession should be called after this to install the
     * account on device.
     *
     * @param accountType The type of account to add; must not be null
     * @param authTokenType The type of auth token (see {@link #getAuthToken})
     *            this account will need to be able to generate, null for none
     * @param requiredFeatures The features (see {@link #hasFeatures}) this
     *            account must have, null for none
     * @param options Authenticator-specific options for the request, may be
     *            null or empty
     * @param activity The {@link Activity} context to use for launching a new
     *            authenticator-defined sub-Activity to prompt the user to
     *            create an account; used only to call startActivity(); if null,
     *            the prompt will not be launched directly, but the necessary
     *            {@link Intent} will be returned to the caller instead
     * @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 Bundle with
     *         these fields if activity was specified and user was authenticated
     *         with an account:
     *         <ul>
     *         <li>{@link #KEY_ACCOUNT_SESSION_BUNDLE} - encrypted Bundle for
     *         adding the the to the device later.
     *         <li>{@link #KEY_ACCOUNT_STATUS_TOKEN} - optional, token to check
     *         status of the account
     *         </ul>
     *         If no activity was specified, the returned Bundle contains only
     *         {@link #KEY_INTENT} with the {@link Intent} needed to launch the
     *         actual account creation process. If authenticator doesn't support
     *         this method, the returned Bundle contains only
     *         {@link #KEY_ACCOUNT_SESSION_BUNDLE} with encrypted
     *         {@code options} needed to add account later. If an error
     *         occurred, {@link AccountManagerFuture#getResult()} throws:
     *         <ul>
     *         <li>{@link AuthenticatorException} if no authenticator was
     *         registered for this account type or the authenticator failed to
     *         respond
     *         <li>{@link OperationCanceledException} if the operation was
     *         canceled for any reason, including the user canceling the
     *         creation process or adding accounts (of this type) has been
     *         disabled by policy
     *         <li>{@link IOException} if the authenticator experienced an I/O
     *         problem creating a new account, usually because of network
     *         trouble
     *         </ul>
     * @see #finishSession
     * @hide
     */
@SystemApi
public AccountManagerFuture<Bundle> startAddAccountSession(final String accountType, final String authTokenType, final String[] requiredFeatures, final Bundle options, final Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) {
    if (accountType == null)
        throw new IllegalArgumentException("accountType is null");
    final Bundle optionsIn = new Bundle();
    if (options != null) {
        optionsIn.putAll(options);
    }
    optionsIn.putString(KEY_ANDROID_PACKAGE_NAME, mContext.getPackageName());
    return new AmsTask(activity, handler, callback) {

        @Override
        public void doWork() throws RemoteException {
            mService.startAddAccountSession(mResponse, accountType, authTokenType, requiredFeatures, activity != null, optionsIn);
        }
    }.start();
}
Also used : Bundle(android.os.Bundle) RemoteException(android.os.RemoteException) SystemApi(android.annotation.SystemApi)

Aggregations

SystemApi (android.annotation.SystemApi)96 Bundle (android.os.Bundle)36 RemoteException (android.os.RemoteException)33 INotificationManager (android.app.INotificationManager)10 RequiresPermission (android.annotation.RequiresPermission)6 ComponentName (android.content.ComponentName)6 NonNull (android.annotation.NonNull)5 Notification (android.app.Notification)5 AudioFormat (android.media.AudioFormat)5 AudioRecord (android.media.AudioRecord)5 AudioTrack (android.media.AudioTrack)5 Parcel (android.os.Parcel)5 TextPaint (android.text.TextPaint)5 FileWriter (java.io.FileWriter)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 ITelecomService (com.android.internal.telecom.ITelecomService)4 ICarrierConfigLoader (com.android.internal.telephony.ICarrierConfigLoader)4 ITelephony (com.android.internal.telephony.ITelephony)4 Implementation (org.robolectric.annotation.Implementation)3