Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
dependencies ▾

Modern-Apps.git / parentalcontrols / AGENTS.md

AGENTS.md5.9 KiBRenderedCodeRaw
1# AGENTS.md — parentalcontrols/ (':parentalcontrols')
2
3> Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `parentalcontrols/` + allowed shared modules. Do not root-scan.
4
5_Install: ./install parentalcontrols (dev by default)._
6- Gradle: :parentalcontrols / dir: parentalcontrols/
7- Package roots present: ui, data, domain, platform, service, notifications
8- Entry files: MainActivity.kt + Route.kt + Navigation.kt (single host) + ui/SetupActivity.kt and ui/PinActivities.kt (PinGateActivity, kept for lock-screen activity-result) + ui/LockActivities.kt (kept OS lock surfaces)
9- Deps: :library:room, :library:aosp-stubs
10- Metadata: metadata_data/parentalcontrols.md (present)
11- Rust: no / screenshotTest: no
12
13## Overview
14**Purpose:** On-device parental controls over Android's supervision APIs — screen-time/bedtime/app-limits, web filters, install restrictions, all PIN-gated (`data/ParentPin`). No account, nothing uploaded.
15**Key features:** `platform/SupervisionMaster` + `SupervisionPolicies`/`Apis`/`Caller` enforce `data/` rules + `domain/TimeWindow`; `platform/Enforcer` + `AppLimits` + `BedtimeScheduler` apply limits; `service/` supervision messengers bridge the system.
16**Entry points:** `MainActivity.kt` → `Navigation.kt` (`Route.Dashboard/DailyLimit/AppLimits/Bedtime/Downtime/SchoolTime/WebFilters/PinSetup/PinGate`) → `platform/SupervisionViewModel.kt`; `ui/SetupActivity.kt` hands off to the host's PinSetup route then the platform setup flow → `platform/SupervisionMaster.kt` → `data/Rules.kt`.
17**Gotchas:**
18- `receiver/` is NOT a closed package root — don't add more files there
19- Enforcement is system-mediated (supervision APIs) — sideloaded builds can't enforce; PIN loss locks parents out by design, no backdoor
20- Screenshot tests are off (`screenshotTest: no`) — verify lock/PIN flows on device
21
22## Key files
23### data/ + domain/ — PIN, rules, windows
24- com/vayunmathur/parentalcontrols/data/ParentPin.kt
25- com/vayunmathur/parentalcontrols/data/ParentalControlsDatabase.kt
26- com/vayunmathur/parentalcontrols/data/Rules.kt
27- com/vayunmathur/parentalcontrols/data/SupervisionRules.kt
28- com/vayunmathur/parentalcontrols/data/Migrations.kt
29- com/vayunmathur/parentalcontrols/domain/TimeWindow.kt
30### platform/ — supervision + enforcement
31- com/vayunmathur/parentalcontrols/platform/SupervisionMaster.kt
32- com/vayunmathur/parentalcontrols/platform/SupervisionPolicies.kt
33- com/vayunmathur/parentalcontrols/platform/SupervisionApis.kt
34- com/vayunmathur/parentalcontrols/platform/SupervisionCaller.kt
35- com/vayunmathur/parentalcontrols/platform/SupervisionViewModel.kt
36- com/vayunmathur/parentalcontrols/platform/Enforcer.kt
37- com/vayunmathur/parentalcontrols/platform/AppLimits.kt
38- com/vayunmathur/parentalcontrols/platform/BedtimeScheduler.kt
39- com/vayunmathur/parentalcontrols/platform/UsageAccess.kt
40- com/vayunmathur/parentalcontrols/platform/WebContentFilters.kt
41### receiver/ + service/ + notifications/ — system bridges
42- com/vayunmathur/parentalcontrols/receiver/Receivers.kt
43- com/vayunmathur/parentalcontrols/service/ParentalControlsAppService.kt
44- com/vayunmathur/parentalcontrols/service/SupervisionMessengerService.kt
45- com/vayunmathur/parentalcontrols/notifications/LockNotifier.kt
46### ui/ — PIN-gated activities (the entries)
47- com/vayunmathur/parentalcontrols/MainActivity.kt
48- com/vayunmathur/parentalcontrols/Route.kt
49- com/vayunmathur/parentalcontrols/Navigation.kt
50- com/vayunmathur/parentalcontrols/ui/DashboardScreen.kt
51- com/vayunmathur/parentalcontrols/ui/SetupActivity.kt
52- com/vayunmathur/parentalcontrols/ui/PinSetupScreen.kt
53- com/vayunmathur/parentalcontrols/ui/PinGateScreen.kt
54- com/vayunmathur/parentalcontrols/ui/PinActivities.kt
55- com/vayunmathur/parentalcontrols/ui/LockScreen.kt
56- com/vayunmathur/parentalcontrols/ui/LockActivities.kt
57- com/vayunmathur/parentalcontrols/ui/AppLimitsScreen.kt
58- com/vayunmathur/parentalcontrols/ui/DailyLimitScreen.kt
59- com/vayunmathur/parentalcontrols/ui/dialogs/DailyLimitPickerDialog.kt (stateless content for the `Route.DailyLimitPickerDialog` route)
60- com/vayunmathur/parentalcontrols/ui/BedtimeScreen.kt
61- com/vayunmathur/parentalcontrols/ui/WindowScheduleScreen.kt
62- com/vayunmathur/parentalcontrols/ui/WebContentFiltersScreen.kt
63
64## Self-protection (force-stop / uninstall) — audit
65
66What stops a child from force-stopping or uninstalling this app, honestly:
67
68- **Already provided by the supervision tier (real):** the `SYSTEM_SUPERVISION` role
69 (granted via `config_systemSupervision`, not by this app), `MANAGE_SUPERVISION`-gated
70 activities, Settings-only IPC (`SupervisionCaller`), the parent PIN, and the platform
71 clearing/re-applying policy state around supervision enable/disable. Enforcement is
72 system-mediated; the app never polices itself.
73- **Implemented in-app (the hardening a normal app can actually do):** re-arm on
74 `BOOT_COMPLETED` (`BootReceiver`) and on our own update (`PackageReplacedReceiver` —
75 alarms, usage observers and the platform binding all die with the old process);
76 block/usage state persisted across process death (`ManagedPackages`, `LimitState`).
77- **Deliberately NOT implemented (fake or abusive at this tier):** a legacy
78 `DeviceAdminReceiver` — after admin activation it can hinder *uninstall* only, it
79 cannot prevent force-stop, and presenting it as tamper-proofing would be lying;
80 an accessibility service watching Settings to intercept force-stop/uninstall taps —
81 an abuse vector this app must never ship. Neither is declared in the manifest.
82- **MAOS-only (platform layer, not app code):** preventing force-stop/uninstall of the
83 supervision app outright, pinning `config_systemSupervision` to this package, the
84 `hidden-api-whitelisted-app` entry, and any privileged placement. A normal
85 (non-privileged) app cannot obtain these from inside its own APK; do not simulate
86 them here.
87
88## Verify (this module only)
89```
90./gradlew :parentalcontrols:compileDevKotlin
91./gradlew :parentalcontrols:lint
92./gradlew :parentalcontrols:checkMetadata
93```