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