From 163c577d7b4460f9be68660c7ac1f2946689bb58 Mon Sep 17 00:00:00 2001 From: Katherine Blizard <414924+kabliz@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:12:38 -0700 Subject: [PATCH] [APT-10344] Initialization State Smoothness - Ensured that ArmadilloPlayer.armadilloStateObservable has a state as soon as the player is initialized - Fixed UnknownHostException being mapped to a HTTP status code issue rather than a Connectivity issue. --- Armadillo/src/main/java/com/scribd/armadillo/StateStore.kt | 4 +++- .../java/com/scribd/armadillo/error/ArmadilloException.kt | 3 ++- .../com/scribd/armadillo/playback/ExoPlaybackExceptionExt.kt | 3 +-- RELEASE.md | 4 ++++ gradle.properties | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Armadillo/src/main/java/com/scribd/armadillo/StateStore.kt b/Armadillo/src/main/java/com/scribd/armadillo/StateStore.kt index b75898a..591818d 100644 --- a/Armadillo/src/main/java/com/scribd/armadillo/StateStore.kt +++ b/Armadillo/src/main/java/com/scribd/armadillo/StateStore.kt @@ -33,7 +33,9 @@ internal class ArmadilloStateStore(private val reducer: Reducer, private val han const val TAG = "ArmadilloStateStore" } - private val armadilloStateObservable = BehaviorSubject.create() + private val armadilloStateObservable = BehaviorSubject.create().also { + it.onNext(ArmadilloState(downloadInfo = emptyList())) + } override fun init(state: ArmadilloState) = armadilloStateObservable.onNext(state) diff --git a/Armadillo/src/main/java/com/scribd/armadillo/error/ArmadilloException.kt b/Armadillo/src/main/java/com/scribd/armadillo/error/ArmadilloException.kt index 2f3bb58..32bfe83 100644 --- a/Armadillo/src/main/java/com/scribd/armadillo/error/ArmadilloException.kt +++ b/Armadillo/src/main/java/com/scribd/armadillo/error/ArmadilloException.kt @@ -3,6 +3,7 @@ package com.scribd.armadillo.error import com.google.android.exoplayer2.upstream.HttpDataSource.HttpDataSourceException import com.scribd.armadillo.actions.Action import java.net.SocketTimeoutException +import java.net.UnknownHostException sealed class ArmadilloException(cause: Throwable? = null, isNetworkRelatedError: Boolean = false, @@ -181,7 +182,7 @@ class DrmDownloadException(cause: Exception) : ArmadilloException( cause = cause, message = "Failed to process DRM license for downloading.", - isNetworkRelatedError = (cause is HttpDataSourceException) || (cause is SocketTimeoutException)) { + isNetworkRelatedError = (cause is HttpDataSourceException) || (cause is SocketTimeoutException) || (cause is UnknownHostException)) { override val errorCode = 701 } diff --git a/Armadillo/src/main/java/com/scribd/armadillo/playback/ExoPlaybackExceptionExt.kt b/Armadillo/src/main/java/com/scribd/armadillo/playback/ExoPlaybackExceptionExt.kt index 14cd799..cde6af7 100644 --- a/Armadillo/src/main/java/com/scribd/armadillo/playback/ExoPlaybackExceptionExt.kt +++ b/Armadillo/src/main/java/com/scribd/armadillo/playback/ExoPlaybackExceptionExt.kt @@ -30,9 +30,8 @@ internal fun ExoPlaybackException.toArmadilloException(): ArmadilloException { val httpCause = source.cause as? HttpDataSource.InvalidResponseCodeException HttpResponseCodeException(httpCause?.responseCode ?: 0, httpCause?.dataSpec?.uri.toString(), source) } + is UnknownHostException, is SocketTimeoutException -> ConnectivityException(source) - is UnknownHostException -> - HttpResponseCodeException(0, source.message, source) // Message is supposed to be the host for UnknownHostException else -> ArmadilloIOException(cause = this, actionThatFailedMessage = "Exoplayer error.") } } diff --git a/RELEASE.md b/RELEASE.md index 9e4a00a..3f7e8b0 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,5 +1,9 @@ # Project Armadillo Release Notes +## 1.5.4 +- Ensured that ArmadilloPlayer.armadilloStateObservable has a state as soon as the player is initialized +- Fixed UnknownHostException being mapped to a HTTP status code issue rather than a Connectivity issue. + ## 1.5.3 - Attempts to renew the widevine license of downloaded DRM content when playback begins, similarly to how streaming does it. - Fixes ANR issue in the Reducer. diff --git a/gradle.properties b/gradle.properties index bb34d89..7cdf70e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ org.gradle.jvmargs=-Xmx1536m # org.gradle.parallel=true PACKAGE_NAME=com.scribd.armadillo GRADLE_PLUGIN_VERSION=7.2.0 -LIBRARY_VERSION=1.5.3 +LIBRARY_VERSION=1.5.4 EXOPLAYER_VERSION=2.19.1 RXJAVA_VERSION=2.2.4 RXANDROID_VERSION=2.0.1