StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.
Kotlin iptv-player
phase 0 and partial phase 1
David Nashashd404e80fcade
diff --git a/app/build.gradle.kts b/app/build.gradle.ktsindex 837327c5..329a5f60 100644--- a/app/build.gradle.kts+++ b/app/build.gradle.kts@@ -119,6 +119,16 @@ android {}matchingFallbacks += listOf("release")}+ create("benchmark") {+ initWith(getByName("release"))+ isDebuggable = false+ isMinifyEnabled = false+ isShrinkResources = false+ if (keystorePropertiesFile.exists()) {+ signingConfig = signingConfigs.getByName("release")+ }+ matchingFallbacks += listOf("release")+ }release {isMinifyEnabled = trueisShrinkResources = truediff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerBackNavigationPolicy.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerBackNavigationPolicy.ktnew file mode 100644index 00000000..12a60412--- /dev/null+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerBackNavigationPolicy.kt@@ -0,0 +1,69 @@+package com.streamvault.app.ui.screens.player++/**+ * The modal priority used by the player Back key and system Back handler.+ *+ * This is deliberately platform-free so the priority can be tested without+ * composing the player or constructing a PlayerViewModel.+ */+internal enum class PlayerBackAction {+ CLEAR_NUMERIC_CHANNEL_INPUT,+ CANCEL_AUTO_PLAY,+ DISMISS_PLAYER_NOTICE,+ CLOSE_PROGRAM_HISTORY,+ CLOSE_SPLIT_DIALOG,+ CLOSE_EPISODE_PICKER,+ CLOSE_SPEED_SELECTION,+ CLOSE_AUDIO_VIDEO_OFFSET_DIALOG,+ CLOSE_STOP_PLAYBACK_TIMER,+ CLOSE_IDLE_STANDBY_TIMER,+ CLOSE_VARIANT_SELECTION,+ CLOSE_TRACK_SELECTION,+ TOGGLE_DIAGNOSTICS,+ CLOSE_CHANNEL_INFO,+ CLOSE_LIVE_OVERLAYS,+ TOGGLE_CONTROLS,+ NAVIGATE_BACK+}++internal data class PlayerBackNavigationState(+ val hasPendingNumericChannelInput: Boolean = false,+ val hasAutoPlayCountdown: Boolean = false,+ val hasPlayerNotice: Boolean = false,+ val showProgramHistory: Boolean = false,+ val showSplitDialog: Boolean = false,+ val showEpisodePicker: Boolean = false,+ val showSpeedSelection: Boolean = false,+ val showAudioVideoOffsetDialog: Boolean = false,+ val showStopPlaybackTimerDialog: Boolean = false,+ val showIdleStandbyTimerDialog: Boolean = false,+ val hasTrackSelection: Boolean = false,+ val showVariantSelection: Boolean = false,+ val showDiagnostics: Boolean = false,+ val showChannelInfoOverlay: Boolean = false,+ val showChannelListOverlay: Boolean = false,+ val showCategoryListOverlay: Boolean = false,+ val showEpgOverlay: Boolean = false,+ val showControls: Boolean = false+)++internal fun playerBackAction(state: PlayerBackNavigationState): PlayerBackAction = when {+ state.hasPendingNumericChannelInput -> PlayerBackAction.CLEAR_NUMERIC_CHANNEL_INPUT+ state.hasAutoPlayCountdown -> PlayerBackAction.CANCEL_AUTO_PLAY+ state.hasPlayerNotice -> PlayerBackAction.DISMISS_PLAYER_NOTICE+ state.showProgramHistory -> PlayerBackAction.CLOSE_PROGRAM_HISTORY+ state.showSplitDialog -> PlayerBackAction.CLOSE_SPLIT_DIALOG+ state.showEpisodePicker -> PlayerBackAction.CLOSE_EPISODE_PICKER+ state.showSpeedSelection -> PlayerBackAction.CLOSE_SPEED_SELECTION+ state.showAudioVideoOffsetDialog -> PlayerBackAction.CLOSE_AUDIO_VIDEO_OFFSET_DIALOG+ state.showStopPlaybackTimerDialog -> PlayerBackAction.CLOSE_STOP_PLAYBACK_TIMER+ state.showIdleStandbyTimerDialog -> PlayerBackAction.CLOSE_IDLE_STANDBY_TIMER+ state.showVariantSelection -> PlayerBackAction.CLOSE_VARIANT_SELECTION+ state.hasTrackSelection -> PlayerBackAction.CLOSE_TRACK_SELECTION+ state.showDiagnostics -> PlayerBackAction.TOGGLE_DIAGNOSTICS+ state.showChannelInfoOverlay -> PlayerBackAction.CLOSE_CHANNEL_INFO+ state.showChannelListOverlay || state.showCategoryListOverlay || state.showEpgOverlay ->+ PlayerBackAction.CLOSE_LIVE_OVERLAYS+ state.showControls -> PlayerBackAction.TOGGLE_CONTROLS+ else -> PlayerBackAction.NAVIGATE_BACK+}diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerLifecycleHost.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerLifecycleHost.ktnew file mode 100644index 00000000..f4348c35--- /dev/null+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerLifecycleHost.kt@@ -0,0 +1,77 @@+package com.streamvault.app.ui.screens.player++import android.view.WindowManager+import androidx.compose.runtime.Composable+import androidx.compose.runtime.DisposableEffect+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.getValue+import androidx.compose.runtime.rememberUpdatedState+import androidx.lifecycle.Lifecycle+import androidx.lifecycle.compose.LifecycleEventEffect+import com.streamvault.app.MainActivity+import com.streamvault.player.PlaybackState++/**+ * Owns player effects that coordinate the Android lifecycle and window state.+ *+ * This host intentionally contains no player rendering. Keeping lifecycle callbacks,+ * Picture-in-Picture state, cleanup, and the keep-screen-on flag together gives the+ * screen coordinator a smaller presentation responsibility without changing effect+ * keys or the existing ViewModel callbacks.+ */+@Composable+internal fun PlayerLifecycleHost(+ mainActivity: MainActivity?,+ playbackState: PlaybackState,+ isPlaying: Boolean,+ isInPictureInPictureMode: Boolean,+ showControls: Boolean,+ preventStandbyDuringPlayback: Boolean,+ viewModel: PlayerViewModel+) {+ val currentPictureInPictureMode by rememberUpdatedState(isInPictureInPictureMode)++ LaunchedEffect(isInPictureInPictureMode) {+ if (isInPictureInPictureMode) {+ viewModel.closeOverlays()+ if (showControls) {+ viewModel.toggleControls()+ }+ }+ }++ LifecycleEventEffect(Lifecycle.Event.ON_START) {+ viewModel.onAppForegrounded()+ }++ LifecycleEventEffect(Lifecycle.Event.ON_STOP) {+ if (currentPictureInPictureMode) {+ viewModel.closeOverlays()+ } else {+ viewModel.onAppBackgrounded()+ }+ }++ DisposableEffect(mainActivity) {+ onDispose {+ mainActivity?.clearPlayerPictureInPictureState()+ viewModel.onPlayerScreenDisposed()+ }+ }++ val playerWindow = mainActivity?.window+ DisposableEffect(Unit) {+ onDispose { playerWindow?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) }+ }++ LaunchedEffect(preventStandbyDuringPlayback, isPlaying, playbackState) {+ if (preventStandbyDuringPlayback) {+ // Keep screen always on while in player — prevents TV OS standby nag+ playerWindow?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)+ } else if (isPlaying || playbackState == PlaybackState.BUFFERING) {+ playerWindow?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)+ } else {+ playerWindow?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)+ }+ }+}diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerScreen.ktindex 3b04b945..2d002f3e 100644--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerScreen.kt+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerScreen.kt@@ -2,14 +2,12 @@ package com.streamvault.app.ui.screens.playerimport android.app.Activityimport android.view.KeyEvent-import android.view.WindowManagerimport androidx.activity.compose.BackHandlerimport androidx.compose.foundation.backgroundimport androidx.compose.foundation.layout.*import androidx.compose.foundation.shape.RoundedCornerShapeimport androidx.hilt.lifecycle.viewmodel.compose.hiltViewModelimport androidx.lifecycle.compose.collectAsStateWithLifecycle-import androidx.lifecycle.compose.LifecycleEventEffectimport androidx.compose.runtime.*import androidx.compose.runtime.saveable.rememberSaveableimport androidx.compose.ui.Alignment@@ -74,7 +72,6 @@ import androidx.compose.material3.SliderDefaultsimport androidx.compose.material3.CircularProgressIndicatorimport com.streamvault.app.ui.components.dialogs.ProgramHistoryDialogimport androidx.compose.ui.res.stringResource-import androidx.lifecycle.Lifecycleimport com.streamvault.app.Rimport com.streamvault.app.MainActivityimport com.streamvault.app.cast.CastConnectionState@@ -239,7 +236,6 @@ fun PlayerScreen(val channelInfoFocusRequester = remember { FocusRequester() }val layoutDirection = LocalLayoutDirection.currentval isRtl = layoutDirection == LayoutDirection.Rtl- val currentPictureInPictureMode by rememberUpdatedState(isInPictureInPictureMode)val enterPictureInPicture = remember(mainActivity) {{mainActivity?.enterPlayerPictureInPictureModeFromPlayer()@@ -277,49 +273,15 @@ fun PlayerScreen(}}- LaunchedEffect(isInPictureInPictureMode) {- if (isInPictureInPictureMode) {- viewModel.closeOverlays()- if (showControls) {- viewModel.toggleControls()- }- }- }-- LifecycleEventEffect(Lifecycle.Event.ON_START) {- viewModel.onAppForegrounded()- }-- LifecycleEventEffect(Lifecycle.Event.ON_STOP) {- if (currentPictureInPictureMode) {- viewModel.closeOverlays()- } else {- viewModel.onAppBackgrounded()- }- }-- DisposableEffect(mainActivity) {- onDispose {- mainActivity?.clearPlayerPictureInPictureState()- viewModel.onPlayerScreenDisposed()- }- }-- // Prevent screen from sleeping during active playback- val playerWindow = mainActivity?.window- DisposableEffect(Unit) {- onDispose { playerWindow?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) }- }- LaunchedEffect(preventStandbyDuringPlayback, isPlaying, playbackState) {- if (preventStandbyDuringPlayback) {- // Keep screen always on while in player — prevents TV OS standby nag- playerWindow?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)- } else if (isPlaying || playbackState == PlaybackState.BUFFERING) {- playerWindow?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)- } else {- playerWindow?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)- }- }+ PlayerLifecycleHost(+ mainActivity = mainActivity,+ playbackState = playbackState,+ isPlaying = isPlaying,+ isInPictureInPictureMode = isInPictureInPictureMode,+ showControls = showControls,+ preventStandbyDuringPlayback = preventStandbyDuringPlayback,+ viewModel = viewModel+ )// Consolidated focus management for all overlaysval liveOverlayVisible = contentType == "LIVE" && (showChannelListOverlay || showCategoryListOverlay || showEpgOverlay || showChannelInfoOverlay)@@ -513,30 +475,53 @@ fun PlayerScreen(showCategoryListOverlay,showEpgOverlay,showControls,- numericChannelInput+ numericChannelInput,+ onBack,+ viewModel) {{- when {- viewModel.hasPendingNumericChannelInput() -> viewModel.clearNumericChannelInput()- autoPlayCountdown != null -> viewModel.cancelAutoPlay()- playerNotice != null -> viewModel.dismissPlayerNotice()- showProgramHistory -> showProgramHistory = false- showSplitDialog -> showSplitDialog = false- showEpisodePicker -> showEpisodePicker = false- showSpeedSelection -> showSpeedSelection = false- showAudioVideoOffsetDialog -> {+ when (playerBackAction(+ PlayerBackNavigationState(+ hasPendingNumericChannelInput = viewModel.hasPendingNumericChannelInput(),+ hasAutoPlayCountdown = autoPlayCountdown != null,+ hasPlayerNotice = playerNotice != null,+ showProgramHistory = showProgramHistory,+ showSplitDialog = showSplitDialog,+ showEpisodePicker = showEpisodePicker,+ showSpeedSelection = showSpeedSelection,+ showAudioVideoOffsetDialog = showAudioVideoOffsetDialog,+ showStopPlaybackTimerDialog = showStopPlaybackTimerDialog,+ showIdleStandbyTimerDialog = showIdleStandbyTimerDialog,+ hasTrackSelection = showTrackSelection != null,+ showVariantSelection = showVariantSelection,+ showDiagnostics = showDiagnostics,+ showChannelInfoOverlay = showChannelInfoOverlay,+ showChannelListOverlay = showChannelListOverlay,+ showCategoryListOverlay = showCategoryListOverlay,+ showEpgOverlay = showEpgOverlay,+ showControls = showControls+ )+ )) {+ PlayerBackAction.CLEAR_NUMERIC_CHANNEL_INPUT -> viewModel.clearNumericChannelInput()+ PlayerBackAction.CANCEL_AUTO_PLAY -> viewModel.cancelAutoPlay()+ PlayerBackAction.DISMISS_PLAYER_NOTICE -> viewModel.dismissPlayerNotice()+ PlayerBackAction.CLOSE_PROGRAM_HISTORY -> showProgramHistory = false+ PlayerBackAction.CLOSE_SPLIT_DIALOG -> showSplitDialog = false+ PlayerBackAction.CLOSE_EPISODE_PICKER -> showEpisodePicker = false+ PlayerBackAction.CLOSE_SPEED_SELECTION -> showSpeedSelection = false+ PlayerBackAction.CLOSE_AUDIO_VIDEO_OFFSET_DIALOG -> {showAudioVideoOffsetDialog = falseviewModel.dismissAudioVideoOffsetPreview()}- showStopPlaybackTimerDialog -> showStopPlaybackTimerDialog = false- showIdleStandbyTimerDialog -> showIdleStandbyTimerDialog = false- showVariantSelection -> showVariantSelection = false- showTrackSelection != null -> showTrackSelection = null- showDiagnostics -> viewModel.toggleDiagnostics()- showChannelInfoOverlay -> viewModel.closeChannelInfoOverlay()- showChannelListOverlay || showCategoryListOverlay || showEpgOverlay -> viewModel.closeOverlays()- showControls -> viewModel.toggleControls()- else -> onBack()+ PlayerBackAction.CLOSE_STOP_PLAYBACK_TIMER -> showStopPlaybackTimerDialog = false+ PlayerBackAction.CLOSE_IDLE_STANDBY_TIMER -> showIdleStandbyTimerDialog = false+ PlayerBackAction.CLOSE_VARIANT_SELECTION -> showVariantSelection = false+ PlayerBackAction.CLOSE_TRACK_SELECTION -> showTrackSelection = null+ PlayerBackAction.TOGGLE_DIAGNOSTICS -> viewModel.toggleDiagnostics()+ PlayerBackAction.CLOSE_CHANNEL_INFO -> viewModel.closeChannelInfoOverlay()+ PlayerBackAction.CLOSE_LIVE_OVERLAYS -> viewModel.closeOverlays()+ PlayerBackAction.TOGGLE_CONTROLS -> viewModel.toggleControls()+ PlayerBackAction.NAVIGATE_BACK -> onBack()}}}diff --git a/app/src/release/AndroidManifest.xml b/app/src/release/AndroidManifest.xmlnew file mode 100644index 00000000..1af7801d--- /dev/null+++ b/app/src/release/AndroidManifest.xml@@ -0,0 +1,6 @@+<?xml version="1.0" encoding="utf-8"?>+<manifest xmlns:android="http://schemas.android.com/apk/res/android">+ <application>+ <profileable android:shell="true" />+ </application>+</manifest>diff --git a/app/src/test/java/com/streamvault/app/ui/screens/player/PlayerBackNavigationPolicyTest.kt b/app/src/test/java/com/streamvault/app/ui/screens/player/PlayerBackNavigationPolicyTest.ktnew file mode 100644index 00000000..104447fd--- /dev/null+++ b/app/src/test/java/com/streamvault/app/ui/screens/player/PlayerBackNavigationPolicyTest.kt@@ -0,0 +1,44 @@+package com.streamvault.app.ui.screens.player++import com.google.common.truth.Truth.assertThat+import org.junit.Test++class PlayerBackNavigationPolicyTest {++ @Test+ fun `numeric input has priority over every visible layer`() {+ val state = PlayerBackNavigationState(+ hasPendingNumericChannelInput = true,+ hasAutoPlayCountdown = true,+ showControls = true+ )++ assertThat(playerBackAction(state)).isEqualTo(PlayerBackAction.CLEAR_NUMERIC_CHANNEL_INPUT)+ }++ @Test+ fun `dialogs close before live overlays`() {+ val state = PlayerBackNavigationState(+ showChannelInfoOverlay = true,+ showAudioVideoOffsetDialog = true+ )++ assertThat(playerBackAction(state)).isEqualTo(PlayerBackAction.CLOSE_AUDIO_VIDEO_OFFSET_DIALOG)+ }++ @Test+ fun `live overlays close before controls`() {+ val state = PlayerBackNavigationState(+ showChannelListOverlay = true,+ showControls = true+ )++ assertThat(playerBackAction(state)).isEqualTo(PlayerBackAction.CLOSE_LIVE_OVERLAYS)+ }++ @Test+ fun `empty player state navigates back`() {+ assertThat(playerBackAction(PlayerBackNavigationState()))+ .isEqualTo(PlayerBackAction.NAVIGATE_BACK)+ }+}diff --git a/benchmark/build.gradle.kts b/benchmark/build.gradle.ktsnew file mode 100644index 00000000..7e3fc873--- /dev/null+++ b/benchmark/build.gradle.kts@@ -0,0 +1,74 @@+import java.io.FileInputStream+import java.util.Properties++val keystorePropertiesFile = rootProject.file("keystore.properties")+val keystoreProperties = Properties()+if (keystorePropertiesFile.exists()) {+ FileInputStream(keystorePropertiesFile).use(keystoreProperties::load)+}++plugins {+ alias(libs.plugins.android.test)+ alias(libs.plugins.kotlin.android)+}++android {+ namespace = "com.streamvault.benchmark"+ compileSdk = 36++ defaultConfig {+ minSdk = 25+ targetSdk = 36+ testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"+ testInstrumentationRunnerArguments["androidx.benchmark.enabledRules"] = "Macrobenchmark"+ }++ targetProjectPath = ":app"+ experimentalProperties["android.experimental.self-instrumenting"] = true++ signingConfigs {+ if (keystorePropertiesFile.exists()) {+ create("release") {+ storeFile = rootProject.file(keystoreProperties.getProperty("storeFile"))+ storePassword = keystoreProperties.getProperty("storePassword")+ keyAlias = keystoreProperties.getProperty("keyAlias")+ keyPassword = keystoreProperties.getProperty("keyPassword")+ }+ }+ }++ buildTypes {+ create("benchmark") {+ isDebuggable = false+ isMinifyEnabled = false+ signingConfig = signingConfigs.findByName("release")+ ?: signingConfigs.getByName("debug")+ matchingFallbacks += listOf("release")+ }+ }++ compileOptions {+ sourceCompatibility = JavaVersion.VERSION_17+ targetCompatibility = JavaVersion.VERSION_17+ }+}++kotlin {+ compilerOptions {+ jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)+ }+}++dependencies {+ implementation(libs.kotlin.stdlib)+ implementation(libs.benchmark.macro.junit4)+ implementation(libs.androidx.test.ext.junit)+ implementation(libs.androidx.test.runner)+ implementation(libs.uiautomator)+ implementation(libs.arch.core.common)+ implementation(libs.arch.core.runtime)+ implementation(libs.profileinstaller)+ implementation(libs.startup.runtime)+ implementation(libs.errorprone.annotations)+ implementation(libs.tracing)+}diff --git a/benchmark/src/main/java/com/streamvault/benchmark/BenchmarkConfig.kt b/benchmark/src/main/java/com/streamvault/benchmark/BenchmarkConfig.ktnew file mode 100644index 00000000..aaaff204--- /dev/null+++ b/benchmark/src/main/java/com/streamvault/benchmark/BenchmarkConfig.kt@@ -0,0 +1,55 @@+package com.streamvault.benchmark++import android.app.Instrumentation+import androidx.benchmark.macro.MacrobenchmarkScope+import androidx.test.platform.app.InstrumentationRegistry+import androidx.test.uiautomator.By+import androidx.test.uiautomator.UiDevice+import androidx.test.uiautomator.Until++internal const val RELEASE_TARGET_PACKAGE = "com.streamvault.app"+internal const val SEEDED_DEBUG_PACKAGE = "com.streamvault.app.debug"+internal const val BENCHMARK_ITERATIONS = 5+internal const val UI_TIMEOUT_MS = 7_000L++private val instrumentation: Instrumentation+ get() = InstrumentationRegistry.getInstrumentation()++private val device: UiDevice+ get() = UiDevice.getInstance(instrumentation)++internal fun MacrobenchmarkScope.startTargetApp() {+ pressHome()+ startActivityAndWait()+}++internal fun MacrobenchmarkScope.openTopLevelDestination(label: String) {+ startTargetApp()+ check(device.wait(Until.hasObject(By.text(label)), UI_TIMEOUT_MS)) {+ "Expected seeded app shell destination '$label'. " ++ "Install a release-like APK with a development provider before running this journey."+ }+ device.findObject(By.text(label)).click()+ device.waitForIdle()+}++internal fun MacrobenchmarkScope.swipeContent(repetitions: Int = 3) {+ val width = device.displayWidth+ val height = device.displayHeight+ repeat(repetitions) {+ device.swipe(+ width / 2,+ (height * 0.78f).toInt(),+ width / 2,+ (height * 0.22f).toInt(),+ 24+ )+ }+}++internal fun MacrobenchmarkScope.navigateLiveAndOpenFocusedChannel() {+ openTopLevelDestination("Live TV")+ device.pressDPadDown()+ device.pressDPadCenter()+ device.waitForIdle()+}diff --git a/benchmark/src/main/java/com/streamvault/benchmark/StreamVaultMacrobenchmark.kt b/benchmark/src/main/java/com/streamvault/benchmark/StreamVaultMacrobenchmark.ktnew file mode 100644index 00000000..be84af70--- /dev/null+++ b/benchmark/src/main/java/com/streamvault/benchmark/StreamVaultMacrobenchmark.kt@@ -0,0 +1,106 @@+package com.streamvault.benchmark++import androidx.benchmark.macro.FrameTimingMetric+import androidx.benchmark.macro.StartupMode+import androidx.benchmark.macro.StartupTimingMetric+import androidx.benchmark.macro.junit4.MacrobenchmarkRule+import androidx.test.ext.junit.runners.AndroidJUnit4+import androidx.test.filters.LargeTest+import org.junit.Rule+import org.junit.Test+import org.junit.runner.RunWith++@LargeTest+@RunWith(AndroidJUnit4::class)+class StreamVaultMacrobenchmark {++ @get:Rule+ val benchmarkRule = MacrobenchmarkRule()++ @Test+ fun coldStartup() = benchmarkRule.measureRepeated(+ packageName = RELEASE_TARGET_PACKAGE,+ metrics = listOf(StartupTimingMetric()),+ startupMode = StartupMode.COLD,+ iterations = BENCHMARK_ITERATIONS+ ) {+ startTargetApp()+ }++ @Test+ fun dashboardVerticalScroll() = benchmarkRule.measureRepeated(+ packageName = SEEDED_DEBUG_PACKAGE,+ metrics = listOf(FrameTimingMetric()),+ startupMode = StartupMode.WARM,+ iterations = BENCHMARK_ITERATIONS,+ setupBlock = {+ openTopLevelDestination("Home")+ }+ ) {+ swipeContent()+ }++ @Test+ fun liveTvCategoryAndChannelNavigation() = benchmarkRule.measureRepeated(+ packageName = SEEDED_DEBUG_PACKAGE,+ metrics = listOf(FrameTimingMetric()),+ startupMode = StartupMode.WARM,+ iterations = BENCHMARK_ITERATIONS,+ setupBlock = {+ openTopLevelDestination("Live TV")+ }+ ) {+ devicePressDPadNavigation()+ }++ @Test+ fun epgHorizontalAndVerticalNavigation() = benchmarkRule.measureRepeated(+ packageName = SEEDED_DEBUG_PACKAGE,+ metrics = listOf(FrameTimingMetric()),+ startupMode = StartupMode.WARM,+ iterations = BENCHMARK_ITERATIONS,+ setupBlock = {+ openTopLevelDestination("Guide")+ }+ ) {+ devicePressDPadNavigation()+ }++ @Test+ fun playerControlsOpenAndNavigate() = benchmarkRule.measureRepeated(+ packageName = SEEDED_DEBUG_PACKAGE,+ metrics = listOf(FrameTimingMetric()),+ startupMode = StartupMode.WARM,+ iterations = BENCHMARK_ITERATIONS,+ setupBlock = {+ navigateLiveAndOpenFocusedChannel()+ }+ ) {+ devicePressDPadNavigation()+ }++ @Test+ fun settingsScrollAndDialogNavigation() = benchmarkRule.measureRepeated(+ packageName = SEEDED_DEBUG_PACKAGE,+ metrics = listOf(FrameTimingMetric()),+ startupMode = StartupMode.WARM,+ iterations = BENCHMARK_ITERATIONS,+ setupBlock = {+ openTopLevelDestination("Settings")+ }+ ) {+ swipeContent()+ }+}++private fun devicePressDPadNavigation() {+ val device = androidx.test.uiautomator.UiDevice.getInstance(+ androidx.test.platform.app.InstrumentationRegistry.getInstrumentation()+ )+ repeat(3) {+ device.pressDPadRight()+ device.pressDPadDown()+ device.pressDPadLeft()+ device.pressDPadUp()+ }+}diff --git a/build.gradle.kts b/build.gradle.ktsindex da0646fd..1c7809d0 100644--- a/build.gradle.kts+++ b/build.gradle.kts@@ -1,5 +1,6 @@plugins {alias(libs.plugins.android.application) apply false+ alias(libs.plugins.android.test) apply falsealias(libs.plugins.android.library) apply falsealias(libs.plugins.kotlin.android) apply falsealias(libs.plugins.kotlin.jvm) apply falsediff --git a/docs/COMPOSE_REDUCTION_AND_UI_ARCHITECTURE_PLAN.md b/docs/COMPOSE_REDUCTION_AND_UI_ARCHITECTURE_PLAN.mdindex 78115c3b..e4c10384 100644--- a/docs/COMPOSE_REDUCTION_AND_UI_ARCHITECTURE_PLAN.md+++ b/docs/COMPOSE_REDUCTION_AND_UI_ARCHITECTURE_PLAN.md@@ -7,9 +7,9 @@ Scope: Android application UI, navigation, build structure, and UI-facing module## Current execution state-Phase 0 is partially complete. The build and Compose compiler baseline is recorded in [`COMPOSE_REDUCTION_BASELINE.md`](COMPOSE_REDUCTION_BASELINE.md), and the Compose compiler diagnostic outputs are now generated under `app/build/reports/compose-compiler/`.+Phase 0 is complete for the available development environment. The build, artifact, memory, Compose compiler, Macrobenchmark, and live-playback baseline is recorded in [`COMPOSE_REDUCTION_BASELINE.md`](COMPOSE_REDUCTION_BASELINE.md), and the Compose compiler diagnostic outputs are generated under `app/build/reports/compose-compiler/`. Physical-device measurements and a stable provider stream are explicitly listed as follow-up limitations, not treated as successful release-quality measurements.-The first Phase 1 refactor has also started: `PlayerControlsOverlayHost` was moved out of `PlayerScreen.kt` into its own file without changing its parameters, callbacks, routes, or playback behavior. This reduced `PlayerScreen.kt` from 1,561 to 1,432 lines. `:app:compileDebugKotlin` passes after the extraction.+The first Phase 1 refactor has also started: `PlayerControlsOverlayHost` was moved out of `PlayerScreen.kt` into its own file without changing its parameters, callbacks, routes, or playback behavior. The player Back-navigation priority is now also isolated in the platform-free `PlayerBackNavigationPolicy`, with focused unit tests. Android lifecycle, Picture-in-Picture cleanup, and keep-screen-on effects are now isolated in `PlayerLifecycleHost` while preserving the original effect keys and callback order. These changes reduced the root screen's coordination responsibilities while preserving the existing callback behavior. `:app:compileDebugKotlin` and the app unit-test suite pass.The full `:app:testDebugUnitTest` task now passes after the test fixture was updated to provide the already-required `m3uClassificationRepository` mock. No production behavior was changed; existing coroutine opt-in warnings remain.@@ -707,6 +707,8 @@ Exit criteria:- Debug-only Compose overhead is not used to judge release runtime.- The team agrees on baseline-relative targets in Section 13.+Phase 0 execution outcome (2026-08-16): the five-run build repeatability checks, five-iteration release-like cold-start benchmark, five-iteration interaction journeys, release APK/dex snapshot, emulator memory snapshot, and two-channel long-duration playback evidence are recorded in `COMPOSE_REDUCTION_BASELINE.md`. Macrobenchmark interaction journeys use the seeded debug fixture because the release-like benchmark target has no provider data; those results are diagnostic only. The CBSN channel completed the full playback window, while the F1 channel received an external HTTP 403 after initially rendering video. Full playback validation therefore remains a Phase 1 gate for playback-facing changes.+### Phase 1 - Source decomposition without behavior changePurpose: make later changes reviewable and lower merge risk.@@ -1031,10 +1033,12 @@ The modernization is complete when:- [x] Capture initial clean-task-graph and warm Gradle baselines. See `docs/COMPOSE_REDUCTION_BASELINE.md`.- [x] Add Compose compiler reports and inspect player/provider stability output. See `docs/COMPOSE_REDUCTION_BASELINE.md`.- [x] Complete the first no-behavior-change slice by extracting `PlayerControlsOverlayHost`.+- [x] Extract and unit-test the player Back-navigation priority policy without changing event handling.+- [x] Extract player lifecycle/window effects into `PlayerLifecycleHost` without changing effect keys or callbacks.- [ ] Run a manual app smoke test for player launch, controls, remote/back handling, seeking, and overlay actions.- [ ] Run full multi-channel Live TV validation before marking the player phase complete.-- [ ] Add or define the Macrobenchmark module and constrained-device benchmark flows.-- [ ] Create the first no-behavior-change PR for `PlayerScreen` decomposition.+- [x] Add or define the Macrobenchmark module and constrained-device benchmark flows.+- [ ] Create the first no-behavior-change PR for `PlayerScreen` decomposition after the manual smoke test.- [ ] Create the second no-behavior-change PR for `ProviderSetupScreen` decomposition.- [ ] Revisit the initial success targets after baseline data is available.diff --git a/docs/COMPOSE_REDUCTION_BASELINE.md b/docs/COMPOSE_REDUCTION_BASELINE.mdindex 3cb0810b..42e0bada 100644--- a/docs/COMPOSE_REDUCTION_BASELINE.md+++ b/docs/COMPOSE_REDUCTION_BASELINE.md@@ -1,6 +1,6 @@# Compose Reduction Baseline-Date: 2026-08-15+Date: 2026-08-16Repository state: existing user changes in `gradle.properties` and `player/build.gradle.kts` were preservedPurpose: Phase 0 baseline for UI architecture and Compose reduction work@@ -14,7 +14,44 @@ Verification after the extraction:- `graphify update .` — passed; graph refreshed to 12,893 nodes and 24,601 edges.- `:app:testDebugUnitTest` — passed after the test fixture was updated to provide the already-required `m3uClassificationRepository` mock. Existing coroutine opt-in warnings remain.-This document records the first build and Compose compiler measurements before any feature UI refactoring. The numbers are directional until repeated with Gradle Profiler and runtime benchmarks.+This document records the Phase 0 baseline and the first Phase 1 source decomposition. Phase 0 is complete for the available emulator/development environment; physical-device and provider-auth limitations are recorded below.++## Phase 0 completion measurements++Validation environment:++- SDK: `E:\androidSdk`+- Emulator: `emulator-5554`, `AOSP_TV_on_x86`, 1920x1080, API 36+- Release-like benchmark target: `com.streamvault.app`, non-debuggable `benchmark` build type+- Seeded interaction fixture: `com.streamvault.app.debug`++### Repeated builds++| Scenario | Runs (seconds) | Result |+|---|---:|---|+| Warm `:app:assembleDebug --no-daemon` | 286.610, 12.046, 11.673, 11.445, 11.692 | Passed; run 1 included variant/configuration work, subsequent runs were stable |+| Touch `PlayerScreen.kt` + `:app:compileDebugKotlin --no-daemon` | 19.671, 9.334, 9.428, 9.447, 9.396 | Passed; four stable incremental runs were about 9.3–9.4s |++### Runtime benchmark and artifacts++- Macrobenchmark module builds and installs successfully.+- Release-like cold startup: 5 iterations, median `975.8 ms`, min `888.4 ms`, max `1,487.6 ms` on the emulator. Android reported the expected emulator warning; do not use this as a physical-device target.+- Seeded interaction journeys: dashboard scroll, Live TV navigation, EPG navigation, player-controls navigation, and settings navigation all completed 5 iterations. Dashboard diagnostic snapshot: median 87 frames, P50 frame overrun 9.5 ms, P90 27.4 ms, P99 79.2 ms.+- Release APK: `18,138,676` bytes; 3 dex files totaling `14,015,356` bytes.+- Release cold `am start -W`: `648 ms` on the same emulator.+- Release-like process memory after 5 seconds: `91,441 kB` total PSS.+- Seeded debug process memory after 5 seconds: `265,167 kB` total PSS. This is diagnostic only and includes debug/runtime overhead.++### Live TV long-run evidence++Each channel used 61 screenshots at a 2-second cadence (120 seconds nominal), with SHA-256 frame-hash progression checked.++| Channel | Frames | Unique hashes | Final media session | Result |+|---|---:|---:|---|---|+| F1 Channel | 61 | 32 | `ERROR`, `Source error` | Failed after initially rendering video; sanitized logs show provider HTTP 403 and no recovery candidate |+| US CBSN New York (D) | 61 | 61 | `PLAYING`, `error=null` | Passed; no fatal/stuck-player error observed |++The F1 result is an external stream/authentication failure, not evidence of a Compose regression. Full multi-channel playback validation remains required after playback-facing Phase 1 changes.## Build baselinediff --git a/gradle/libs.versions.toml b/gradle/libs.versions.tomlindex 2436d781..61d8b685 100644--- a/gradle/libs.versions.toml+++ b/gradle/libs.versions.toml@@ -8,6 +8,13 @@ compose-tv-foundation = "1.0.0-beta01"# Pinned intentionally; stable as of 2026-03-18, update only after TV regression testing.# Remaining experimental TV Material usage is limited to FilterChip in SearchScreen.compose-tv-material = "1.0.1"+benchmark = "1.4.1"+uiautomator = "2.3.0"+arch-core = "2.2.0"+profileinstaller = "1.4.1"+startup-runtime = "1.1.1"+errorprone-annotations = "2.36.0"+tracing = "1.2.0"media3 = "1.9.2"room = "2.8.4"hilt = "2.56.2"@@ -42,6 +49,7 @@ espresso = "3.6.1"androidx-test-runner = "1.6.2"[libraries]+kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" }# Compose BOMcompose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }compose-ui = { group = "androidx.compose.ui", name = "ui" }@@ -122,6 +130,14 @@ play-services-cast-framework = { group = "com.google.android.gms", name = "play-play-services-auth = { group = "com.google.android.gms", name = "play-services-auth", version.ref = "play-services-auth" }# Test+benchmark-macro-junit4 = { group = "androidx.benchmark", name = "benchmark-macro-junit4", version.ref = "benchmark" }+uiautomator = { group = "androidx.test.uiautomator", name = "uiautomator", version.ref = "uiautomator" }+arch-core-common = { group = "androidx.arch.core", name = "core-common", version.ref = "arch-core" }+arch-core-runtime = { group = "androidx.arch.core", name = "core-runtime", version.ref = "arch-core" }+profileinstaller = { group = "androidx.profileinstaller", name = "profileinstaller", version.ref = "profileinstaller" }+startup-runtime = { group = "androidx.startup", name = "startup-runtime", version.ref = "startup-runtime" }+errorprone-annotations = { group = "com.google.errorprone", name = "error_prone_annotations", version.ref = "errorprone-annotations" }+tracing = { group = "androidx.tracing", name = "tracing", version.ref = "tracing" }junit = { group = "junit", name = "junit", version.ref = "junit" }truth = { group = "com.google.truth", name = "truth", version.ref = "truth" }coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutines" }@@ -134,6 +150,7 @@ espresso-core = { group = "androidx.test.espresso", name = "espresso-core", vers[plugins]android-application = { id = "com.android.application", version.ref = "agp" }+android-test = { id = "com.android.test", version.ref = "agp" }android-library = { id = "com.android.library", version.ref = "agp" }kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }diff --git a/settings.gradle.kts b/settings.gradle.ktsindex 4bdea7b9..d4dc850e 100644--- a/settings.gradle.kts+++ b/settings.gradle.kts@@ -17,6 +17,7 @@ dependencyResolutionManagement {rootProject.name = "StreamVault"include(":app")+include(":benchmark")include(":domain")include(":data")include(":player")