Fix a bunch of misc analysis warnings

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=209758330
This commit is contained in:
olly 2018-08-22 06:53:11 -07:00 committed by Oliver Woodman
parent 9ccbb5bd6d
commit 9f0303b079
17 changed files with 35 additions and 40 deletions

View File

@ -39,7 +39,7 @@ class CombinedJavadocPlugin implements Plugin<Project> {
libraryModules.each { libraryModule -> libraryModules.each { libraryModule ->
libraryModule.android.libraryVariants.all { variant -> libraryModule.android.libraryVariants.all { variant ->
def name = variant.buildType.name def name = variant.buildType.name
if (name.equals("release")) { if (name == "release") {
classpath += classpath +=
libraryModule.project.files( libraryModule.project.files(
variant.javaCompile.classpath.files, variant.javaCompile.classpath.files,
@ -63,7 +63,7 @@ class CombinedJavadocPlugin implements Plugin<Project> {
} }
// Returns Android library modules that declare a generateJavadoc task. // Returns Android library modules that declare a generateJavadoc task.
private Set<Project> getLibraryModules(Project project) { private static Set<Project> getLibraryModules(Project project) {
project.subprojects.findAll { project.subprojects.findAll {
it.plugins.findPlugin("com.android.library") && it.plugins.findPlugin("com.android.library") &&
it.tasks.findByName("generateJavadoc") it.tasks.findByName("generateJavadoc")

View File

@ -418,6 +418,7 @@ public final class C {
/** Indicates that a buffer is (at least partially) encrypted. */ /** Indicates that a buffer is (at least partially) encrypted. */
public static final int BUFFER_FLAG_ENCRYPTED = 1 << 30; // 0x40000000 public static final int BUFFER_FLAG_ENCRYPTED = 1 << 30; // 0x40000000
/** Indicates that a buffer should be decoded but not rendered. */ /** Indicates that a buffer should be decoded but not rendered. */
@SuppressWarnings("NumericOverflow")
public static final int BUFFER_FLAG_DECODE_ONLY = 1 << 31; // 0x80000000 public static final int BUFFER_FLAG_DECODE_ONLY = 1 << 31; // 0x80000000
/** /**

View File

@ -424,12 +424,10 @@ public interface Player {
*/ */
int STATE_ENDED = 4; int STATE_ENDED = 4;
/** /** Repeat modes for playback. */
* Repeat modes for playback.
*/
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@IntDef({REPEAT_MODE_OFF, REPEAT_MODE_ONE, REPEAT_MODE_ALL}) @IntDef({REPEAT_MODE_OFF, REPEAT_MODE_ONE, REPEAT_MODE_ALL})
public @interface RepeatMode {} @interface RepeatMode {}
/** /**
* Normal playback without repetition. * Normal playback without repetition.
*/ */
@ -452,7 +450,7 @@ public interface Player {
DISCONTINUITY_REASON_AD_INSERTION, DISCONTINUITY_REASON_AD_INSERTION,
DISCONTINUITY_REASON_INTERNAL DISCONTINUITY_REASON_INTERNAL
}) })
public @interface DiscontinuityReason {} @interface DiscontinuityReason {}
/** /**
* Automatic playback transition from one period in the timeline to the next. The period index may * Automatic playback transition from one period in the timeline to the next. The period index may
* be the same as it was before the discontinuity in case the current period is repeated. * be the same as it was before the discontinuity in case the current period is repeated.
@ -470,13 +468,14 @@ public interface Player {
/** Discontinuity introduced internally by the source. */ /** Discontinuity introduced internally by the source. */
int DISCONTINUITY_REASON_INTERNAL = 4; int DISCONTINUITY_REASON_INTERNAL = 4;
/** /** Reasons for timeline and/or manifest changes. */
* Reasons for timeline and/or manifest changes.
*/
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@IntDef({TIMELINE_CHANGE_REASON_PREPARED, TIMELINE_CHANGE_REASON_RESET, @IntDef({
TIMELINE_CHANGE_REASON_DYNAMIC}) TIMELINE_CHANGE_REASON_PREPARED,
public @interface TimelineChangeReason {} TIMELINE_CHANGE_REASON_RESET,
TIMELINE_CHANGE_REASON_DYNAMIC
})
@interface TimelineChangeReason {}
/** /**
* Timeline and manifest changed as a result of a player initialization with new media. * Timeline and manifest changed as a result of a player initialization with new media.
*/ */

View File

@ -231,7 +231,7 @@ public final class PlayerMessage {
* Player.EventListener#onPlayerError(ExoPlaybackException)}. * Player.EventListener#onPlayerError(ExoPlaybackException)}.
* *
* @return This message. * @return This message.
* @throws IllegalStateException If {@link #send()} has already been called. * @throws IllegalStateException If this message has already been sent.
*/ */
public PlayerMessage send() { public PlayerMessage send() {
Assertions.checkState(!isSent); Assertions.checkState(!isSent);

View File

@ -202,7 +202,7 @@ public interface Renderer extends PlayerMessage.Target {
* @param operatingRate The operating rate. * @param operatingRate The operating rate.
* @throws ExoPlaybackException If an error occurs handling the operating rate. * @throws ExoPlaybackException If an error occurs handling the operating rate.
*/ */
default void setOperatingRate(float operatingRate) throws ExoPlaybackException {}; default void setOperatingRate(float operatingRate) throws ExoPlaybackException {}
/** /**
* Incrementally renders the {@link SampleStream}. * Incrementally renders the {@link SampleStream}.

View File

@ -39,12 +39,10 @@ public interface DrmSession<T extends ExoMediaCrypto> {
} }
/** /** The state of the DRM session. */
* The state of the DRM session.
*/
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@IntDef({STATE_RELEASED, STATE_ERROR, STATE_OPENING, STATE_OPENED, STATE_OPENED_WITH_KEYS}) @IntDef({STATE_RELEASED, STATE_ERROR, STATE_OPENING, STATE_OPENED, STATE_OPENED_WITH_KEYS})
public @interface State {} @interface State {}
/** /**
* The session has been released. * The session has been released.
*/ */

View File

@ -81,7 +81,6 @@ public final class AdtsReader implements ElementaryStreamReader {
private int firstFrameSampleRateIndex; private int firstFrameSampleRateIndex;
private int currentFrameVersion; private int currentFrameVersion;
private int currentFrameSampleRateIndex;
// Used when parsing the header. // Used when parsing the header.
private boolean hasOutputFormat; private boolean hasOutputFormat;
@ -327,7 +326,7 @@ public final class AdtsReader implements ElementaryStreamReader {
adtsScratch.data[0] = buffer.data[buffer.getPosition()]; adtsScratch.data[0] = buffer.data[buffer.getPosition()];
adtsScratch.setPosition(2); adtsScratch.setPosition(2);
currentFrameSampleRateIndex = adtsScratch.readBits(4); int currentFrameSampleRateIndex = adtsScratch.readBits(4);
if (firstFrameSampleRateIndex != C.INDEX_UNSET if (firstFrameSampleRateIndex != C.INDEX_UNSET
&& currentFrameSampleRateIndex != firstFrameSampleRateIndex) { && currentFrameSampleRateIndex != firstFrameSampleRateIndex) {
// Invalid header. // Invalid header.

View File

@ -56,8 +56,8 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
private static final int FONT_FACE_ITALIC = 0x0002; private static final int FONT_FACE_ITALIC = 0x0002;
private static final int FONT_FACE_UNDERLINE = 0x0004; private static final int FONT_FACE_UNDERLINE = 0x0004;
private static final int SPAN_PRIORITY_LOW = (0xFF << Spanned.SPAN_PRIORITY_SHIFT); private static final int SPAN_PRIORITY_LOW = 0xFF << Spanned.SPAN_PRIORITY_SHIFT;
private static final int SPAN_PRIORITY_HIGH = (0x00 << Spanned.SPAN_PRIORITY_SHIFT); private static final int SPAN_PRIORITY_HIGH = 0;
private static final int DEFAULT_FONT_FACE = 0; private static final int DEFAULT_FONT_FACE = 0;
private static final int DEFAULT_COLOR = Color.WHITE; private static final int DEFAULT_COLOR = Color.WHITE;

View File

@ -191,7 +191,7 @@ public final class SimpleCache implements Cache {
Assertions.checkState(!released); Assertions.checkState(!released);
CachedContent cachedContent = index.get(key); CachedContent cachedContent = index.get(key);
return cachedContent == null || cachedContent.isEmpty() return cachedContent == null || cachedContent.isEmpty()
? new TreeSet<CacheSpan>() ? new TreeSet<>()
: new TreeSet<CacheSpan>(cachedContent.getSpans()); : new TreeSet<CacheSpan>(cachedContent.getSpans());
} }

View File

@ -401,8 +401,8 @@ public final class SilenceSkippingAudioProcessorTest {
public void appendFrames(int count, short... channelLevels) { public void appendFrames(int count, short... channelLevels) {
Assertions.checkState(!built); Assertions.checkState(!built);
for (int i = 0; i < count; i += channelCount) { for (int i = 0; i < count; i += channelCount) {
for (int j = 0; j < channelLevels.length; j++) { for (short channelLevel : channelLevels) {
buffer.put(channelLevels[j]); buffer.put(channelLevel);
} }
} }
} }

View File

@ -95,15 +95,15 @@ public class MergingMediaSourceTest {
for (int i = 0; i < timelines.length; i++) { for (int i = 0; i < timelines.length; i++) {
mediaSources[i] = new FakeMediaSource(timelines[i], null); mediaSources[i] = new FakeMediaSource(timelines[i], null);
} }
MergingMediaSource mediaSource = new MergingMediaSource(mediaSources); MergingMediaSource mergingMediaSource = new MergingMediaSource(mediaSources);
MediaSourceTestRunner testRunner = new MediaSourceTestRunner(mediaSource, null); MediaSourceTestRunner testRunner = new MediaSourceTestRunner(mergingMediaSource, null);
try { try {
Timeline timeline = testRunner.prepareSource(); Timeline timeline = testRunner.prepareSource();
// The merged timeline should always be the one from the first child. // The merged timeline should always be the one from the first child.
assertThat(timeline).isEqualTo(timelines[0]); assertThat(timeline).isEqualTo(timelines[0]);
testRunner.releaseSource(); testRunner.releaseSource();
for (int i = 0; i < mediaSources.length; i++) { for (FakeMediaSource mediaSource : mediaSources) {
mediaSources[i].assertReleased(); mediaSource.assertReleased();
} }
} finally { } finally {
testRunner.release(); testRunner.release();

View File

@ -61,8 +61,7 @@ public final class CachedRegionTrackerTest {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
when(cache.addListener(anyString(), any(Cache.Listener.class))) when(cache.addListener(anyString(), any(Cache.Listener.class))).thenReturn(new TreeSet<>());
.thenReturn(new TreeSet<CacheSpan>());
tracker = new CachedRegionTracker(cache, CACHE_KEY, CHUNK_INDEX); tracker = new CachedRegionTracker(cache, CACHE_KEY, CHUNK_INDEX);
cacheDir = Util.createTempDirectory(RuntimeEnvironment.application, "ExoPlayerTest"); cacheDir = Util.createTempDirectory(RuntimeEnvironment.application, "ExoPlayerTest");
index = new CachedContentIndex(cacheDir); index = new CachedContentIndex(cacheDir);

View File

@ -191,8 +191,7 @@ public class HlsDownloaderTest {
private static ArrayList<StreamKey> getKeys(int... variantIndices) { private static ArrayList<StreamKey> getKeys(int... variantIndices) {
ArrayList<StreamKey> streamKeys = new ArrayList<>(); ArrayList<StreamKey> streamKeys = new ArrayList<>();
for (int variantIndex : variantIndices) { for (int variantIndex : variantIndices) {
final int trackIndex = variantIndex; streamKeys.add(new StreamKey(HlsMasterPlaylist.GROUP_INDEX_VARIANT, variantIndex));
streamKeys.add(new StreamKey(HlsMasterPlaylist.GROUP_INDEX_VARIANT, trackIndex));
} }
return streamKeys; return streamKeys;
} }

View File

@ -213,7 +213,7 @@ public class SsManifestParser implements ParsingLoadable.Parser<SsManifest> {
/** /**
* @param xmlParser The underlying {@link XmlPullParser} * @param xmlParser The underlying {@link XmlPullParser}
* @throws ParserException * @throws ParserException If a parsing error occurs.
*/ */
protected void parseStartTag(XmlPullParser xmlParser) throws ParserException { protected void parseStartTag(XmlPullParser xmlParser) throws ParserException {
// Do nothing. // Do nothing.

View File

@ -64,9 +64,7 @@ public class SsManifestTest {
SsManifest sourceManifest = SsManifest sourceManifest =
newSsManifest(newStreamElement("1", formats[0]), newStreamElement("2", formats[1])); newSsManifest(newStreamElement("1", formats[0]), newStreamElement("2", formats[1]));
List<StreamKey> keys = Arrays.asList(new StreamKey(1, 0)); List<StreamKey> keys = Collections.singletonList(new StreamKey(1, 0));
// Keys don't need to be in any particular order
Collections.shuffle(keys, new Random(0));
SsManifest copyManifest = sourceManifest.copy(keys); SsManifest copyManifest = sourceManifest.copy(keys);

View File

@ -14,12 +14,14 @@
limitations under the License. limitations under the License.
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:layoutDirection="ltr" android:layoutDirection="ltr"
android:background="#CC000000" android:background="#CC000000"
android:orientation="vertical"> android:orientation="vertical"
tools:targetApi="28">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -95,7 +95,7 @@ public final class TestDownloadManagerListener implements DownloadManager.Listen
private ArrayBlockingQueue<Integer> getStateQueue(DownloadAction action) { private ArrayBlockingQueue<Integer> getStateQueue(DownloadAction action) {
synchronized (actionStates) { synchronized (actionStates) {
if (!actionStates.containsKey(action)) { if (!actionStates.containsKey(action)) {
actionStates.put(action, new ArrayBlockingQueue<Integer>(10)); actionStates.put(action, new ArrayBlockingQueue<>(10));
} }
return actionStates.get(action); return actionStates.get(action);
} }