testsAndMisc/focus_owner
Krzysztof kuhy Rudnicki db1d8f8247
Some checks are pending
Pre-commit checks / pre-commit (push) Waiting to run
Python tests / test (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
Pin RethinkDNS as always-on VPN, the layer that reaches every app
Hiding the YouTube package stops the app. It does nothing about
youtube.com in Firefox, in a webview, or in any client nobody has
enumerated. This is that layer.

setAlwaysOnVpnPackage from the device owner is not the mechanism that
failed on 2026-08-09 -- that was `settings put secure always_on_vpn_app`,
which writes successfully, survives a reboot, and is ignored by
VpnManager. The DPM call takes effect: dumpsys now reports
mAlwaysOnVpnPackage=com.celzero.bravedns.

Lockdown stays off. It drops all traffic whenever the tunnel is down,
and the wipe checklist names it together with the DISALLOW_*
restrictions as the combination most likely to leave an unrecoverable
device. DISALLOW_CONFIG_VPN is deferred for the same reason: locking VPN
configuration before the filter is confirmed working would pin a broken
setup in place.

The exporter emits always_on_vpn_package only when the provider is also
in never_disable_prefixes, and RethinkDNS was added there. Pinning a
package the sweep can hide is the worst case -- the restriction would
point at a hidden app and cost general connectivity, not just the
filter. The pin is re-asserted every pass and, unlike the uninstall
block, does not track the decision: the network filter must not lift
when the geofence says AWAY.

releaseDeviceOwner now unpins the VPN and clears the restriction before
clearing ownership, for the same reason it already unblocked uninstall.

Not yet active, and the commit does not pretend otherwise: the tunnel
needs a one-time in-app VPN consent tap that adb cannot grant, and
RethinkDNS is at first-run state because its wildcard rules live in
app-private storage that the backup never reached. They have to be
re-entered by hand.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014DqEd1uUhyT52KjaNeLanC
2026-08-10 21:40:04 +02:00
..
android Pin RethinkDNS as always-on VPN, the layer that reaches every app 2026-08-10 21:40:04 +02:00
assets Pin RethinkDNS as always-on VPN, the layer that reaches every app 2026-08-10 21:40:04 +02:00
docs focus_owner: keep the unhide path reachable, never hide the enforcer 2026-08-10 15:33:18 +02:00
lib Run enforcement from exact alarms, and re-arm it before first unlock 2026-08-09 21:50:58 +02:00
scripts Provision home coordinates out of git; layer the workout signal; drop the test hook 2026-08-09 21:42:20 +02:00
test Provision home coordinates out of git; layer the workout signal; drop the test hook 2026-08-09 21:42:20 +02:00
.gitignore Make focus policy and blocklist usable without root; fix workout CDN unblock 2026-08-05 09:15:02 +02:00
.metadata Make focus policy and blocklist usable without root; fix workout CDN unblock 2026-08-05 09:15:02 +02:00
analysis_options.yaml Make focus policy and blocklist usable without root; fix workout CDN unblock 2026-08-05 09:15:02 +02:00
pubspec.lock Make focus policy and blocklist usable without root; fix workout CDN unblock 2026-08-05 09:15:02 +02:00
pubspec.yaml Exempt the generated policy asset from prettier 2026-08-05 09:40:44 +02:00
README.md Make focus policy and blocklist usable without root; fix workout CDN unblock 2026-08-05 09:15:02 +02:00

focus_owner

Device Owner companion app for unrooted focus mode. Currently inert: it can be provisioned as device owner, but it applies no restrictions.

Why the escape hatch ships first

dpm remove-active-admin does not work on a device owner. The only exit that avoids a factory reset is DevicePolicyManager.clearDeviceOwnerApp(), callable solely by this package on itself. An app that locks the device down before proving it can let go leaves a soft-brick recoverable only through fastboot — painful on a locked bootloader, and impossible to reach if DISALLOW_FACTORY_RESET is ever set.

So: DevicePolicyBridge.releaseDeviceOwner() is implemented, unit-tested, and reachable from the app's main screen with no PC attached. Enforcement is added only after that path has been exercised on a provisioned device.

Provisioning (NOT done yet — requires a factory reset)

dpm set-device-owner refuses to run while any account exists on the device. The Pixel 6a has 6, so provisioning means a wipe. See ~/.claude/projects/-home-kuhy-testsAndMisc/memory/device-owner-not-root-banking-works.md for what does and does not survive that, and for the Google Wallet open risk.

Once wiped, before adding any account:

adb install -r build/app/outputs/flutter-apk/app-debug.apk
adb shell dpm set-device-owner com.kuhy.focus_owner/.FocusDeviceAdminReceiver

Then immediately verify tap-to-pay and banking apps, while the release button is still reachable.

Build and verify

cd ~/testsAndMisc/focus_owner
flutter analyze && flutter test
flutter build apk --debug
adb -s 23181JEGR08034 install -r build/app/outputs/flutter-apk/app-debug.apk
adb -s 23181JEGR08034 shell am start -n com.kuhy.focus_owner/.MainActivity

The status screen reads live state over the platform channel; "Android SDK 36" confirms the Kotlin bridge is working.

Still to do

  • Consume the policy JSON from python_pkg/focus_policy (export.py).
  • Add enforcement (setApplicationHidden, addUserRestriction, setAlwaysOnVpnPackage) — only after the release path is verified on-device.
  • Verify setApplicationHidden survives a reboot. pm suspend and pm disable-user both do NOT; do not assume the DPM equivalent behaves the same until measured.