PlayBridge Android
Establish ownership
- Treat
mobile/android/andtv/android/as separate Gradle roots. - Treat
shared/andgradle/libs.versions.tomlas cross-consumer code. Give them one writer and inspect both Android consumers. - The phone consumes Cast Core through
cast/ffi/JNI and checked-in libraries undermobile/android/app/src/main/jniLibs/; loadplaybridge-rust-corefor session, sender-services, or ABI changes. - Load
playbridge-stream-proxy-rustas well when the embedded proxy, HLS rewriting, or Android upstream callbacks change. - Split phone and TV work between subagents only when their edits do not overlap. Keep shared files with the primary integrator or one designated owner.
- Load
playbridge-protocolas well when wire messages, pairing, or generated protocol bindings change.
Work safely
- Follow the root
AGENTS.md, including adaptive Serena/graph exploration. - Run every Gradle command from the project that owns the change.
- Preserve TV cleartext stream support and the scoped TLS behavior in
ContentSniffer.kt. - Keep GeckoView and Media3 versions compatible with both Android roots and
prebuilt/media3/. - Never log tokens, pairing credentials, signing material, or authenticated stream URLs.
- Preserve Google Cast's physical local-network binding around VPNs, application-ready handshake, fresh-session behavior after receiver exit, and distinction between stopping media and ending the receiver.
- For phone media detection / cast-sheet expectations (SPA soft-nav keeps rows, hard load clears, site patterns), see
docs/video-detection.md. The phone detector is generated fromextension/src/core/andextension/src/geckoview/; change source and runpnpm buildfromextension/, then inspect the Kotlin consumer and generated assets together. - For device/emulator control, load
android-adb. Reuse an authorized target selected by the user; check existing ADB devices and wireless-debugging mDNS before a LAN scan. Use the device's advertised connection port, then the FOSS debug rebuild/install/launch workflow and verify the actual interaction. - For phone
adb logcatrecipes (detection, cast, proxy, TV, downloads), seemobile/android/docs/logging.md.
Website playback
- Read
docs/bridged-apps.mdfor installed-app lifecycle, detection opt-out, permissions, and the page API. Keep normal browser tab selection separate from app sessions across process death; preserve the app's identity and return target when opening Dashboard or Remote. - Installed apps save a Home URL (initially the manifest’s
start_url). Fresh process launches and finishing/reopening the Activity start app tabs at that URL without restoring old page history; configuration recreation and Dashboard/Remote switches retain live sessions.BridgedAppStartup.ktowns the tab-reset policy. Do not reset ordinary browser tabs or select hidden app tabs during startup cleanup. - Restore tab metadata/history on launch Dashboard without loading pages.
BrowserSessionRestorePolicyallows engine creation only for a page explicitly opened in Browser/app mode; tab-switcher fallback selection must remain unloaded. Preserve live sessions across Dashboard/Remote/configuration changes, fence host ownership before suspension on finish, and keep one navigation/Tabs tree mounted while the selected engine is absent. Website picker requests are consumable events, not replayable counters. - The phone-only GeckoView disconnect guard and document-port cleanup are described in
docs/android-browser-lifecycle.md. Keep permission revocation/cancellation immediate without competing native teardown; run./gradlew -p buildSrc testwhen changing the guard or GeckoView. Review/remove the transform if the upstream port shape changes, and never suppress first-time native failures. - Long-press app tiles open Info with name/home editing and confirmed removal. Edits preserve origin, icon, tab identity and tile order; home URLs stay on the installed origin under the existing HTTPS/local-HTTP and no-credentials policy. Update never-loaded tabs after home edits without interrupting live or hibernated pages. Preserve editor selection/drafts across Activity recreation. Removal closes the app session but keeps website data and casting grants; installation management is native UI, not a website API.
PagePlaybackCoordinator.ktselects local/native/external playback;PagePlayerSession.ktandPlayerActivity.ktown local progress and lazy queues. Both work against Media3Player, neverExoPlayeralone: the phone also plays through mpv (MpvMediaPlayer), chosen by the Phone player setting or Automatic fallback. Keep ExoPlayer-only calls behind a type check. Seemobile/android/docs/phone-player.md. The page'splay()uses the existing device picker and selected destination, including This device. Recheck it after asynchronous preparation and reject stale document/session results. Unlink releases website authority while playback continues.- A valid bridged-site declaration suppresses automatic detection. Media detect → Advanced → Detect on bridged sites is an override, off by default; toggling categories must stop their work, remove existing rows and reject late results.
- Coordinate page API changes with
extension/src/geckoview/and the Apple host; companion Streams UI lives in the separatebridged-appsrepo.
Retired content data
The Android sender has no built-in content catalog, provider resolver or provider-script engine.
Room v25 drops retired content tables; RetiredContentCleanup removes their settings and caches
once at startup on IO. Preserve browser preferences, receiver credentials, downloads, collections,
IPTV and user-added bridged apps. Older backups ignore retired sections.
Verify
On macOS, invoke Gradle through zsh after sourcing ~/.zshrc.
From mobile/android/, select the narrowest relevant checks:
zsh -c "source ~/.zshrc && ./gradlew :app:testFossDebugUnitTest"
zsh -c "source ~/.zshrc && ./gradlew :app:assembleFossDebug"
zsh -c "source ~/.zshrc && ./gradlew :app:lintFossDebug"
From tv/android/, select the narrowest relevant checks:
zsh -c "source ~/.zshrc && ./gradlew test"
zsh -c "source ~/.zshrc && ./gradlew :player:app:assembleFossDebug"
zsh -c "source ~/.zshrc && ./gradlew lint"
Validate shared/ changes through both roots when both consume the affected code.
For flavor-specific plugin or shared phone changes that could affect store builds,
also assemble :app:assemblePlayDebug; passing the FOSS build does not verify the
Play source set. For installed-app startup or editing changes, include
BridgedAppStartupTest, BridgedAppStoreTest, BrowserTabSelectionTest and
RemoteReturnTargetTest; model tests do not verify physical long-press/rotation UI.
When Cast Core JNI, sender services, proxy callbacks, or their ABI changes, run
sh cast/build-android.sh from the repository root before the phone checks and
verify both armeabi-v7a and arm64-v8a outputs were replaced.