diff --git a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinator.kt b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinator.kt index b4cd67ac..56155918 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinator.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinator.kt @@ -363,7 +363,7 @@ internal class BackupCoordinator( val packageMetadata = metadataManager.getPackageMetadata(packageName) val oldPackageState = packageMetadata?.state - if (oldPackageState != null && oldPackageState != packageState) { + if (oldPackageState != packageState) { Log.i( TAG, "Package $packageName was in $oldPackageState" + ", update to $packageState" diff --git a/app/src/test/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinatorTest.kt b/app/src/test/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinatorTest.kt index fcf8a4af..03967e66 100644 --- a/app/src/test/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinatorTest.kt +++ b/app/src/test/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinatorTest.kt @@ -417,6 +417,34 @@ internal class BackupCoordinatorTest : BackupTest() { } } + @Test + fun `APK backup of not allowed apps updates state even without old state`() = runBlocking { + every { packageService.notAllowedPackages } returns listOf(packageInfo) + every { + notificationManager.onOptOutAppBackup(packageInfo.packageName, 1, 1) + } just Runs + coEvery { apkBackup.backupApkIfNecessary(packageInfo, NOT_ALLOWED, any()) } returns null + every { + metadataManager.getPackageMetadata(packageInfo.packageName) + } returns null + coEvery { plugin.getMetadataOutputStream() } returns metadataOutputStream + every { + metadataManager.onPackageBackupError( + packageInfo, + NOT_ALLOWED, + metadataOutputStream + ) + } just Runs + every { metadataOutputStream.close() } just Runs + + backup.backUpNotAllowedPackages() + + verify { + metadataManager.onPackageBackupError(packageInfo, NOT_ALLOWED, metadataOutputStream) + metadataOutputStream.close() + } + } + private fun expectApkBackupAndMetadataWrite() { coEvery { apkBackup.backupApkIfNecessary(