From 465f7c06d8c8050c8bfc32fac3b9bde8bb8e1a25 Mon Sep 17 00:00:00 2001 From: aquilescanta Date: Thu, 24 Jun 2021 15:09:16 +0100 Subject: [PATCH] Add ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED And assign it to CleartextNotPermittedException. PiperOrigin-RevId: 381247430 --- .../google/android/exoplayer2/PlaybackException.java | 11 +++++++++++ .../android/exoplayer2/ExoPlayerImplInternal.java | 2 ++ 2 files changed, 13 insertions(+) diff --git a/library/common/src/main/java/com/google/android/exoplayer2/PlaybackException.java b/library/common/src/main/java/com/google/android/exoplayer2/PlaybackException.java index 6cb2480d20..419acf566f 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/PlaybackException.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/PlaybackException.java @@ -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. + * + *

See this corresponding + * troubleshooting topic. + */ + 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: diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java index 9d43ab7abf..a9b0a00f95 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java @@ -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) {