Skip to content

Commit

Permalink
In DemoUtil, don't set cookie handler when using HttpEngineDataSource.
Browse files Browse the repository at this point in the history
HttpEngine does not support cookie storage.

#cherrypick

PiperOrigin-RevId: 646084702
  • Loading branch information
okunhardt authored and copybara-github committed Jun 24, 2024
1 parent 938fac4 commit bb568b5
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public static synchronized DataSource.Factory getHttpDataSourceFactory(Context c
}
context = context.getApplicationContext();
if (Build.VERSION.SDK_INT >= 34) {
setCookieHandler();
HttpEngine httpEngine = new HttpEngine.Builder(context).build();
httpDataSourceFactory =
new HttpEngineDataSource.Factory(httpEngine, Executors.newSingleThreadExecutor());
Expand All @@ -122,15 +121,11 @@ public static synchronized DataSource.Factory getHttpDataSourceFactory(Context c
}
// The device doesn't support HttpEngine or we don't want to allow Cronet, or we failed to
// instantiate a CronetEngine.
setCookieHandler();
httpDataSourceFactory = new DefaultHttpDataSource.Factory();
return httpDataSourceFactory;
}

private static void setCookieHandler() {
CookieManager cookieManager = new CookieManager();
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ORIGINAL_SERVER);
CookieHandler.setDefault(cookieManager);
httpDataSourceFactory = new DefaultHttpDataSource.Factory();
return httpDataSourceFactory;
}

/** Returns a {@link DataSource.Factory}. */
Expand Down

0 comments on commit bb568b5

Please sign in to comment.