Skip to content

StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.

Harden external Downloads route checks

David Nashash3cf5baf24f65
diff --git a/app/src/androidTest/java/com/streamvault/app/navigation/ExternalDownloadsRouteRuntimeTest.kt b/app/src/androidTest/java/com/streamvault/app/navigation/ExternalDownloadsRouteRuntimeTest.kt
new file mode 100644
index 00000000..31362eed
--- /dev/null
+++ b/app/src/androidTest/java/com/streamvault/app/navigation/ExternalDownloadsRouteRuntimeTest.kt
@@ -0,0 +1,51 @@
+package com.streamvault.app.navigation
+
+import android.content.Intent
+import androidx.test.core.app.ActivityScenario
+import androidx.test.core.app.ApplicationProvider
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.test.uiautomator.By
+import androidx.test.uiautomator.UiDevice
+import androidx.test.uiautomator.Until
+import com.streamvault.app.MainActivity
+import org.junit.Assert.assertTrue
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class ExternalDownloadsRouteRuntimeTest {
+ private val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
+ private val app = ApplicationProvider.getApplicationContext<android.app.Application>()
+
+ @Test
+ fun externalDownloadsRouteOpensOnColdStart() {
+ val intent = externalDownloadsIntent()
+
+ ActivityScenario.launch<MainActivity>(intent).use {
+ assertTrue(
+ "Cold launch did not reach Downloads",
+ device.wait(Until.hasObject(downloadsDestination), 20_000)
+ )
+ }
+ }
+
+ @Test
+ fun externalDownloadsRouteOpensInAlreadyRunningActivity() {
+ ActivityScenario.launch<MainActivity>(Intent(app, MainActivity::class.java)).use { scenario ->
+ scenario.onActivity { activity -> activity.onNewIntent(externalDownloadsIntent()) }
+
+ assertTrue(
+ "Running activity did not reach Downloads",
+ device.wait(Until.hasObject(downloadsDestination), 20_000)
+ )
+ }
+ }
+
+ private fun externalDownloadsIntent() = Intent(app, MainActivity::class.java)
+ .putExtra(MainActivity.EXTRA_EXTERNAL_ROUTE, "downloads")
+
+ private companion object {
+ val downloadsDestination = By.descStartsWith("streamvault.destination:downloads")
+ }
+}
diff --git a/app/src/test/java/com/streamvault/app/navigation/ExternalNavigationRequestParserTest.kt b/app/src/test/java/com/streamvault/app/navigation/ExternalNavigationRequestParserTest.kt
index 30e4a6fd..ea0951d9 100644
--- a/app/src/test/java/com/streamvault/app/navigation/ExternalNavigationRequestParserTest.kt
+++ b/app/src/test/java/com/streamvault/app/navigation/ExternalNavigationRequestParserTest.kt
@@ -1,8 +1,10 @@
package com.streamvault.app.navigation
import android.app.SearchManager
+import android.content.ComponentName
import android.content.Intent
import android.net.Uri
+import android.content.pm.PackageManager
import android.speech.RecognizerIntent
import com.google.common.truth.Truth.assertThat
import com.streamvault.app.MainActivity
@@ -46,6 +48,26 @@ class ExternalNavigationRequestParserTest {
)
}
+ @Test
+ fun advertisedExternalRoutesAreAcceptedByTheLegacyParser() {
+ @Suppress("DEPRECATION")
+ val activityInfo = context.packageManager.getActivityInfo(
+ ComponentName(context, MainActivity::class.java),
+ PackageManager.GET_META_DATA
+ )
+ val routes = checkNotNull(activityInfo.metaData)
+ .getString("com.streamvault.app.EXTERNAL_ROUTES")
+ .orEmpty()
+ .split(',')
+ .map(String::trim)
+ .filter(String::isNotEmpty)
+
+ assertThat(routes).containsExactly("home", "plugins", "downloads").inOrder()
+ routes.forEach { route ->
+ assertThat(AppRouteCodec.decodeLegacyExternalRoute(route)).isNotNull()
+ }
+ }
+
@Test
fun playlistMimeWithContentUriBecomesImportRequest() {
val uri = Uri.parse("content://example/playlist")
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index e6e0ec70..eef77373 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -5,6 +5,7 @@ All notable product changes are recorded in this document.
## [1.2.3]
### Added
+- Added support for launcher shortcuts to open the Downloads screen directly.
- Added backup export selection so you can choose which sections to include when saving, sharing, or uploading a backup to Google Drive.
- Added QR-based phone setup for EPG sources and Stremio add-ons, so their URLs can be submitted from a phone on the same local network.
- Added recognition of Brazilian Portuguese sports listings, including matchups, broadcast notes, and Brazilian and South American competitions.