Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/acs/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<application
android:label="SinalACS ACS"
android:allowBackup="false"
android:fullBackupContent="false"
android:dataExtractionRules="@xml/data_extraction_rules"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
Expand Down
27 changes: 27 additions & 0 deletions apps/acs/android/app/src/main/res/xml/data_extraction_rules.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- #152: nada do app do ACS vai para o backup na nuvem nem para a
transferência entre aparelhos (Android 12+). Com targetSdk 31+,
`android:allowBackup="false"` não desliga a transferência: sem estas
regras, o banco SQLCipher da fila de visitas e as SharedPreferences (o
WipeJournal da #81 e o EncryptedSharedPreferences do
flutter_secure_storage) iriam para o aparelho novo, onde a chave do
Keystore não existe. O resultado seria a recuperação de chave perdida ou
um estado inconsistente. Antes da API 31 valem
`android:fullBackupContent="false"` e `android:allowBackup="false"`.
Mesma regra do app do paciente (#136). -->
<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>
35 changes: 35 additions & 0 deletions apps/acs/test/android_manifest_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,41 @@ void main() {
);
});

// #152: com targetSdk 31+, `allowBackup="false"` não desliga a transferência
// entre aparelhos (Android 12+). Sem as regras abaixo, o banco SQLCipher da
// fila e as SharedPreferences (WipeJournal da #81, EncryptedSharedPreferences
// do flutter_secure_storage) iriam para o aparelho novo, sem a chave do
// Keystore. Mesma regra do paciente (#136, `android_backup_manifest_test`).
final application = RegExp(r'<application\b[^>]*>').firstMatch(manifest)?.group(0) ?? '';

test('fullBackupContent="false" no <application> (API < 31)', () {
expect(application.contains('android:fullBackupContent="false"'), isTrue);
});

test('dataExtractionRules aponta para @xml/data_extraction_rules (API 31+)', () {
expect(
application.contains('android:dataExtractionRules="@xml/data_extraction_rules"'),
isTrue,
);
});

test('regras excluem root, file, database, sharedpref e external em cloud-backup e device-transfer', () {
final rulesFile = File('android/app/src/main/res/xml/data_extraction_rules.xml');
expect(rulesFile.existsSync(), isTrue, reason: 'o recurso referenciado precisa existir');
final rules = rulesFile.readAsStringSync();
for (final section in ['cloud-backup', 'device-transfer']) {
final block = RegExp('<$section[^>]*>([\\s\\S]*?)</$section>').firstMatch(rules);
expect(block, isNotNull, reason: 'falta <$section>');
for (final domain in ['root', 'file', 'database', 'sharedpref', 'external']) {
final exclude = RegExp('<exclude\\s+domain="$domain"\\s+path="\\."\\s*/>');
expect(exclude.hasMatch(block!.group(1)!), isTrue,
reason: '$section deve excluir o domínio $domain');
}
expect(RegExp(r'<include\b').hasMatch(block!.group(1)!), isFalse,
reason: '$section não deve incluir nada');
}
});

test('o nome na gaveta do aparelho é legível, não o identificador do pacote', () {
expect(manifest, isNot(contains('android:label="sinalacs_acs"')));
expect(manifest, contains('android:label="SinalACS ACS"'));
Expand Down