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
2fbad210
authored
Nov 25, 2020
by
olly
Committed by
Andrew Lewis
Nov 27, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make special exception for cleartext-not-permitted
#exofixit PiperOrigin-RevId: 344246408
parent
1201466b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
6 deletions
demos/main/src/main/res/values/strings.xml
extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSource.java
extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSource.java
library/common/src/main/java/com/google/android/exoplayer2/upstream/HttpDataSource.java
library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java
library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultLoadErrorHandlingPolicy.java
demos/main/src/main/res/values/strings.xml
View file @
2fbad210
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
<string
name=
"unexpected_intent_action"
>
Unexpected intent action:
<xliff:g
id=
"action"
>
%1$s
</xliff:g></string>
<string
name=
"unexpected_intent_action"
>
Unexpected intent action:
<xliff:g
id=
"action"
>
%1$s
</xliff:g></string>
<string
name=
"error_cleartext_not_permitted"
>
Cleartext
traffic not
permitted
</string>
<string
name=
"error_cleartext_not_permitted"
>
Cleartext
HTTP traffic not permitted. See https://exoplayer.dev/issues/cleartext-not-
permitted
</string>
<string
name=
"error_generic"
>
Playback failed
</string>
<string
name=
"error_generic"
>
Playback failed
</string>
...
...
extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSource.java
View file @
2fbad210
...
@@ -443,8 +443,14 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
...
@@ -443,8 +443,14 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
transferInitializing
(
dataSpec
);
transferInitializing
(
dataSpec
);
try
{
try
{
boolean
connectionOpened
=
blockUntilConnectTimeout
();
boolean
connectionOpened
=
blockUntilConnectTimeout
();
if
(
exception
!=
null
)
{
@Nullable
IOException
connectionOpenException
=
exception
;
throw
new
OpenException
(
exception
,
dataSpec
,
getStatus
(
urlRequest
));
if
(
connectionOpenException
!=
null
)
{
@Nullable
String
message
=
connectionOpenException
.
getMessage
();
if
(
message
!=
null
&&
Util
.
toLowerInvariant
(
message
).
contains
(
"err_cleartext_not_permitted"
))
{
throw
new
CleartextNotPermittedException
(
connectionOpenException
,
dataSpec
);
}
throw
new
OpenException
(
connectionOpenException
,
dataSpec
,
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
(
new
SocketTimeoutException
(),
dataSpec
,
getStatus
(
urlRequest
));
throw
new
OpenException
(
new
SocketTimeoutException
(),
dataSpec
,
getStatus
(
urlRequest
));
...
...
extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSource.java
View file @
2fbad210
...
@@ -242,6 +242,11 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
...
@@ -242,6 +242,11 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
responseBody
=
Assertions
.
checkNotNull
(
response
.
body
());
responseBody
=
Assertions
.
checkNotNull
(
response
.
body
());
responseByteStream
=
responseBody
.
byteStream
();
responseByteStream
=
responseBody
.
byteStream
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
@Nullable
String
message
=
e
.
getMessage
();
if
(
message
!=
null
&&
Util
.
toLowerInvariant
(
message
).
matches
(
"cleartext communication.*not permitted.*"
))
{
throw
new
CleartextNotPermittedException
(
e
,
dataSpec
);
}
throw
new
HttpDataSourceException
(
throw
new
HttpDataSourceException
(
"Unable to connect"
,
e
,
dataSpec
,
HttpDataSourceException
.
TYPE_OPEN
);
"Unable to connect"
,
e
,
dataSpec
,
HttpDataSourceException
.
TYPE_OPEN
);
}
}
...
...
library/common/src/main/java/com/google/android/exoplayer2/upstream/HttpDataSource.java
View file @
2fbad210
...
@@ -271,7 +271,24 @@ public interface HttpDataSource extends DataSource {
...
@@ -271,7 +271,24 @@ public interface HttpDataSource extends DataSource {
this
.
dataSpec
=
dataSpec
;
this
.
dataSpec
=
dataSpec
;
this
.
type
=
type
;
this
.
type
=
type
;
}
}
}
/**
* Thrown when cleartext HTTP traffic is not permitted. For more information including how to
* enable cleartext traffic, see the <a
* href="https://exoplayer.dev/issues/cleartext-not-permitted">corresponding troubleshooting
* topic</a>.
*/
final
class
CleartextNotPermittedException
extends
HttpDataSourceException
{
public
CleartextNotPermittedException
(
IOException
cause
,
DataSpec
dataSpec
)
{
super
(
"Cleartext HTTP traffic not permitted. See"
+
" https://exoplayer.dev/issues/cleartext-not-permitted"
,
cause
,
dataSpec
,
TYPE_OPEN
);
}
}
}
/**
/**
...
@@ -285,7 +302,6 @@ public interface HttpDataSource extends DataSource {
...
@@ -285,7 +302,6 @@ public interface HttpDataSource extends DataSource {
super
(
"Invalid content type: "
+
contentType
,
dataSpec
,
TYPE_OPEN
);
super
(
"Invalid content type: "
+
contentType
,
dataSpec
,
TYPE_OPEN
);
this
.
contentType
=
contentType
;
this
.
contentType
=
contentType
;
}
}
}
}
/**
/**
...
...
library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java
View file @
2fbad210
...
@@ -306,6 +306,11 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
...
@@ -306,6 +306,11 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
try
{
try
{
connection
=
makeConnection
(
dataSpec
);
connection
=
makeConnection
(
dataSpec
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
@Nullable
String
message
=
e
.
getMessage
();
if
(
message
!=
null
&&
Util
.
toLowerInvariant
(
message
).
matches
(
"cleartext http traffic.*not permitted.*"
))
{
throw
new
CleartextNotPermittedException
(
e
,
dataSpec
);
}
throw
new
HttpDataSourceException
(
throw
new
HttpDataSourceException
(
"Unable to connect"
,
e
,
dataSpec
,
HttpDataSourceException
.
TYPE_OPEN
);
"Unable to connect"
,
e
,
dataSpec
,
HttpDataSourceException
.
TYPE_OPEN
);
}
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultLoadErrorHandlingPolicy.java
View file @
2fbad210
...
@@ -19,6 +19,7 @@ import static java.lang.Math.min;
...
@@ -19,6 +19,7 @@ import static java.lang.Math.min;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.ParserException
;
import
com.google.android.exoplayer2.ParserException
;
import
com.google.android.exoplayer2.upstream.HttpDataSource.CleartextNotPermittedException
;
import
com.google.android.exoplayer2.upstream.HttpDataSource.InvalidResponseCodeException
;
import
com.google.android.exoplayer2.upstream.HttpDataSource.InvalidResponseCodeException
;
import
com.google.android.exoplayer2.upstream.Loader.UnexpectedLoaderException
;
import
com.google.android.exoplayer2.upstream.Loader.UnexpectedLoaderException
;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
...
@@ -86,14 +87,16 @@ public class DefaultLoadErrorHandlingPolicy implements LoadErrorHandlingPolicy {
...
@@ -86,14 +87,16 @@ public class DefaultLoadErrorHandlingPolicy implements LoadErrorHandlingPolicy {
/**
/**
* Retries for any exception that is not a subclass of {@link ParserException}, {@link
* Retries for any exception that is not a subclass of {@link ParserException}, {@link
* FileNotFoundException} or {@link UnexpectedLoaderException}. The retry delay is calculated as
* FileNotFoundException}, {@link CleartextNotPermittedException} or {@link
* {@code Math.min((errorCount - 1) * 1000, 5000)}.
* UnexpectedLoaderException}. The retry delay is calculated as {@code Math.min((errorCount - 1) *
* 1000, 5000)}.
*/
*/
@Override
@Override
public
long
getRetryDelayMsFor
(
LoadErrorInfo
loadErrorInfo
)
{
public
long
getRetryDelayMsFor
(
LoadErrorInfo
loadErrorInfo
)
{
IOException
exception
=
loadErrorInfo
.
exception
;
IOException
exception
=
loadErrorInfo
.
exception
;
return
exception
instanceof
ParserException
return
exception
instanceof
ParserException
||
exception
instanceof
FileNotFoundException
||
exception
instanceof
FileNotFoundException
||
exception
instanceof
CleartextNotPermittedException
||
exception
instanceof
UnexpectedLoaderException
||
exception
instanceof
UnexpectedLoaderException
?
C
.
TIME_UNSET
?
C
.
TIME_UNSET
:
min
((
loadErrorInfo
.
errorCount
-
1
)
*
1000
,
5000
);
:
min
((
loadErrorInfo
.
errorCount
-
1
)
*
1000
,
5000
);
...
...
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