Skip to content

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

refactor(live): extract epg lock policy

David Nashash844a1f198e45
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgScreen.kt
index 8ffb45d6..12cecdfc 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgScreen.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgScreen.kt
@@ -5,6 +5,7 @@ import com.streamvault.domain.playback.ArchiveReplayMechanism
import com.streamvault.domain.playback.archivePlaybackCapability
import com.streamvault.domain.playback.isArchivePlayable
import com.streamvault.feature.live.presentation.epg.resolveLiveGuideFocus
+import com.streamvault.feature.live.presentation.epg.isLiveGuideChannelLocked
import com.streamvault.feature.live.presentation.epg.LiveGuideNowProvider
import com.streamvault.feature.live.presentation.epg.currentLiveGuideNow
import com.streamvault.feature.live.presentation.epg.LiveGuideSearchOverlay
@@ -981,14 +982,6 @@ private fun isGuideChannelLocked(
channel: Channel,
categoriesById: Map<Long, Category>,
parentalControlLevel: Int
-): Boolean {
- if (parentalControlLevel !in 1..2) {
- return false
- }
- val categoryLocked = channel.categoryId?.let(categoriesById::get)?.let { category ->
- category.isAdult || category.isUserProtected
- } ?: false
- return channel.isAdult || channel.isUserProtected || categoryLocked
-}
+): Boolean = isLiveGuideChannelLocked(channel, categoriesById, parentalControlLevel)
diff --git a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
index 90127ddb..3b0802cd 100644
--- a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
+++ b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
@@ -141,6 +141,7 @@ pane, guide toolbar, guide message state, hero badge, timeline header, grid
rows/cells, grid host, EPG content host, focus reconciliation, Home layout
metrics, and Home parental-lock policy are now feature-owned, with the options
overlay and EPG-match dialog also feature-owned
+and the EPG guide-channel lock policy now feature-owned
while the Home and EPG
screen/dialog composition remains in `:app` for the remaining app-specific
dialogs.
@@ -154,7 +155,7 @@ series-assignment dialogs, the EPG search overlay, guide category picker, and
compact guide-program dialog, guide control rows, EPG preview pane, guide
toolbar, guide message state, hero badge, stable EPG channel-key helper,
timeline header, grid rows/cells, grid host, EPG content host, focus
-reconciliation, Home layout metrics, Home parental-lock policy, options overlay,
-and EPG-match dialog are independent of app code;
+reconciliation, Home layout metrics, Home parental-lock policy, EPG guide-channel
+lock policy, options overlay, and EPG-match dialog are independent of app code;
screen/resource moves, golden/runtime/performance gates, and legacy app cleanup
remain open, so no live slice acceptance gate is claimed yet.
diff --git a/docs/superpowers/plans/2026-08-28-live-feature-extraction.md b/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
index 75fcdf33..b7fb1a14 100644
--- a/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
+++ b/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
@@ -31,6 +31,7 @@ pane, guide toolbar, guide message state, hero badge, timeline header, grid
rows/cells, grid host, EPG content host, focus reconciliation, Home layout
metrics, and Home parental-lock policy are now feature-owned, with the options
overlay and EPG-match dialog also feature-owned
+and the EPG guide-channel lock policy now feature-owned
and their feature checks are green. Home screen/dialog composition, the
remaining live cards/rows, complete locale resource migration, and acceptance
gates remain open.
@@ -730,7 +731,10 @@ Home layout metrics now preserve the existing device/mode breakpoints behind a
feature-owned pure contract while `HomeScreen` supplies the configuration and
device inputs. Home parental-lock policy likewise preserves normalized unlock
IDs and selected/source-category protection behind feature-owned pure
-predicates while the app supplies current state.
+predicates while the app supplies current state. EPG guide-channel lock policy
+now preserves the existing parental-control level, channel protection, and
+source-category protection behind a feature-owned pure predicate; `EpgScreen`
+keeps its compatibility wrapper while supplying current state.
quick-filter key/selection rules are covered by `LiveQuickFiltersTest`. The
remaining app-owned live cards and shell/dialog composition still require
compatibility seams before the full Home move.
diff --git a/feature/live/src/main/java/com/streamvault/feature/live/presentation/epg/LiveGuideLockPolicy.kt b/feature/live/src/main/java/com/streamvault/feature/live/presentation/epg/LiveGuideLockPolicy.kt
new file mode 100644
index 00000000..c83c73fa
--- /dev/null
+++ b/feature/live/src/main/java/com/streamvault/feature/live/presentation/epg/LiveGuideLockPolicy.kt
@@ -0,0 +1,19 @@
+package com.streamvault.feature.live.presentation.epg
+
+import com.streamvault.domain.model.Category
+import com.streamvault.domain.model.Channel
+
+fun isLiveGuideChannelLocked(
+ channel: Channel,
+ categoriesById: Map<Long, Category>,
+ parentalControlLevel: Int
+): Boolean {
+ if (parentalControlLevel !in 1..2) {
+ return false
+ }
+ val categoryLocked = channel.categoryId
+ ?.let(categoriesById::get)
+ ?.let { category -> category.isAdult || category.isUserProtected }
+ ?: false
+ return channel.isAdult || channel.isUserProtected || categoryLocked
+}
diff --git a/feature/live/src/test/java/com/streamvault/feature/live/presentation/epg/LiveGuideLockPolicyTest.kt b/feature/live/src/test/java/com/streamvault/feature/live/presentation/epg/LiveGuideLockPolicyTest.kt
new file mode 100644
index 00000000..3445fe3f
--- /dev/null
+++ b/feature/live/src/test/java/com/streamvault/feature/live/presentation/epg/LiveGuideLockPolicyTest.kt
@@ -0,0 +1,48 @@
+package com.streamvault.feature.live.presentation.epg
+
+import com.google.common.truth.Truth.assertThat
+import com.streamvault.domain.model.Category
+import com.streamvault.domain.model.Channel
+import org.junit.Test
+
+class LiveGuideLockPolicyTest {
+ @Test
+ fun `guide channel is locked by its own protection or source category`() {
+ val protectedCategory = Category(id = 4L, name = "Protected", isAdult = true)
+ val channel = Channel(id = 9L, name = "Channel", categoryId = 4L)
+
+ assertThat(
+ isLiveGuideChannelLocked(
+ channel = channel,
+ categoriesById = mapOf(protectedCategory.id to protectedCategory),
+ parentalControlLevel = 1
+ )
+ ).isTrue()
+ }
+
+ @Test
+ fun `guide channel is unlocked when parental controls are inactive`() {
+ val protectedChannel = Channel(id = 9L, name = "Channel", isUserProtected = true)
+
+ assertThat(
+ isLiveGuideChannelLocked(
+ channel = protectedChannel,
+ categoriesById = emptyMap(),
+ parentalControlLevel = 0
+ )
+ ).isFalse()
+ }
+
+ @Test
+ fun `guide channel is unlocked when it has no protection`() {
+ val channel = Channel(id = 9L, name = "Channel")
+
+ assertThat(
+ isLiveGuideChannelLocked(
+ channel = channel,
+ categoriesById = emptyMap(),
+ parentalControlLevel = 2
+ )
+ ).isFalse()
+ }
+}