Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
dependencies ▾

Modern-Apps.git / translate / src / main / res / xml / data_extraction_rules.xml

data_extraction_rules.xml85 lines · 4.6 KiBRaw
1<?xml version="1.0" encoding="utf-8"?>
2<!--
3 Translate. Audited state:
4 * databases/translate-db — Room DB holding translation history and
5 favourites (TranslationRecord). Genuinely user data, worth restoring.
6 * files/datastore/translate_settings.preferences_pb — last used source and
7 target language plus per-direction recents (TranslateSettings).
8 * files/datastore_default.preferences_pb — per-file model download progress
9 (DataStoreUtils). Tiny, portable, and re-derived by the download gate,
10 so carrying it needs no codec and costs nothing.
11 * secure_prefs.xml — SQLCipher passphrase for translate-db, wrapped by a
12 non-exportable AndroidKeyStore key.
13 * externalFilesDir/nllb600/ and madlad400/ — downloaded language models
14 (617 MB + 1,015 MB). NllbModel.deleteRetired additionally removes the
15 retired SMaLL-100 files under small100/ on first run.
16
17 translate-db is excluded from both sections: it is SQLCipher-encrypted
18 under a passphrase wrapped by a non-exportable AndroidKeyStore key, which
19 never leaves the device, so a restored copy of the raw file cannot be
20 opened — the database builder mints a fresh key and passphrase, the
21 encrypt-existing check skips the already-encrypted file, and Room throws
22 SQLiteNotADatabaseException. Shipping it would trade a clean first launch
23 for a crash.
24
25 History/favourites still migrate: translate declares its own BackupAgent
26 (platform/AppBackupAgent), which uses SqlCipherDbCodec to export the DB to
27 plaintext inside the backup payload and re-encrypt it under the new
28 device's key on restore. The agent also carries the translate_settings
29 datastore. That path is the one that works; the raw file copy would only
30 get in its way.
31
32 The model packs are excluded from both channels. They are re-derivable:
33 NllbModel/MadladModel fetch them mirror-only from data.maproj.org with
34 SHA-256 pinning, and InitialModelDownloadChecker in MainActivity
35 re-fetches the active pack automatically on first launch. Carrying them
36 over device transfer saved one re-download but moved over a gigabyte
37 across for data that is not the user's.
38
39 SCOPE: translate declares android:backupAgent=".platform.AppBackupAgent"
40 and does NOT set android:fullBackupOnly, so Android uses key/value backup
41 here and the <cloud-backup> section below is NOT consulted. Cloud content
42 is exactly AppBackupAgent's translateDbConfigs(this) plus the
43 translate_settings datastore — translate-db, exported to plaintext by
44 SqlCipherDbCodec and re-encrypted on restore. That is the path that
45 carries history/favourites across, and it works. The rules below govern
46 <device-transfer>, and are the correct control if the backupAgent is ever
47 removed.
48-->
49<data-extraction-rules>
50 <!-- Not consulted while android:backupAgent is declared; see SCOPE above. -->
51 <cloud-backup disableIfNoEncryptionCapabilities="true">
52 <include domain="root" path="." />
53 <include domain="file" path="." />
54 <include domain="database" path="." />
55 <exclude domain="database" path="translate-db" />
56 <exclude domain="database" path="translate-db-wal" />
57 <exclude domain="database" path="translate-db-shm" />
58 <exclude domain="database" path="translate-db-journal" />
59 <include domain="sharedpref" path="." />
60 <exclude domain="sharedpref" path="secure_prefs.xml" />
61 <include domain="external" path="." />
62 <!-- Downloaded model packs: past the cloud quota and re-fetchable
63 with hash pinning. -->
64 <exclude domain="external" path="nllb600" />
65 <exclude domain="external" path="madlad400" />
66 <exclude domain="external" path="small100" />
67 </cloud-backup>
68 <device-transfer>
69 <include domain="root" path="." />
70 <include domain="file" path="." />
71 <include domain="database" path="." />
72 <exclude domain="database" path="translate-db" />
73 <exclude domain="database" path="translate-db-wal" />
74 <exclude domain="database" path="translate-db-shm" />
75 <exclude domain="database" path="translate-db-journal" />
76 <include domain="sharedpref" path="." />
77 <exclude domain="sharedpref" path="secure_prefs.xml" />
78 <include domain="external" path="." />
79 <!-- Model packs re-download on first launch; do not move ~1.6 GB
80 across the transfer for re-derivable weights. -->
81 <exclude domain="external" path="nllb600" />
82 <exclude domain="external" path="madlad400" />
83 <exclude domain="external" path="small100" />
84 </device-transfer>
85</data-extraction-rules>