Skip to content

Commit

Permalink
Merge pull request #935 from UweTrottmann/android-12-device-2-device-…
Browse files Browse the repository at this point in the history
…backup

Android 12: add device-to-device backup rules, include database.
  • Loading branch information
UweTrottmann authored Aug 3, 2023
2 parents 091d964 + 786d591 commit 9725763
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 11 deletions.
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.

0 comments on commit 9725763

Please sign in to comment.