Search in sources :

Example 41 with SystemApi

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

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)

Example 42 with SystemApi

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

the class NotificationListenerService method registerAsSystemService.

/**
     * Directly register this service with the Notification Manager.
     *
     * <p>Only system services may use this call. It will fail for non-system callers.
     * Apps should ask the user to add their listener in Settings.
     *
     * @param context Context required for accessing resources. Since this service isn't
     *    launched as a real Service when using this method, a context has to be passed in.
     * @param componentName the component that will consume the notification information
     * @param currentUser the user to use as the stream filter
     * @hide
     */
@SystemApi
public void registerAsSystemService(Context context, ComponentName componentName, int currentUser) throws RemoteException {
    if (mWrapper == null) {
        mWrapper = new NotificationListenerWrapper();
    }
    mSystemContext = context;
    INotificationManager noMan = getNotificationInterface();
    mHandler = new MyHandler(context.getMainLooper());
    mCurrentUser = currentUser;
    noMan.registerListener(mWrapper, componentName, currentUser);
}
Also used : INotificationManager(android.app.INotificationManager) SystemApi(android.annotation.SystemApi)

Example 43 with SystemApi

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

the class NotificationListenerService method unregisterAsSystemService.

/**
     * Directly unregister this service from the Notification Manager.
     *
     * <p>This method will fail for listeners that were not registered
     * with (@link registerAsService).
     * @hide
     */
@SystemApi
public void unregisterAsSystemService() throws RemoteException {
    if (mWrapper != null) {
        INotificationManager noMan = getNotificationInterface();
        noMan.unregisterListener(mWrapper, mCurrentUser);
    }
}
Also used : INotificationManager(android.app.INotificationManager) SystemApi(android.annotation.SystemApi)

Example 44 with SystemApi

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

the class NotificationListenerService method getActiveNotifications.

/**
     * Request one or more notifications by key. Useful if you have been keeping track of
     * notifications but didn't want to retain the bits, and now need to go back and extract
     * more data out of those notifications.
     *
     * @hide
     *
     * @param keys the keys of the notifications to request
     * @param trim trim of the notifications to be returned. See <code>TRIM_*</code> constants.
     * @return An array of notifications corresponding to the requested keys, in the
     * same order as the key list.
     */
@SystemApi
public StatusBarNotification[] getActiveNotifications(String[] keys, int trim) {
    if (!isBound())
        return null;
    try {
        ParceledListSlice<StatusBarNotification> parceledList = getNotificationInterface().getActiveNotificationsFromListener(mWrapper, keys, trim);
        List<StatusBarNotification> list = parceledList.getList();
        ArrayList<StatusBarNotification> corruptNotifications = null;
        int N = list.size();
        for (int i = 0; i < N; i++) {
            StatusBarNotification sbn = list.get(i);
            Notification notification = sbn.getNotification();
            try {
                // convert icon metadata to legacy format for older clients
                createLegacyIconExtras(notification);
                // populate remote views for older clients.
                maybePopulateRemoteViews(notification);
            } catch (IllegalArgumentException e) {
                if (corruptNotifications == null) {
                    corruptNotifications = new ArrayList<>(N);
                }
                corruptNotifications.add(sbn);
                Log.w(TAG, "onNotificationPosted: can't rebuild notification from " + sbn.getPackageName());
            }
        }
        if (corruptNotifications != null) {
            list.removeAll(corruptNotifications);
        }
        return list.toArray(new StatusBarNotification[list.size()]);
    } catch (android.os.RemoteException ex) {
        Log.v(TAG, "Unable to contact notification manager", ex);
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) RemoteException(android.os.RemoteException) Notification(android.app.Notification) SystemApi(android.annotation.SystemApi)

Example 45 with SystemApi

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

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