Locking down an Android phone with a device-owner app
androiddevice-ownerdpmparental-controlskiosklockdowncall-screening
A device owner is an app with full Device Policy Manager authority, normally set by an MDM at provisioning. Setting your own app as device owner over adb turns a spare phone into a managed device with no Google services. This was used to build a locked-down phone for a 12-year-old (Pixel 2 XL on LineageOS 22.2, guardian app com.phone.guardian, the Message SMS app providing the texting allowlist).
Becoming device owner
adb shell dpm set-device-owner com.phone.guardian/.GuardianDeviceAdminReceiver- Requires zero accounts on the device, so run it right after flashing, before any sign-in.
- The owner app's signing key can never change afterward; install the release build. See Android app signing keys and why losing one is permanent.
Restrictions that matter
User restrictions applied by the owner: DISALLOW_INSTALL_APPS, DISALLOW_INSTALL_UNKNOWN_SOURCES, DISALLOW_CONFIG_PRIVATE_DNS, DISALLOW_FACTORY_RESET, DISALLOW_SAFE_BOOT, DISALLOW_ADD_USER, DISALLOW_USB_FILE_TRANSFER, and the one first forgotten:
- DISALLOW_APPS_CONTROL: without it the user can go to Settings > Apps > Clear data on the messaging app, wiping its parent PIN and allowlist.
- DISALLOW_DEBUGGING_FEATURES kills adb, so apply it last, only after everything else is verified. Expose it as an exported broadcast receiver that can only add the restriction (adb shell am broadcast -a <pkg>.APPLY_DEBUG_LOCKDOWN), and keep a "lift lockdown" path in the parent UI. After that, the app's own update channel is the only management path.
Other owner powers used:
- Private DNS forced to a family filter (family-filter-dns.cleanbrowsing.org, which also forces YouTube Restricted Mode).
- Force a default browser with addPersistentPreferredActivity (cleared on lift).
- Silent app installs from a parent-uploaded APK via PackageInstaller (device owners need no user confirmation). The app reads package and versionCode from the downloaded file (getPackageArchiveInfo) so the server need not parse APKs, and reports install status back. The installer never uninstalls itself and reports status before installing its own update, since the process dies on success.
- Disable stock apps with pm disable-user --user 0 <pkg> (for example the built-in browser).
Calls and texts
- Hold the
CALL_SCREENINGrole to reject incoming calls not on the allowlist (fail closed on blank caller ID) andCALL_REDIRECTIONto cancel outgoing ones. Emergency numbers always pass. Grant roles over adb:cmd role add-role-holder --user 0 android.app.role.CALL_SCREENING <pkg>. - Texting rules live in the SMS app (it holds the SMS role): messages from strangers are stored but hidden, never notified, visible in a PIN-gated log; outgoing is blocked at every entry point including
HeadlessSmsSendService(call-screen quick replies). One stranger in a group blocks the thread. - Parent PIN hashed with PBKDF2, lockout escalating from 30 s to 32 min.
Remote management design
Server is the single source of truth; both apps pull it (on boot, hourly via WorkManager, and on a manual "Sync now"), replace their lists wholesale, and keep the last good config on any failure. Hourly polling exists so a parent's removals land without the child's cooperation. A device token is provisioned once into both apps (typing a 64-hex token with adb shell input text works well). See Doze, WorkManager backoff, and background sync that stalls for why hourly sync stalled.
Accepted limits
- An unlocked bootloader on LineageOS cannot practically be relocked; a child with a PC and fastboot could reflash (destructive and obvious).
- WebViews inside approved apps are browsing surfaces; the curated app and domain lists are the real control.
- Text content filtering was chosen as deliver-and-flag (alert the parent, never block text), since the allowlist already blocks strangers and false positives would block family.
See also
- A domain-whitelisted browser built on Android WebView
- Flashing LineageOS on a Pixel (A/B slots, recovery, sideload)
- In-app updates for sideloaded Android apps
Linked from
- A domain-whitelisted browser built on Android WebView
- Android app signing keys and why losing one is permanent
- App lock, PINs and brute-force lockout on Android
- Doze, WorkManager backoff, and background sync that stalls
- Flashing LineageOS on a Pixel (A/B slots, recovery, sideload)
- Message, Justin's Android SMS app (architecture and decisions)
- Server-sent push notifications (FCM HTTP v1, Web Push, ntfy)