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
5bc1c483
authored
Jul 28, 2021
by
aquilescanta
Committed by
bachinger
Jul 29, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Assign CronetDataSource error codes
PiperOrigin-RevId: 387301144
parent
9c27cfcd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
8 deletions
extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSource.java
extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSource.java
View file @
5bc1c483
...
@@ -669,11 +669,12 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
...
@@ -669,11 +669,12 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
if
(
message
!=
null
&&
Ascii
.
toLowerCase
(
message
).
contains
(
"err_cleartext_not_permitted"
))
{
if
(
message
!=
null
&&
Ascii
.
toLowerCase
(
message
).
contains
(
"err_cleartext_not_permitted"
))
{
throw
new
CleartextNotPermittedException
(
connectionOpenException
,
dataSpec
);
throw
new
CleartextNotPermittedException
(
connectionOpenException
,
dataSpec
);
}
}
@PlaybackException
.
ErrorCode
int
errorCode
=
getErrorCodeForException
(
connectionOpenException
,
/* occurredWhileOpeningConnection*/
true
);
throw
new
OpenException
(
throw
new
OpenException
(
connectionOpenException
,
connectionOpenException
,
dataSpec
,
errorCode
,
getStatus
(
urlRequest
));
dataSpec
,
PlaybackException
.
ERROR_CODE_IO_NETWORK_CONNECTION_FAILED
,
getStatus
(
urlRequest
));
}
else
if
(!
connectionOpened
)
{
}
else
if
(!
connectionOpened
)
{
// The timeout was reached before the connection was opened.
// The timeout was reached before the connection was opened.
throw
new
OpenException
(
throw
new
OpenException
(
...
@@ -1026,7 +1027,10 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
...
@@ -1026,7 +1027,10 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
throw
(
HttpDataSourceException
)
e
;
throw
(
HttpDataSourceException
)
e
;
}
else
{
}
else
{
throw
new
OpenException
(
throw
new
OpenException
(
e
,
dataSpec
,
PlaybackException
.
ERROR_CODE_IO_UNSPECIFIED
,
Status
.
READING_RESPONSE
);
e
,
dataSpec
,
getErrorCodeForException
(
e
,
/* occurredWhileOpeningConnection= */
false
),
Status
.
READING_RESPONSE
);
}
}
}
}
}
}
...
@@ -1098,9 +1102,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
...
@@ -1098,9 +1102,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
throw
new
HttpDataSourceException
(
throw
new
HttpDataSourceException
(
exception
,
exception
,
dataSpec
,
dataSpec
,
exception
instanceof
UnknownHostException
getErrorCodeForException
(
exception
,
/* occurredWhileOpeningConnection= */
false
),
?
PlaybackException
.
ERROR_CODE_IO_DNS_FAILED
:
PlaybackException
.
ERROR_CODE_IO_UNSPECIFIED
,
HttpDataSourceException
.
TYPE_READ
);
HttpDataSourceException
.
TYPE_READ
);
}
}
}
}
...
@@ -1114,6 +1116,25 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
...
@@ -1114,6 +1116,25 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
return
readBuffer
;
return
readBuffer
;
}
}
@PlaybackException
.
ErrorCode
private
static
int
getErrorCodeForException
(
IOException
exception
,
boolean
occurredWhileOpeningConnection
)
{
if
(
exception
instanceof
UnknownHostException
)
{
return
PlaybackException
.
ERROR_CODE_IO_DNS_FAILED
;
}
@Nullable
String
message
=
exception
.
getMessage
();
if
(
message
!=
null
)
{
if
(
message
.
contains
(
"net::ERR_INTERNET_DISCONNECTED"
))
{
return
PlaybackException
.
ERROR_CODE_IO_NETWORK_UNAVAILABLE
;
}
}
if
(
occurredWhileOpeningConnection
)
{
return
PlaybackException
.
ERROR_CODE_IO_NETWORK_CONNECTION_FAILED
;
}
else
{
return
PlaybackException
.
ERROR_CODE_IO_NETWORK_CONNECTION_CLOSED
;
}
}
private
static
boolean
isCompressed
(
UrlResponseInfo
info
)
{
private
static
boolean
isCompressed
(
UrlResponseInfo
info
)
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
info
.
getAllHeadersAsList
())
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
info
.
getAllHeadersAsList
())
{
if
(
entry
.
getKey
().
equalsIgnoreCase
(
"Content-Encoding"
))
{
if
(
entry
.
getKey
().
equalsIgnoreCase
(
"Content-Encoding"
))
{
...
...
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