Stop setting custom user agent in demo app
PiperOrigin-RevId: 401741202
This commit is contained in:
parent
e66f9fafe1
commit
b03ebbeb89
@ -16,9 +16,7 @@
|
||||
package com.google.android.exoplayer2.demo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import com.google.android.exoplayer2.DefaultRenderersFactory;
|
||||
import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
|
||||
import com.google.android.exoplayer2.RenderersFactory;
|
||||
import com.google.android.exoplayer2.database.DatabaseProvider;
|
||||
import com.google.android.exoplayer2.database.ExoDatabaseProvider;
|
||||
@ -61,13 +59,6 @@ public final class DemoUtil {
|
||||
*/
|
||||
private static final boolean USE_CRONET_FOR_NETWORKING = true;
|
||||
|
||||
private static final String USER_AGENT =
|
||||
"ExoPlayerDemo/"
|
||||
+ ExoPlayerLibraryInfo.VERSION
|
||||
+ " (Linux; Android "
|
||||
+ Build.VERSION.RELEASE
|
||||
+ ") "
|
||||
+ ExoPlayerLibraryInfo.VERSION_SLASHY;
|
||||
private static final String TAG = "DemoUtil";
|
||||
private static final String DOWNLOAD_ACTION_FILE = "actions";
|
||||
private static final String DOWNLOAD_TRACKER_ACTION_FILE = "tracked_actions";
|
||||
@ -104,9 +95,7 @@ public final class DemoUtil {
|
||||
if (httpDataSourceFactory == null) {
|
||||
if (USE_CRONET_FOR_NETWORKING) {
|
||||
context = context.getApplicationContext();
|
||||
@Nullable
|
||||
CronetEngine cronetEngine =
|
||||
CronetUtil.buildCronetEngine(context, USER_AGENT, /* preferGMSCoreCronet= */ false);
|
||||
@Nullable CronetEngine cronetEngine = CronetUtil.buildCronetEngine(context);
|
||||
if (cronetEngine != null) {
|
||||
httpDataSourceFactory =
|
||||
new CronetDataSource.Factory(cronetEngine, Executors.newSingleThreadExecutor());
|
||||
@ -117,7 +106,7 @@ public final class DemoUtil {
|
||||
CookieManager cookieManager = new CookieManager();
|
||||
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ORIGINAL_SERVER);
|
||||
CookieHandler.setDefault(cookieManager);
|
||||
httpDataSourceFactory = new DefaultHttpDataSource.Factory().setUserAgent(USER_AGENT);
|
||||
httpDataSourceFactory = new DefaultHttpDataSource.Factory();
|
||||
}
|
||||
}
|
||||
return httpDataSourceFactory;
|
||||
|
@ -35,9 +35,30 @@ public final class CronetUtil {
|
||||
private static final String TAG = "CronetUtil";
|
||||
|
||||
/**
|
||||
* Builds a {@link CronetEngine} suitable for use with ExoPlayer. When choosing a {@link
|
||||
* CronetProvider Cronet provider} to build the {@link CronetEngine}, disabled providers are not
|
||||
* considered. Neither are fallback providers, since it's more efficient to use {@link
|
||||
* Builds a {@link CronetEngine} suitable for use with {@link CronetDataSource}. When choosing a
|
||||
* {@link CronetProvider Cronet provider} to build the {@link CronetEngine}, disabled providers
|
||||
* are not considered. Neither are fallback providers, since it's more efficient to use {@link
|
||||
* DefaultHttpDataSource} than it is to use {@link CronetDataSource} with a fallback {@link
|
||||
* CronetEngine}.
|
||||
*
|
||||
* <p>Note that it's recommended for applications to create only one instance of {@link
|
||||
* CronetEngine}, so if your application already has an instance for performing other networking,
|
||||
* then that instance should be used and calling this method is unnecessary. See the <a
|
||||
* href="https://developer.android.com/guide/topics/connectivity/cronet/start">Android developer
|
||||
* guide</a> to learn more about using Cronet for network operations.
|
||||
*
|
||||
* @param context A context.
|
||||
* @return The {@link CronetEngine}, or {@code null} if no suitable engine could be built.
|
||||
*/
|
||||
@Nullable
|
||||
public static CronetEngine buildCronetEngine(Context context) {
|
||||
return buildCronetEngine(context, /* userAgent= */ null, /* preferGooglePlayServices= */ false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a {@link CronetEngine} suitable for use with {@link CronetDataSource}. When choosing a
|
||||
* {@link CronetProvider Cronet provider} to build the {@link CronetEngine}, disabled providers
|
||||
* are not considered. Neither are fallback providers, since it's more efficient to use {@link
|
||||
* DefaultHttpDataSource} than it is to use {@link CronetDataSource} with a fallback {@link
|
||||
* CronetEngine}.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user