Search in sources :

Example 16 with VisibleForTesting

use of androidx.annotation.VisibleForTesting in project ExoPlayer by google.

the class MappingTrackSelector method buildTracksInfo.

@VisibleForTesting
static /* package */
TracksInfo buildTracksInfo(@NullableType TrackSelection[] selections, MappedTrackInfo mappedTrackInfo) {
    ImmutableList.Builder<TracksInfo.TrackGroupInfo> builder = new ImmutableList.Builder<>();
    for (int rendererIndex = 0; rendererIndex < mappedTrackInfo.getRendererCount(); rendererIndex++) {
        TrackGroupArray trackGroupArray = mappedTrackInfo.getTrackGroups(rendererIndex);
        @Nullable TrackSelection trackSelection = selections[rendererIndex];
        for (int groupIndex = 0; groupIndex < trackGroupArray.length; groupIndex++) {
            TrackGroup trackGroup = trackGroupArray.get(groupIndex);
            @C.FormatSupport int[] trackSupport = new int[trackGroup.length];
            boolean[] selected = new boolean[trackGroup.length];
            for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
                trackSupport[trackIndex] = mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex);
                boolean isTrackSelected = trackSelection != null && trackSelection.getTrackGroup().equals(trackGroup) && trackSelection.indexOf(trackIndex) != C.INDEX_UNSET;
                selected[trackIndex] = isTrackSelected;
            }
            @C.TrackType int trackGroupType = mappedTrackInfo.getRendererType(rendererIndex);
            builder.add(new TracksInfo.TrackGroupInfo(trackGroup, trackSupport, trackGroupType, selected));
        }
    }
    TrackGroupArray unmappedTrackGroups = mappedTrackInfo.getUnmappedTrackGroups();
    for (int groupIndex = 0; groupIndex < unmappedTrackGroups.length; groupIndex++) {
        TrackGroup trackGroup = unmappedTrackGroups.get(groupIndex);
        @C.FormatSupport int[] trackSupport = new int[trackGroup.length];
        Arrays.fill(trackSupport, C.FORMAT_UNSUPPORTED_TYPE);
        // A track group only contains tracks of the same type, thus only consider the first track.
        @C.TrackType int trackGroupType = MimeTypes.getTrackType(trackGroup.getFormat(0).sampleMimeType);
        // Initialized to false.
        boolean[] selected = new boolean[trackGroup.length];
        builder.add(new TracksInfo.TrackGroupInfo(trackGroup, trackSupport, trackGroupType, selected));
    }
    return new TracksInfo(builder.build());
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) TracksInfo(com.google.android.exoplayer2.TracksInfo) FormatSupport(com.google.android.exoplayer2.C.FormatSupport) TrackGroup(com.google.android.exoplayer2.source.TrackGroup) Nullable(androidx.annotation.Nullable) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 17 with VisibleForTesting

use of androidx.annotation.VisibleForTesting in project ExoPlayer by google.

the class RtspTrackTiming method resolveUri.

/**
 * Resolves the input string to always be an absolute URL with RTP-Info headers
 *
 * <p>Handles some servers do not send absolute URL in RTP-Info headers. This method takes in
 * RTP-Info header's url string, and returns the correctly formatted {@link Uri url} for this
 * track. The input url string could be
 *
 * <ul>
 *   <li>A correctly formatted URL, like "{@code rtsp://foo.bar/video}".
 *   <li>A correct URI that is missing the scheme, like "{@code foo.bar/video}".
 *   <li>A path to the resource, like "{@code video}" or "{@code /video}".
 * </ul>
 *
 * @param urlString The URL included in the RTP-Info header, without the {@code url=} identifier.
 * @param sessionUri The session URI, must include an {@code rtsp} scheme, or {@link
 *     IllegalArgumentException} is thrown.
 * @return The formatted URL.
 */
@VisibleForTesting
static /* package */
Uri resolveUri(String urlString, Uri sessionUri) {
    checkArgument(checkNotNull(sessionUri.getScheme()).equals("rtsp"));
    Uri uri = Uri.parse(urlString);
    if (uri.isAbsolute()) {
        return uri;
    }
    // The urlString is at least missing the scheme.
    uri = Uri.parse("rtsp://" + urlString);
    String sessionUriString = sessionUri.toString();
    String host = checkNotNull(uri.getHost());
    if (host.equals(sessionUri.getHost())) {
        // Handles the case that the urlString is only missing the scheme.
        return uri;
    }
    return sessionUriString.endsWith("/") ? UriUtil.resolveToUri(sessionUriString, urlString) : UriUtil.resolveToUri(sessionUriString + "/", urlString);
}
Also used : Uri(android.net.Uri) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 18 with VisibleForTesting

use of androidx.annotation.VisibleForTesting in project ExoPlayer by google.

the class CachedContentIndex method getNewId.

/**
 * Returns an id which isn't used in the given array. If the maximum id in the array is smaller
 * than {@link java.lang.Integer#MAX_VALUE} it just returns the next bigger integer. Otherwise it
 * returns the smallest unused non-negative integer.
 */
@VisibleForTesting
static /* package */
int getNewId(SparseArray<@NullableType String> idToKey) {
    int size = idToKey.size();
    int id = size == 0 ? 0 : (idToKey.keyAt(size - 1) + 1);
    if (id < 0) {
        // TODO optimization: defragmentation or binary search?
        for (id = 0; id < size; id++) {
            if (id != idToKey.keyAt(id)) {
                break;
            }
        }
    }
    return id;
}
Also used : SuppressLint(android.annotation.SuppressLint) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 19 with VisibleForTesting

use of androidx.annotation.VisibleForTesting in project android-priority-jobqueue by yigit.

the class FrameworkScheduler method toPersistentBundle.

@VisibleForTesting
static PersistableBundle toPersistentBundle(SchedulerConstraint constraint) {
    PersistableBundle bundle = new PersistableBundle();
    // put boolean is api 22
    bundle.putString(KEY_UUID, constraint.getUuid());
    bundle.putInt(KEY_NETWORK_STATUS, constraint.getNetworkStatus());
    bundle.putLong(KEY_DELAY, constraint.getDelayInMs());
    Long deadline = constraint.getOverrideDeadlineInMs();
    if (deadline != null) {
        bundle.putLong(KEY_DEADLINE, deadline);
    }
    return bundle;
}
Also used : PersistableBundle(android.os.PersistableBundle) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 20 with VisibleForTesting

use of androidx.annotation.VisibleForTesting in project Signal-Android by WhisperSystems.

the class AttachmentDatabase method getDataStream.

@SuppressWarnings("WeakerAccess")
@VisibleForTesting
@Nullable
protected InputStream getDataStream(AttachmentId attachmentId, String dataType, long offset) {
    DataInfo dataInfo = getAttachmentDataFileInfo(attachmentId, dataType);
    if (dataInfo == null) {
        return null;
    }
    try {
        if (dataInfo.random != null && dataInfo.random.length == 32) {
            return ModernDecryptingPartInputStream.createFor(attachmentSecret, dataInfo.random, dataInfo.file, offset);
        } else {
            InputStream stream = ClassicDecryptingPartInputStream.createFor(attachmentSecret, dataInfo.file);
            long skipped = stream.skip(offset);
            if (skipped != offset) {
                Log.w(TAG, "Skip failed: " + skipped + " vs " + offset);
                return null;
            }
            return stream;
        }
    } catch (IOException e) {
        Log.w(TAG, e);
        return null;
    }
}
Also used : ModernDecryptingPartInputStream(org.thoughtcrime.securesms.crypto.ModernDecryptingPartInputStream) ClassicDecryptingPartInputStream(org.thoughtcrime.securesms.crypto.ClassicDecryptingPartInputStream) DigestInputStream(java.security.DigestInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) VisibleForTesting(androidx.annotation.VisibleForTesting) Nullable(androidx.annotation.Nullable)

Aggregations

VisibleForTesting (androidx.annotation.VisibleForTesting)385 Intent (android.content.Intent)36 ArrayList (java.util.ArrayList)36 Context (android.content.Context)34 Bundle (android.os.Bundle)30 Uri (android.net.Uri)18 View (android.view.View)18 Preference (androidx.preference.Preference)18 TextView (android.widget.TextView)16 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)16 MetricsFeatureProvider (com.android.settingslib.core.instrumentation.MetricsFeatureProvider)16 SuppressLint (android.annotation.SuppressLint)15 Activity (android.app.Activity)14 RemoteException (android.os.RemoteException)14 SubscriptionInfo (android.telephony.SubscriptionInfo)12 ImageView (android.widget.ImageView)12 BluetoothDevice (android.bluetooth.BluetoothDevice)11 ComponentName (android.content.ComponentName)11 Drawable (android.graphics.drawable.Drawable)11 SharedPreferences (android.content.SharedPreferences)10