Merge pull request #603 from seedvault-app/bugfix/excluded-apk-backups
Stop backing up excluded app APKs
This commit is contained in:
commit
695c33e466
4 changed files with 23 additions and 2 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -6,6 +6,9 @@ hs_err_pid*
|
|||
|
||||
## Intellij
|
||||
out/
|
||||
build/
|
||||
storage/build/
|
||||
contactsbackup/build/
|
||||
/lib/
|
||||
.idea/*
|
||||
!.idea/runConfigurations*
|
||||
|
|
|
@ -55,6 +55,12 @@ internal class ApkBackup(
|
|||
// do not back up when setting is not enabled
|
||||
if (!settingsManager.backupApks()) return null
|
||||
|
||||
// do not back up if package is blacklisted
|
||||
if (!settingsManager.isBackupEnabled(packageName)) {
|
||||
Log.d(TAG, "Package $packageName is blacklisted. Not backing it up.")
|
||||
return null
|
||||
}
|
||||
|
||||
// do not back up test-only apps as we can't re-install them anyway
|
||||
// see: https://commonsware.com/blog/2017/10/31/android-studio-3p0-flag-test-only.html
|
||||
if (packageInfo.isTestOnly()) {
|
||||
|
|
|
@ -107,6 +107,7 @@ internal class ApkBackupRestoreTest : TransportTest() {
|
|||
writeBytes(splitBytes)
|
||||
}.absolutePath)
|
||||
|
||||
every { settingsManager.isBackupEnabled(any()) } returns true
|
||||
every { settingsManager.backupApks() } returns true
|
||||
every { sigInfo.hasMultipleSigners() } returns false
|
||||
every { sigInfo.signingCertificateHistory } returns sigs
|
||||
|
|
|
@ -62,6 +62,15 @@ internal class ApkBackupTest : BackupTest() {
|
|||
@Test
|
||||
fun `does not back up when setting disabled`() = runBlocking {
|
||||
every { settingsManager.backupApks() } returns false
|
||||
every { settingsManager.isBackupEnabled(any()) } returns true
|
||||
|
||||
assertNull(apkBackup.backupApkIfNecessary(packageInfo, UNKNOWN_ERROR, streamGetter))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `does not back up when app blacklisted`() = runBlocking {
|
||||
every { settingsManager.backupApks() } returns true
|
||||
every { settingsManager.isBackupEnabled(any()) } returns false
|
||||
|
||||
assertNull(apkBackup.backupApkIfNecessary(packageInfo, UNKNOWN_ERROR, streamGetter))
|
||||
}
|
||||
|
@ -70,8 +79,8 @@ internal class ApkBackupTest : BackupTest() {
|
|||
fun `does not back up test-only apps`() = runBlocking {
|
||||
packageInfo.applicationInfo.flags = FLAG_TEST_ONLY
|
||||
|
||||
every { settingsManager.isBackupEnabled(any()) } returns true
|
||||
every { settingsManager.backupApks() } returns true
|
||||
|
||||
assertNull(apkBackup.backupApkIfNecessary(packageInfo, UNKNOWN_ERROR, streamGetter))
|
||||
}
|
||||
|
||||
|
@ -79,8 +88,8 @@ internal class ApkBackupTest : BackupTest() {
|
|||
fun `does not back up system apps`() = runBlocking {
|
||||
packageInfo.applicationInfo.flags = FLAG_SYSTEM
|
||||
|
||||
every { settingsManager.isBackupEnabled(any()) } returns true
|
||||
every { settingsManager.backupApks() } returns true
|
||||
|
||||
assertNull(apkBackup.backupApkIfNecessary(packageInfo, UNKNOWN_ERROR, streamGetter))
|
||||
}
|
||||
|
||||
|
@ -112,6 +121,7 @@ internal class ApkBackupTest : BackupTest() {
|
|||
@Test
|
||||
fun `do not accept empty signature`() = runBlocking {
|
||||
every { settingsManager.backupApks() } returns true
|
||||
every { settingsManager.isBackupEnabled(any()) } returns true
|
||||
every {
|
||||
metadataManager.getPackageMetadata(packageInfo.packageName)
|
||||
} returns packageMetadata
|
||||
|
@ -229,6 +239,7 @@ internal class ApkBackupTest : BackupTest() {
|
|||
}
|
||||
|
||||
private fun expectChecks(packageMetadata: PackageMetadata = this.packageMetadata) {
|
||||
every { settingsManager.isBackupEnabled(any()) } returns true
|
||||
every { settingsManager.backupApks() } returns true
|
||||
every {
|
||||
metadataManager.getPackageMetadata(packageInfo.packageName)
|
||||
|
|
Loading…
Reference in a new issue