From f7730d3034560d52de8c79479d44ae9ca0913d90 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Wed, 13 Mar 2024 09:55:46 -0300 Subject: [PATCH] Report total number of user apps when showing final notification Before, we showed the number of apps we requested the backup for which in case of non-d2d may be much lower than the number of installed apps. In the future we may decide to also include certain system apps in that count. --- .../ui/notification/NotificationBackupObserver.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/notification/NotificationBackupObserver.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/notification/NotificationBackupObserver.kt index 5f5eaea4..41498d89 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/ui/notification/NotificationBackupObserver.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/notification/NotificationBackupObserver.kt @@ -10,6 +10,7 @@ import android.util.Log.isLoggable import com.stevesoltys.seedvault.MAGIC_PACKAGE_MANAGER import com.stevesoltys.seedvault.R import com.stevesoltys.seedvault.metadata.MetadataManager +import com.stevesoltys.seedvault.transport.backup.PackageService import com.stevesoltys.seedvault.worker.BackupRequester import org.koin.core.component.KoinComponent import org.koin.core.component.inject @@ -24,6 +25,7 @@ internal class NotificationBackupObserver( private val nm: BackupNotificationManager by inject() private val metadataManager: MetadataManager by inject() + private val packageService: PackageService by inject() private var currentPackage: String? = null private var numPackages: Int = 0 private var pmCounted: Boolean = false @@ -81,7 +83,13 @@ internal class NotificationBackupObserver( val success = status == 0 val numBackedUp = if (success) metadataManager.getPackagesNumBackedUp() else null val size = if (success) metadataManager.getPackagesBackupSize() else 0L - nm.onBackupFinished(success, numBackedUp, requestedPackages, size) + val total = try { + packageService.allUserPackages.size + } catch (e: Exception) { + Log.e(TAG, "Error getting number of all user packages: ", e) + requestedPackages + } + nm.onBackupFinished(success, numBackedUp, total, size) } }