Search in sources :

Example 86 with SystemApi

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

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 87 with SystemApi

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

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 88 with SystemApi

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

the class AbstractAccountAuthenticator method startUpdateCredentialsSession.

/**
     * Asks user to re-authenticate for an account but defers updating the
     * locally stored credentials. No file I/O should be performed in this call.
     * Local credentials should be updated 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 account the account whose credentials are to be updated, will
     *            never be null
     * @param authTokenType the type of auth token to retrieve after updating
     *            the credentials, 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
     *         updating the locally stored credentials later, and if account is
     *         re-authenticated, optional {@link AccountManager#KEY_PASSWORD}
     *         and {@link AccountManager#KEY_ACCOUNT_STATUS_TOKEN} for checking
     *         the status of the account later, 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 startUpdateCredentialsSession(final AccountAuthenticatorResponse response, final Account account, final String authTokenType, 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.putParcelable(KEY_ACCOUNT, account);
            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 89 with SystemApi

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

the class AbstractAccountAuthenticator method isCredentialsUpdateSuggested.

/**
     * Checks if update of the account credentials is suggested.
     *
     * @param response to send the result back to the AccountManager, will never be null.
     * @param account the account to check, will never be null
     * @param statusToken a String of token to check if update of credentials is suggested.
     * @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_BOOLEAN_RESULT}, true if update of account's
     *         credentials is suggested, false otherwise
     *         <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
     * @hide
     */
@SystemApi
public Bundle isCredentialsUpdateSuggested(final AccountAuthenticatorResponse response, Account account, String statusToken) throws NetworkErrorException {
    Bundle result = new Bundle();
    result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, false);
    return result;
}
Also used : Bundle(android.os.Bundle) SystemApi(android.annotation.SystemApi)

Example 90 with SystemApi

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

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)

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