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
f53f44c9
authored
Jul 26, 2021
by
olly
Committed by
bachinger
Jul 27, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Move NetworkTypeObserver 5G-NSA config to separate Config class
PiperOrigin-RevId: 386970718
parent
9e615ce5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
7 deletions
library/core/src/main/java/com/google/android/exoplayer2/util/NetworkTypeObserver.java
library/core/src/main/java/com/google/android/exoplayer2/util/NetworkTypeObserver.java
View file @
f53f44c9
...
@@ -58,8 +58,25 @@ public final class NetworkTypeObserver {
...
@@ -58,8 +58,25 @@ public final class NetworkTypeObserver {
void
onNetworkTypeChanged
(
@C
.
NetworkType
int
networkType
);
void
onNetworkTypeChanged
(
@C
.
NetworkType
int
networkType
);
}
}
/*
* Static configuration that may need to be set at app startup time is located in a separate
* static Config class. This allows apps to set their desired config without incurring unnecessary
* class loading costs during startup.
*/
/** Configuration for {@link NetworkTypeObserver}. */
public
static
final
class
Config
{
private
static
volatile
boolean
disable5GNsaDisambiguation
;
/** Disables logic to disambiguate 5G-NSA networks from 4G networks. */
public
static
void
disable5GNsaDisambiguation
()
{
disable5GNsaDisambiguation
=
true
;
}
private
Config
()
{}
}
@Nullable
private
static
NetworkTypeObserver
staticInstance
;
@Nullable
private
static
NetworkTypeObserver
staticInstance
;
private
static
volatile
boolean
disable5GNsaDisambiguation
;
private
final
Handler
mainHandler
;
private
final
Handler
mainHandler
;
// This class needs to hold weak references as it doesn't require listeners to unregister.
// This class needs to hold weak references as it doesn't require listeners to unregister.
...
@@ -70,11 +87,6 @@ public final class NetworkTypeObserver {
...
@@ -70,11 +87,6 @@ public final class NetworkTypeObserver {
@C
.
NetworkType
@C
.
NetworkType
private
int
networkType
;
private
int
networkType
;
/** Disables logic to disambiguate 5G-NSA networks from 4G networks. */
public
static
void
disable5GNsaDisambiguation
()
{
disable5GNsaDisambiguation
=
true
;
}
/**
/**
* Returns a network type observer instance.
* Returns a network type observer instance.
*
*
...
@@ -223,7 +235,9 @@ public final class NetworkTypeObserver {
...
@@ -223,7 +235,9 @@ public final class NetworkTypeObserver {
@Override
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
@C
.
NetworkType
int
networkType
=
getNetworkTypeFromConnectivityManager
(
context
);
@C
.
NetworkType
int
networkType
=
getNetworkTypeFromConnectivityManager
(
context
);
if
(
Util
.
SDK_INT
>=
29
&&
!
disable5GNsaDisambiguation
&&
networkType
==
C
.
NETWORK_TYPE_4G
)
{
if
(
Util
.
SDK_INT
>=
29
&&
!
Config
.
disable5GNsaDisambiguation
&&
networkType
==
C
.
NETWORK_TYPE_4G
)
{
// Delay update of the network type to check whether this is actually 5G-NSA.
// Delay update of the network type to check whether this is actually 5G-NSA.
try
{
try
{
// We can't access TelephonyManager getters like getServiceState() directly as they
// We can't access TelephonyManager getters like getServiceState() directly as they
...
...
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