Commit c4808182 by tonihei Committed by Oliver Woodman

Fix some random AndroidStudio warnings.

PiperOrigin-RevId: 245956915
parent 0bb32a8f
Showing with 83 additions and 124 deletions
......@@ -82,7 +82,6 @@ public class DownloadTracker {
return download != null && download.state != Download.STATE_FAILED;
}
@SuppressWarnings("unchecked")
public DownloadRequest getDownloadRequest(Uri uri) {
Download download = downloads.get(uri);
return download != null && download.state != Download.STATE_FAILED ? download.request : null;
......
......@@ -952,8 +952,7 @@ public final class MediaSessionConnector {
}
if (description.getMediaId() != null) {
builder.putString(
MediaMetadataCompat.METADATA_KEY_MEDIA_ID,
String.valueOf(description.getMediaId()));
MediaMetadataCompat.METADATA_KEY_MEDIA_ID, description.getMediaId());
}
if (description.getMediaUri() != null) {
builder.putString(
......
......@@ -80,7 +80,7 @@ public abstract class TimelineQueueNavigator implements MediaSessionConnector.Qu
* <p>Often artworks and icons need to be loaded asynchronously. In such a case, return a {@link
* MediaDescriptionCompat} without the images, load your images asynchronously off the main thread
* and then call {@link MediaSessionConnector#invalidateMediaSessionQueue()} to make the connector
* update the queue by calling {@link #getMediaDescription(Player, int)} again.
* update the queue by calling this method again.
*
* @param player The current player.
* @param windowIndex The timeline window index for which to provide a description.
......
......@@ -494,7 +494,6 @@ public final class C {
/** Indicates that a buffer is (at least partially) encrypted. */
public static final int BUFFER_FLAG_ENCRYPTED = 1 << 30; // 0x40000000
/** Indicates that a buffer should be decoded but not rendered. */
@SuppressWarnings("NumericOverflow")
public static final int BUFFER_FLAG_DECODE_ONLY = 1 << 31; // 0x80000000
/**
......
......@@ -302,7 +302,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
// Handler.Callback implementation.
@SuppressWarnings("unchecked")
@Override
public boolean handleMessage(Message msg) {
try {
......
......@@ -253,13 +253,11 @@ public final class DefaultPlaybackSessionManager implements PlaybackSessionManag
if (windowIndex == C.INDEX_UNSET) {
return false;
}
if (adMediaPeriodId != null) {
int newPeriodIndex = newTimeline.getIndexOfPeriod(adMediaPeriodId.periodUid);
if (newPeriodIndex == C.INDEX_UNSET) {
return false;
}
if (adMediaPeriodId == null) {
return true;
}
return true;
int newPeriodIndex = newTimeline.getIndexOfPeriod(adMediaPeriodId.periodUid);
return newPeriodIndex != C.INDEX_UNSET;
}
public boolean belongsToSession(
......
......@@ -1218,7 +1218,6 @@ public final class DefaultAudioSink implements AudioSink {
audioTrack.setVolume(volume);
}
@SuppressWarnings("deprecation")
private static void setVolumeInternalV3(AudioTrack audioTrack, float volume) {
audioTrack.setStereoVolume(volume, volume);
}
......
......@@ -500,7 +500,6 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
}
@Override
@SuppressWarnings("unchecked")
public void handleMessage(Message msg) {
Object request = msg.obj;
Object response;
......
......@@ -428,7 +428,6 @@ public final class DrmInitData implements Comparator<SchemeData>, Parcelable {
dest.writeByte((byte) (requiresSecureDecryption ? 1 : 0));
}
@SuppressWarnings("hiding")
public static final Parcelable.Creator<SchemeData> CREATOR =
new Parcelable.Creator<SchemeData>() {
......
......@@ -92,7 +92,7 @@ public final class OfflineLicenseHelper<T extends ExoMediaCrypto> {
* @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
* instantiated.
* @see DefaultDrmSessionManager#DefaultDrmSessionManager(java.util.UUID, ExoMediaDrm,
* MediaDrmCallback, HashMap, Handler, DefaultDrmSessionEventListener)
* MediaDrmCallback, HashMap)
*/
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
String defaultLicenseUrl,
......@@ -115,7 +115,7 @@ public final class OfflineLicenseHelper<T extends ExoMediaCrypto> {
* @param optionalKeyRequestParameters An optional map of parameters to pass as the last argument
* to {@link MediaDrm#getKeyRequest(byte[], byte[], String, int, HashMap)}. May be null.
* @see DefaultDrmSessionManager#DefaultDrmSessionManager(java.util.UUID, ExoMediaDrm,
* MediaDrmCallback, HashMap, Handler, DefaultDrmSessionEventListener)
* MediaDrmCallback, HashMap)
*/
public OfflineLicenseHelper(
UUID uuid,
......
......@@ -218,40 +218,38 @@ import java.util.Arrays;
int mappingsCount = bitArray.readBits(6) + 1;
for (int i = 0; i < mappingsCount; i++) {
int mappingType = bitArray.readBits(16);
switch (mappingType) {
case 0:
int submaps;
if (bitArray.readBit()) {
submaps = bitArray.readBits(4) + 1;
} else {
submaps = 1;
}
int couplingSteps;
if (bitArray.readBit()) {
couplingSteps = bitArray.readBits(8) + 1;
for (int j = 0; j < couplingSteps; j++) {
bitArray.skipBits(iLog(channels - 1)); // magnitude
bitArray.skipBits(iLog(channels - 1)); // angle
}
} /*else {
couplingSteps = 0;
}*/
if (bitArray.readBits(2) != 0x00) {
throw new ParserException("to reserved bits must be zero after mapping coupling steps");
}
if (submaps > 1) {
for (int j = 0; j < channels; j++) {
bitArray.skipBits(4); // mappingMux
}
}
for (int j = 0; j < submaps; j++) {
bitArray.skipBits(8); // discard
bitArray.skipBits(8); // submapFloor
bitArray.skipBits(8); // submapResidue
}
break;
default:
Log.e(TAG, "mapping type other than 0 not supported: " + mappingType);
if (mappingType != 0) {
Log.e(TAG, "mapping type other than 0 not supported: " + mappingType);
continue;
}
int submaps;
if (bitArray.readBit()) {
submaps = bitArray.readBits(4) + 1;
} else {
submaps = 1;
}
int couplingSteps;
if (bitArray.readBit()) {
couplingSteps = bitArray.readBits(8) + 1;
for (int j = 0; j < couplingSteps; j++) {
bitArray.skipBits(iLog(channels - 1)); // magnitude
bitArray.skipBits(iLog(channels - 1)); // angle
}
} /*else {
couplingSteps = 0;
}*/
if (bitArray.readBits(2) != 0x00) {
throw new ParserException("to reserved bits must be zero after mapping coupling steps");
}
if (submaps > 1) {
for (int j = 0; j < channels; j++) {
bitArray.skipBits(4); // mappingMux
}
}
for (int j = 0; j < submaps; j++) {
bitArray.skipBits(8); // discard
bitArray.skipBits(8); // submapFloor
bitArray.skipBits(8); // submapResidue
}
}
}
......
......@@ -827,7 +827,6 @@ public final class MediaCodecUtil {
}
@SuppressWarnings("deprecation")
private static final class MediaCodecListCompatV16 implements MediaCodecListCompat {
@Override
......
......@@ -177,7 +177,6 @@ public final class MetadataRenderer extends BaseRenderer implements Callback {
pendingMetadataCount = 0;
}
@SuppressWarnings("unchecked")
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
......
......@@ -156,10 +156,10 @@ public abstract class MappingTrackSelector extends TrackSelector {
public @RendererSupport int getRendererSupport(int rendererIndex) {
int bestRendererSupport = RENDERER_SUPPORT_NO_TRACKS;
int[][] rendererFormatSupport = rendererFormatSupports[rendererIndex];
for (int i = 0; i < rendererFormatSupport.length; i++) {
for (int j = 0; j < rendererFormatSupport[i].length; j++) {
for (int[] trackGroupFormatSupport : rendererFormatSupport) {
for (int trackFormatSupport : trackGroupFormatSupport) {
int trackRendererSupport;
switch (rendererFormatSupport[i][j] & RendererCapabilities.FORMAT_SUPPORT_MASK) {
switch (trackFormatSupport & RendererCapabilities.FORMAT_SUPPORT_MASK) {
case RendererCapabilities.FORMAT_HANDLED:
return RENDERER_SUPPORT_PLAYABLE_TRACKS;
case RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES:
......
......@@ -342,7 +342,7 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
totalElapsedTimeMs += sampleElapsedTimeMs;
totalBytesTransferred += sampleBytesTransferred;
if (sampleElapsedTimeMs > 0) {
float bitsPerSecond = (sampleBytesTransferred * 8000) / sampleElapsedTimeMs;
float bitsPerSecond = (sampleBytesTransferred * 8000f) / sampleElapsedTimeMs;
slidingPercentile.addSample((int) Math.sqrt(sampleBytesTransferred), bitsPerSecond);
if (totalElapsedTimeMs >= ELAPSED_MILLIS_FOR_ESTIMATE
|| totalBytesTransferred >= BYTES_TRANSFERRED_FOR_ESTIMATE) {
......
......@@ -199,7 +199,6 @@ public final class CacheDataSink implements DataSink {
outputStreamBytesWritten = 0;
}
@SuppressWarnings("ThrowFromFinallyBlock")
private void closeCurrentOutputStream() throws IOException {
if (outputStream == null) {
return;
......
......@@ -94,7 +94,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
@Nullable private Storage previousStorage;
/** Returns whether the file is an index file. */
public static final boolean isIndexFile(String fileName) {
public static boolean isIndexFile(String fileName) {
// Atomic file backups add additional suffixes to the file name.
return fileName.startsWith(FILE_NAME_ATOMIC);
}
......
......@@ -780,7 +780,6 @@ public final class SimpleCache implements Cache {
*
* @param files The files belonging to the root directory.
* @return The loaded UID, or {@link #UID_UNSET} if a UID has not yet been created.
* @throws IOException If there is an error loading or generating the UID.
*/
private static long loadUid(File[] files) {
for (File file : files) {
......
......@@ -198,7 +198,6 @@ public class ActionFileUpgradeUtilTest {
assertThat(download.state).isEqualTo(state);
}
@SuppressWarnings("unchecked")
private static List<StreamKey> asList(StreamKey... streamKeys) {
return Arrays.asList(streamKeys);
}
......
......@@ -763,15 +763,10 @@ public class DownloadManagerTest {
private void block() throws InterruptedException {
try {
while (true) {
try {
blocker.block();
break;
} catch (InterruptedException e) {
interrupted = true;
throw e;
}
}
blocker.block();
} catch (InterruptedException e) {
interrupted = true;
throw e;
} finally {
blocker.close();
}
......
......@@ -266,14 +266,9 @@ public final class AdaptiveTrackSelectionTest {
/* mediaChunkIterators= */ THREE_EMPTY_MEDIA_CHUNK_ITERATORS);
ArgumentMatcher<Format[]> matcher =
new ArgumentMatcher<Format[]>() {
@Override
public boolean matches(Format[] argument) {
Format[] formats = (Format[]) argument;
return formats.length == 3
formats ->
formats.length == 3
&& Arrays.asList(formats).containsAll(Arrays.asList(format1, format2, format3));
}
};
verify(estimator)
.getBitrates(
argThat(matcher),
......
......@@ -401,11 +401,8 @@ public class SimpleCacheTest {
private static void addCache(SimpleCache simpleCache, String key, int position, int length)
throws IOException {
File file = simpleCache.startFile(key, position, length);
FileOutputStream fos = new FileOutputStream(file);
try {
try (FileOutputStream fos = new FileOutputStream(file)) {
fos.write(generateData(key, position, length));
} finally {
fos.close();
}
simpleCache.commitFile(file, length);
}
......@@ -413,11 +410,8 @@ public class SimpleCacheTest {
private static void assertCachedDataReadCorrect(CacheSpan cacheSpan) throws IOException {
assertThat(cacheSpan.isCached).isTrue();
byte[] expected = generateData(cacheSpan.key, (int) cacheSpan.position, (int) cacheSpan.length);
FileInputStream inputStream = new FileInputStream(cacheSpan.file);
try {
try (FileInputStream inputStream = new FileInputStream(cacheSpan.file)) {
assertThat(toByteArray(inputStream)).isEqualTo(expected);
} finally {
inputStream.close();
}
}
......
......@@ -219,9 +219,8 @@ import java.util.regex.Pattern;
int totalTracksInPreviousAdaptationSets = 0;
int tracksInCurrentAdaptationSet =
manifestAdaptationSets.get(adaptationSetIndices[0]).representations.size();
for (int i = 0; i < trackIndices.length; i++) {
while (trackIndices[i]
>= totalTracksInPreviousAdaptationSets + tracksInCurrentAdaptationSet) {
for (int trackIndex : trackIndices) {
while (trackIndex >= totalTracksInPreviousAdaptationSets + tracksInCurrentAdaptationSet) {
currentAdaptationSetIndex++;
totalTracksInPreviousAdaptationSets += tracksInCurrentAdaptationSet;
tracksInCurrentAdaptationSet =
......@@ -234,7 +233,7 @@ import java.util.regex.Pattern;
new StreamKey(
periodIndex,
adaptationSetIndices[currentAdaptationSetIndex],
trackIndices[i] - totalTracksInPreviousAdaptationSets));
trackIndex - totalTracksInPreviousAdaptationSets));
}
}
return streamKeys;
......@@ -515,10 +514,9 @@ import java.util.regex.Pattern;
int[] adaptationSetIndices = new int[1 + extraAdaptationSetIds.length];
adaptationSetIndices[0] = i;
int outputIndex = 1;
for (int j = 0; j < extraAdaptationSetIds.length; j++) {
for (String adaptationSetId : extraAdaptationSetIds) {
int extraIndex =
idToIndexMap.get(
Integer.parseInt(extraAdaptationSetIds[j]), /* valueIfKeyNotFound= */ -1);
idToIndexMap.get(Integer.parseInt(adaptationSetId), /* valueIfKeyNotFound= */ -1);
if (extraIndex != -1) {
adaptationSetUsedFlags[extraIndex] = true;
adaptationSetIndices[outputIndex] = extraIndex;
......
......@@ -100,7 +100,7 @@ public class DashManifestParser extends DefaultHandler
long durationMs = parseDuration(xpp, "mediaPresentationDuration", C.TIME_UNSET);
long minBufferTimeMs = parseDuration(xpp, "minBufferTime", C.TIME_UNSET);
String typeString = xpp.getAttributeValue(null, "type");
boolean dynamic = typeString != null && "dynamic".equals(typeString);
boolean dynamic = "dynamic".equals(typeString);
long minUpdateTimeMs = dynamic ? parseDuration(xpp, "minimumUpdatePeriod", C.TIME_UNSET)
: C.TIME_UNSET;
long timeShiftBufferDepthMs = dynamic
......
......@@ -17,7 +17,6 @@ package com.google.android.exoplayer2.ui;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
......@@ -1076,8 +1075,8 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
* Should be called when the player is visible to the user and if {@code surface_type} is {@code
* spherical_view}. It is the counterpart to {@link #onPause()}.
*
* <p>This method should typically be called in {@link Activity#onStart()}, or {@link
* Activity#onResume()} for API versions &lt;= 23.
* <p>This method should typically be called in {@code Activity.onStart()}, or {@code
* Activity.onResume()} for API versions &lt;= 23.
*/
public void onResume() {
if (surfaceView instanceof SphericalSurfaceView) {
......@@ -1089,8 +1088,8 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
* Should be called when the player is no longer visible to the user and if {@code surface_type}
* is {@code spherical_view}. It is the counterpart to {@link #onResume()}.
*
* <p>This method should typically be called in {@link Activity#onStop()}, or {@link
* Activity#onPause()} for API versions &lt;= 23.
* <p>This method should typically be called in {@code Activity.onStop()}, or {@code
* Activity.onPause()} for API versions &lt;= 23.
*/
public void onPause() {
if (surfaceView instanceof SphericalSurfaceView) {
......@@ -1316,7 +1315,6 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
logo.setBackgroundColor(resources.getColor(R.color.exo_edit_mode_background_color, null));
}
@SuppressWarnings("deprecation")
private static void configureEditModeLogo(Resources resources, ImageView logo) {
logo.setImageDrawable(resources.getDrawable(R.drawable.exo_edit_mode_logo));
logo.setBackgroundColor(resources.getColor(R.color.exo_edit_mode_background_color));
......
......@@ -80,7 +80,6 @@ public final class SphericalSurfaceView extends GLSurfaceView {
private final SensorManager sensorManager;
private final @Nullable Sensor orientationSensor;
private final OrientationListener orientationListener;
private final Renderer renderer;
private final Handler mainHandler;
private final TouchTracker touchTracker;
private final SceneRenderer scene;
......@@ -114,7 +113,7 @@ public final class SphericalSurfaceView extends GLSurfaceView {
this.orientationSensor = orientationSensor;
scene = new SceneRenderer();
renderer = new Renderer(scene);
Renderer renderer = new Renderer(scene);
touchTracker = new TouchTracker(context, renderer, PX_PER_DEGREES);
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
......@@ -332,7 +331,7 @@ public final class SphericalSurfaceView extends GLSurfaceView {
private float calculateFieldOfViewInYDirection(float aspect) {
boolean landscapeMode = aspect > 1;
if (landscapeMode) {
double halfFovX = FIELD_OF_VIEW_DEGREES / 2;
double halfFovX = FIELD_OF_VIEW_DEGREES / 2f;
double tanY = Math.tan(Math.toRadians(halfFovX)) / aspect;
double halfFovY = Math.toDegrees(Math.atan(tanY));
return (float) (halfFovY * 2);
......
......@@ -114,14 +114,11 @@ public final class CacheAsserts {
*/
public static void assertReadData(DataSource dataSource, DataSpec dataSpec, byte[] expected)
throws IOException {
DataSourceInputStream inputStream = new DataSourceInputStream(dataSource, dataSpec);
byte[] bytes = null;
try {
try (DataSourceInputStream inputStream = new DataSourceInputStream(dataSource, dataSpec)) {
bytes = Util.toByteArray(inputStream);
} catch (IOException e) {
// Ignore
} finally {
inputStream.close();
}
assertThat(bytes).isEqualTo(expected);
}
......
......@@ -176,8 +176,8 @@ public final class MediaPeriodAsserts {
for (int i = 0; i < trackGroup.length; i++) {
allFormats.add(trackGroup.getFormat(i));
}
for (int i = 0; i < formats.length; i++) {
if (!allFormats.remove(formats[i])) {
for (Format format : formats) {
if (!allFormats.remove(format)) {
return false;
}
}
......@@ -189,22 +189,21 @@ public final class MediaPeriodAsserts {
DummyMainThread dummyMainThread = new DummyMainThread();
ConditionVariable preparedCondition = new ConditionVariable();
dummyMainThread.runOnMainThread(
() -> {
mediaPeriod.prepare(
new Callback() {
@Override
public void onPrepared(MediaPeriod mediaPeriod) {
trackGroupArray.set(mediaPeriod.getTrackGroups());
preparedCondition.open();
}
@Override
public void onContinueLoadingRequested(MediaPeriod source) {
// Ignore.
}
},
/* positionUs= */ 0);
});
() ->
mediaPeriod.prepare(
new Callback() {
@Override
public void onPrepared(MediaPeriod mediaPeriod) {
trackGroupArray.set(mediaPeriod.getTrackGroups());
preparedCondition.open();
}
@Override
public void onContinueLoadingRequested(MediaPeriod source) {
// Ignore.
}
},
/* positionUs= */ 0));
try {
preparedCondition.block();
} catch (InterruptedException e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment