From e150e0d39fe29b4b925046ee0ee96d75c954aa64 Mon Sep 17 00:00:00 2001 From: ibaker Date: Thu, 23 May 2024 10:00:22 -0700 Subject: [PATCH] Remove `OkHttpDataSource` constructors & `OkHttDataSourceFactory` Use `OkHttpDataSource.Factory` instead. PiperOrigin-RevId: 636585523 --- RELEASENOTES.md | 2 + .../datasource/okhttp/OkHttpDataSource.java | 38 ------ .../okhttp/OkHttpDataSourceFactory.java | 117 ------------------ 3 files changed, 2 insertions(+), 155 deletions(-) delete mode 100644 libraries/datasource_okhttp/src/main/java/androidx/media3/datasource/okhttp/OkHttpDataSourceFactory.java diff --git a/RELEASENOTES.md b/RELEASENOTES.md index c91ad4c35f..92ad27042d 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -199,6 +199,8 @@ * Remove `setContentTypePredicate(Predicate)` method from `DefaultHttpDataSource`, `OkHttpDataSource` and `CronetDataSource`. Use the equivalent method on each `XXXDataSource.Factory` instead. + * Remove `OkHttpDataSource` constructors and `OkHttpDataSourceFactory`. + Use `OkHttpDataSource.Factory` instead. ## 1.4 diff --git a/libraries/datasource_okhttp/src/main/java/androidx/media3/datasource/okhttp/OkHttpDataSource.java b/libraries/datasource_okhttp/src/main/java/androidx/media3/datasource/okhttp/OkHttpDataSource.java index 207bf72e3f..fa4020a41a 100644 --- a/libraries/datasource_okhttp/src/main/java/androidx/media3/datasource/okhttp/OkHttpDataSource.java +++ b/libraries/datasource_okhttp/src/main/java/androidx/media3/datasource/okhttp/OkHttpDataSource.java @@ -196,44 +196,6 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource { private long bytesToRead; private long bytesRead; - /** - * @deprecated Use {@link OkHttpDataSource.Factory} instead. - */ - @SuppressWarnings("deprecation") - @UnstableApi - @Deprecated - public OkHttpDataSource(Call.Factory callFactory) { - this(callFactory, /* userAgent= */ null); - } - - /** - * @deprecated Use {@link OkHttpDataSource.Factory} instead. - */ - @SuppressWarnings("deprecation") - @UnstableApi - @Deprecated - public OkHttpDataSource(Call.Factory callFactory, @Nullable String userAgent) { - this(callFactory, userAgent, /* cacheControl= */ null, /* defaultRequestProperties= */ null); - } - - /** - * @deprecated Use {@link OkHttpDataSource.Factory} instead. - */ - @UnstableApi - @Deprecated - public OkHttpDataSource( - Call.Factory callFactory, - @Nullable String userAgent, - @Nullable CacheControl cacheControl, - @Nullable RequestProperties defaultRequestProperties) { - this( - callFactory, - userAgent, - cacheControl, - defaultRequestProperties, - /* contentTypePredicate= */ null); - } - private OkHttpDataSource( Call.Factory callFactory, @Nullable String userAgent, diff --git a/libraries/datasource_okhttp/src/main/java/androidx/media3/datasource/okhttp/OkHttpDataSourceFactory.java b/libraries/datasource_okhttp/src/main/java/androidx/media3/datasource/okhttp/OkHttpDataSourceFactory.java deleted file mode 100644 index 1a476fd5be..0000000000 --- a/libraries/datasource_okhttp/src/main/java/androidx/media3/datasource/okhttp/OkHttpDataSourceFactory.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package androidx.media3.datasource.okhttp; - -import androidx.annotation.Nullable; -import androidx.media3.common.util.UnstableApi; -import androidx.media3.datasource.HttpDataSource; -import androidx.media3.datasource.HttpDataSource.BaseFactory; -import androidx.media3.datasource.TransferListener; -import okhttp3.CacheControl; -import okhttp3.Call; - -/** - * @deprecated Use {@link OkHttpDataSource.Factory} instead. - */ -@Deprecated -@UnstableApi -public final class OkHttpDataSourceFactory extends BaseFactory { - - private final Call.Factory callFactory; - @Nullable private final String userAgent; - @Nullable private final TransferListener listener; - @Nullable private final CacheControl cacheControl; - - /** - * Creates an instance. - * - * @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use - * by the sources created by the factory. - */ - public OkHttpDataSourceFactory(Call.Factory callFactory) { - this(callFactory, /* userAgent= */ null, /* listener= */ null, /* cacheControl= */ null); - } - - /** - * Creates an instance. - * - * @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use - * by the sources created by the factory. - * @param userAgent An optional User-Agent string. - */ - public OkHttpDataSourceFactory(Call.Factory callFactory, @Nullable String userAgent) { - this(callFactory, userAgent, /* listener= */ null, /* cacheControl= */ null); - } - - /** - * Creates an instance. - * - * @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use - * by the sources created by the factory. - * @param userAgent An optional User-Agent string. - * @param cacheControl An optional {@link CacheControl} for setting the Cache-Control header. - */ - public OkHttpDataSourceFactory( - Call.Factory callFactory, @Nullable String userAgent, @Nullable CacheControl cacheControl) { - this(callFactory, userAgent, /* listener= */ null, cacheControl); - } - - /** - * Creates an instance. - * - * @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use - * by the sources created by the factory. - * @param userAgent An optional User-Agent string. - * @param listener An optional listener. - */ - public OkHttpDataSourceFactory( - Call.Factory callFactory, @Nullable String userAgent, @Nullable TransferListener listener) { - this(callFactory, userAgent, listener, /* cacheControl= */ null); - } - - /** - * Creates an instance. - * - * @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use - * by the sources created by the factory. - * @param userAgent An optional User-Agent string. - * @param listener An optional listener. - * @param cacheControl An optional {@link CacheControl} for setting the Cache-Control header. - */ - public OkHttpDataSourceFactory( - Call.Factory callFactory, - @Nullable String userAgent, - @Nullable TransferListener listener, - @Nullable CacheControl cacheControl) { - this.callFactory = callFactory; - this.userAgent = userAgent; - this.listener = listener; - this.cacheControl = cacheControl; - } - - // Calls deprecated constructor. - @SuppressWarnings("deprecation") - @Override - protected OkHttpDataSource createDataSourceInternal( - HttpDataSource.RequestProperties defaultRequestProperties) { - OkHttpDataSource dataSource = - new OkHttpDataSource(callFactory, userAgent, cacheControl, defaultRequestProperties); - if (listener != null) { - dataSource.addTransferListener(listener); - } - return dataSource; - } -}