Update state of opt-out apps, even if they never had any state
This commit is contained in:
parent
a9402f4644
commit
0a8a286826
2 changed files with 29 additions and 1 deletions
|
@ -363,7 +363,7 @@ internal class BackupCoordinator(
|
||||||
val packageMetadata =
|
val packageMetadata =
|
||||||
metadataManager.getPackageMetadata(packageName)
|
metadataManager.getPackageMetadata(packageName)
|
||||||
val oldPackageState = packageMetadata?.state
|
val oldPackageState = packageMetadata?.state
|
||||||
if (oldPackageState != null && oldPackageState != packageState) {
|
if (oldPackageState != packageState) {
|
||||||
Log.i(
|
Log.i(
|
||||||
TAG, "Package $packageName was in $oldPackageState" +
|
TAG, "Package $packageName was in $oldPackageState" +
|
||||||
", update to $packageState"
|
", update to $packageState"
|
||||||
|
|
|
@ -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() {
|
private fun expectApkBackupAndMetadataWrite() {
|
||||||
coEvery {
|
coEvery {
|
||||||
apkBackup.backupApkIfNecessary(
|
apkBackup.backupApkIfNecessary(
|
||||||
|
|
Loading…
Reference in a new issue