Search in sources :

Example 36 with SystemApi

use of android.annotation.SystemApi in project platform_frameworks_base by android.

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

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

the class AudioPolicy method createAudioRecordSink.

/**
     * Create an {@link AudioRecord} instance that is associated with the given {@link AudioMix}.
     * Audio buffers recorded through the created instance will contain the mix of the audio
     * streams that fed the given mixer.
     * @param mix a non-null {@link AudioMix} instance whose routing flags was defined with
     *     {@link AudioMix#ROUTE_FLAG_LOOP_BACK}, previously added to this policy.
     * @return a new {@link AudioRecord} instance whose data format is the one defined in the
     *     {@link AudioMix}, or null if this policy was not successfully registered
     *     with {@link AudioManager#registerAudioPolicy(AudioPolicy)}.
     * @throws IllegalArgumentException
     */
@SystemApi
public AudioRecord createAudioRecordSink(AudioMix mix) throws IllegalArgumentException {
    if (!policyReadyToUse()) {
        Log.e(TAG, "Cannot create AudioRecord sink for AudioMix");
        return null;
    }
    checkMixReadyToUse(mix, false);
    // create an AudioFormat from the mix format compatible with recording, as the mix
    // was defined for playback
    AudioFormat mixFormat = new AudioFormat.Builder(mix.getFormat()).setChannelMask(AudioFormat.inChannelMaskFromOutChannelMask(mix.getFormat().getChannelMask())).build();
    // create the AudioRecord, configured for loop back, using the same format as the mix
    AudioRecord ar = new AudioRecord(new AudioAttributes.Builder().setInternalCapturePreset(MediaRecorder.AudioSource.REMOTE_SUBMIX).addTag(addressForTag(mix)).build(), mixFormat, AudioRecord.getMinBufferSize(mix.getFormat().getSampleRate(), // using stereo for buffer size to avoid the current poor support for masks
    AudioFormat.CHANNEL_IN_STEREO, mix.getFormat().getEncoding()), AudioManager.AUDIO_SESSION_ID_GENERATE);
    return ar;
}
Also used : AudioRecord(android.media.AudioRecord) AudioFormat(android.media.AudioFormat) SystemApi(android.annotation.SystemApi)

Example 38 with SystemApi

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

the class AudioPolicy method createAudioTrackSource.

/**
     * Create an {@link AudioTrack} instance that is associated with the given {@link AudioMix}.
     * Audio buffers played through the created instance will be sent to the given mix
     * to be recorded through the recording APIs.
     * @param mix a non-null {@link AudioMix} instance whose routing flags was defined with
     *     {@link AudioMix#ROUTE_FLAG_LOOP_BACK}, previously added to this policy.
     * @return a new {@link AudioTrack} instance whose data format is the one defined in the
     *     {@link AudioMix}, or null if this policy was not successfully registered
     *     with {@link AudioManager#registerAudioPolicy(AudioPolicy)}.
     * @throws IllegalArgumentException
     */
@SystemApi
public AudioTrack createAudioTrackSource(AudioMix mix) throws IllegalArgumentException {
    if (!policyReadyToUse()) {
        Log.e(TAG, "Cannot create AudioTrack source for AudioMix");
        return null;
    }
    checkMixReadyToUse(mix, true);
    // create the AudioTrack, configured for loop back, using the same format as the mix
    AudioTrack at = new AudioTrack(new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_VIRTUAL_SOURCE).addTag(addressForTag(mix)).build(), mix.getFormat(), AudioTrack.getMinBufferSize(mix.getFormat().getSampleRate(), mix.getFormat().getChannelMask(), mix.getFormat().getEncoding()), AudioTrack.MODE_STREAM, AudioManager.AUDIO_SESSION_ID_GENERATE);
    return at;
}
Also used : AudioTrack(android.media.AudioTrack) SystemApi(android.annotation.SystemApi)

Example 39 with SystemApi

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

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

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

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)

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