repo: replaced permissive backup rules with per-app data extraction rules
- Commit
c68f15ab2367f52e502925727bd6bf51cebde8c6- Author
- Vayun Mathur <[email protected]>
- When
- 2026-08-06 03:37 UTC (4 months ago)
- Parents
409ba47
Diff
appstore/src/main/res/xml/data_extraction_rules.xml
diff --git a/appstore/src/main/res/xml/data_extraction_rules.xml b/appstore/src/main/res/xml/data_extraction_rules.xmlindex 15f36f1c4b..9deadedfe9 100644--- a/appstore/src/main/res/xml/data_extraction_rules.xml+++ b/appstore/src/main/res/xml/data_extraction_rules.xml@@ -1,13 +1,37 @@ <?xml version="1.0" encoding="utf-8"?>+<!-- App store client. Overrides the permissive default in the shared :library module, and+ replaces an earlier rule set that cloud-backed the whole database and all preferences.++ Storage audit:+ database appstore-db Room. RepoEntity (the user's configured F-Droid repos),+ CachedAppEntity (the full index of every app in every enabled+ repo — multi-megabyte and refetched on demand) and+ PinnedStampEntity (trust-on-first-use signer pins).+ file datastore/play_auth.preferences_pb A serialized Play AuthData: the+ dispensed anonymous account with its auth token, gsfId and+ device profile, plus the dispense timestamp. A live session+ credential with a max age, re-dispensed whenever it is absent.+ sharedpref appstore-update-check.xml The comma-joined package list from the last+ update notification, used only to suppress repeats. It is a+ list of the user's installed apps.+ cache <pkg>.apk, PlayDownloads/, fdroid-index/, fdroid-verified.json Download and+ verification scratch under getCacheDir(), never backed up.++ Cloud backup is denied. The repo list is the only non-regenerable state and it shares one+ Room file with the bulk index cache and the TOFU signer pins; the update-check preference+ is a regenerable inventory of installed apps; the Play auth blob is a session credential.+ The Play credential is excluded from device transfer as well — it is bound to a gsfId and+ device profile that do not survive the move, and a stale one just costs a round-trip. --> <data-extraction-rules> <cloud-backup>- <include domain="sharedpref" path="." />- <exclude domain="sharedpref" path="device.xml" />- <include domain="database" path="." />+ <exclude domain="root" path="." />+ <exclude domain="file" path="." />+ <exclude domain="database" path="." />+ <exclude domain="sharedpref" path="." />+ <exclude domain="external" path="." /> </cloud-backup> <device-transfer>- <include domain="sharedpref" path="." />- <include domain="database" path="." />- <include domain="file" path="." />+ <exclude domain="file" path="datastore/play_auth.preferences_pb" />+ <exclude domain="external" path="." /> </device-transfer> </data-extraction-rules>
astronomy/src/main/res/xml/data_extraction_rules.xml
diff --git a/astronomy/src/main/res/xml/data_extraction_rules.xml b/astronomy/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..758bd105f6--- /dev/null+++ b/astronomy/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,27 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Astronomy. Audited state: preferences only, via DataStoreUtils into+ filesDir/datastore_default.preferences_pb (AstronomyViewModel) — the user's+ observing location and display options. No Room database, no file I/O, nothing+ on external storage. The constellation artwork (andromeda.png and friends) is+ read-only APK/resource content.++ Small and worth keeping: re-entering an observing location on a new phone is+ exactly the kind of papercut backup should prevent. Back everything up.+-->+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
calculator/src/main/res/xml/data_extraction_rules.xml
diff --git a/calculator/src/main/res/xml/data_extraction_rules.xml b/calculator/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..52942cd393--- /dev/null+++ b/calculator/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,29 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Calculator. Audited state: none. There is no Room database, no+ SharedPreferences, no DataStore and no file I/O anywhere in the module. The+ calculation history shown by HistoryDialog is held in Compose state+ (remember / rememberSaveable) and is gone when the process dies, so there is+ nothing on disk to back up today.++ The rules are still declared explicitly rather than inherited so that the app+ keeps "back up whatever exists" semantics on its own terms, and so that if+ history or settings persistence is added later it is covered by default+ instead of being silently dropped.+-->+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
calendar/src/main/res/xml/data_extraction_rules.xml
diff --git a/calendar/src/main/res/xml/data_extraction_rules.xml b/calendar/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..923ca3a0aa--- /dev/null+++ b/calendar/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,20 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Overrides the permissive default in the shared :library module.++ Storage audited:+ (no app-owned event store) CalendarViewModel reads and writes the system calendar+ provider, which the OS and the account sync adapters back+ up on their own.+ file/datastore_default.preferences_pb UI settings only: theme_mode,+ default_calendar_layout, last_selected_calendar_id.++ Event content lives in the system provider, so the only thing worth restoring here+ is the settings file. Everything else is excluded by the allowlist. -->+<data-extraction-rules>+ <cloud-backup>+ <include domain="file" path="datastore_default.preferences_pb" />+ </cloud-backup>+ <device-transfer>+ <include domain="file" path="datastore_default.preferences_pb" />+ </device-transfer>+</data-extraction-rules>
camera/src/main/res/xml/data_extraction_rules.xml
diff --git a/camera/src/main/res/xml/data_extraction_rules.xml b/camera/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..d45c9102eb--- /dev/null+++ b/camera/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,37 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Camera. Audited state: settings only, persisted through DataStoreUtils into+ filesDir/datastore_default.preferences_pb (CameraViewModel) — capture mode,+ ratio, flash, timer and similar.++ Captured media is NOT app storage. Photos, videos and panoramas are written+ through MediaStoreSaver / saveToMediaStore into DCIM/Camera on shared storage,+ which lives outside the app sandbox entirely; the `external` domain only ever+ covers getExternalFilesDir(). Verified there are no getExternalFilesDir()+ writes anywhere in the module, so no captured media can reach a backup through+ these rules. The user's photo library is Google Photos' problem, not this+ app's.++ Intermediate capture files (motion_*.mp4, VID_*.mp4, TL_*.mp4) go to cacheDir,+ which the platform excludes from every backup on its own. erdnet.param /+ erdnet.bin are bundled ncnn assets loaded from the APK by PortraitSegmenter,+ not downloads.++ Nothing large, nothing personal — back the settings up in both directions.+-->+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
clock/src/main/res/xml/data_extraction_rules.xml
diff --git a/clock/src/main/res/xml/data_extraction_rules.xml b/clock/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..11204630ab--- /dev/null+++ b/clock/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,56 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Clock. Audited state:+ * The Room DB (ClockDatabase: Timer, Alarm) is opened at every call site as+ buildDatabase<ClockDatabase>(useDeviceProtectedStorage = true) — with no+ dbName argument, so it takes the library default and the file is literally+ named "passwords-db". Because it uses device-protected storage it lives in+ the device_database domain, which the backup framework does not include by+ default, so alarms and timers are already out of scope for both cloud+ backup and D2D. Nothing to exclude there, and nothing to fix here.+ * secure_prefs — SQLCipher passphrase; SqlCipher.kt migrates it into+ device-protected storage on first run, but a credential-protected copy can+ linger from before that migration.+ * cities.bin is a read-only APK asset (timezone city list).++ The one thing worth excluding is the stale credential-protected copy of+ "passwords-db". buildDatabase() calls moveDatabaseFrom() to relocate an older+ install's DB into device-protected storage, but until that runs — or if the+ move ever fails — an encrypted leftover sits in databases/. Restoring it is+ useless: it is SQLCipher ciphertext under a passphrase wrapped by a+ non-exportable AndroidKeystore key, so the new device can never open it, and+ a stale file there would be picked up by the next moveDatabaseFrom() and+ shadow the real one.++ Alarms and timers are also device-scheduled state — AlarmManager registrations+ do not survive a migration regardless of what the file layer does — so there+ is no user value being given up here.++ Everything else backs up normally.+-->+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <exclude domain="database" path="passwords-db" />+ <exclude domain="database" path="passwords-db-wal" />+ <exclude domain="database" path="passwords-db-shm" />+ <exclude domain="database" path="passwords-db-journal" />+ <include domain="sharedpref" path="." />+ <exclude domain="sharedpref" path="secure_prefs.xml" />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <exclude domain="database" path="passwords-db" />+ <exclude domain="database" path="passwords-db-wal" />+ <exclude domain="database" path="passwords-db-shm" />+ <exclude domain="database" path="passwords-db-journal" />+ <include domain="sharedpref" path="." />+ <exclude domain="sharedpref" path="secure_prefs.xml" />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
code/src/main/res/xml/data_extraction_rules.xml
diff --git a/code/src/main/res/xml/data_extraction_rules.xml b/code/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..06d5b93cc2--- /dev/null+++ b/code/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,20 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Code editor. Overrides the permissive default in the shared :library module.++ Storage audit:+ file datastore/code_editor.preferences_pb Two keys: soft_wrap and folder_uri, the+ SAF tree URI of the last opened project+ folder.+ No database, no SharedPreferences, no app-private files or caches. Source files are+ edited in place through SAF in storage the app does not own.++ Both keys are settings, so the DataStore is allowlisted for cloud backup. folder_uri will+ need re-granting after a restore but is harmless to carry. -->+<data-extraction-rules>+ <cloud-backup>+ <include domain="file" path="datastore/code_editor.preferences_pb" />+ </cloud-backup>+ <device-transfer>+ <include domain="file" path="datastore/code_editor.preferences_pb" />+ </device-transfer>+</data-extraction-rules>
contacts/src/main/res/xml/data_extraction_rules.xml
diff --git a/contacts/src/main/res/xml/data_extraction_rules.xml b/contacts/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..a052655340--- /dev/null+++ b/contacts/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,22 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Overrides the permissive default in the shared :library module.++ Storage audited:+ (no app-owned contact store) ContactViewModel reads and writes the system+ ContactsContract provider, which the OS backs up on its+ own. Nothing here should duplicate contact records.+ file/datastore_default.preferences_pb UI/account settings only: hidden_accounts,+ extra_accounts_set, last_account_name/type,+ calendar_sync_enabled, show_account_labels.+ cache/*.vcf share/export scratch files; Android never backs up cacheDir.++ Only the settings file is allowlisted, so contact data is never duplicated into a+ backup. It does carry account names, so cloud backup is gated on device encryption. -->+<data-extraction-rules>+ <cloud-backup disableIfNoEncryptionCapabilities="true">+ <include domain="file" path="datastore_default.preferences_pb" />+ </cloud-backup>+ <device-transfer>+ <include domain="file" path="datastore_default.preferences_pb" />+ </device-transfer>+</data-extraction-rules>
education/src/main/res/xml/data_extraction_rules.xml
diff --git a/education/src/main/res/xml/data_extraction_rules.xml b/education/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..18f0b3d4be--- /dev/null+++ b/education/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,51 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Education. Audited state:+ * databases/education-db — Room DB with Learner, SkillProgress and Deadline+ entities.+ * No SharedPreferences or DataStore usage found; the DB is the app's only+ persistent store.++ education-db is excluded from both sections because it is SQLCipher-encrypted+ via library:room buildDatabase(), and the passphrase is wrapped by an+ AndroidKeystore key (DatabaseHelper alias db_no_auth_key) that is hardware-+ bound and never leaves the device. A restored copy cannot be decrypted:+ isKeyGenerated() returns false on the new device, a fresh key and passphrase+ are minted, encryptExistingDatabase() skips the file because its header is+ not "SQLite format 3", and Room then fails to open it. Including the file+ would turn a clean install into a crash on launch.++ secure_prefs.xml is excluded with it — it stores only the Keystore-wrapped+ ciphertext of the passphrase, which is meaningless without the key.++ Heads-up: education declares no android:backupAgent, so there is no+ SqlCipherDbCodec re-keying path here. Learner progress therefore does not+ migrate to a new device today. That is a pre-existing gap in the app, not+ something these rules introduce, but it needs a BackupAgent to fix.+-->+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <exclude domain="database" path="education-db" />+ <exclude domain="database" path="education-db-wal" />+ <exclude domain="database" path="education-db-shm" />+ <exclude domain="database" path="education-db-journal" />+ <include domain="sharedpref" path="." />+ <exclude domain="sharedpref" path="secure_prefs.xml" />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <exclude domain="database" path="education-db" />+ <exclude domain="database" path="education-db-wal" />+ <exclude domain="database" path="education-db-shm" />+ <exclude domain="database" path="education-db-journal" />+ <include domain="sharedpref" path="." />+ <exclude domain="sharedpref" path="secure_prefs.xml" />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
email/src/main/res/xml/data_extraction_rules.xml
diff --git a/email/src/main/res/xml/data_extraction_rules.xml b/email/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..99c69df49b--- /dev/null+++ b/email/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,64 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Allowlist. Overrides the permissive include-everything default in the shared :library+ module. Both sections use <include>, so anything not named here is excluded.++ ALLOWED: shared_prefs/email_settings.xml+ Holds one key, "load_remote_images" (EmailSettings.kt). It is an app-wide privacy+ preference with no account scope, no PII and no crypto dependency, and it is the one+ setting a user would notice silently reverting after a restore. The cloud-backup+ section sets disableIfNoEncryptionCapabilities="true" so even this only leaves the+ device under Google's client-side end-to-end encryption.++ EXCLUDED (by omission from the allowlist):++ databases/email-db (+ -wal/-shm/-journal), databases/email-db_temp+ The EmailAccount table holds accessToken and refreshToken as PLAINTEXT columns+ (EmailModels.kt:88-89) alongside passwordEncrypted/passwordIv wrapped by the+ AndroidKeyStore alias "email_account_pw". The same table holds every account's+ server config, and the EmailMessage table holds all cached message bodies. Account+ config cannot be separated from the tokens: they are columns on the same row, in+ the same file. The file is SQLCipher-encrypted under a passphrase wrapped by+ "db_no_auth_key", and neither Keystore alias survives cloud backup or D2D, so a+ restored database is unreadable as well as unsafe. email-db_temp is the plaintext+ staging file from the plaintext->SQLCipher migration.+ shared_prefs/secure_prefs.xml+ Wrapped SQLCipher passphrase + IV. Restoring it without its Keystore key leaves+ DatabaseHelper.isKeyGenerated() reporting a key that no longer exists.+ shared_prefs/outlook_oauth.xml+ In-flight PKCE "verifier" and "state" plus "emailHint". A restored verifier/state+ pair is a stale CSRF token for an authorization request that no longer exists, and+ emailHint is an account address. No value, real risk.+ shared_prefs/email_notif_last_seen.xml+ Keys are literally "<accountEmail>::<folderName>", so the file enumerates the+ user's email addresses. The only benefit is suppressing one burst of duplicate+ notifications, and since the accounts database is not restored there is nothing+ for those UIDs to line up against.+ shared_prefs/email_idle_state.xml+ "idle_restart_pending" is transient runtime state. Restoring it true would enqueue+ an IMAP IDLE restart on a device with no configured accounts.+ files/outbox/<entryId>/ and files/outbox/<entryId>/inline/+ Attachment and inline-image payloads for queued outgoing mail, stored as plaintext+ files. Unsent user mail content; must not be uploaded.+ files/ Glance widget state+ androidx.glance.appwidget writes per-widget-id state files under files/. Widget ids+ are not stable across installs, so the state is meaningless after a restore, and+ the widget caches message subjects and senders. Regenerable.+ databases/androidx.work.workdb (+ sidecars)+ WorkManager scheduling state, including serialized worker input data. Regenerable.+ cache/cid/, cache/eml_cid/, cache/inline/, cache/eml_attachments/+ Decoded inline images and attachments from received mail. The framework never+ backs up cacheDir, but they are named here so the audit is complete.++ Device transfer carries the same single preference. It is not widened relative to cloud+ backup, because D2D does not migrate AndroidKeyStore material and the accounts database+ would arrive unopenable.+-->+<data-extraction-rules>+ <cloud-backup disableIfNoEncryptionCapabilities="true">+ <include domain="sharedpref" path="email_settings.xml" />+ </cloud-backup>+ <device-transfer>+ <include domain="sharedpref" path="email_settings.xml" />+ </device-transfer>+</data-extraction-rules>
everysync/src/main/res/xml/data_extraction_rules.xml
diff --git a/everysync/src/main/res/xml/data_extraction_rules.xml b/everysync/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..6da1ad1448--- /dev/null+++ b/everysync/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,33 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Contacts/calendar/health sync client. Overrides the permissive default in the shared+ :library module.++ Storage audit:+ file datastore_default.preferences_pb One shared DataStore holding everything:+ - tok_oauth_<account> OAuth access + refresh tokens (TokenStore)+ - tok_dav_<account> CalDAV/CardDAV base URL, username and password, including+ iCloud app-specific passwords+ - the AccountConfig list (account names, providers, endpoints, enabled data types)+ - global settings: global_interval_minutes, wifi_only, conflict_policy+ No database, no SharedPreferences, no app-private files or caches. Synced contacts,+ calendars and health records land in the system providers, not in app storage.++ Secrets are AES-GCM sealed under an AndroidKeyStore key that cannot leave the device, so a+ cloud copy would be undecryptable ciphertext — but shipping a user's refresh tokens and+ DAV passwords to Google's servers at all is not a trade worth making, and they are not+ separable from the settings because they share one DataStore file. Cloud backup is denied.+ Device transfer keeps the file so account configuration and settings survive a migration;+ the sealed blobs will fail to decrypt on the new device and TokenStore.load() already+ returns null in that case, which re-prompts for sign-in. -->+<data-extraction-rules>+ <cloud-backup>+ <exclude domain="root" path="." />+ <exclude domain="file" path="." />+ <exclude domain="database" path="." />+ <exclude domain="sharedpref" path="." />+ <exclude domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="file" path="datastore_default.preferences_pb" />+ </device-transfer>+</data-extraction-rules>
files/src/main/res/xml/data_extraction_rules.xml
diff --git a/files/src/main/res/xml/data_extraction_rules.xml b/files/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..43e7685fb1--- /dev/null+++ b/files/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,20 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- File manager. Overrides the permissive default in the shared :library module.++ Storage audit:+ sharedpref files_prefs.xml sort_by, sort_ascending, view_mode, show_hidden,+ has_prompted_notifications, and a bookmarks string-set of+ on-device folder paths.+ No database, no DataStore, no app-private files or caches. The files the app browses+ live in shared storage it does not own and are never part of its backup set.++ files_prefs is genuinely restorable UI state, so it is allowlisted for cloud backup. The+ bookmark paths are the user's own directory names and carry no credentials. -->+<data-extraction-rules>+ <cloud-backup>+ <include domain="sharedpref" path="files_prefs.xml" />+ </cloud-backup>+ <device-transfer>+ <include domain="sharedpref" path="files_prefs.xml" />+ </device-transfer>+</data-extraction-rules>
findfamily/src/main/res/xml/data_extraction_rules.xml
diff --git a/findfamily/src/main/res/xml/data_extraction_rules.xml b/findfamily/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..b50aa121b6--- /dev/null+++ b/findfamily/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,30 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Overrides the permissive default in the shared :library module.++ Storage audited:+ database/passwords-db FFDatabase (User/Waypoint/LocationValue/TemporaryLink):+ precise location history and family link state.+ file/datastore_default.preferences_pb userid plus the E2EE identity keypair and+ the "ff_pqc" post-quantum keys (Networking.init ->+ E2eeIdentity/PqcIdentity.loadOrCreate). Private key material.+ sharedpref/secure_prefs keystore-wrapped SQLCipher passphrase.++ Nothing leaves for cloud backup: location history is sensitive and the DataStore+ holds long-term private keys. Device transfer carries the location history only;+ the key material stays on the device that generated it, so a new device+ re-establishes its own identity and family links. -->+<data-extraction-rules>+ <cloud-backup>+ <exclude domain="root" path="." />+ <exclude domain="file" path="." />+ <exclude domain="database" path="." />+ <exclude domain="sharedpref" path="." />+ <exclude domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <!-- Allowlist: the database domain only, so the DataStore holding the E2EE and+ PQC private keys is excluded. Whole-domain include keeps the -wal/-shm+ sidecars with the database. -->+ <include domain="database" path="." />+ </device-transfer>+</data-extraction-rules>
games/alchemist/src/main/res/xml/data_extraction_rules.xml
diff --git a/games/alchemist/src/main/res/xml/data_extraction_rules.xml b/games/alchemist/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..0ec4aa6ee9--- /dev/null+++ b/games/alchemist/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,33 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Alchemist. Audited state: filesDir/datastore_default.preferences_pb+ (DataStoreUtils) holding discovered combinations, achievements and settings.+ No Room database and no files written to filesDir or external storage;+ items.json and achievements.json are read-only APK assets.++ Back everything up. The discovery set is the entire game — it is small and+ irreplaceable.++ SCOPE: alchemist declares android:backupAgent=".util.AppBackupAgent" and does+ NOT set android:fullBackupOnly, so Android uses key/value backup and the+ <cloud-backup> section below is NOT consulted. Cloud content is exactly+ AppBackupAgent's datastoreNames = ["datastore_default"], which is the same+ data this file would have sent. <device-transfer> IS governed here, and these+ rules become the cloud control too if the backupAgent is ever removed.+-->+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
games/chess/src/main/res/xml/data_extraction_rules.xml
diff --git a/games/chess/src/main/res/xml/data_extraction_rules.xml b/games/chess/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..f644a29dff--- /dev/null+++ b/games/chess/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,36 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Chess. Audited state: everything the app persists lives in+ filesDir/datastore_default.preferences_pb (DataStoreUtils) — Learn-mode stars,+ achievements and game settings. No Room database, no files written to filesDir+ or external storage; puzzles.dat / learn.json / achievements.json are read-only+ APK assets. Stockfish's NNUE is read straight out of the APK.++ So: back everything up. Losing Learn progress on a phone migration is exactly+ the outcome these rules exist to prevent. Nothing here is large or personal+ enough to warrant an exclusion, and the platform already drops cacheDir and+ code_cache on its own.++ SCOPE: chess declares android:backupAgent=".util.AppBackupAgent" and does NOT+ set android:fullBackupOnly, so Android uses key/value backup and the+ <cloud-backup> section below is NOT consulted. Cloud content is exactly+ AppBackupAgent's datastoreNames = ["datastore_default"], which is the same+ data this file would have sent. <device-transfer> IS governed here, and these+ rules become the cloud control too if the backupAgent is ever removed.+-->+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
games/hub/src/main/res/xml/data_extraction_rules.xml
diff --git a/games/hub/src/main/res/xml/data_extraction_rules.xml b/games/hub/src/main/res/xml/data_extraction_rules.xmlindex e6a94bbadb..5706e46c01 100644--- a/games/hub/src/main/res/xml/data_extraction_rules.xml+++ b/games/hub/src/main/res/xml/data_extraction_rules.xml@@ -1,16 +1,77 @@ <?xml version="1.0" encoding="utf-8"?>+<!--+ Games Hub. Audited state:+ * databases/games-hub-db — Room DB (GamesHubDatabase) with play sessions,+ achievement progress, player profile and a cross-app activity feed+ aggregated from the other eight games.+ * secure_prefs.xml — the SQLCipher passphrase for that DB.+ * filesDir/datastore_default.preferences_pb — UI settings.++ games-hub-db is excluded from BOTH sections, for a correctness reason before+ a privacy one. It is built via library:room buildDatabase(), so it is+ SQLCipher-encrypted with a random passphrase that DatabaseHelper wraps using+ an AndroidKeystore key (alias db_no_auth_key). Keystore keys are hardware-bound+ and are never backed up or transferred. On a restored device the alias is+ gone, so DatabaseHelper.isKeyGenerated() returns false, buildDatabase()+ generates a fresh key and a brand-new passphrase, and+ encryptExistingDatabase() sees a non-plaintext header and leaves the file+ alone — Room then opens the restored ciphertext with the wrong key and throws+ SQLiteNotADatabaseException. Shipping the raw file doesn't restore the user's+ data, it bricks first launch.++ Migration is handled properly by the app's own BackupAgent instead: it uses+ SqlCipherDbCodec to sqlcipher_export() to plaintext at backup time and+ re-encrypt under the new device's key at restore time.++ secure_prefs.xml goes with it — it holds only the Keystore-wrapped ciphertext+ of the passphrase, which is undecryptable off-device and is regenerated on+ first launch anyway.++ SCOPE — READ BEFORE RELYING ON THE <cloud-backup> SECTION BELOW.+ hub declares android:backupAgent=".util.AppBackupAgent" and does NOT set+ android:fullBackupOnly, so Android uses key/value backup for this app and the+ <cloud-backup> section here is NOT consulted. What actually leaves the device+ for cloud is whatever AppBackupAgent lists: dbConfigs (games-hub-db, exported+ by SqlCipherDbCodec) and datastoreNames (datastore_default). The rules below+ govern <device-transfer>, and they are the correct control if the backupAgent+ is ever removed.++ Privacy note, corrected: hub's DB is a cross-app behavioural profile (what the+ user plays and for how long, across eight apps). An earlier version of this+ comment claimed the exclusion below keeps that profile off Google's servers.+ That is WRONG. Because this app is key/value, the agent ships games-hub-db to+ cloud regardless of this file — and SqlCipherDbCodec.exportDatabase()+ sqlcipher_export()s it to PLAINTEXT inside the backup payload first. If that+ profile should not leave the device, the fix is to drop DB_NAME from+ AppBackupAgent.dbConfigs, not to edit this XML.+--> <data-extraction-rules>+ <!-- Not consulted while android:backupAgent is declared; see SCOPE above.+ Kept correct so behaviour is right if the agent is ever removed. --> <cloud-backup> <include domain="root" path="." /> <include domain="file" path="." /> <include domain="database" path="." />+ <exclude domain="database" path="games-hub-db" />+ <exclude domain="database" path="games-hub-db-wal" />+ <exclude domain="database" path="games-hub-db-shm" />+ <exclude domain="database" path="games-hub-db-journal" /> <include domain="sharedpref" path="." />+ <exclude domain="sharedpref" path="secure_prefs.xml" />+ <include domain="external" path="." /> </cloud-backup> <device-transfer> <include domain="root" path="." /> <include domain="file" path="." /> <include domain="database" path="." />+ <!-- Same Keystore problem applies to D2D: the wrapping key does not+ leave the source device either. -->+ <exclude domain="database" path="games-hub-db" />+ <exclude domain="database" path="games-hub-db-wal" />+ <exclude domain="database" path="games-hub-db-shm" />+ <exclude domain="database" path="games-hub-db-journal" /> <include domain="sharedpref" path="." />+ <exclude domain="sharedpref" path="secure_prefs.xml" /> <include domain="external" path="." /> </device-transfer> </data-extraction-rules>
games/logicgate/src/main/res/xml/data_extraction_rules.xml
diff --git a/games/logicgate/src/main/res/xml/data_extraction_rules.xml b/games/logicgate/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..408d0610b7--- /dev/null+++ b/games/logicgate/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,35 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Logic Gate. Audited state: the "logicgate_stats" SharedPreferences file+ (ProgressRepository) plus filesDir/datastore_default.preferences_pb, which is+ where the user's saved circuits live (under the logicgate_circuits_v1 key —+ see the note in AppBackupAgent). No Room database, nothing on external+ storage; achievements.json is a read-only APK asset.++ Back everything up. Saved circuits are user-authored content, so dropping the+ file domain here would destroy real work.++ SCOPE: logicgate declares android:backupAgent=".util.AppBackupAgent" and does+ NOT set android:fullBackupOnly, so Android uses key/value backup and the+ <cloud-backup> section below is NOT consulted. Cloud content is exactly+ AppBackupAgent's prefNames = ["logicgate_stats"] plus datastoreNames =+ ["datastore_default"] — so the saved circuits do reach the cloud, same as this+ file intends. <device-transfer> IS governed here, and these rules become the+ cloud control too if the backupAgent is ever removed.+-->+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
games/pipes/src/main/res/xml/data_extraction_rules.xml
diff --git a/games/pipes/src/main/res/xml/data_extraction_rules.xml b/games/pipes/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..ae4ae5e138--- /dev/null+++ b/games/pipes/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,32 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Pipes. Audited state: the "level_stats" and "daily_stats" SharedPreferences+ files (AppBackupAgent.prefNames) holding per-level completion and daily+ streaks. No Room database, nothing written to filesDir or external storage —+ every packs/*.json and achievements.json is a read-only APK asset.++ Back everything up; it is a few KB of pure user progress.++ SCOPE: pipes declares android:backupAgent=".util.AppBackupAgent" and does NOT+ set android:fullBackupOnly, so Android uses key/value backup and the+ <cloud-backup> section below is NOT consulted. Cloud content is exactly+ AppBackupAgent's prefNames = ["level_stats", "daily_stats"], which is the same+ data this file would have sent. <device-transfer> IS governed here, and these+ rules become the cloud control too if the backupAgent is ever removed.+-->+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
games/solitaire/src/main/res/xml/data_extraction_rules.xml
diff --git a/games/solitaire/src/main/res/xml/data_extraction_rules.xml b/games/solitaire/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..6765ced796--- /dev/null+++ b/games/solitaire/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,33 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Solitaire. Audited state: the "solitaire_stats" SharedPreferences file+ (SolitaireStatsRepository / AppBackupAgent.prefNames) holding win counts, best+ times and streaks. No Room database and nothing written to filesDir or+ external storage; achievements.json is a read-only APK asset.++ Back everything up — lifetime stats are the thing a solitaire player would be+ most annoyed to lose.++ SCOPE: solitaire declares android:backupAgent=".util.AppBackupAgent" and does+ NOT set android:fullBackupOnly, so Android uses key/value backup and the+ <cloud-backup> section below is NOT consulted. Cloud content is exactly+ AppBackupAgent's prefNames = ["solitaire_stats"], which is the same data this+ file would have sent. <device-transfer> IS governed here, and these rules+ become the cloud control too if the backupAgent is ever removed.+-->+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
games/unblockjam/src/main/res/xml/data_extraction_rules.xml
diff --git a/games/unblockjam/src/main/res/xml/data_extraction_rules.xml b/games/unblockjam/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..de86a1c428--- /dev/null+++ b/games/unblockjam/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,34 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Unblock Jam. Audited state: two SharedPreferences files, "level_stats" and+ "daily_stats" (per LevelStatsRepository / AppBackupAgent.prefNames), holding+ level completion, stars and daily-challenge streaks. No Room database and no+ files written to filesDir or external storage — original_pack.json and+ achievements.json are read-only APK assets.++ Back everything up: level progress and streaks are precisely what a user+ expects to survive a new phone, and the whole payload is a few KB.++ SCOPE: unblockjam declares android:backupAgent=".util.AppBackupAgent" and does+ NOT set android:fullBackupOnly, so Android uses key/value backup and the+ <cloud-backup> section below is NOT consulted. Cloud content is exactly+ AppBackupAgent's prefNames = ["level_stats", "daily_stats"], which is the same+ data this file would have sent. <device-transfer> IS governed here, and these+ rules become the cloud control too if the backupAgent is ever removed.+-->+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
games/voxels/src/main/res/xml/data_extraction_rules.xml
diff --git a/games/voxels/src/main/res/xml/data_extraction_rules.xml b/games/voxels/src/main/res/xml/data_extraction_rules.xmlindex 81a97e0f26..39f32244c7 100644--- a/games/voxels/src/main/res/xml/data_extraction_rules.xml+++ b/games/voxels/src/main/res/xml/data_extraction_rules.xml@@ -1,14 +1,55 @@ <?xml version="1.0" encoding="utf-8"?>+<!--+ Voxels. Audited state:+ * "voxels_prefs" SharedPreferences (AppBackupAgent.prefNames) — settings.+ * filesDir/worlds/<world-id>/ — one directory per world, containing+ world.json (name, seed, timestamps), player.json (position/inventory) and+ regions/c_<x>_<z>.dat, the saved chunks written by the Rust save layer+ (src/main/rust/src/world/save.rs).+ * cacheDir/*.wav — SoundFx generates its sound effects at runtime. The+ platform already excludes cacheDir from every backup, so no rule needed.++ Why regions/ is a problem for cloud backup: each chunk file is up to+ SECTIONS_PER_CHUNK * ~12 KB, and chunk_map.rs keeps a render distance of 12,+ so an explored world is easily hundreds of megabytes. Android Auto Backup has+ a ~25 MB per-app quota, and blowing it doesn't just drop the big files — it+ fails the backup for the entire app, silently taking voxels_prefs down with+ it.++ The rules format has no wildcards, so there is no way to keep+ worlds/<id>/world.json while dropping worlds/<id>/regions. Excluding the whole+ worlds tree from cloud-backup is the deliberate choice: a truncated world is+ actively worse than no world, because decode_chunk() treats an unreadable+ chunk as ungenerated and regenerates it from the seed, silently erasing+ whatever the player built there.++ Device transfer has no quota and runs over a direct local link, so worlds go+ across intact — that is the path that actually preserves builds.++ SCOPE: voxels declares android:backupAgent=".util.AppBackupAgent" and does NOT+ set android:fullBackupOnly, so Android uses key/value backup here and the+ <cloud-backup> section below is NOT consulted today. In practice the outcome+ matches the intent anyway: AppBackupAgent lists only prefNames =+ ["voxels_prefs"], so settings reach the cloud and saved worlds do not. The+ exclusion below is kept so that stays true if the backupAgent is ever removed+ and Auto Backup takes over. <device-transfer> IS governed by this file.+--> <data-extraction-rules>+ <!-- Not consulted while android:backupAgent is declared; see SCOPE above. --> <cloud-backup> <include domain="root" path="." /> <include domain="file" path="." />+ <!-- Saved worlds: far over the 25 MB cloud quota, and a partial restore+ regenerates terrain from the seed and destroys player builds. -->+ <exclude domain="file" path="worlds" /> <include domain="database" path="." /> <include domain="sharedpref" path="." /> <include domain="external" path="." /> </cloud-backup> <device-transfer> <include domain="root" path="." />+ <!-- Worlds included: no quota on D2D, and this is the only path that+ migrates a player's builds. --> <include domain="file" path="." /> <include domain="database" path="." /> <include domain="sharedpref" path="." />
games/wordmaker/src/main/res/xml/data_extraction_rules.xml
diff --git a/games/wordmaker/src/main/res/xml/data_extraction_rules.xml b/games/wordmaker/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..c301e8c936--- /dev/null+++ b/games/wordmaker/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,36 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Word Maker. Audited state: a single Preferences DataStore declared as+ preferencesDataStore(name = "settings") in LevelDataStore.kt, which lands at+ filesDir/datastore/settings.preferences_pb and holds level progress and+ settings. No Room database, nothing written to external storage; the word+ lists (wordgen/common_words_list.txt, wordgen/bad-words.txt) and+ achievements.json are read-only APK assets.++ Back everything up — it is a small preferences blob and it is the user's+ progress.++ SCOPE: wordmaker declares android:backupAgent=".util.AppBackupAgent" and does+ NOT set android:fullBackupOnly, so Android uses key/value backup and the+ <cloud-backup> section below is NOT consulted. Cloud content is exactly+ AppBackupAgent's datastoreNames = ["settings"], matching the DataStore named+ in LevelDataStore.kt — the same data this file would have sent.+ <device-transfer> IS governed here, and these rules become the cloud control+ too if the backupAgent is ever removed.+-->+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
health/src/main/res/xml/data_extraction_rules.xml
diff --git a/health/src/main/res/xml/data_extraction_rules.xml b/health/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..47b49d0352--- /dev/null+++ b/health/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,31 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Overrides the permissive default in the shared :library module.++ Storage audited:+ database/passwords-db HealthDatabase (Record/Ingredient/Recipe/ServingUnit/+ RecipeIngredient): health, nutrition, sleep and exercise+ records. Highly sensitive.+ file/food.db, food.db.part, food.bin.part, food.bin.meta.json+ Open Food Facts index unpacked from a bundled asset.+ Large and fully regenerable.+ file/datastore_default.preferences_pb sync bookkeeping.+ sharedpref/sync declared in HealthAPI but never read or written.+ sharedpref/secure_prefs keystore-wrapped SQLCipher passphrase.++ Health records must not reach Google's servers, so cloud backup is off entirely.+ Device-to-device transfer never leaves the two devices, so records move with the+ user; the regenerable food index and the keystore-bound passphrase do not. -->+<data-extraction-rules>+ <cloud-backup>+ <exclude domain="root" path="." />+ <exclude domain="file" path="." />+ <exclude domain="database" path="." />+ <exclude domain="sharedpref" path="." />+ <exclude domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <!-- Whole-domain include so the -wal/-shm sidecars travel with the database. -->+ <include domain="database" path="." />+ <include domain="file" path="datastore_default.preferences_pb" />+ </device-transfer>+</data-extraction-rules>
keyboard/src/main/res/xml/data_extraction_rules.xml
diff --git a/keyboard/src/main/res/xml/data_extraction_rules.xml b/keyboard/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..51a3db4312--- /dev/null+++ b/keyboard/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,36 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Keyboard. Audited state: ten settings persisted through DataStoreUtils into+ filesDir/datastore_default.preferences_pb — haptics, sound, auto-capitalise,+ double-space-period, suggestions, autocorrect, number row, key height, the+ enabled layout list and the active layout (KeyboardSettings.Keys).++ Checked specifically for a learned-words / user dictionary, since an IME that+ records what the user types would be sensitive regardless of this app's+ general risk level. There is none. Dictionary.load() and+ PinyinDictionary.load() read fixed APK assets (dict/words_en.txt,+ dict/bopomofo.txt, emoji.txt) and are never written back; the only writes+ anywhere in the module are the ds.setBoolean/setString calls in SetupScreen+ and the active-layout write in KeyboardService. There is also no persisted+ clipboard history — the clipboard page is UI-only.++ So nothing the user has typed is stored on disk, and there is nothing to hold+ back from cloud backup. Settings back up in full; restoring them is the whole+ point, since reconfiguring layouts by hand on a new phone is tedious.+-->+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
library/src/main/res/xml/data_extraction_rules.xml
diff --git a/library/src/main/res/xml/data_extraction_rules.xml b/library/src/main/res/xml/data_extraction_rules.xmlindex 81a97e0f26..e348e72204 100644--- a/library/src/main/res/xml/data_extraction_rules.xml+++ b/library/src/main/res/xml/data_extraction_rules.xml@@ -1,17 +1,35 @@ <?xml version="1.0" encoding="utf-8"?>+<!--+ Fail-safe fallback only. Every app in the repo currently ships its own+ res/xml/data_extraction_rules.xml, which shadows this one, so nothing uses+ this file today.++ It denies cloud-backup on purpose. A new app that forgets to write its own+ rules gets no cloud backup rather than silently uploading everything: this+ file used to <include> root, file, database, sharedpref and external in both+ sections, which meant any app inheriting it shipped its entire sandbox to+ Google. Several apps store E2EE identity keys in files/datastore_default and+ OAuth tokens in shared_prefs, so that default was the wrong way round.++ If you are adding an app: write a real per-app rules file listing what is+ genuinely worth restoring. Two things to know first.+ - Room databases here are SQLCipher-encrypted with a passphrase wrapped by+ a non-exportable AndroidKeyStore key, so a copied .db file cannot be+ decrypted on the target device. Backing one up needs a BackupAgent that+ re-keys it (see BaseBackupAgent + SqlCipherDbCodec), not a rule.+ - If your app declares android:backupAgent without fullBackupOnly, it uses+ key/value backup and the <cloud-backup> section below is not consulted.+--> <data-extraction-rules> <cloud-backup>- <include domain="root" path="." />- <include domain="file" path="." />- <include domain="database" path="." />- <include domain="sharedpref" path="." />- <include domain="external" path="." />+ <exclude domain="root" path="." />+ <exclude domain="file" path="." />+ <exclude domain="database" path="." />+ <exclude domain="sharedpref" path="." />+ <exclude domain="external" path="." /> </cloud-backup> <device-transfer>- <include domain="root" path="." /> <include domain="file" path="." />- <include domain="database" path="." /> <include domain="sharedpref" path="." />- <include domain="external" path="." /> </device-transfer> </data-extraction-rules>
maps/src/main/res/xml/data_extraction_rules.xml
diff --git a/maps/src/main/res/xml/data_extraction_rules.xml b/maps/src/main/res/xml/data_extraction_rules.xmlindex 09ef73361c..c1ea8e8c96 100644--- a/maps/src/main/res/xml/data_extraction_rules.xml+++ b/maps/src/main/res/xml/data_extraction_rules.xml@@ -1,32 +1,62 @@ <?xml version="1.0" encoding="utf-8"?> <!--- Maps-specific backup/transfer rules. The shared library rules include- `external` storage, but for this module that domain holds tens to hundreds- of megabytes of downloaded offline data (zone_*.pmtiles map tiles, the- streamed-basemap disk cache under tilecache/, plus the single global routing- files nodes.bin, edges.bin, transit_voyages.bin, transit_attributes.bin,- amenities.db, metadata.bin, road_names.bin, intermediate.bin).+ Maps. Audited state:+ * externalFilesDir/zone_<id>.pmtiles — downloaded offline map zones.+ * externalFilesDir/tilecache/ (falls back to filesDir/tilecache when there is+ no external storage) — the streamed-basemap disk cache from MapTileCache.+ * externalFilesDir/{nodes,edges,transit_voyages,transit_attributes,metadata,+ road_names,intermediate}.bin — the global routing data set.+ * externalFilesDir/amenities.db — the downloaded amenity/address database.+ * databases/amenities.db — a SECOND copy. buildAmenityDatabase() uses Room's+ createFromFile(), which copies the external file into the standard+ databases/ directory on first open.+ * filesDir/datastore_default.preferences_pb — Home and Work quick-access+ places (SavedPlacesViewModel), plus zone download progress. - Cloud Auto Backup has a 25 MB quota; including these files would blow past- it on the first sync and silently disable backup for the whole app. They're- re-downloadable from data.vayunmathur.com (or re-streamed from protomaps) on- demand, so we exclude them.+ All of the downloaded data is excluded from cloud backup. It runs to tens or+ hundreds of megabytes against a ~25 MB Auto Backup quota, and going over does+ not merely skip the big files — it fails the backup for the entire app,+ silently taking Home/Work with it. Everything excluded here is re-downloadable+ from data.vayunmathur.com or re-streamable from protomaps on demand.++ The databases/amenities.db copy matters and is easy to miss: it sits in the+ `database` domain, not `external`, so excluding external alone would still let+ a large regenerable file through. It is excluded from device transfer too,+ since Room rebuilds it from the external amenities.db via createFromFile() and+ sending both copies would double the transfer for no gain.++ Home and Work are the only personal data here (there is no persisted search or+ location history — the search UI holds results in memory). They are a couple+ of small JSON strings in the DataStore file and are exactly what a user wants+ back on a new phone, so they stay in both sections. --> <data-extraction-rules> <cloud-backup> <include domain="root" path="." /> <include domain="file" path="." />- <!-- tilecache/ falls back to internal files when there's no external- storage; keep it out of the cloud-backup quota either way. -->+ <!-- tilecache/ falls back to internal files when there is no external+ storage; keep it out of the cloud quota either way. --> <exclude domain="file" path="tilecache" /> <include domain="database" path="." />+ <!-- Room's createFromFile() copy of the downloaded amenity DB. -->+ <exclude domain="database" path="amenities.db" />+ <exclude domain="database" path="amenities.db-wal" />+ <exclude domain="database" path="amenities.db-shm" />+ <exclude domain="database" path="amenities.db-journal" /> <include domain="sharedpref" path="." />- <!-- external: deliberately excluded — see comment above. -->+ <!-- external: holds the pmtiles zones, routing .bin set, tilecache and+ amenities.db — all far past the cloud quota and all re-downloadable. --> </cloud-backup> <device-transfer> <include domain="root" path="." /> <include domain="file" path="." /> <include domain="database" path="." />+ <!-- Rebuilt from the external amenities.db on first open; transferring+ both copies would double the payload for nothing. -->+ <exclude domain="database" path="amenities.db" />+ <exclude domain="database" path="amenities.db-wal" />+ <exclude domain="database" path="amenities.db-shm" />+ <exclude domain="database" path="amenities.db-journal" /> <include domain="sharedpref" path="." /> <!-- external IS included for device transfer so a new phone gets the user's already-downloaded zones rather than re-downloading them. -->
measure/src/main/res/xml/data_extraction_rules.xml
diff --git a/measure/src/main/res/xml/data_extraction_rules.xml b/measure/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..4a67378cd3--- /dev/null+++ b/measure/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,24 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Measure. Audited state: preferences only, via DataStoreUtils into+ filesDir/datastore_default.preferences_pb (MeasureViewModel) — unit selection+ and calibration. No Room database, no file I/O, nothing on external storage.++ A few bytes of settings, no privacy concerns. Back everything up.+-->+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
messages/src/main/res/xml/data_extraction_rules.xml
diff --git a/messages/src/main/res/xml/data_extraction_rules.xml b/messages/src/main/res/xml/data_extraction_rules.xmlindex 5713e159ae..ef04f43a1c 100644--- a/messages/src/main/res/xml/data_extraction_rules.xml+++ b/messages/src/main/res/xml/data_extraction_rules.xml@@ -1,14 +1,67 @@ <?xml version="1.0" encoding="utf-8"?>-<!-- Only sharedpref is included in backup; everything else (cookies,- WebView local storage, the Room cache) is intentionally per-install- so a backup doesn't carry an authenticated Google session to a- different physical device. The omitted domains are excluded by- default — no explicit <exclude> needed. -->+<!--+ Deny-all.++ This replaces an earlier rules file that included the whole sharedpref domain. That was+ wrong: every SharedPreferences file this app writes holds long-term secret material, so+ the previous policy uploaded live E2EE private keys to Google cloud backup.++ What is on disk and why none of it may be copied:++ shared_prefs/whatsapp_auth.xml Noise X25519 static keypair, identity keypair,+ registrationId, signed pre-key + signature,+ advSecretKey, signed device identity. PLAINTEXT.+ shared_prefs/wa_appstate.xml WhatsApp app-state sync keys, "key_<id>" -> base64+ key material. PLAINTEXT.+ shared_prefs/meta_auth.xml Messenger/Instagram authenticated session blobs.+ PLAINTEXT.+ shared_prefs/secure_prefs.xml SQLCipher passphrase wrapped by the non-exportable+ AndroidKeyStore key "db_no_auth_key".+ files/datastore_default.preferences_pb+ signal_auth_data (ACI/PNI identity keypairs,+ account password, masterKey, accountEntropyPool),+ signal_device_data, telegram_auth_data (MTProto+ authKey), gmessages_auth_data (ECDSA refresh key,+ tachyon token), gvoice_auth_data. PLAINTEXT JSON.+ databases/signal_protocol.db signal_sessions, signal_identity_keys,+ signal_pre_keys, signal_signed_pre_keys,+ signal_kyber_pre_keys, signal_sender_keys,+ plus profileKey and group masterKey columns.+ databases/whatsapp_database whatsapp_e2e_sessions, whatsapp_e2e_identities,+ whatsapp_e2e_pre_keys, whatsapp_e2e_signed_pre_keys,+ whatsapp_e2e_sender_keys, whatsapp_poll_secret.+ databases/messages.db,+ databases/meta_database Message bodies and thread contents.+ (each of the above also has -wal/-shm/-journal sidecars and a transient _temp file,+ covered by the domain-wide exclude)+ root domain app_webview/ cookie and local-storage stores for+ the WhatsApp and Meta login WebViews, i.e. live+ authenticated sessions.++ Device transfer is denied as well, and that is deliberate rather than an oversight.+ Copying Double Ratchet state (session records, pre-keys, sender keys) onto a second+ device desynchronises the ratchet against the peer's chain: both installs advance from+ the same state, message keys are consumed twice, and messages become permanently+ undecryptable. Correct multi-device behaviour is to re-link the new device through each+ platform's own provisioning flow, which issues fresh keys. D2D also cannot carry the+ AndroidKeyStore key, so the SQLCipher databases would arrive unopenable regardless.++ There is no benign counterweight to include: this app persists no theme, sort-order or+ notification preference. Every artifact above is a secret or a message body.+--> <data-extraction-rules> <cloud-backup>- <include domain="sharedpref" path="." />+ <exclude domain="root" path="." />+ <exclude domain="file" path="." />+ <exclude domain="database" path="." />+ <exclude domain="sharedpref" path="." />+ <exclude domain="external" path="." /> </cloud-backup> <device-transfer>- <include domain="sharedpref" path="." />+ <exclude domain="root" path="." />+ <exclude domain="file" path="." />+ <exclude domain="database" path="." />+ <exclude domain="sharedpref" path="." />+ <exclude domain="external" path="." /> </device-transfer> </data-extraction-rules>
music/src/main/res/xml/data_extraction_rules.xml
diff --git a/music/src/main/res/xml/data_extraction_rules.xml b/music/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..e478d5abb1--- /dev/null+++ b/music/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,32 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Local music player. Overrides the permissive default in the shared :library module.++ Storage audit:+ database passwords-db Room (buildDatabase<MusicDatabase>() uses the default dbName).+ Music/Album/Artist rows are a mirror of MediaStore keyed by+ device-local content URIs; Playlist rows reference those same+ URIs. SyncWorker rebuilds the mirror from MediaStore.+ file datastore_default.preferences_pb+ Single key last_music_generation, the MediaStore generation+ marker SyncWorker compares against.+ Album art is an in-process LruCache only; nothing is written to disk.++ Nothing here survives a move to different hardware: every row points at a MediaStore URI+ that will not exist on the new device, and restoring a stale last_music_generation would+ make SyncWorker skip the rescan that repopulates the library. Cloud backup is therefore+ denied, and device transfer carries the library so playlists survive a same-user+ migration where the media files move too. -->+<data-extraction-rules>+ <cloud-backup>+ <exclude domain="root" path="." />+ <exclude domain="file" path="." />+ <exclude domain="database" path="." />+ <exclude domain="sharedpref" path="." />+ <exclude domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="database" path="passwords-db" />+ <include domain="database" path="passwords-db-wal" />+ <include domain="database" path="passwords-db-shm" />+ </device-transfer>+</data-extraction-rules>
musicbrainz/src/main/res/xml/data_extraction_rules.xml
diff --git a/musicbrainz/src/main/res/xml/data_extraction_rules.xml b/musicbrainz/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..e03e968dba--- /dev/null+++ b/musicbrainz/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,28 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- MusicBrainz lookup and tagging client. Overrides the permissive default in the shared+ :library module.++ Storage audit:+ file datastore/musicbrainz.preferences_pb Settings: music_folder_uri,+ fetch_lyrics, embed_cover_art.+ database musicbrainz-db Room, one LocalTrack table: the index+ LibraryScanner builds by walking the+ user's music folder. Rebuilt by a+ rescan, and it enumerates the user's+ audio files.+ MusicBrainz API responses are cached in in-memory HashMaps only. Downloads are written+ through SAF into the user's chosen folder, outside app storage.++ Cloud backup allowlists the settings DataStore. The scan index is regenerable and+ describes the user's music collection, so it is device-transfer only. -->+<data-extraction-rules>+ <cloud-backup>+ <include domain="file" path="datastore/musicbrainz.preferences_pb" />+ </cloud-backup>+ <device-transfer>+ <include domain="file" path="datastore/musicbrainz.preferences_pb" />+ <include domain="database" path="musicbrainz-db" />+ <include domain="database" path="musicbrainz-db-wal" />+ <include domain="database" path="musicbrainz-db-shm" />+ </device-transfer>+</data-extraction-rules>
notes/src/main/res/xml/data_extraction_rules.xml
diff --git a/notes/src/main/res/xml/data_extraction_rules.xml b/notes/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..cd33c503d5--- /dev/null+++ b/notes/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,28 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Overrides the permissive default in the shared :library module.++ Storage audited:+ database/notes-db NoteDatabase (Note): the user's note content. Also the+ legacy passwords-db, deleted after migration in MainActivity.+ file/note_images images embedded in notes (NoteImageStore). User content.+ file/datastore_default.preferences_pb app settings.+ cache/shared_notes markdown export scratch; Android never backs up cacheDir.+ sharedpref/secure_prefs keystore-wrapped SQLCipher passphrase.++ Notes are user-authored content worth restoring on a new device, so both channels+ carry the notes database and its images. Cloud backup is gated on device encryption+ because note text can contain anything. Caches and the keystore-bound passphrase are+ left out by the allowlist. -->+<data-extraction-rules>+ <cloud-backup disableIfNoEncryptionCapabilities="true">+ <!-- Whole-domain include so the -wal/-shm sidecars travel with the database. -->+ <include domain="database" path="." />+ <include domain="file" path="note_images" />+ <include domain="file" path="datastore_default.preferences_pb" />+ </cloud-backup>+ <device-transfer>+ <include domain="database" path="." />+ <include domain="file" path="note_images" />+ <include domain="file" path="datastore_default.preferences_pb" />+ </device-transfer>+</data-extraction-rules>
office/src/main/res/xml/data_extraction_rules.xml
diff --git a/office/src/main/res/xml/data_extraction_rules.xml b/office/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..1df396fc96--- /dev/null+++ b/office/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,31 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Office document editor. Overrides the permissive default in the shared :library module.++ Storage audit:+ sharedpref office_settings.xml Editor preferences.+ sharedpref office_recent.xml Recently opened document URIs.+ file documents/ Documents the app itself created and owns. Not+ regenerable, and the only true user data here.+ file datastore_default.preferences_pb+ Shared DataStore. Holds the OfficeSync PqcIdentity+ private key material (PqcIdentity.loadOrCreate writes+ through DataStoreKeyStore), the officeDeviceId, the+ online document index and the per-document CRDT trees.+ cache crdt_merge.fodt, online_*.fodt Merge scratch and downloaded copies of+ online docs; getCacheDir() is never backed up.++ Cloud backup allowlists the editor settings and the owned documents. The DataStore is+ excluded from cloud backup because the sync identity's private keys live in it — a second+ device holding that key is a duplicated identity, not a restore. office_recent is left out+ too: its URIs will not resolve after a cloud restore and it leaks document file names. -->+<data-extraction-rules>+ <cloud-backup>+ <include domain="sharedpref" path="office_settings.xml" />+ <include domain="file" path="documents" />+ </cloud-backup>+ <device-transfer>+ <!-- Exclude-only: the sync identity and CRDT state move with a direct migration,+ which is exactly the retire-old-device case they are meant for. -->+ <exclude domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
openassistant/src/main/res/xml/data_extraction_rules.xml
diff --git a/openassistant/src/main/res/xml/data_extraction_rules.xml b/openassistant/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..410563bd12--- /dev/null+++ b/openassistant/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,34 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Overrides the permissive default in the shared :library module.++ Storage audited:+ database/passwords-db AppDatabase (Conversation/Message/Memory): the full+ conversation history plus remembered facts. Free-form user+ text, so it can contain anything.+ external/ on-demand model downloads in getExternalFilesDir(null):+ gemma4-2b.litertlm, the SigLIP2 ONNX encoders and+ tokenizer.model. Gigabytes, and re-downloadable.+ file/datastore_default.preferences_pb model download progress and version markers+ (progress_*, dlid_*, siglip_model_version). Meaningless once+ the models are gone.+ cache/ recordings and attachment scratch files; Android never backs+ up cacheDir.+ sharedpref/secure_prefs keystore-wrapped SQLCipher passphrase.++ No API keys or remote credentials were found - inference runs on-device - so the only+ secret-grade material is the keystore passphrase. Conversation history must not reach+ Google's servers, and everything else here is regenerable, so cloud backup is off+ entirely. Device transfer carries the history and nothing else. -->+<data-extraction-rules>+ <cloud-backup>+ <exclude domain="root" path="." />+ <exclude domain="file" path="." />+ <exclude domain="database" path="." />+ <exclude domain="sharedpref" path="." />+ <exclude domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <!-- Whole-domain include so the -wal/-shm sidecars travel with the database. -->+ <include domain="database" path="." />+ </device-transfer>+</data-extraction-rules>
passwords/src/main/res/xml/data_extraction_rules.xml
diff --git a/passwords/src/main/res/xml/data_extraction_rules.xml b/passwords/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..fe8051f53e--- /dev/null+++ b/passwords/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,65 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ SCOPE LIMIT — READ BEFORE TRUSTING THE <cloud-backup> SECTION BELOW.+ This app declares android:backupAgent=".util.AppBackupAgent" and does not set+ android:fullBackupOnly="true". AppBackupAgent extends BaseBackupAgent, which overrides+ onBackup()/onRestore() (library/src/main/java/com/vayunmathur/library/util/BackupAgent.kt:21,48),+ so cloud backup for this app runs through the KEY/VALUE transport and the <cloud-backup>+ section here is NOT consulted. What actually leaves the device is whatever the agent puts+ in its stream: today that is dbConfigs = listOf("passwords-db" to passphrase), which+ BackupHelper exports DECRYPTED via SqlCipherDbCodec. That is a plaintext vault going to+ Google, and no XML in this file can stop it. Fixing it requires a code change to the+ agent, or android:fullBackupOnly="true" to route cloud through these rules instead.++ The <device-transfer> section below IS effective: BaseBackupAgent does not override+ onFullBackup(), so the default BackupAgent.onFullBackup() runs for D2D and honours these+ rules. The <cloud-backup> section is kept deliberately, as correct-by-default policy for+ the day the agent is removed or fullBackupOnly is set.++ Deny-all. Overrides the permissive include-everything default in the shared :library module.++ Nothing this app persists is safe to copy off the device, and nothing it persists is+ restorable even if it were copied:++ databases/passwords-db (+ -wal/-shm/-journal/_temp)+ The vault. SQLCipher-encrypted; the passphrase is AES-GCM wrapped by the+ non-exportable AndroidKeyStore key "db_no_auth_key", which never leaves the+ device on either backup path. -wal/-shm are listed because WAL contents would+ otherwise leak plaintext pages independently of the main file. _temp is the+ plaintext staging file used during the plaintext->SQLCipher migration.+ files/kdbx-sync-backup.kdbx+ Pre-overwrite copy of the user's KDBX vault, protected only by the master+ password. Offline-crackable, so this must never reach Google's servers.+ shared_prefs/secure_prefs.xml, shared_prefs/kdbx_sync_prefs.xml+ Keystore-wrapped passphrase + IV, and the wrapped KDBX master password.+ Restoring these is actively harmful: DatabaseHelper.isKeyGenerated() only checks+ that the IV is present, so a restored prefs file with no matching Keystore key+ puts the app on the decrypt path with a key that does not exist.+ files/datastore_default.preferences_pb+ kdbx sync settings, including kdbx_sync_document_uri. The persisted SAF URI+ permission grant does not survive backup, so restoring the URI only produces a+ sync that fails against an unreadable document.+ databases/androidx.work.workdb (+ sidecars)+ Regenerable WorkManager scheduling state.++ Device transfer is denied too, not just cloud backup. D2D does not touch Google's+ servers, but it also does not migrate AndroidKeyStore material, so carrying the vault+ across yields an unopenable database and the corrupt-state trap described above. The+ supported migration path is the app's own KDBX sync to a user-chosen SAF document.+-->+<data-extraction-rules>+ <cloud-backup>+ <exclude domain="root" path="." />+ <exclude domain="file" path="." />+ <exclude domain="database" path="." />+ <exclude domain="sharedpref" path="." />+ <exclude domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <exclude domain="root" path="." />+ <exclude domain="file" path="." />+ <exclude domain="database" path="." />+ <exclude domain="sharedpref" path="." />+ <exclude domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
pdf/src/main/res/xml/data_extraction_rules.xml
diff --git a/pdf/src/main/res/xml/data_extraction_rules.xml b/pdf/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..eecd85a349--- /dev/null+++ b/pdf/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,28 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- PDF viewer. Overrides the permissive default in the shared :library module.++ Storage audit:+ sharedpref pdf_viewer_state.xml One int per document: the last first-visible page.+ The key is "safe_page_<first 20 chars of the file+ name>_<hash of the full URI>", so the file names of+ every PDF the user has opened are embedded in it.+ cache <uuid>.jpg Scanned page captures; the framework never backs up+ getCacheDir(), so no rule is needed.+ No database, no DataStore. The PDFs themselves are opened through SAF and live in+ storage the app does not own.++ The saved pages are keyed by content URIs that will not resolve after a cloud restore, so+ backing them up buys nothing and ships a list of document file names to Google. Denied+ for cloud, kept for device transfer where the same documents are still reachable. -->+<data-extraction-rules>+ <cloud-backup>+ <exclude domain="root" path="." />+ <exclude domain="file" path="." />+ <exclude domain="database" path="." />+ <exclude domain="sharedpref" path="." />+ <exclude domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="sharedpref" path="pdf_viewer_state.xml" />+ </device-transfer>+</data-extraction-rules>
photos/src/main/res/xml/data_extraction_rules.xml
diff --git a/photos/src/main/res/xml/data_extraction_rules.xml b/photos/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..6e1f4044ca--- /dev/null+++ b/photos/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,33 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Overrides the permissive default in the shared :library module.++ Storage audited:+ database/passwords-db PhotoDatabase (Photo/Person/PhotoFace): a derived index over+ MediaStore. EXIF, lat/long, OCR text of every image, CLIP+ embeddings and face-cluster centroids. No user edits are+ stored here - the cropped*/projection* columns are panorama+ projection metadata, and Person has no user-assigned name.+ Regenerable by re-running SyncWorker, and privacy-heavy.+ database/vault-db VaultDatabase for the secure folder, opened with a+ user-supplied password rather than the keystore passphrase.+ file/secure_vault the secure folder's stored photos. User content the user+ deliberately hid.+ file/datastore_default.preferences_pb grid column count and model-version markers.+ cache/image_cache Coil disk cache; Android never backs up cacheDir.++ Cloud backup carries the grid preference only. The index is regenerable and would+ ship OCR text, geotags and face vectors off the device; the secure folder is hidden+ by intent and stays local. Device transfer carries both databases and the vault so a+ new phone does not have to re-index the whole library, and so hidden photos survive+ the move without passing through Google. -->+<data-extraction-rules>+ <cloud-backup disableIfNoEncryptionCapabilities="true">+ <include domain="file" path="datastore_default.preferences_pb" />+ </cloud-backup>+ <device-transfer>+ <!-- Whole-domain include so the -wal/-shm sidecars travel with each database. -->+ <include domain="database" path="." />+ <include domain="file" path="secure_vault" />+ <include domain="file" path="datastore_default.preferences_pb" />+ </device-transfer>+</data-extraction-rules>
speech/src/main/res/xml/data_extraction_rules.xml
diff --git a/speech/src/main/res/xml/data_extraction_rules.xml b/speech/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..f32d9aa014--- /dev/null+++ b/speech/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,28 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Overrides the permissive default in the shared :library module.++ Storage audited:+ external/piper/voices/** Piper TTS voice archives and unpacked ncnn models+ (PiperVoiceRegistry). Hundreds of MB, re-downloadable.+ external/<whisper dir> Whisper recognition model files (WhisperModel). Same.+ file/datastore_default.preferences_pb download bookkeeping keyed per model+ (progress_*, dlid_*, speed_*), plus any app settings.+ (no Room database, and no learned or adaptation data was found - neither the+ recognition service nor the TTS service persists user speech or per-user models.)++ Everything large here is a re-downloadable model, so nothing goes to cloud backup.+ The DataStore is excluded from cloud backup too: it is download state with no restore+ value, and its full key set could not be enumerated with certainty, so it defaults to+ private. Device transfer carries it so any settings survive the move. -->+<data-extraction-rules>+ <cloud-backup>+ <exclude domain="root" path="." />+ <exclude domain="file" path="." />+ <exclude domain="database" path="." />+ <exclude domain="sharedpref" path="." />+ <exclude domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="file" path="datastore_default.preferences_pb" />+ </device-transfer>+</data-extraction-rules>
things/src/main/res/xml/data_extraction_rules.xml
diff --git a/things/src/main/res/xml/data_extraction_rules.xml b/things/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..0ed2cb8e7a--- /dev/null+++ b/things/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,27 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Things. Audited state: the "hydration" SharedPreferences file (MainActivity) —+ the user's hydration goal and running intake log. No Room database, no+ DataStore, no file I/O, nothing on external storage.++ This is a small personal health-adjacent log, but it is also the entire+ contents of the app: excluding it would make a restore indistinguishable from+ a fresh install. It is a handful of counters rather than anything identifying,+ so back it up in both directions.+-->+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
translate/src/main/res/xml/data_extraction_rules.xml
diff --git a/translate/src/main/res/xml/data_extraction_rules.xml b/translate/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..7d48c59301--- /dev/null+++ b/translate/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,45 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Translate. Audited state:+ * externalFilesDir/small100/ — the SMaLL-100 ncnn translation model:+ encoder.ncnn.bin, decoder.ncnn.bin, sentencepiece.bpe.model, vocab.txt,+ pos_weights.f32.bin and the two .param files (Small100Model.FILES).+ * filesDir/datastore/translate_settings.preferences_pb — last used source and+ target language (TranslateSettings).+ * filesDir/datastore_default.preferences_pb — per-file download progress.++ The model is excluded from cloud backup: the fp16 weights are far past the+ ~25 MB Auto Backup quota, and exceeding that quota fails the backup for the+ whole app, which would take the language preferences down with it. It is also+ fully regenerable — Small100Model downloads it mirror-only from+ data.vayunmathur.com with SHA-256 pinning, and InitialModelDownloadChecker in+ MainActivity re-fetches it automatically on first launch.++ It is kept for device transfer. D2D has no quota and runs over a direct local+ link, so carrying the already-downloaded model across saves the user a+ multi-hundred-megabyte re-download on a brand new phone. This matches the+ approach already taken in maps for its offline map data.++ Language preferences are tiny and back up in both directions.+-->+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <include domain="external" path="." />+ <!-- Downloaded SMaLL-100 weights: over the cloud quota and re-fetchable+ with hash pinning. -->+ <exclude domain="external" path="small100" />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <include domain="sharedpref" path="." />+ <!-- Model included: no quota on D2D, and it spares the user a large+ re-download. -->+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
travel/src/main/res/xml/data_extraction_rules.xml
diff --git a/travel/src/main/res/xml/data_extraction_rules.xml b/travel/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..0eadf621e8--- /dev/null+++ b/travel/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,58 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Travel. Audited state:+ * databases/travel-db — Room DB with RecentSearch, BookedTrip, FrequentFlyer+ and Customer entities.+ * secure_prefs.xml — SQLCipher passphrase for that DB.+ * filesDir/datastore_default.preferences_pb — UI preferences (TravelViewModel).++ travel-db is excluded from both sections. Two independent reasons:++ 1. Correctness. It is built with library:room buildDatabase(), so it is+ SQLCipher-encrypted under a passphrase wrapped by an AndroidKeystore key+ that is hardware-bound and never backed up. On the restored device+ DatabaseHelper.isKeyGenerated() is false, a new key and passphrase are+ generated, encryptExistingDatabase() leaves the already-encrypted file+ alone, and Room opens it with the wrong key —+ SQLiteNotADatabaseException. The restored file is unusable by+ construction.++ 2. Sensitivity. Customer and FrequentFlyer rows are passenger PII (names,+ loyalty numbers) and BookedTrip is an itinerary. Even if the encryption+ problem were solved, this is not content to push to cloud backup casually.++ Heads-up for whoever owns this app: unlike weather and games/hub, travel does+ NOT declare an android:backupAgent, so there is currently no SqlCipherDbCodec+ path either. That means bookings do not migrate to a new device at all today.+ These rules do not cause that — they just stop the migration from failing+ loudly at first launch instead of quietly. Fixing it needs a BackupAgent, not+ a backup rule.++ Preferences and the DataStore file still back up normally.+-->+<data-extraction-rules>+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <exclude domain="database" path="travel-db" />+ <exclude domain="database" path="travel-db-wal" />+ <exclude domain="database" path="travel-db-shm" />+ <exclude domain="database" path="travel-db-journal" />+ <include domain="sharedpref" path="." />+ <exclude domain="sharedpref" path="secure_prefs.xml" />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <exclude domain="database" path="travel-db" />+ <exclude domain="database" path="travel-db-wal" />+ <exclude domain="database" path="travel-db-shm" />+ <exclude domain="database" path="travel-db-journal" />+ <include domain="sharedpref" path="." />+ <exclude domain="sharedpref" path="secure_prefs.xml" />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
vpn/src/main/res/xml/data_extraction_rules.xml
diff --git a/vpn/src/main/res/xml/data_extraction_rules.xml b/vpn/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..09daa1eddb--- /dev/null+++ b/vpn/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,50 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Allowlist. Overrides the permissive include-everything default in the shared :library+ module. Both sections use <include>, so anything not named here is excluded.++ ALLOWED: files/datastore_default.preferences_pb+ For this app the DataStore holds exactly one key, "bypass_packages" (BypassList.kt),+ the split-tunnel package allowlist. It is a plaintext user preference with no crypto+ dependency, it is tedious to rebuild by hand, and it restores correctly. It does+ reveal which apps are installed and which ones the user routes around the tunnel, so+ the cloud-backup section sets disableIfNoEncryptionCapabilities="true" and that+ fingerprint only leaves the device when Google's client-side end-to-end encryption+ is available.++ EXCLUDED (by omission from the allowlist):++ databases/vpn-db (+ -wal/-shm/-journal)+ VpnConfigEntity stores privateKey, peerPublicKey and peerPresharedKey as TEXT+ columns: the WireGuard X25519 static private keys and PSKs. The same file also+ holds ConnectionLogEntity, a per-flow log of resolved domains, package names and+ byte counts, i.e. a complete browsing history. The file is SQLCipher-encrypted,+ but the passphrase is wrapped by the non-exportable AndroidKeyStore key+ "db_no_auth_key", so the ciphertext is neither safe to ship nor usable once+ restored. Tunnel profile metadata (name, address, DNS, MTU, endpoint) lives in the+ same row as the private key, so it cannot be split out at file granularity.+ databases/vpn-db_temp+ Transient staging file for the plaintext->SQLCipher migration. This is the one+ file in the app that can contain private keys as PLAINTEXT SQLite if the process+ dies mid-migration.+ shared_prefs/secure_prefs.xml+ Wrapped SQLCipher passphrase + IV. Restoring it without the Keystore key is worse+ than not restoring it: DatabaseHelper.isKeyGenerated() sees the IV, reports the+ key as present, and sends the app down the decrypt path with a missing key.+ files/datastore_default.preferences_pb.tmp+ DataStore's atomic-commit temp sibling. Not a named path in the allowlist, so it+ is not backed up.++ Device transfer carries the same single preference. It is not made more permissive than+ cloud backup here, because D2D does not migrate AndroidKeyStore material either, so the+ database would arrive unopenable. Kill switch / always-on / lockdown are system-owned+ settings, not app storage, and are outside these rules entirely.+-->+<data-extraction-rules>+ <cloud-backup disableIfNoEncryptionCapabilities="true">+ <include domain="file" path="datastore_default.preferences_pb" />+ </cloud-backup>+ <device-transfer>+ <include domain="file" path="datastore_default.preferences_pb" />+ </device-transfer>+</data-extraction-rules>
weather/src/main/res/xml/data_extraction_rules.xml
diff --git a/weather/src/main/res/xml/data_extraction_rules.xml b/weather/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..8c3e84efce--- /dev/null+++ b/weather/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,66 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Weather. Audited state:+ * databases/weather-db — Room DB holding SavedLocation (the user's saved+ places, genuinely worth restoring) and WeatherCache (forecast responses,+ regenerable).+ * secure_prefs.xml — SQLCipher passphrase for that DB.+ * The Rust/NDK layer (src/main/rust) keeps its HTTP Range block cache in+ memory only — Mutex<HashMap<u64, Vec<u8>>> in lib.rs. It writes nothing to+ disk, so there is no native cache directory to exclude.++ weather-db is excluded from both sections for the same reason as the other+ buildDatabase() apps: it is SQLCipher-encrypted under a passphrase wrapped by+ a non-exportable AndroidKeystore key. That key never leaves the device, so a+ restored copy of this file cannot be opened — buildDatabase() mints a fresh+ key and passphrase, encryptExistingDatabase() skips the already-encrypted+ file, and Room throws SQLiteNotADatabaseException. Shipping it would trade a+ clean first launch for a crash.++ The saved locations still migrate: weather declares its own BackupAgent, which+ uses SqlCipherDbCodec to export the DB to plaintext inside the backup payload+ and re-encrypt it under the new device's key on restore. That path is the one+ that works; the raw file copy would only get in its way.++ Everything else — UI preferences, units, widget state — backs up normally.++ SCOPE: weather declares android:backupAgent=".util.AppBackupAgent" and does+ NOT set android:fullBackupOnly, so Android uses key/value backup here and the+ <cloud-backup> section below is NOT consulted. Cloud content is exactly+ AppBackupAgent's weatherDbConfigs(this) — weather-db, exported to plaintext by+ SqlCipherDbCodec and re-encrypted on restore. That is the path that carries+ SavedLocation across, and it works. The rules below govern <device-transfer>,+ and are the correct control if the backupAgent is ever removed.++ Worth knowing: because the codec exports to plaintext inside the payload, the+ cloud copy includes WeatherCache rows (regenerable forecast data) as well as+ saved locations. Trimming that would be a change to weatherDbConfigs, not to+ this file.+-->+<data-extraction-rules>+ <!-- Not consulted while android:backupAgent is declared; see SCOPE above. -->+ <cloud-backup>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <exclude domain="database" path="weather-db" />+ <exclude domain="database" path="weather-db-wal" />+ <exclude domain="database" path="weather-db-shm" />+ <exclude domain="database" path="weather-db-journal" />+ <include domain="sharedpref" path="." />+ <exclude domain="sharedpref" path="secure_prefs.xml" />+ <include domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <include domain="root" path="." />+ <include domain="file" path="." />+ <include domain="database" path="." />+ <exclude domain="database" path="weather-db" />+ <exclude domain="database" path="weather-db-wal" />+ <exclude domain="database" path="weather-db-shm" />+ <exclude domain="database" path="weather-db-journal" />+ <include domain="sharedpref" path="." />+ <exclude domain="sharedpref" path="secure_prefs.xml" />+ <include domain="external" path="." />+ </device-transfer>+</data-extraction-rules>
web/src/main/res/xml/data_extraction_rules.xml
diff --git a/web/src/main/res/xml/data_extraction_rules.xml b/web/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..6931869224--- /dev/null+++ b/web/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,33 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Browser. Overrides the permissive default in the shared :library module.++ Storage audit:+ database web-browser-db Room: HistoryEntry, Bookmark, BookmarkFolder, SitePermission,+ StorageInfo, DownloadEntry, InstalledSite (PWAs), ShieldSetting.+ sharedpref web_prefs.xml Browser + Brave Shields defaults AND the serialized open-tab+ list (full URLs) for every window.+ root app_webview/ WebView profile: cookies, localStorage, IndexedDB, service+ workers. Session credentials.+ file shields/ ~8 MB serialized adblock engine snapshot, rebuilt from the+ bundled assets whenever it is missing or stale.+ Downloads go to the public Downloads dir via DownloadManager, not app storage.++ Cloud backup is denied outright, and not reflexively: bookmarks and shield settings are+ worth restoring, but they are not separable from the data that must not leave the device.+ Bookmarks/ShieldSetting share one Room file with browsing history, and the shield/browser+ defaults share one SharedPreferences file with the open-tab URLs. Splitting bookmarks and+ settings into their own stores is the prerequisite for a partial cloud allowlist here. -->+<data-extraction-rules>+ <cloud-backup>+ <exclude domain="root" path="." />+ <exclude domain="file" path="." />+ <exclude domain="database" path="." />+ <exclude domain="sharedpref" path="." />+ <exclude domain="external" path="." />+ </cloud-backup>+ <device-transfer>+ <!-- Exclude-only: everything not listed here transfers, which is correct for a+ direct device-to-device migration that never reaches Google's servers. -->+ <exclude domain="file" path="shields" />+ </device-transfer>+</data-extraction-rules>
youpipe/src/main/res/xml/data_extraction_rules.xml
diff --git a/youpipe/src/main/res/xml/data_extraction_rules.xml b/youpipe/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 0000000000..5525a3d42f--- /dev/null+++ b/youpipe/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,34 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- YouTube client. Overrides the permissive default in the shared :library module.++ Storage audit:+ database passwords-db Room. The buildDatabase() default dbName is used because+ MainActivity calls buildDatabase<SubscriptionDatabase>() with+ no name; the file is per-app so the name is only confusing.+ Holds Subscription, SubscriptionVideo, HistoryVideo,+ DownloadedVideo, CachedRelatedVideo, RecommendationImpression+ and the recommendation/channel/keyword preference tables.+ sharedpref sabr_* PoToken caches and playback diagnostics. Session tokens bound+ to this device and install; useless and unsafe off-device.+ file datastore_default.preferences_pb+ Settings only: sponsorblock_enabled + categories,+ dearrow_enabled, youtube_language, default page.+ file sabr-cloud-policy.bin/.rev Fetched playback policy, refetched on demand.+ external downloads/ Downloaded video files. Large and re-downloadable.++ Cloud backup is an allowlist holding just the settings DataStore. Subscriptions are worth+ restoring but sit in the same Room file as watch history and per-video recommendation+ impressions, so the whole database is device-transfer only. -->+<data-extraction-rules>+ <cloud-backup>+ <include domain="file" path="datastore_default.preferences_pb" />+ </cloud-backup>+ <device-transfer>+ <exclude domain="external" path="downloads" />+ <exclude domain="file" path="sabr-cloud-policy.bin" />+ <exclude domain="file" path="sabr-cloud-policy.rev" />+ <exclude domain="sharedpref" path="sabr_local_dom_video_token_cache.xml" />+ <exclude domain="sharedpref" path="sabr_webpo_video_token_cache.xml" />+ <exclude domain="sharedpref" path="sabr_playback_diagnostics.xml" />+ </device-transfer>+</data-extraction-rules>