testsAndMisc/docs/superpowers/evidence/focus-owner-release-signing-2026-08-10.json
Krzysztof kuhy Rudnicki 6bf7343c0f
Some checks are pending
Pre-commit checks / pre-commit (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
Make the enforcer real: block YouTube, and refuse to be uninstalled
The device owner is provisioned, so enforcement stops being theoretical.
Three things had to be true before it was safe to switch on.

Release signing. A device owner can only be replaced by an APK with the
same signature, and `dpm remove-active-admin` does not work on one, so a
debug-signed device owner could never be updated -- the only exit would
be another factory reset. focus_owner now uses the shared key.properties
config the other apps use. No minify: an untested ProGuard pass that
strips a DevicePolicyManager callback produces a device owner that
cannot release itself.

Uninstall blocking. Device owner hides Settings' uninstall button, but
`adb uninstall` still worked, and that is the route that strands
ownership with no holder. setSelfUninstallBlocked closes it, re-asserted
every pass so it self-heals. The ordering in releaseDeviceOwner is not
stylistic: unblock, THEN clear. Reversed, the block outlives the
ownership required to lift it.

The allowlist. config.sh describes the rooted phone, so the hide set was
computed on the PC before any pass ran -- which caught pl.infakt.infakt
in it. infakt is device-paired to a bank over SMS, so hiding it would
have stranded the same re-authentication chain as hiding Messages.

Verified on the Pixel 6a as a real device owner: hid 27, and youtube,
youtube.music, chrome, vending and videos are all hidden=true, while
phone, messages, keepass, mbank, revolut, infakt, mobywatel, settings
and signal stay hidden=false. `adb uninstall` returns
DELETE_FAILED_DEVICE_POLICY_MANAGER. All of it survives a reboot, which
is exactly what `pm suspend` and `pm disable-user` failed to do here.

restore_apps.sh reinstalls the 54 backed-up packages via
install-multiple, since split APKs make a bare `adb install` fail. It
skips the device owner's own package by name.

Enforcement is permanent for now, not geofenced: push_home_location.sh
delivers coordinates through `run-as`, which is dead on a release build,
so every pass decides LOCATION_UNKNOWN and fails closed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014DqEd1uUhyT52KjaNeLanC
2026-08-10 21:12:53 +02:00

52 lines
4.3 KiB
JSON

{
"intent": "Give focus_owner a real release signing config before provisioning it as device owner. A device owner can only be replaced by an APK with the same signature, and `dpm remove-active-admin` does not work on one -- so provisioning a debug-signed build would mean an app that can never be updated, whose only exit is another factory reset.",
"scope": [
"focus_owner/android/app/build.gradle.kts",
"focus_owner/android/key.properties (gitignored, not committed)",
"Non-goal: minify/shrink, deliberately left off"
],
"changes": [
"Added the shared key.properties signing pattern already used by diet-guard, untools and home_inventory: storeFile/storePassword/keyAlias/keyPassword read from a gitignored file, falling back to the debug key when absent so a fresh clone still builds.",
"Replaced the scaffold `signingConfig = signingConfigs.getByName(\"debug\")` TODO in the release build type.",
"Deliberately did NOT enable isMinifyEnabled/isShrinkResources. An untested ProGuard pass that strips a DevicePolicyManager callback would produce a device owner that cannot release itself, and that costs a factory reset to undo."
],
"verification": [
{
"command": "apksigner verify --print-certs app-release.apk",
"result": "pass",
"evidence": "Signer #1 certificate DN: CN=kuhy, OU=kuhy, O=kuhy, C=PL (SHA-256 9dcc2e6c...). Not the Android debug key, so the APK is upgradable in place after provisioning."
},
{
"command": "adb install -r app-release.apk over the existing debug build",
"result": "fail (expected, and the reason this was tested pre-wipe)",
"evidence": "INSTALL_FAILED_UPDATE_INCOMPATIBLE: signatures do not match. Caught before the factory reset, while a debug build was still available to fall back on. Resolved by uninstall + clean install."
},
{
"command": "launch release build, check logcat for crashes",
"result": "pass",
"evidence": "ActivityTaskManager: Fully drawn com.kuhy.focus_owner/.MainActivity: +185ms, no AndroidRuntime/FATAL. A release build can fail where debug succeeds, so this was checked before it mattered."
},
{
"command": "post-wipe: dpm set-device-owner com.kuhy.focus_owner/.FocusDeviceAdminReceiver",
"result": "pass",
"evidence": "Success. dumpsys device_policy: Device Owner admin=ComponentInfo{...FocusDeviceAdminReceiver}, provisioningState: 3, testOnlyAdmin=false, Device Owner Type: 0. Pre-wipe the same command failed with IllegalStateException: there are already some accounts on the device (6 accounts)."
},
{
"command": "escape hatch: Release device owner -> confirm dialog -> Release",
"result": "pass",
"evidence": "logcat: 'FocusOwner: clearDeviceOwnerApp -> released=true' then 'Device admin disabled'. dumpsys then reported Device Owner Type: -1, provisioningState: 0. Tested at the one moment when failure was free -- before any account was added. Re-provisioned successfully afterwards, so both directions are proven."
}
],
"risks": [
"The keystore password sits in plaintext in focus_owner/android/key.properties. It is gitignored (focus_owner/android/.gitignore line 12), matching the three other repos that share this key, so it does not reach the repo -- but it is on disk unencrypted.",
"No minify means a larger APK (44.4MB) than a shrunk release would be. Accepted deliberately for the device-owner reliability reason above.",
"The phone currently has a provisioned device owner with `Restrictions: none (inert build)`. No enforcement is applied yet; that is the next stage and the checklist says one restriction at a time, re-testing the release path after each.",
"Signal message history was permanently destroyed by the wipe. The user was told the backup was missing, chose to proceed anyway, and confirmed explicitly. Signal itself re-registers with the number and PIN."
],
"rollback": [
"git revert restores the debug-key fallback. Any already-signed release APK keeps working; only future builds change signature, which would then fail to install over a release-signed install.",
"The device owner itself is removed from inside the app: Release device owner (clearDeviceOwnerApp), verified working. `dpm remove-active-admin` does NOT work on a device owner.",
"If the app is uninstalled without releasing first, the only exit is another factory reset."
]
}