From 869a91bba880ce95e2c63bb882b4608704bfba84 Mon Sep 17 00:00:00 2001 From: ibaker Date: Mon, 23 Sep 2024 09:53:26 -0700 Subject: [PATCH] Remove `DemoUtil.ALLOW_CRONET_FOR_NETWORKING` This boolean only exists to be changed in source, but it is now used as part of a 3-way fallback logic (since adding `HttpEngine` integration), so it's not really more convenient or clearer to change this constant than just hack the code of `getHttpDataSourceFactory` directly. PiperOrigin-RevId: 677834348 --- .../androidx/media3/demo/main/DemoUtil.java | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/demos/main/src/main/java/androidx/media3/demo/main/DemoUtil.java b/demos/main/src/main/java/androidx/media3/demo/main/DemoUtil.java index 5d73c58cbb..9b6d9ce21a 100644 --- a/demos/main/src/main/java/androidx/media3/demo/main/DemoUtil.java +++ b/demos/main/src/main/java/androidx/media3/demo/main/DemoUtil.java @@ -50,16 +50,6 @@ public final class DemoUtil { public static final String DOWNLOAD_NOTIFICATION_CHANNEL_ID = "download_channel"; - /** - * Whether the demo application uses Cronet for networking when {@link HttpEngine} is not - * supported. Note that Cronet does not provide automatic support for cookies - * (https://github.com/google/ExoPlayer/issues/5975). - * - *

If set to false, the {@link DefaultHttpDataSource} is used with a {@link CookieManager} - * configured in {@link #getHttpDataSourceFactory} when {@link HttpEngine} is not supported. - */ - private static final boolean ALLOW_CRONET_FOR_NETWORKING = true; - private static final String TAG = "DemoUtil"; private static final String DOWNLOAD_CONTENT_DIRECTORY = "downloads"; @@ -114,16 +104,13 @@ public final class DemoUtil { new HttpEngineDataSource.Factory(httpEngine, Executors.newSingleThreadExecutor()); return httpDataSourceFactory; } - if (ALLOW_CRONET_FOR_NETWORKING) { - @Nullable CronetEngine cronetEngine = CronetUtil.buildCronetEngine(context); - if (cronetEngine != null) { - httpDataSourceFactory = - new CronetDataSource.Factory(cronetEngine, Executors.newSingleThreadExecutor()); - return httpDataSourceFactory; - } + @Nullable CronetEngine cronetEngine = CronetUtil.buildCronetEngine(context); + if (cronetEngine != null) { + httpDataSourceFactory = + new CronetDataSource.Factory(cronetEngine, Executors.newSingleThreadExecutor()); + return httpDataSourceFactory; } - // The device doesn't support HttpEngine or we don't want to allow Cronet, or we failed to - // instantiate a CronetEngine. + // The device doesn't support HttpEngine and we failed to instantiate a CronetEngine. CookieManager cookieManager = new CookieManager(); cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ORIGINAL_SERVER); CookieHandler.setDefault(cookieManager);