From e615402458a0c77b11d465d3f72dcbc76d2424bf Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Thu, 22 Feb 2024 09:41:53 -0300 Subject: [PATCH] During restore, show apps without APK as failed Previously, we backed up APKs of apps we could not back up (even if APK backup was disabled) so the user had a chance to get at least the apps back when restoring. Now, it is enough to record metadata about the app and the user will be able to manually install the app. The install apps step won't be skipped anymore. --- .../seedvault/restore/install/ApkRestore.kt | 14 ++++++++------ .../seedvault/worker/BackupRequester.kt | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/stevesoltys/seedvault/restore/install/ApkRestore.kt b/app/src/main/java/com/stevesoltys/seedvault/restore/install/ApkRestore.kt index 4b6ea82d..36326e0a 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/restore/install/ApkRestore.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/restore/install/ApkRestore.kt @@ -38,14 +38,12 @@ internal class ApkRestore( private val pm = context.packageManager - @Suppress("BlockingMethodInNonBlockingContext") fun restore(backup: RestorableBackup) = flow { - // filter out packages without APK and get total + // we don't filter out apps without APK, so the user can manually install them val packages = backup.packageMetadataMap.filter { - // We also need to exclude the DocumentsProvider used to retrieve backup data. + // We need to exclude the DocumentsProvider used to retrieve backup data. // Otherwise, it gets killed when we install it, terminating our restoration. - val isStorageProvider = it.key == storagePlugin.providerPackageName - it.value.hasApk() && !isStorageProvider + it.key != storagePlugin.providerPackageName } val total = packages.size var progress = 0 @@ -66,7 +64,11 @@ internal class ApkRestore( // re-install individual packages and emit updates for ((packageName, metadata) in packages) { try { - restore(this, backup, packageName, metadata, installResult) + if (metadata.hasApk()) { + restore(this, backup, packageName, metadata, installResult) + } else { + emit(installResult.fail(packageName)) + } } catch (e: IOException) { Log.e(TAG, "Error re-installing APK for $packageName.", e) emit(installResult.fail(packageName)) diff --git a/app/src/main/java/com/stevesoltys/seedvault/worker/BackupRequester.kt b/app/src/main/java/com/stevesoltys/seedvault/worker/BackupRequester.kt index 9eac7406..02d4cc3b 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/worker/BackupRequester.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/worker/BackupRequester.kt @@ -102,7 +102,7 @@ internal class BackupRequester( (packageIndex + NUM_PACKAGES_PER_TRANSACTION).coerceAtMost(packages.size) val packageChunk = packages.subList(packageIndex, nextChunkIndex).toTypedArray() val numBackingUp = packageIndex + packageChunk.size - Log.i(TAG, "Requesting backup for $numBackingUp/${packages.size} packages...") + Log.i(TAG, "Requesting backup for $numBackingUp of ${packages.size} packages...") packageIndex += packageChunk.size return packageChunk }