Enforcement
What an armed phone enforces, and how. Android 10 (API 29) is the minimum; the app targets the current SDK.
DNS
- Private DNS is set with
DevicePolicyManager.setGlobalPrivateDnsModeSpecifiedHost, off the main thread, with its result code checked, and locked withDISALLOW_CONFIG_PRIVATE_DNS. - The default host is
family-filter-dns.cleanbrowsing.org(adult content blocked, SafeSearch enforced). The host is a config field; changing it is a loosening change, whichever way it goes. - The call tests the resolver before accepting the host, so arming needs the phone online and refuses a host that does not serve DNS over TLS.
- When the self-check has to restore a DNS setting that drifted and that test fails (no network, DNS over TLS blocked), it writes the Private DNS settings directly instead, without the test: the filter must come back even offline.
- It fails closed. On a network that blocks DNS over TLS the phone has no name resolution. There is no fallback to unfiltered DNS.
Restrictions applied at arm
| Restriction | Purpose |
|---|---|
DISALLOW_CONFIG_PRIVATE_DNS | Lock DNS |
DISALLOW_CONFIG_VPN | Stop a VPN bypass |
DISALLOW_DEBUGGING_FEATURES | Keep adb off outside a debugging window (Connecting) |
DISALLOW_SAFE_BOOT | Stop a safe-mode bypass |
DISALLOW_FACTORY_RESET | Close the Settings reset path |
DISALLOW_NETWORK_RESET | Stop a network settings reset |
DISALLOW_ADD_USER | Stop a clean secondary user |
DISALLOW_ADD_MANAGED_PROFILE | Stop a work profile |
DISALLOW_CONFIG_DATE_TIME | Protect the countdown clock |
Also: QuitLock blocks its own uninstall, and automatic time is forced on. Private Space (DISALLOW_ADD_PRIVATE_PROFILE, API 35 and later) needs nothing from QuitLock: Android already enforces it on any phone with a device owner, and a device owner cannot change it.
Two restrictions are deliberately not set: DISALLOW_INSTALL_UNKNOWN_SOURCES (it would block F-Droid; app rules replace it) and DISALLOW_USB_FILE_TRANSFER (the file fallback needs it).
Browsers
The browsers QuitLock can configure are listed in Browsers.kt (Browsers): Chrome, which is verified, and Chromium-based candidates. Every verified and candidate browser gets the same managed configuration (setApplicationRestrictions), installed or not, so one installed later has it before it first opens. Keys are Chromium policy names:
- incognito disabled
- SafeSearch forced
- the browser’s own DNS over HTTPS off, so it uses the system’s DNS
- the URL blocklist and allowlist from the config’s
[chrome]section, which keeps its name but applies to every configured browser
Verified browsers are exempt from the browser rule below. Candidates are exempt only in dev and tester builds (BuildConfig.TRUST_CANDIDATE_BROWSERS) until a phone test marks them verified. A release build refuses to arm unless an exempt browser is installed, since every other browser is suspended.
Domain lists apply only inside browsers that honour the configuration, and an allowlist entry cannot unblock a domain the DNS provider blocks.
App rules
Checked on every package install (while QuitLock’s process runs), at boot and on a periodic job (at most every 15 minutes).
| Config field | Effect |
|---|---|
install_policy = "open" | No install-source check |
install_policy = "trusted_installers" (default) | Apps from other sources are suspended until allowed |
install_policy = "approval_required" | Every new app is suspended until allowed |
trusted_installers | Default: the Play Store and F-Droid |
blocklist | Always suspended |
allowlist | Allowed apps |
browser_allowlist | Browsers exempt from automatic suspension |
-
Browsers: any app that can open
httporhttpslinks as a browser is suspended unless it is a managed browser (see above) or onbrowser_allowlist, whatever the install policy. This includes browsers installed before arming, such as one that came with the phone. A browser found in the baseline is remembered, so it stays suspended even if, once suspended, it no longer answers the browser query. -
Apps installed through adb (possible only while USB debugging is allowed) count as coming from an untrusted source.
-
Apps already installed when the phone is armed are left alone unless they are on the blocklist or are browsers.
-
Suspension uses
setPackagesSuspended. Some system packages cannot be suspended; failures are logged and shown in the status. -
What the phone needs is never suspended, whatever the config, so the phone can always be unlocked and QuitLock reached (
AppRules.kept):- core system apps: Settings, the system UI, the phone, telecom and emergency apps, the permission controller and the package installer, matched only against system apps, since another phone’s system app name can be taken by a sideloaded one;
- a keyboard, home screen, dialer or SMS app that is a system app or was installed before arming;
- if every app in one of those roles would be suspended, the one in use, whatever it is.
An app installed after arming gets no protection from filling a role while another remains, so a new browser cannot escape the browser rule by also being a keyboard. The self-check names every app kept this way.
-
Updates to an app already allowed are not checked again.
-
To allow a suspended app: tap Allow next to it on the phone and approve the change, or add it to
allowlist(a browser tobrowser_allowlist) andquitlock config push. Either way it is a loosening change.
Self-check
Runs at boot, when the app opens, on the periodic job and at the end of every debugging window. It checks every policy above, re-applies any that drifted, clears a global HTTP proxy, and, when armed with no debugging window open, makes sure adb is off and the debugging restriction applied (this covers the app being killed with a window open). Problems are shown on the status screen and written to the event log.
When the app fails
The policies above stay in force whatever happens to the app; only the app can lift them. So a fault in the app must never take away the ways out. A factory reset from recovery mode always remains, but it erases the phone.
- A fault in a connection ends that connection, not the app. Every connection, wake-up, upkeep and boot thread runs under a guard (
Crashes.thread) that catches anything thrown, records it and lets that thread’s work end. The USB accessory’s reader and session catch everything too, and the session answers a fault on its side with a BYE,error. - Garbage from a computer is only refused. Unit tests feed every parser (canonical JSON, payloads, envelopes, frames, the sync scanner, a whole connection) random and damaged input, and the bundle processor every shared vector cut short, flipped and padded. None may throw.
- A record of what went wrong. Before anything else starts, the app installs a handler that records each crash: the time, the thread’s name and the exception’s class, never a message. The last 20 records stay on the phone.
- Recovery, apart from the main screen. If the main screen fails to show, or has crashed twice in 10 minutes, it opens Recovery instead. Long-pressing QuitLock’s icon offers it too. Recovery is a plain screen that shares as little as it can with the rest of the app. It shows the state and the phone’s device ID, and offers Import a bundle from a file, Pair a new key, Remove now (when not armed), the tester code (tester builds), the Leave screen, and the main screen again. It goes through the same bundle processor and teardown as everything else, so it can do nothing the other ways out cannot: it lifts no protection by itself.
- Ways out that do not need the computer’s connection: a bundle from a file (
--to-filewith--device-id, for an exit, a config, an update or a re-pair), and Request exit on the phone with the owner phone secret. Setup recommends setting one.
Teardown
In order: unsuspend everything QuitLock suspended, clear the browsers’ managed configuration, return Private DNS to automatic, clear every user restriction, lift the uninstall block, then clear device owner. Only then does the app offer to uninstall itself. Teardown is safe to re-run if it was interrupted.
Nothing may hold a removal up for good (invariant 2):
- Every step is tried, whatever happened to the ones before it.
- A removal is marked as started before anything is undone, and upkeep (boot, the periodic job, opening the app) finishes one left half-done.
- Device owner is given up only once every step that only the device owner can undo has taken. Otherwise something could be left that nobody can remove.
- Private DNS is the exception: once its lock is cleared the user can change it in Settings, so failing to set it back to automatic does not stop the removal; the screen and the log name the host it was left at.