Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b03ebbeb
authored
Oct 08, 2021
by
olly
Committed by
bachinger
Oct 09, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Stop setting custom user agent in demo app
PiperOrigin-RevId: 401741202
parent
e66f9faf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
16 deletions
demos/main/src/main/java/com/google/android/exoplayer2/demo/DemoUtil.java
extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetUtil.java
demos/main/src/main/java/com/google/android/exoplayer2/demo/DemoUtil.java
View file @
b03ebbeb
...
@@ -16,9 +16,7 @@
...
@@ -16,9 +16,7 @@
package
com
.
google
.
android
.
exoplayer2
.
demo
;
package
com
.
google
.
android
.
exoplayer2
.
demo
;
import
android.content.Context
;
import
android.content.Context
;
import
android.os.Build
;
import
com.google.android.exoplayer2.DefaultRenderersFactory
;
import
com.google.android.exoplayer2.DefaultRenderersFactory
;
import
com.google.android.exoplayer2.ExoPlayerLibraryInfo
;
import
com.google.android.exoplayer2.RenderersFactory
;
import
com.google.android.exoplayer2.RenderersFactory
;
import
com.google.android.exoplayer2.database.DatabaseProvider
;
import
com.google.android.exoplayer2.database.DatabaseProvider
;
import
com.google.android.exoplayer2.database.ExoDatabaseProvider
;
import
com.google.android.exoplayer2.database.ExoDatabaseProvider
;
...
@@ -61,13 +59,6 @@ public final class DemoUtil {
...
@@ -61,13 +59,6 @@ public final class DemoUtil {
*/
*/
private
static
final
boolean
USE_CRONET_FOR_NETWORKING
=
true
;
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
TAG
=
"DemoUtil"
;
private
static
final
String
DOWNLOAD_ACTION_FILE
=
"actions"
;
private
static
final
String
DOWNLOAD_ACTION_FILE
=
"actions"
;
private
static
final
String
DOWNLOAD_TRACKER_ACTION_FILE
=
"tracked_actions"
;
private
static
final
String
DOWNLOAD_TRACKER_ACTION_FILE
=
"tracked_actions"
;
...
@@ -104,9 +95,7 @@ public final class DemoUtil {
...
@@ -104,9 +95,7 @@ public final class DemoUtil {
if
(
httpDataSourceFactory
==
null
)
{
if
(
httpDataSourceFactory
==
null
)
{
if
(
USE_CRONET_FOR_NETWORKING
)
{
if
(
USE_CRONET_FOR_NETWORKING
)
{
context
=
context
.
getApplicationContext
();
context
=
context
.
getApplicationContext
();
@Nullable
@Nullable
CronetEngine
cronetEngine
=
CronetUtil
.
buildCronetEngine
(
context
);
CronetEngine
cronetEngine
=
CronetUtil
.
buildCronetEngine
(
context
,
USER_AGENT
,
/* preferGMSCoreCronet= */
false
);
if
(
cronetEngine
!=
null
)
{
if
(
cronetEngine
!=
null
)
{
httpDataSourceFactory
=
httpDataSourceFactory
=
new
CronetDataSource
.
Factory
(
cronetEngine
,
Executors
.
newSingleThreadExecutor
());
new
CronetDataSource
.
Factory
(
cronetEngine
,
Executors
.
newSingleThreadExecutor
());
...
@@ -117,7 +106,7 @@ public final class DemoUtil {
...
@@ -117,7 +106,7 @@ public final class DemoUtil {
CookieManager
cookieManager
=
new
CookieManager
();
CookieManager
cookieManager
=
new
CookieManager
();
cookieManager
.
setCookiePolicy
(
CookiePolicy
.
ACCEPT_ORIGINAL_SERVER
);
cookieManager
.
setCookiePolicy
(
CookiePolicy
.
ACCEPT_ORIGINAL_SERVER
);
CookieHandler
.
setDefault
(
cookieManager
);
CookieHandler
.
setDefault
(
cookieManager
);
httpDataSourceFactory
=
new
DefaultHttpDataSource
.
Factory
()
.
setUserAgent
(
USER_AGENT
)
;
httpDataSourceFactory
=
new
DefaultHttpDataSource
.
Factory
();
}
}
}
}
return
httpDataSourceFactory
;
return
httpDataSourceFactory
;
...
...
extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetUtil.java
View file @
b03ebbeb
...
@@ -35,9 +35,30 @@ public final class CronetUtil {
...
@@ -35,9 +35,30 @@ public final class CronetUtil {
private
static
final
String
TAG
=
"CronetUtil"
;
private
static
final
String
TAG
=
"CronetUtil"
;
/**
/**
* Builds a {@link CronetEngine} suitable for use with ExoPlayer. When choosing a {@link
* Builds a {@link CronetEngine} suitable for use with {@link CronetDataSource}. When choosing a
* CronetProvider Cronet provider} to build the {@link CronetEngine}, disabled providers are not
* {@link CronetProvider Cronet provider} to build the {@link CronetEngine}, disabled providers
* considered. Neither are fallback providers, since it's more efficient to use {@link
* 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
* DefaultHttpDataSource} than it is to use {@link CronetDataSource} with a fallback {@link
* CronetEngine}.
* CronetEngine}.
*
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment