{ "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." ] }