Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 12: add device-to-device backup rules, include database. #935

Merged
merged 1 commit into from
Aug 3, 2023
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
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
android:name="com.battlelancer.seriesguide.SgApp"
android:allowBackup="true"
android:backupAgent="com.battlelancer.seriesguide.SgBackupAgent"
android:fullBackupContent="@xml/sg_full_backup_rules"
android:dataExtractionRules="@xml/sg_backup_rules_android_12"
android:fullBackupContent="@xml/sg_backup_rules"
android:fullBackupOnly="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import java.util.Calendar

object AutoBackupTools {

private const val BACKUP_FOLDER_NAME = "Backups"

@Throws(AutoBackupException::class)
fun getBackupDirectory(context: Context): File {
val storage = context.getExternalFilesDir(null)
Expand All @@ -20,7 +22,7 @@ object AutoBackupTools {
throw AutoBackupException("Storage not mounted.")
}

return File(storage, "Backups")
return File(storage, BACKUP_FOLDER_NAME)
}

fun deleteOldBackups(context: Context) {
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/res/xml/sg_backup_rules.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- Configures auto-backup for Android 6 up to 11. -->
<!-- https://developer.android.com/guide/topics/data/autobackup -->
<full-backup-content>
<!-- Including the database, it likely won't exceed the 25 MB limit for Cloud. -->
<!-- E.g. 2000 episodes (~15 shows) consume around 2 MB. -->
<include domain="database" />

<!-- Include all settings files (app, extensions, widget, Trakt),
might include some unnecessary ones (Crashlytics) but all are < 1 KB. -->
<include domain="sharedpref" />

<!-- Do not include automatic backups to keep below 25 MB limit for CLoud. -->

</full-backup-content>
30 changes: 30 additions & 0 deletions app/src/main/res/xml/sg_backup_rules_android_12.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- Configures auto-backup for Android 12+. -->
<!-- https://developer.android.com/guide/topics/data/autobackup -->
<data-extraction-rules>
<cloud-backup disableIfNoEncryptionCapabilities="false">
<!-- Including the database, it likely won't exceed the 25 MB limit for Cloud. -->
<!-- E.g. 2000 episodes (~15 shows) consume around 2 MB. -->
<include domain="database" />

<!-- Include all settings files (app, extensions, widget, Trakt),
might include some unnecessary ones (Crashlytics) but all are < 1 KB. -->
<include domain="sharedpref" />

<!-- Do not include automatic backups to keep below 25 MB limit for CLoud. -->
</cloud-backup>
<device-transfer>
<!-- Include as much as possible as device-to-device transfer has a 2 GB limit. -->
<include domain="database" />

<!-- Include all settings files (app, extensions, widget, Trakt),
might include some unnecessary ones (Crashlytics) but all are < 1 KB. -->
<include domain="sharedpref" />

<!-- Include automatic backup files. -->
<include
domain="external"
path="Backups/" />
</device-transfer>
</data-extraction-rules>
9 changes: 0 additions & 9 deletions app/src/main/res/xml/sg_full_backup_rules.xml

This file was deleted.