Fix/suppress some analysis warnings.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=136710546
This commit is contained in:
andrewlewis 2016-10-20 07:08:38 -07:00 committed by Oliver Woodman
parent 862552c2ed
commit a0fe258e8d
23 changed files with 87 additions and 70 deletions

View File

@ -37,7 +37,7 @@ android {
dependencies {
compile project(':library')
compile('com.squareup.okhttp3:okhttp:+') {
compile('com.squareup.okhttp3:okhttp:3.4.1') {
exclude group: 'org.json'
}
}

View File

@ -73,10 +73,13 @@ import javax.microedition.khronos.opengles.GL10;
private final int[] yuvTextures = new int[3];
private final AtomicReference<VpxOutputBuffer> pendingOutputBufferReference;
// Kept in a field rather than a local variable so that it doesn't get garbage collected before
// glDrawArrays uses it.
@SuppressWarnings("FieldCanBeLocal")
private FloatBuffer textureCoords;
private int program;
private int texLocation;
private int colorMatrixLocation;
private FloatBuffer textureCoords;
private int previousWidth;
private int previousStride;

View File

@ -55,7 +55,7 @@ dependencies {
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
androidTestCompile 'org.mockito:mockito-core:1.9.5'
compile 'com.android.support:support-annotations:24.2.0'
compile 'com.android.support:support-annotations:24.2.1'
}
android.libraryVariants.all { variant ->

View File

@ -249,6 +249,7 @@ import java.io.IOException;
// Handler.Callback implementation.
@SuppressWarnings("unchecked")
@Override
public boolean handleMessage(Message msg) {
try {
@ -335,8 +336,7 @@ import java.io.IOException;
}
}
private void prepareInternal(MediaSource mediaSource, boolean resetPosition)
throws ExoPlaybackException {
private void prepareInternal(MediaSource mediaSource, boolean resetPosition) {
resetInternal();
loadControl.onPrepared();
if (resetPosition) {
@ -884,8 +884,7 @@ import java.io.IOException;
}
}
private void attemptRestart(Timeline newTimeline, Timeline oldTimeline,
int oldPeriodIndex) throws ExoPlaybackException {
private void attemptRestart(Timeline newTimeline, Timeline oldTimeline, int oldPeriodIndex) {
int newPeriodIndex = C.INDEX_UNSET;
while (newPeriodIndex == C.INDEX_UNSET
&& oldPeriodIndex < oldTimeline.getPeriodCount() - 1) {
@ -1260,7 +1259,7 @@ import java.io.IOException;
}
public long updatePeriodTrackSelection(long positionUs, LoadControl loadControl,
boolean forceRecreateStreams, boolean[] streamResetFlags) throws ExoPlaybackException {
boolean forceRecreateStreams, boolean[] streamResetFlags) {
for (int i = 0; i < trackSelections.length; i++) {
mayRetainStreamFlags[i] = !forceRecreateStreams
&& Util.areEqual(periodTrackSelections == null ? null : periodTrackSelections.get(i),

View File

@ -23,6 +23,7 @@ import android.os.ConditionVariable;
import android.os.SystemClock;
import android.util.Log;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util;
@ -981,6 +982,9 @@ public final class AudioTrack {
case C.ENCODING_PCM_32BIT:
resampledSize = size / 2;
break;
case C.ENCODING_PCM_16BIT:
case C.ENCODING_INVALID:
case Format.NO_VALUE:
default:
// Never happens.
throw new IllegalStateException();
@ -1016,6 +1020,9 @@ public final class AudioTrack {
resampledBuffer.put(buffer.get(i + 3));
}
break;
case C.ENCODING_PCM_16BIT:
case C.ENCODING_INVALID:
case Format.NO_VALUE:
default:
// Never happens.
throw new IllegalStateException();

View File

@ -76,7 +76,8 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
* has obtained the keys necessary to decrypt encrypted regions of the media.
*/
public MediaCodecAudioRenderer(MediaCodecSelector mediaCodecSelector,
DrmSessionManager drmSessionManager, boolean playClearSamplesWithoutKeys) {
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
boolean playClearSamplesWithoutKeys) {
this(mediaCodecSelector, drmSessionManager, playClearSamplesWithoutKeys, null, null);
}

View File

@ -40,7 +40,7 @@ import java.io.IOException;
}
/**
* @see Extractor#sniff
* @see com.google.android.exoplayer2.extractor.Extractor#sniff(ExtractorInput)
*/
public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
long inputLength = input.getLength();

View File

@ -26,7 +26,7 @@ import com.google.android.exoplayer2.util.Assertions;
/* package */ final class VorbisBitArray {
public final byte[] data;
private int limit;
private final int limit;
private int byteOffset;
private int bitOffset;

View File

@ -47,7 +47,6 @@ public final class RawCcExtractor implements Extractor {
private final ParsableByteArray dataScratch;
private ExtractorOutput extractorOutput;
private TrackOutput trackOutput;
private int parserState;
@ -63,10 +62,9 @@ public final class RawCcExtractor implements Extractor {
@Override
public void init(ExtractorOutput output) {
this.extractorOutput = output;
extractorOutput.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
trackOutput = extractorOutput.track(0);
extractorOutput.endTracks();
output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
trackOutput = output.track(0);
output.endTracks();
trackOutput.format(Format.createTextSampleFormat(null, MimeTypes.APPLICATION_CEA608,
null, Format.NO_VALUE, 0, null, null));

View File

@ -23,6 +23,7 @@ import android.media.MediaCodecList;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
import android.util.SparseIntArray;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util;
import java.util.ArrayList;
@ -63,8 +64,8 @@ public final class MediaCodecUtil {
// Codecs to constant mappings.
// AVC.
private static final Map<Integer, Integer> AVC_PROFILE_NUMBER_TO_CONST;
private static final Map<Integer, Integer> AVC_LEVEL_NUMBER_TO_CONST;
private static final SparseIntArray AVC_PROFILE_NUMBER_TO_CONST;
private static final SparseIntArray AVC_LEVEL_NUMBER_TO_CONST;
private static final String CODEC_ID_AVC1 = "avc1";
private static final String CODEC_ID_AVC2 = "avc2";
// HEVC.
@ -364,8 +365,8 @@ public final class MediaCodecUtil {
Log.w(TAG, "Ignoring malformed AVC codec string: " + codec);
return null;
}
Integer profileInteger = null;
Integer levelInteger = null;
Integer profileInteger;
Integer levelInteger;
try {
if (codecsParts[1].length() == 6) {
// Format: avc1.xxccyy, where xx is profile and yy level, both hexadecimal.
@ -555,13 +556,13 @@ public final class MediaCodecUtil {
}
static {
AVC_PROFILE_NUMBER_TO_CONST = new HashMap<>();
AVC_PROFILE_NUMBER_TO_CONST = new SparseIntArray();
AVC_PROFILE_NUMBER_TO_CONST.put(66, CodecProfileLevel.AVCProfileBaseline);
AVC_PROFILE_NUMBER_TO_CONST.put(77, CodecProfileLevel.AVCProfileMain);
AVC_PROFILE_NUMBER_TO_CONST.put(88, CodecProfileLevel.AVCProfileExtended);
AVC_PROFILE_NUMBER_TO_CONST.put(100, CodecProfileLevel.AVCProfileHigh);
AVC_LEVEL_NUMBER_TO_CONST = new HashMap<>();
AVC_LEVEL_NUMBER_TO_CONST = new SparseIntArray();
AVC_LEVEL_NUMBER_TO_CONST.put(10, CodecProfileLevel.AVCLevel1);
// TODO: Find int for CodecProfileLevel.AVCLevel1b.
AVC_LEVEL_NUMBER_TO_CONST.put(11, CodecProfileLevel.AVCLevel11);

View File

@ -15,7 +15,6 @@
*/
package com.google.android.exoplayer2.metadata.id3;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.metadata.MetadataDecoder;
import com.google.android.exoplayer2.metadata.MetadataDecoderException;
import com.google.android.exoplayer2.util.MimeTypes;
@ -124,7 +123,7 @@ public final class Id3Decoder implements MetadataDecoder<List<Id3Frame>> {
/**
* @param id3Buffer A {@link ParsableByteArray} from which data should be read.
* @return The size of ID3 frames in bytes, excluding the header and footer.
* @throws ParserException If ID3 file identifier != "ID3".
* @throws MetadataDecoderException If ID3 file identifier != "ID3".
*/
private static int decodeId3Header(ParsableByteArray id3Buffer) throws MetadataDecoderException {
int id1 = id3Buffer.readUnsignedByte();

View File

@ -149,9 +149,9 @@ import java.util.IdentityHashMap;
}
// It must be possible to seek enabled periods to the new position, if there is one.
if (positionUs != C.TIME_UNSET) {
for (int i = 0; i < enabledPeriods.length; i++) {
if (enabledPeriods[i] != periods[0]
&& enabledPeriods[i].seekToUs(positionUs) != positionUs) {
for (MediaPeriod enabledPeriod : enabledPeriods) {
if (enabledPeriod != periods[0]
&& enabledPeriod.seekToUs(positionUs) != positionUs) {
throw new IllegalStateException("Children seeked to different positions");
}
}

View File

@ -69,7 +69,6 @@ import java.util.List;
private int pendingPrepareCount;
private HlsPlaylist playlist;
private boolean seenFirstTrackSelection;
private long durationUs;
private boolean isLive;
private TrackGroupArray trackGroups;
private HlsSampleStreamWrapper[] sampleStreamWrappers;
@ -280,7 +279,7 @@ import java.util.List;
}
// The wrapper at index 0 is the one of type TRACK_TYPE_DEFAULT.
durationUs = sampleStreamWrappers[0].getDurationUs();
long durationUs = sampleStreamWrappers[0].getDurationUs();
isLive = sampleStreamWrappers[0].isLive();
int totalTrackGroupCount = 0;

View File

@ -20,7 +20,7 @@ package com.google.android.exoplayer2.text;
*/
/* package */ final class SimpleSubtitleOutputBuffer extends SubtitleOutputBuffer {
private SimpleSubtitleDecoder owner;
private final SimpleSubtitleDecoder owner;
/**
* @param owner The decoder that owns this buffer.

View File

@ -28,6 +28,7 @@ import com.google.android.exoplayer2.util.ParsableByteArray;
public final class Cea608Decoder extends CeaDecoder {
private static final int NTSC_CC_FIELD_1 = 0x00;
private static final int CC_TYPE_MASK = 0x03;
private static final int CC_VALID_FLAG = 0x04;
private static final int PAYLOAD_TYPE_CC = 4;
@ -223,7 +224,8 @@ public final class Cea608Decoder extends CeaDecoder {
byte ccData2 = (byte) (ccData.readUnsignedByte() & 0x7F);
// Only examine valid NTSC_CC_FIELD_1 packets
if (ccTypeAndValid != (CC_VALID_FLAG | NTSC_CC_FIELD_1)) {
if ((ccTypeAndValid & CC_VALID_FLAG) == 0
|| (ccTypeAndValid & CC_TYPE_MASK) != NTSC_CC_FIELD_1) {
// TODO: Add support for NTSC_CC_FIELD_2 packets
continue;
}

View File

@ -92,21 +92,22 @@ import java.util.Map;
builder.setSpan(new AlignmentSpan.Standard(style.getTextAlign()), start, end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (style.getFontSizeUnit() != TtmlStyle.UNSPECIFIED) {
switch (style.getFontSizeUnit()) {
case TtmlStyle.FONT_SIZE_UNIT_PIXEL:
builder.setSpan(new AbsoluteSizeSpan((int) style.getFontSize(), true), start, end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
case TtmlStyle.FONT_SIZE_UNIT_EM:
builder.setSpan(new RelativeSizeSpan(style.getFontSize()), start, end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
case TtmlStyle.FONT_SIZE_UNIT_PERCENT:
builder.setSpan(new RelativeSizeSpan(style.getFontSize() / 100), start, end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
}
switch (style.getFontSizeUnit()) {
case TtmlStyle.FONT_SIZE_UNIT_PIXEL:
builder.setSpan(new AbsoluteSizeSpan((int) style.getFontSize(), true), start, end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
case TtmlStyle.FONT_SIZE_UNIT_EM:
builder.setSpan(new RelativeSizeSpan(style.getFontSize()), start, end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
case TtmlStyle.FONT_SIZE_UNIT_PERCENT:
builder.setSpan(new RelativeSizeSpan(style.getFontSize() / 100), start, end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
case TtmlStyle.UNSPECIFIED:
// Do nothing.
break;
}
}

View File

@ -413,21 +413,22 @@ import java.util.regex.Pattern;
spannedText.setSpan(new AlignmentSpan.Standard(style.getTextAlign()), start, end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (style.getFontSizeUnit() != WebvttCssStyle.UNSPECIFIED) {
switch (style.getFontSizeUnit()) {
case WebvttCssStyle.FONT_SIZE_UNIT_PIXEL:
spannedText.setSpan(new AbsoluteSizeSpan((int) style.getFontSize(), true), start, end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
case WebvttCssStyle.FONT_SIZE_UNIT_EM:
spannedText.setSpan(new RelativeSizeSpan(style.getFontSize()), start, end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
case WebvttCssStyle.FONT_SIZE_UNIT_PERCENT:
spannedText.setSpan(new RelativeSizeSpan(style.getFontSize() / 100), start, end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
}
switch (style.getFontSizeUnit()) {
case WebvttCssStyle.FONT_SIZE_UNIT_PIXEL:
spannedText.setSpan(new AbsoluteSizeSpan((int) style.getFontSize(), true), start, end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
case WebvttCssStyle.FONT_SIZE_UNIT_EM:
spannedText.setSpan(new RelativeSizeSpan(style.getFontSize()), start, end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
case WebvttCssStyle.FONT_SIZE_UNIT_PERCENT:
spannedText.setSpan(new RelativeSizeSpan(style.getFontSize() / 100), start, end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
case WebvttCssStyle.UNSPECIFIED:
// Do nothing.
break;
}
}

View File

@ -70,8 +70,8 @@ public abstract class MappingTrackSelector extends TrackSelector<MappedTrackInfo
* Returns whether this override contains the specified track index.
*/
public boolean containsTrack(int track) {
for (int i = 0; i < tracks.length; i++) {
if (tracks[i] == track) {
for (int overrideTrack : tracks) {
if (overrideTrack == track) {
return true;
}
}

View File

@ -54,7 +54,7 @@ public final class RawResourceDataSource implements DataSource {
* @param rawResourceId A raw resource identifier (i.e. a constant defined in {@code R.raw}).
* @return The corresponding {@link Uri}.
*/
public static final Uri buildRawResourceUri(int rawResourceId) {
public static Uri buildRawResourceUri(int rawResourceId) {
return Uri.parse(RAW_RESOURCE_SCHEME + ":///" + rawResourceId);
}

View File

@ -14,6 +14,7 @@
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
@ -37,6 +38,7 @@
style="@style/ExoMediaButton.Rewind"/>
<ImageButton android:id="@+id/play"
tools:ignore="ContentDescription"
style="@style/ExoMediaButton"/>
<ImageButton android:id="@+id/ffwd"

View File

@ -28,6 +28,7 @@ import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;
import com.google.android.exoplayer2.drm.HttpMediaDrmCallback;
import com.google.android.exoplayer2.drm.StreamingDrmSessionManager;
import com.google.android.exoplayer2.drm.UnsupportedDrmException;
@ -696,8 +697,9 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
@Override
@TargetApi(18)
@SuppressWarnings("ResourceType")
protected final StreamingDrmSessionManager buildDrmSessionManager(final String userAgent) {
StreamingDrmSessionManager drmSessionManager = null;
protected final StreamingDrmSessionManager<FrameworkMediaCrypto> buildDrmSessionManager(
final String userAgent) {
StreamingDrmSessionManager<FrameworkMediaCrypto> drmSessionManager = null;
if (isWidevineEncrypted) {
try {
// Force L3 if secure decoder is not available.

View File

@ -30,6 +30,7 @@ import com.google.android.exoplayer2.audio.AudioRendererEventListener;
import com.google.android.exoplayer2.audio.AudioTrack;
import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;
import com.google.android.exoplayer2.playbacktests.util.HostActivity.HostedTest;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.trackselection.AdaptiveVideoTrackSelection;
@ -130,7 +131,7 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
trackSelector = buildTrackSelector(host, bandwidthMeter);
String userAgent = "ExoPlayerPlaybackTests";
DrmSessionManager drmSessionManager = buildDrmSessionManager(userAgent);
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = buildDrmSessionManager(userAgent);
player = buildExoPlayer(host, surface, trackSelector, drmSessionManager);
player.prepare(buildSource(host, Util.getUserAgent(host, userAgent), bandwidthMeter));
player.addListener(this);
@ -296,7 +297,7 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen
// Internal logic
protected DrmSessionManager buildDrmSessionManager(String userAgent) {
protected DrmSessionManager<FrameworkMediaCrypto> buildDrmSessionManager(String userAgent) {
// Do nothing. Interested subclasses may override.
return null;
}
@ -309,7 +310,8 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen
@SuppressWarnings("unused")
protected SimpleExoPlayer buildExoPlayer(HostActivity host, Surface surface,
MappingTrackSelector trackSelector, DrmSessionManager drmSessionManager) {
MappingTrackSelector trackSelector,
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(host, trackSelector,
new DefaultLoadControl(), drmSessionManager, false, 0);
player.setVideoSurface(surface);

View File

@ -232,7 +232,7 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba
}
@SuppressLint("InlinedApi")
private static final int getWifiLockMode() {
private static int getWifiLockMode() {
return Util.SDK_INT < 12 ? WifiManager.WIFI_MODE_FULL : WifiManager.WIFI_MODE_FULL_HIGH_PERF;
}