Enable Android Auto Backup of the notes DB and sync settings

OS-level safety net so a reinstall can restore data through Android's
backup/restore flow. Sets allowBackup=true and points fullBackupContent
(pre-31) and dataExtractionRules (API 31+) at empty rule sets, which back
up the default locations: the app files dir (local CRDT DB todo.db),
databases, and shared_prefs (GitHub sync settings + token).

Backing up shared_prefs is intentional — it restores the sync config on
reinstall so recovery needs no re-auth (zero-touch). The token is a
narrowly-scoped contents-only PAT for the single private sync repo, kept
in the user's own Google backup.

Caveats: Auto Backup is scheduled (~daily, Wi-Fi+charging) so very recent
changes may not be captured, and restore fires through the Play Store /
device-setup flow, not an `adb install -r`. Auto-sync remains the primary
durability path; this is the secondary net. Verified the attributes merge
into the app manifest via a debug build.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Krzysztof kuhy Rudnicki 2026-06-15 22:04:59 +02:00
parent 085287861c
commit f9794512b4
3 changed files with 32 additions and 1 deletions

View File

@ -6,7 +6,10 @@
<application
android:label="todo"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/ic_launcher"
android:allowBackup="true"
android:fullBackupContent="@xml/backup_rules"
android:dataExtractionRules="@xml/data_extraction_rules">
<activity
android:name=".MainActivity"
android:exported="true"

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Legacy Auto Backup rules (pre-Android 12 / API < 31). An empty
<full-backup-content> means "back up the default set" — the app's files dir
(the local CRDT DB todo.db), databases, and shared_prefs (sync settings +
token). See data_extraction_rules.xml for the rationale on backing up the
token for zero-touch recovery.
-->
<full-backup-content>
</full-backup-content>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Android Auto Backup rules (API 31+ / Android 12+).
Empty <cloud-backup> and <device-transfer> elements mean "back up the default
set": the app's files dir (which holds the local CRDT DB, todo.db), the
databases dir, and shared_prefs (which holds the GitHub sync settings + token).
Backing up shared_prefs is intentional: it lets a reinstall restore the sync
configuration too, so recovery is zero-touch (no re-auth). The token is a
narrowly-scoped, contents-only PAT for the single private sync repo, stored in
the user's own Google backup. Auto-sync (the app's primary durability path)
still covers device loss; this is the secondary, OS-level safety net.
-->
<data-extraction-rules>
<cloud-backup />
<device-transfer />
</data-extraction-rules>