Skip to content
mikesibiuPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

57 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JW Library Auto — Android Auto Media App

Stream weekly meeting content and Kingdom songs through Android Auto for safe in-car spiritual enrichment.

Overview

JW Library Auto is an Android Auto media app that streams real JW.org content:

  • Weekly Bible reading assignments
  • Watchtower Study articles
  • Congregation Bible Study (CBS) lessons
  • Meeting Workbook audio
  • Kingdom Songs (grouped, browsable)
  • Bible Dramas
  • JW Broadcasting (Mediator API)

Content is organized as This Week / Last Week / Next Week, calculated from the real device date using Monday-based week boundaries.

Architecture

Android Auto (Gearhead)
        │ binds
        ▼
JWLibraryAutoService          ← MediaBrowserServiceCompat
   ├── ContentRepository       ← browsable media tree + week routing
   │     └── JWOrgRepository   ← cache → jw.org API → JSON fallback → inline map
   │           ├── Room DB     ← caches API responses (TTL: 5 weeks)
   │           └── MeetingSectionsProvider  ← reads meeting_sections.json
   ├── PlaybackManager         ← ExoPlayer + AudioFocus + MediaSession
   └── ContentSyncWorker       ← WorkManager 24h background pre-fetch

Content Resolution Chain (and how CBS stays in sync with jw.org)

For Watchtower, Workbook, Songs, and Broadcasting:

  1. Room cache (if fresh < 5 weeks)
  2. jw.org API live fetch
  3. JSON/manual fallbacks where applicable

For Bible reading and Congregation Bible Study (CBS):

  • We start from res/raw/meeting_sections.json which encodes the official Meeting Workbook schedule per week.
  • That JSON lists CBS as two “lfb_E_###.mp3” filenames per week. Those numbers are the workbook’s internal file indices, not the spoken lesson numbers.
  • Many “lfb_E_###.mp3” files are section intros; therefore file index ≠ spoken lesson number. Example: lfb_E_082.mp3 is spoken lesson 70.

CBS playback uses a two‑step process:

  • Label (what you see in the AA row): derived from meeting_sections.json, e.g., “lfb lessons 70–71”. This always matches the workbook schedule for that week.
  • Audio (what actually plays): the app maps those workbook lesson numbers to the real mp3 URLs using jw.org’s official API (GETPUBMEDIALINKS?pub=lfb). This guarantees we play the correct “lfb_E_###.mp3” even when workbook numbers and file indices diverge.

At runtime we log both to make validation trivial:

CONTENT_CHECK congregation_study 2026-03-16 WORKBOOK=lfb 70–71 RESOLVED=[lfb_E_082.mp3, lfb_E_083.mp3]

Use adb logcat -d | grep CONTENT_CHECK to verify any week.

Key Files

File Purpose
service/JWLibraryAutoService.kt MediaBrowserService, session lifecycle
data/JWOrgRepository.kt Content resolution chain, cache-bust logic
data/ContentRepository.kt Browsable tree builder, week routing
data/api/JWOrgContentUrls.kt WATCHTOWER_OVERRIDES, WORKBOOK_OVERRIDES
data/meeting/MeetingSectionsProvider.kt Parses meeting_sections.json
playback/PlaybackManager.kt ExoPlayer + AudioFocus
res/raw/meeting_sections.json Bible reading + CBS URLs through 2026-04-27

Data Coverage

Content Source Coverage
Bible reading meeting_sections.json Through 2026-04-27
CBS lessons meeting_sections.json Through 2026-04-27
Watchtower WATCHTOWER_OVERRIDES Through 2026-04-27
Workbook WORKBOOK_OVERRIDES + API API handles dates beyond 2026-02-23
Songs jw.org API + Room Dynamic
JW Broadcasting Mediator API Dynamic (no offline cache)

Action required ~April 2026: Update meeting_sections.json and WATCHTOWER_OVERRIDES with new weeks.

Cache-Bust on APK Update

JWOrgRepository.clearCacheIfVersionChanged() runs synchronously in Service.onCreate() via runBlocking(Dispatchers.IO). If BuildConfig.VERSION_CODE differs from the value stored in SharedPreferences, the entire Room cache is cleared before any content request is served.

Rule: Bump versionCode in app/build.gradle.kts on every install.

Building

Requirements

  • JDK 17 (Temurin recommended — Homebrew Java 25 breaks Gradle)
  • Android SDK 34

Build Commands

export JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home

# Debug build
./gradlew assembleDebug

# Release build (signed)
./gradlew assembleRelease

# Run unit tests (QA gate — must pass before install)
./gradlew test

QA / Testing

Unit Tests

JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home ./gradlew test

Key test suites:

Suite What it catches
WeeklyContentSnapshotTest Exact filename assertions for all weeks Mar–Apr 2026
CacheBustAndFetchTest Cache-bust correctness, stale URL protection
ServiceSmokeTest Service onCreate() doesn't crash (Room threading, WorkManager init)
JWOrgRepositoryTest Live network calls to jw.org API (requires internet)
JWOrgRepositoryDramaTest Drama URL resolution with fake services

On-Device Verification

ContentVerificationTest (instrumented) connects as a real MediaBrowserCompat client to JWLibraryAutoService and asserts:

  • CBS is NOT lesson 57 (known bad mapping bug)
  • CBS lesson is 68 or later (correct for current weeks)
  • Bible reading is NOT Isaiah 40 or earlier
  • All 4 "This Week" items are present
# WARNING: uninstalls app after test run — only run with explicit permission
./gradlew connectedDebugAndroidTest

Runtime Logcat Verification

After installing, both the workbook label and the resolved filenames are logged for each week:

adb logcat | grep CONTENT_CHECK

Example output:

CONTENT_CHECK congregation_study 2026-03-16 WORKBOOK=lfb 70–71 RESOLVED=[lfb_E_082.mp3, lfb_E_083.mp3]
CONTENT_CHECK bible_reading 2026-03-16 -> [bi12_23_Isa_E_45.mp3, bi12_23_Isa_E_46.mp3, bi12_23_Isa_E_47.mp3]

Security

  • Package validation in onGetRoot() — only Android Auto / Google Assistant can bind
  • HTTPS-only URI validation in PlaybackManager
  • Network security config with cleartext blocked
  • allowBackup="false" in manifest

Known Issues

  • None open for CBS mapping. The app now derives the schedule from the workbook and the audio from jw.org’s LFB catalog, and logs both.

Android Auto Testing

# Start Desktop Head Unit
$ANDROID_SDK_ROOT/extras/google/auto/desktop-head-unit

# Enable developer mode on phone
adb shell settings put global android_auto_dev_mode 1

License

Reference implementation for personal/educational use. Respect jw.org terms of service for content distribution.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages