Search in sources :

Example 61 with SystemApi

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

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

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

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

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

the class TelecomManager method dumpAnalytics.

/**
     * Dumps telecom analytics for uploading.
     *
     * @return
     * @hide
     */
@SystemApi
@RequiresPermission(Manifest.permission.DUMP)
public TelecomAnalytics dumpAnalytics() {
    ITelecomService service = getTelecomService();
    TelecomAnalytics result = null;
    if (service != null) {
        try {
            result = service.dumpCallAnalytics();
        } catch (RemoteException e) {
            Log.e(TAG, "Error dumping call analytics", e);
        }
    }
    return result;
}
Also used : ITelecomService(com.android.internal.telecom.ITelecomService) RemoteException(android.os.RemoteException) SystemApi(android.annotation.SystemApi) RequiresPermission(android.annotation.RequiresPermission)

Example 64 with SystemApi

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

the class PackageItemInfo method loadSafeLabel.

/**
     * Same as {@link #loadLabel(PackageManager)} with the addition that
     * the returned label is safe for being presented in the UI since it
     * will not contain new lines and the length will be limited to a
     * reasonable amount. This prevents a malicious party to influence UI
     * layout via the app label misleading the user into performing a
     * detrimental for them action. If the label is too long it will be
     * truncated and ellipsized at the end.
     *
     * @param pm A PackageManager from which the label can be loaded; usually
     * the PackageManager from which you originally retrieved this item
     * @return Returns a CharSequence containing the item's label. If the
     * item does not have a label, its name is returned.
     *
     * @hide
     */
@SystemApi
@NonNull
public CharSequence loadSafeLabel(@NonNull PackageManager pm) {
    // loadLabel() always returns non-null
    String label = loadLabel(pm).toString();
    // strip HTML tags to avoid <br> and other tags overwriting original message
    String labelStr = Html.fromHtml(label).toString();
    // If the label contains new line characters it may push the UI
    // down to hide a part of it. Labels shouldn't have new line
    // characters, so just truncate at the first time one is seen.
    final int labelLength = labelStr.length();
    int offset = 0;
    while (offset < labelLength) {
        final int codePoint = labelStr.codePointAt(offset);
        final int type = Character.getType(codePoint);
        if (type == Character.LINE_SEPARATOR || type == Character.CONTROL || type == Character.PARAGRAPH_SEPARATOR) {
            labelStr = labelStr.substring(0, offset);
            break;
        }
        // replace all non-break space to " " in order to be trimmed
        if (type == Character.SPACE_SEPARATOR) {
            labelStr = labelStr.substring(0, offset) + " " + labelStr.substring(offset + Character.charCount(codePoint));
        }
        offset += Character.charCount(codePoint);
    }
    labelStr = labelStr.trim();
    if (labelStr.isEmpty()) {
        return packageName;
    }
    TextPaint paint = new TextPaint();
    paint.setTextSize(42);
    return TextUtils.ellipsize(labelStr, paint, MAX_LABEL_SIZE_PX, TextUtils.TruncateAt.END);
}
Also used : TextPaint(android.text.TextPaint) TextPaint(android.text.TextPaint) SystemApi(android.annotation.SystemApi) NonNull(android.annotation.NonNull)

Example 65 with SystemApi

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

the class Condition method copy.

@SystemApi
public Condition copy() {
    final Parcel parcel = Parcel.obtain();
    try {
        writeToParcel(parcel, 0);
        parcel.setDataPosition(0);
        return new Condition(parcel);
    } finally {
        parcel.recycle();
    }
}
Also used : Parcel(android.os.Parcel) 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