Skip to content

Audit fixes: trim-level dispatch, torn shared-file reads, cold-start double scan, boot-shield audio - #8

Merged
GothwadTech merged 9 commits into
mainfrom
arena/76822d85-launcher
Oct 18, 2026
Merged

GothwadTech merged 9 commits into
mainfrom
arena/76822d85-launcher

Conversation

@GothwadTech

Copy link
Copy Markdown
Owner

Summary

Bugs and lightweight/solid-ness improvements from a full codebase audit. Everything below is behaviour-preserving except where a bug made it not so.

Fixed — correctness & stability

  • onTrimMemory dispatched nearly every level as a critical trim. The framework levels are three groups, not one monotonic scale: UI_HIDDEN (20) = our UI just went away, BACKGROUND/MODERATE/COMPLETE (40/60/80) = we are backgrounded. The old level >= RUNNING_CRITICAL (15) test caught them all first — so with aggressive trim enabled, simply opening Netflix from the launcher killed the user's other background apps (music included). The TRIM_MEMORY_COMPLETE branch was unreachable dead code. Now: 15 = critical, 10 = gentle, 20 = no-op, 40/60/80 = gentle while backgrounded.
  • Heartbeat / relaunch-policy / self-heal files are written atomically (temp + rename). A plain writeText truncates first — the :watchdog polling mid-write could read an empty file, parse 0, decide "the launcher is dead", and yank the TV back to HOME mid-movie.
  • Boot shield no longer silences user media. The 45–90 s window silenced any active audio every 2 s, including a Netflix stream the user deliberately started. It now only silences boot-ad-like cases (stock launcher in front, our home in front, or no identifiable foreground).
  • Cold start no longer runs two full app scans concurrently (MainActivity + TvLauncherFragment): scans are serialised with a Mutex, second caller hits the memory cache. Artwork decode/rasterise capped at 6 concurrent ops. Corrupt app-art cache files are no longer protected from pruning.

Lightweight / solid

  • Heartbeat + policy writes moved off the main thread onto one daemon thread (project rule ci: fix truncated build_apk.yml in main (workflow files under ci/workflows) #3).
  • DensityAdapter persists uiScale/font-scale prefs only on a real change (was on every config emission).
  • PACKAGE_REMOVED no longer probes PackageManager for the already-gone package; accessibility-service package seed runs on Dispatchers.IO.
  • Dead MainActivity code removed (pass-through dispatchKeyEvent, empty setupNavigation()).

Tests

  • ProcessHeartbeatAtomicWriteTest (3) locks in the atomic-replace write.

Checklist

  • tools/ktcheck.py clean (57 files), tools/check_resources.py clean (0 broken refs)
  • CHANGELOG.md, docs/PERFORMANCE.md, docs/TESTING.md updated
  • No Compose, no new dependencies, no config-shape changes
  • ./gradlew assembleDebug testDebugUnitTest lintDebug assembleRelease — no JDK/Android SDK in this sandbox; please let CI verify

GothwadTech and others added 9 commits October 18, 2026 10:59
…e scan

Correctness & stability:
- onTrimMemory treated UI_HIDDEN (20) and every background level (40/60/80) as a
  CRITICAL trim because they matched 'level >= RUNNING_CRITICAL' (15) first, and the
  TRIM_MEMORY_COMPLETE branch was unreachable dead code. Opening an app from the
  launcher used to kill the user's other background apps when aggressive trim was on.
- Shared cross-process files (heartbeat, relaunch policy, self-heal) are now written
  atomically (temp + rename): a plain writeText truncates first, and the :watchdog
  reading in that window parsed an empty file as 'the launcher is dead' and yanked the
  screen back to HOME mid-movie.
- The boot shield no longer silences audio while a known user app is in front; only
  boot-ad-like cases (stock launcher / our home / unknown foreground) are silenced.

Lightweight:
- AppRepository scans are serialised with a Mutex (MainActivity + TvLauncherFragment
  both scanned on cold start), artwork decoding capped at 6 concurrent ops, and only
  loaded cache names protect files from pruning.
- Heartbeat writes moved off the main thread onto a dedicated daemon thread (rule #3);
  policy writes too.
- DensityAdapter persists uiScale/font-scale prefs only on a real change.
- PACKAGE_REMOVED no longer probes PackageManager for the already-gone package; dead
  MainActivity code (pass-through dispatchKeyEvent, empty setupNavigation) removed.
- getInstalledPackages in the accessibility service runs on Dispatchers.IO.

Tests: ProcessHeartbeatAtomicWriteTest locks in the atomic-replace write.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…icker with auto-change

Settings UI fixes (colour + remote navigation):
- 27 of 33 buttons hard-coded white text while the focused background is solid white,
  so the label vanished exactly when the control got focus ('remote navigation pata
  hi nahi chalta'). All buttons now use the color_settings_btn_text state list.
- Chevron icons were replaced with static-colour drawables that killed the
  state-aware tint; back/close icons had the same fixed-white bug. Both now flip
  dark on the white focus highlight.
- Selected state was identical to focused (both solid white). Selected now draws as
  the accent-cyan chip with a dark label.
- SettingsDisplayDelegate force-set text colours in code, overriding the focus
  state lists; it now drives selection through isSelected.
- Entering a settings sub-page left D-pad focus on the hidden row (remote looked
  dead); every page change now focuses the first control.

Wallpaper picker (user-visible feature):
- The five name-only buttons (labels that no longer matched their gradients) are
  replaced by visual tiles rendering the actual gradients, a live preview box, and
  a check badge on the committed choice. The custom photo is a tile too.
- Auto-change wallpaper: Off / 15 min / 1 hour / 6 hours / Daily, rotating the
  presets via the existing clock loop (WallpaperRotator - no alarms/services; a
  custom photo is never auto-replaced; long absence advances one step only).

Tests: WallpaperRotatorTest (6) covers the rotation rule.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…lock, night light, backup

- CI workflow (build debug+release, unit tests, lint) on every push/PR
- 10 full themes + 10 accents + wallpaper-palette accent; 10 wallpapers total
- Layout modes (banner/compact/large/icon grid), 3-8 columns, app size 60-160%
- Focus effects (scale/glow/outline/fill) + focus scale, label show/size
- Animation speed, reduced-motion, app-open transitions, perf profiles
- Clock styles, date formats, time-of-day greeting, night-light overlay
- App sort modes, favourites + recents quick row, long-press app quick menu
- Settings backup export/import (JSON via system file picker)
- New Settings > Theme & Style page (all controls, D-pad friendly)
- Tests: CustomizationConfigTest (7)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…otations

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
… formatters

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
@GothwadTech
GothwadTech merged commit 0e79e1c into main Oct 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant