Add ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED

And assign it to CleartextNotPermittedException.

PiperOrigin-RevId: 381247430
This commit is contained in:
aquilescanta 2021-06-24 15:09:16 +01:00 committed by Oliver Woodman
parent bcd4bb87e5
commit 465f7c06d8
2 changed files with 13 additions and 0 deletions

View File

@ -55,6 +55,7 @@ public class PlaybackException extends Exception implements Bundleable {
ERROR_CODE_IO_DNS_FAILED,
ERROR_CODE_IO_FILE_NOT_FOUND,
ERROR_CODE_IO_NO_PERMISSION,
ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED,
ERROR_CODE_PARSING_CONTAINER_MALFORMED,
ERROR_CODE_PARSING_MANIFEST_MALFORMED,
ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED,
@ -110,6 +111,14 @@ public class PlaybackException extends Exception implements Bundleable {
* access internet or external storage.
*/
public static final int ERROR_CODE_IO_NO_PERMISSION = 2008;
/**
* Caused by the player trying to access cleartext HTTP traffic (meaning http:// rather than
* https://) when the app's Network Security Configuration does not permit it.
*
* <p>See <a href="https://exoplayer.dev/issues/cleartext-not-permitted">this corresponding
* troubleshooting topic</a>.
*/
public static final int ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED = 2009;
// Content parsing errors (3xxx).
@ -202,6 +211,8 @@ public class PlaybackException extends Exception implements Bundleable {
return "ERROR_CODE_IO_FILE_NOT_FOUND";
case ERROR_CODE_IO_NO_PERMISSION:
return "ERROR_CODE_IO_NO_PERMISSION";
case ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED:
return "ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED";
case ERROR_CODE_PARSING_CONTAINER_MALFORMED:
return "ERROR_CODE_PARSING_CONTAINER_MALFORMED";
case ERROR_CODE_PARSING_MANIFEST_MALFORMED:

View File

@ -611,6 +611,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
errorCode = PlaybackException.ERROR_CODE_UNSPECIFIED;
}
handleIoException(e, errorCode);
} catch (HttpDataSource.CleartextNotPermittedException e) {
handleIoException(e, PlaybackException.ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED);
} catch (HttpDataSource.InvalidResponseCodeException e) {
handleIoException(e, PlaybackException.ERROR_CODE_IO_BAD_HTTP_STATUS);
} catch (HttpDataSource.HttpDataSourceException e) {