Search in sources :

Example 16 with SystemApi

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

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

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

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)

Example 18 with SystemApi

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

the class AccountManager method startUpdateCredentialsSession.

/**
     * Asks the user to enter a new password for an account but not updating the
     * saved credentials for the account until {@link #finishSession} is called.
     * <p>
     * This method may be called from any thread, but the returned
     * {@link AccountManagerFuture} must not be used on the main thread.
     * <p>
     * <b>NOTE:</b> The saved credentials for the account alone will not be
     * updated by calling this API alone. #finishSession should be called after
     * this to update local credentials
     *
     * @param account The account to update credentials for
     * @param authTokenType The credentials entered must allow an auth token of
     *            this type to be created (but no actual auth token is
     *            returned); may be null
     * @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 enter
     *            a password; 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 an activity was supplied and user was
     *         successfully re-authenticated to the account:
     *         <ul>
     *         <li>{@link #KEY_ACCOUNT_SESSION_BUNDLE} - encrypted Bundle for
     *         updating the local credentials on 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
     *         {@link #KEY_INTENT} with the {@link Intent} needed to launch the
     *         password prompt. If an error occurred,
     *         {@link AccountManagerFuture#getResult()} throws:
     *         <ul>
     *         <li>{@link AuthenticatorException} if the authenticator failed to
     *         respond
     *         <li>{@link OperationCanceledException} if the operation was
     *         canceled for any reason, including the user canceling the
     *         password prompt
     *         <li>{@link IOException} if the authenticator experienced an I/O
     *         problem verifying the password, usually because of network
     *         trouble
     *         </ul>
     * @see #finishSession
     * @hide
     */
@SystemApi
public AccountManagerFuture<Bundle> startUpdateCredentialsSession(final Account account, final String authTokenType, final Bundle options, final Activity activity, final AccountManagerCallback<Bundle> callback, final Handler handler) {
    if (account == null) {
        throw new IllegalArgumentException("account is null");
    }
    // Always include the calling package name. This just makes life easier
    // down stream.
    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.startUpdateCredentialsSession(mResponse, account, authTokenType, activity != null, optionsIn);
        }
    }.start();
}
Also used : Bundle(android.os.Bundle) RemoteException(android.os.RemoteException) SystemApi(android.annotation.SystemApi)

Example 19 with SystemApi

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

the class CarrierConfigManager method updateConfigForPhoneId.

/**
     * Request the carrier config loader to update the cofig for phoneId.
     * <p>
     * Depending on simState, the config may be cleared or loaded from config app. This is only used
     * by SubscriptionInfoUpdater.
     * </p>
     *
     * @hide
     */
@SystemApi
public void updateConfigForPhoneId(int phoneId, String simState) {
    try {
        ICarrierConfigLoader loader = getICarrierConfigLoader();
        if (loader == null) {
            Rlog.w(TAG, "Error updating config for phoneId=" + phoneId + " ICarrierConfigLoader is null");
            return;
        }
        loader.updateConfigForPhoneId(phoneId, simState);
    } catch (RemoteException ex) {
        Rlog.e(TAG, "Error updating config for phoneId=" + phoneId + ": " + ex.toString());
    }
}
Also used : ICarrierConfigLoader(com.android.internal.telephony.ICarrierConfigLoader) RemoteException(android.os.RemoteException) SystemApi(android.annotation.SystemApi)

Example 20 with SystemApi

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

the class TelephonyManager method setDataEnabled.

/** @hide */
@SystemApi
public void setDataEnabled(int subId, boolean enable) {
    try {
        Log.d(TAG, "setDataEnabled: enabled=" + enable);
        ITelephony telephony = getITelephony();
        if (telephony != null)
            telephony.setDataEnabled(subId, enable);
    } catch (RemoteException e) {
        Log.e(TAG, "Error calling ITelephony#needsOtaServiceProvisioning", e);
    } catch (NullPointerException npe) {
        Log.e(TAG, "Error calling ITelephony#needsOtaServiceProvisioning", npe);
    }
}
Also used : RemoteException(android.os.RemoteException) ITelephony(com.android.internal.telephony.ITelephony) 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