fix(android): default UA (#3429)

* Update DataSourceUtil.java

* fix(android): default UA
This commit is contained in:
lovegaoshi 2023-12-20 10:49:26 -08:00 committed by GitHub
parent c8983f4094
commit dd7bb54720
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,11 +87,16 @@ public class DataSourceUtil {
ForwardingCookieHandler handler = new ForwardingCookieHandler(context);
container.setCookieJar(new JavaNetCookieJar(handler));
OkHttpDataSource.Factory okHttpDataSourceFactory = new OkHttpDataSource.Factory((Call.Factory) client)
.setUserAgent(getUserAgent(context))
.setTransferListener(bandwidthMeter);
if (requestHeaders != null)
if (requestHeaders != null) {
okHttpDataSourceFactory.setDefaultRequestProperties(requestHeaders);
if (!requestHeaders.containsKey("User-Agent")) {
okHttpDataSourceFactory.setUserAgent(getUserAgent(context));
}
} else {
okHttpDataSourceFactory.setUserAgent(getUserAgent(context));
}
return okHttpDataSourceFactory;
}