Remove deprecated setContentTypePredicate()
methods
Use the suggested alternative on the respective `XXXDataSource.Factory` instead. PiperOrigin-RevId: 636560182
This commit is contained in:
parent
68c16782d7
commit
4986fdd1a6
@ -192,10 +192,13 @@
|
|||||||
artist in the Media3 media item
|
artist in the Media3 media item
|
||||||
([#1255](https://github.com/androidx/media/pull/1255)).
|
([#1255](https://github.com/androidx/media/pull/1255)).
|
||||||
* Test Utilities:
|
* Test Utilities:
|
||||||
* Remove deprecated symbols:
|
|
||||||
* Demo app:
|
* Demo app:
|
||||||
* Allow setting repeat mode with `Intent` arguments from command line
|
* Allow setting repeat mode with `Intent` arguments from command line
|
||||||
([#1266](https://github.com/androidx/media/pull/1266)).
|
([#1266](https://github.com/androidx/media/pull/1266)).
|
||||||
|
* Remove deprecated symbols:
|
||||||
|
* Remove `setContentTypePredicate(Predicate)` method from
|
||||||
|
`DefaultHttpDataSource`, `OkHttpDataSource` and `CronetDataSource`. Use
|
||||||
|
the equivalent method on each `XXXDataSource.Factory` instead.
|
||||||
|
|
||||||
## 1.4
|
## 1.4
|
||||||
|
|
||||||
|
@ -257,9 +257,9 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
|
|||||||
@Nullable private final String userAgent;
|
@Nullable private final String userAgent;
|
||||||
@Nullable private final RequestProperties defaultRequestProperties;
|
@Nullable private final RequestProperties defaultRequestProperties;
|
||||||
private final RequestProperties requestProperties;
|
private final RequestProperties requestProperties;
|
||||||
|
@Nullable private final Predicate<String> contentTypePredicate;
|
||||||
private final boolean keepPostFor302Redirects;
|
private final boolean keepPostFor302Redirects;
|
||||||
|
|
||||||
@Nullable private Predicate<String> contentTypePredicate;
|
|
||||||
@Nullable private DataSpec dataSpec;
|
@Nullable private DataSpec dataSpec;
|
||||||
@Nullable private HttpURLConnection connection;
|
@Nullable private HttpURLConnection connection;
|
||||||
@Nullable private InputStream inputStream;
|
@Nullable private InputStream inputStream;
|
||||||
@ -352,16 +352,6 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
|
|||||||
this.keepPostFor302Redirects = keepPostFor302Redirects;
|
this.keepPostFor302Redirects = keepPostFor302Redirects;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link DefaultHttpDataSource.Factory#setContentTypePredicate(Predicate)}
|
|
||||||
* instead.
|
|
||||||
*/
|
|
||||||
@UnstableApi
|
|
||||||
@Deprecated
|
|
||||||
public void setContentTypePredicate(@Nullable Predicate<String> contentTypePredicate) {
|
|
||||||
this.contentTypePredicate = contentTypePredicate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -459,7 +459,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
|
|||||||
private final Clock clock;
|
private final Clock clock;
|
||||||
private final int readBufferSize;
|
private final int readBufferSize;
|
||||||
|
|
||||||
@Nullable private Predicate<String> contentTypePredicate;
|
@Nullable private final Predicate<String> contentTypePredicate;
|
||||||
private final boolean keepPostFor302Redirects;
|
private final boolean keepPostFor302Redirects;
|
||||||
|
|
||||||
// Accessed by the calling thread only.
|
// Accessed by the calling thread only.
|
||||||
@ -517,15 +517,6 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
|
|||||||
operation = new ConditionVariable();
|
operation = new ConditionVariable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link CronetDataSource.Factory#setContentTypePredicate(Predicate)} instead.
|
|
||||||
*/
|
|
||||||
@UnstableApi
|
|
||||||
@Deprecated
|
|
||||||
public void setContentTypePredicate(@Nullable Predicate<String> contentTypePredicate) {
|
|
||||||
this.contentTypePredicate = contentTypePredicate;
|
|
||||||
}
|
|
||||||
|
|
||||||
// HttpDataSource implementation.
|
// HttpDataSource implementation.
|
||||||
|
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
|
@ -111,19 +111,8 @@ public final class CronetDataSourceTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
Map<String, String> defaultRequestProperties = new HashMap<>();
|
|
||||||
defaultRequestProperties.put("defaultHeader1", "defaultValue1");
|
|
||||||
defaultRequestProperties.put("defaultHeader2", "defaultValue2");
|
|
||||||
|
|
||||||
executorService = Executors.newSingleThreadExecutor();
|
executorService = Executors.newSingleThreadExecutor();
|
||||||
dataSourceUnderTest =
|
dataSourceUnderTest = (CronetDataSource) createCronetDataSourceFactory().createDataSource();
|
||||||
(CronetDataSource)
|
|
||||||
new CronetDataSource.Factory(mockCronetEngine, executorService)
|
|
||||||
.setConnectionTimeoutMs(TEST_CONNECT_TIMEOUT_MS)
|
|
||||||
.setReadTimeoutMs(TEST_READ_TIMEOUT_MS)
|
|
||||||
.setResetTimeoutOnRedirects(true)
|
|
||||||
.setDefaultRequestProperties(defaultRequestProperties)
|
|
||||||
.createDataSource();
|
|
||||||
dataSourceUnderTest.addTransferListener(mockTransferListener);
|
dataSourceUnderTest.addTransferListener(mockTransferListener);
|
||||||
when(mockCronetEngine.newUrlRequestBuilder(
|
when(mockCronetEngine.newUrlRequestBuilder(
|
||||||
anyString(), any(UrlRequest.Callback.class), any(Executor.class)))
|
anyString(), any(UrlRequest.Callback.class), any(Executor.class)))
|
||||||
@ -436,15 +425,18 @@ public final class CronetDataSourceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void requestOpenValidatesContentTypePredicate() {
|
public void requestOpenValidatesContentTypePredicate() throws Exception {
|
||||||
mockResponseStartSuccess();
|
|
||||||
|
|
||||||
ArrayList<String> testedContentTypes = new ArrayList<>();
|
ArrayList<String> testedContentTypes = new ArrayList<>();
|
||||||
dataSourceUnderTest.setContentTypePredicate(
|
dataSourceUnderTest =
|
||||||
|
(CronetDataSource)
|
||||||
|
createCronetDataSourceFactory()
|
||||||
|
.setContentTypePredicate(
|
||||||
(String input) -> {
|
(String input) -> {
|
||||||
testedContentTypes.add(input);
|
testedContentTypes.add(input);
|
||||||
return false;
|
return false;
|
||||||
});
|
})
|
||||||
|
.createDataSource();
|
||||||
|
mockResponseStartSuccess();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
dataSourceUnderTest.open(testDataSpec);
|
dataSourceUnderTest.open(testDataSpec);
|
||||||
@ -1572,6 +1564,17 @@ public final class CronetDataSourceTest {
|
|||||||
|
|
||||||
// Helper methods.
|
// Helper methods.
|
||||||
|
|
||||||
|
private CronetDataSource.Factory createCronetDataSourceFactory() {
|
||||||
|
Map<String, String> defaultRequestProperties = new HashMap<>();
|
||||||
|
defaultRequestProperties.put("defaultHeader1", "defaultValue1");
|
||||||
|
defaultRequestProperties.put("defaultHeader2", "defaultValue2");
|
||||||
|
return new CronetDataSource.Factory(mockCronetEngine, executorService)
|
||||||
|
.setConnectionTimeoutMs(TEST_CONNECT_TIMEOUT_MS)
|
||||||
|
.setReadTimeoutMs(TEST_READ_TIMEOUT_MS)
|
||||||
|
.setResetTimeoutOnRedirects(true)
|
||||||
|
.setDefaultRequestProperties(defaultRequestProperties);
|
||||||
|
}
|
||||||
|
|
||||||
private void mockStatusResponse() {
|
private void mockStatusResponse() {
|
||||||
doAnswer(
|
doAnswer(
|
||||||
invocation -> {
|
invocation -> {
|
||||||
|
@ -187,8 +187,8 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
|
|||||||
@Nullable private final String userAgent;
|
@Nullable private final String userAgent;
|
||||||
@Nullable private final CacheControl cacheControl;
|
@Nullable private final CacheControl cacheControl;
|
||||||
@Nullable private final RequestProperties defaultRequestProperties;
|
@Nullable private final RequestProperties defaultRequestProperties;
|
||||||
|
@Nullable private final Predicate<String> contentTypePredicate;
|
||||||
|
|
||||||
@Nullable private Predicate<String> contentTypePredicate;
|
|
||||||
@Nullable private DataSpec dataSpec;
|
@Nullable private DataSpec dataSpec;
|
||||||
@Nullable private Response response;
|
@Nullable private Response response;
|
||||||
@Nullable private InputStream responseByteStream;
|
@Nullable private InputStream responseByteStream;
|
||||||
@ -249,15 +249,6 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
|
|||||||
this.requestProperties = new RequestProperties();
|
this.requestProperties = new RequestProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link OkHttpDataSource.Factory#setContentTypePredicate(Predicate)} instead.
|
|
||||||
*/
|
|
||||||
@UnstableApi
|
|
||||||
@Deprecated
|
|
||||||
public void setContentTypePredicate(@Nullable Predicate<String> contentTypePredicate) {
|
|
||||||
this.contentTypePredicate = contentTypePredicate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user