Modern Apps git

← Modern-Apps.git

wordmaker, pipes, unblockjam, solitaire, voxels, flashcards, photos: back up datastore_default so streaks and achievements survive a restore (#548)

Commit
42dde6674a1ef8af3a946ad4a908394928a3f37d
Author
vayun-mathur <[email protected]>
When
2026-08-18 18:16 UTC (3 months ago)
Parents
9684101
DataStoreUtils writes to filesDir/datastore_default.preferences_pb, which is where
DailyChallengeStore keeps daily streaks and AchievementsManager keeps unlocks. These
apps declare a backupAgent without fullBackupOnly, so cloud backup is exactly what the
agent lists and the permissive data_extraction_rules.xml is never consulted - and none
of them listed datastore_default. Restoring silently reset every streak and achievement.

wordmaker only listed the ''settings'' store (level progress), which is why the reported
streak came back as 1. flashcards and photos already documented datastore_default as
intended for cloud backup in their XML, but the agent has to repeat it to make that true.

Also corrects the audit comments, which named the wrong agent class and claimed these
apps persisted nothing outside the files they listed, and drops openassistant''s claim
that conversation history stays off Google''s servers - its agent has always shipped the
conversation database to cloud backup.

Diff

flashcards/src/main/java/com/vayunmathur/flashcards/util/AppBackupAgent.kt
diff --git a/flashcards/src/main/java/com/vayunmathur/flashcards/util/AppBackupAgent.kt b/flashcards/src/main/java/com/vayunmathur/flashcards/util/AppBackupAgent.ktindex 15247fe77a..9c1f8ab0ff 100644--- a/flashcards/src/main/java/com/vayunmathur/flashcards/util/AppBackupAgent.kt+++ b/flashcards/src/main/java/com/vayunmathur/flashcards/util/AppBackupAgent.kt@@ -11,6 +11,11 @@ class AppBackupAgent : BaseBackupAgent() {     override val dbConfigs: List<Pair<String, String>>         get() = flashcardsDbConfigs(this) +    // The shared DataStoreUtils file, holding app settings. res/xml/data_extraction_rules.xml+    // already lists it; the agent has to repeat it because it, not the XML, drives cloud backup.+    override val datastoreNames: List<String>+        get() = listOf("datastore_default")+     override val extraFiles: List<File>         get() = emptyList() }
games/pipes/src/main/java/com/vayunmathur/games/pipes/platform/AppBackupAgent.kt
diff --git a/games/pipes/src/main/java/com/vayunmathur/games/pipes/platform/AppBackupAgent.kt b/games/pipes/src/main/java/com/vayunmathur/games/pipes/platform/AppBackupAgent.ktindex 88a435a08a..740daa3344 100644--- a/games/pipes/src/main/java/com/vayunmathur/games/pipes/platform/AppBackupAgent.kt+++ b/games/pipes/src/main/java/com/vayunmathur/games/pipes/platform/AppBackupAgent.kt@@ -5,4 +5,9 @@ import com.vayunmathur.library.util.BaseBackupAgent class AppBackupAgent : BaseBackupAgent() {     override val prefNames: List<String>         get() = listOf("level_stats", "daily_stats")++    // The shared DataStoreUtils file, holding AchievementsManager unlocks and the+    // DailyChallengeStore("pipes_daily") streak.+    override val datastoreNames: List<String>+        get() = listOf("datastore_default") }
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.xmlindex ae4ae5e138..f3c3616102 100644--- a/games/pipes/src/main/res/xml/data_extraction_rules.xml+++ b/games/pipes/src/main/res/xml/data_extraction_rules.xml@@ -2,17 +2,20 @@ <!--   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.+  streaks, plus filesDir/datastore_default.preferences_pb, the shared+  DataStoreUtils file holding the DailyChallengeStore("pipes_daily") streak and+  the AchievementsManager unlocks. No Room database, nothing written to 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+  SCOPE: pipes declares android:backupAgent=".platform.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.+  AppBackupAgent's prefNames = ["level_stats", "daily_stats"] plus+  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>
games/solitaire/src/main/java/com/vayunmathur/games/solitaire/platform/AppBackupAgent.kt
diff --git a/games/solitaire/src/main/java/com/vayunmathur/games/solitaire/platform/AppBackupAgent.kt b/games/solitaire/src/main/java/com/vayunmathur/games/solitaire/platform/AppBackupAgent.ktindex a5c0f5b97a..c11daaa885 100644--- a/games/solitaire/src/main/java/com/vayunmathur/games/solitaire/platform/AppBackupAgent.kt+++ b/games/solitaire/src/main/java/com/vayunmathur/games/solitaire/platform/AppBackupAgent.kt@@ -5,5 +5,9 @@ import com.vayunmathur.library.util.BaseBackupAgent class AppBackupAgent : BaseBackupAgent() {     override val prefNames: List<String>         get() = listOf("solitaire_stats")++    // The shared DataStoreUtils file, holding AchievementsManager unlocks.+    override val datastoreNames: List<String>+        get() = listOf("datastore_default") } 
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.xmlindex 6765ced796..771f82a340 100644--- a/games/solitaire/src/main/res/xml/data_extraction_rules.xml+++ b/games/solitaire/src/main/res/xml/data_extraction_rules.xml@@ -2,18 +2,21 @@ <!--   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.+  times and streaks, plus filesDir/datastore_default.preferences_pb, the shared+  DataStoreUtils file holding the AchievementsManager unlocks. No Room database+  and nothing written to external storage; achievements.json is a read-only APK+  asset. -  Back everything up — lifetime stats are the thing a solitaire player would be+  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+  SCOPE: solitaire declares android:backupAgent=".platform.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.+  AppBackupAgent's prefNames = ["solitaire_stats"] plus 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>
games/unblockjam/src/main/java/com/vayunmathur/games/unblockjam/platform/AppBackupAgent.kt
diff --git a/games/unblockjam/src/main/java/com/vayunmathur/games/unblockjam/platform/AppBackupAgent.kt b/games/unblockjam/src/main/java/com/vayunmathur/games/unblockjam/platform/AppBackupAgent.ktindex 775e85a9d9..c8d46c1dba 100644--- a/games/unblockjam/src/main/java/com/vayunmathur/games/unblockjam/platform/AppBackupAgent.kt+++ b/games/unblockjam/src/main/java/com/vayunmathur/games/unblockjam/platform/AppBackupAgent.kt@@ -5,4 +5,9 @@ import com.vayunmathur.library.util.BaseBackupAgent class AppBackupAgent : BaseBackupAgent() {     override val prefNames: List<String>         get() = listOf("level_stats", "daily_stats")++    // The shared DataStoreUtils file, holding AchievementsManager unlocks and the+    // DailyChallengeStore("unblockjam_daily") streak.+    override val datastoreNames: List<String>+        get() = listOf("datastore_default") }
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.xmlindex de86a1c428..68d21b56ce 100644--- a/games/unblockjam/src/main/res/xml/data_extraction_rules.xml+++ b/games/unblockjam/src/main/res/xml/data_extraction_rules.xml@@ -2,19 +2,22 @@ <!--   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.+  level completion, stars and daily-challenge streaks, plus+  filesDir/datastore_default.preferences_pb, the shared DataStoreUtils file+  holding the DailyChallengeStore("unblockjam_daily") streak and the+  AchievementsManager unlocks. No Room database and nothing written to 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+  SCOPE: unblockjam declares android:backupAgent=".platform.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.+  AppBackupAgent's prefNames = ["level_stats", "daily_stats"] plus+  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>
games/voxels/src/main/java/com/vayunmathur/games/voxels/platform/AppBackupAgent.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/platform/AppBackupAgent.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/platform/AppBackupAgent.ktindex 1b2b270907..3df1054065 100644--- a/games/voxels/src/main/java/com/vayunmathur/games/voxels/platform/AppBackupAgent.kt+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/platform/AppBackupAgent.kt@@ -4,4 +4,9 @@ import com.vayunmathur.library.util.BaseBackupAgent  class AppBackupAgent : BaseBackupAgent() {     override val prefNames: List<String> get() = listOf("voxels_prefs")++    // The shared DataStoreUtils file, holding AchievementsManager unlocks and VoxelsSync state.+    // Saved worlds live in filesDir/worlds and stay out of the cloud payload deliberately; see+    // res/xml/data_extraction_rules.xml.+    override val datastoreNames: List<String> get() = listOf("datastore_default") }
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 39f32244c7..0e9e747559 100644--- a/games/voxels/src/main/res/xml/data_extraction_rules.xml+++ b/games/voxels/src/main/res/xml/data_extraction_rules.xml@@ -1,8 +1,11 @@ <?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+    * "voxels_prefs" SharedPreferences (AppBackupAgent.prefNames) - settings.+    * filesDir/datastore_default.preferences_pb (AppBackupAgent.datastoreNames) -+      the shared DataStoreUtils file, holding AchievementsManager unlocks and+      VoxelsSync state.+    * 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).@@ -26,13 +29,14 @@   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+  SCOPE: voxels declares android:backupAgent=".platform.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.+  matches the intent anyway: AppBackupAgent lists prefNames = ["voxels_prefs"]+  and datastoreNames = ["datastore_default"], so settings and achievements 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. -->
games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/platform/AppBackupAgent.kt
diff --git a/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/platform/AppBackupAgent.kt b/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/platform/AppBackupAgent.ktindex 4f54d43c15..6cf4946cb5 100644--- a/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/platform/AppBackupAgent.kt+++ b/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/platform/AppBackupAgent.kt@@ -3,6 +3,9 @@ package com.vayunmathur.games.wordmaker.platform import com.vayunmathur.library.util.BaseBackupAgent  class AppBackupAgent : BaseBackupAgent() {+    // "settings" is LevelDataStore's preferencesDataStore(name = "settings"); datastore_default is+    // the shared DataStoreUtils file, which is where DailyChallengeStore keeps the daily streak and+    // AchievementsManager keeps unlocks. Omitting it silently reset both on every restore.     override val datastoreNames: List<String>-        get() = listOf("settings")+        get() = listOf("settings", "datastore_default") }
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.xmlindex c301e8c936..08dbfd125d 100644--- a/games/wordmaker/src/main/res/xml/data_extraction_rules.xml+++ b/games/wordmaker/src/main/res/xml/data_extraction_rules.xml@@ -1,20 +1,22 @@ <?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+  Word Maker. Audited state:+    * filesDir/datastore/settings.preferences_pb - the Preferences DataStore+      declared as preferencesDataStore(name = "settings") in LevelDataStore.kt,+      holding level progress and settings.+    * filesDir/datastore_default.preferences_pb - the shared DataStoreUtils file,+      holding the DailyChallengeStore("wordmaker_daily") streak and the+      AchievementsManager unlocks.+  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+  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+  SCOPE: wordmaker declares android:backupAgent=".platform.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.+  AppBackupAgent's datastoreNames = ["settings", "datastore_default"], matching+  the two files listed above - 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. -->
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.xmlindex 410563bd12..27cada0283 100644--- a/openassistant/src/main/res/xml/data_extraction_rules.xml+++ b/openassistant/src/main/res/xml/data_extraction_rules.xml@@ -16,9 +16,18 @@        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. -->+     secret-grade material is the keystore passphrase.++     SCOPE: openassistant declares android:backupAgent=".util.AppBackupAgent" and does NOT set+     android:fullBackupOnly, so cloud backup runs through the agent and the <cloud-backup>+     section below is NOT consulted. What actually reaches the cloud is the agent's+     dbConfigs = ["passwords-db"], i.e. the conversation history, exported decrypted by+     SqlCipherDbCodec. That is deliberate: losing a new phone's whole assistant history is+     worse than the exposure, and the history is the only thing here that is not+     regenerable. The <cloud-backup> denials below are kept as the policy that applies if+     the agent is ever removed and Auto Backup takes over: the models are gigabytes and+     re-downloadable, and the download markers are meaningless without them.+     <device-transfer> IS governed here and carries the history and nothing else. --> <data-extraction-rules>     <cloud-backup>         <exclude domain="root" path="." />
photos/src/main/java/com/vayunmathur/photos/util/AppBackupAgent.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/AppBackupAgent.kt b/photos/src/main/java/com/vayunmathur/photos/util/AppBackupAgent.ktindex e5201ed821..31007ac125 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/AppBackupAgent.kt+++ b/photos/src/main/java/com/vayunmathur/photos/util/AppBackupAgent.kt@@ -14,6 +14,12 @@ class AppBackupAgent : BaseBackupAgent() {             return listOf("vault-db" to pass)         } +    // The shared DataStoreUtils file, holding the grid column count and model-version markers.+    // res/xml/data_extraction_rules.xml already lists it; the agent has to repeat it because it,+    // not the XML, drives cloud backup.+    override val datastoreNames: List<String>+        get() = listOf("datastore_default")+     override val extraFiles: List<File>         get() = listOf(File(filesDir, "secure_vault")) }