From 2d47aa3d9f6c30e04b027c9f8b3514fd1a549185 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Thu, 10 Oct 2024 11:52:38 -0300 Subject: [PATCH] don't crash in BackupMonitor when there is no packageName this can happens when it tells us that restore has finished overall --- app/src/main/java/com/stevesoltys/seedvault/BackupMonitor.kt | 5 ++--- .../seedvault/transport/backup/BackupTransportMonitor.kt | 4 ++-- .../com/stevesoltys/seedvault/worker/ApkBackupManager.kt | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/stevesoltys/seedvault/BackupMonitor.kt b/app/src/main/java/com/stevesoltys/seedvault/BackupMonitor.kt index fe5c6adb..b9c6f70e 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/BackupMonitor.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/BackupMonitor.kt @@ -23,13 +23,12 @@ open class BackupMonitor : IBackupManagerMonitor.Stub() { onEvent( id = bundle.getInt(EXTRA_LOG_EVENT_ID), category = bundle.getInt(EXTRA_LOG_EVENT_CATEGORY), - packageName = bundle.getString(EXTRA_LOG_EVENT_PACKAGE_NAME) - ?: error("no package name for $bundle"), + packageName = bundle.getString(EXTRA_LOG_EVENT_PACKAGE_NAME), bundle = bundle, ) } - open fun onEvent(id: Int, category: Int, packageName: String, bundle: Bundle) { + open fun onEvent(id: Int, category: Int, packageName: String?, bundle: Bundle) { if (id == LOG_EVENT_ID_ERROR_PREFLIGHT) { val preflightResult = bundle.getLong(EXTRA_LOG_PREFLIGHT_ERROR, -1) Log.w(TAG, "Pre-flight error from $packageName: $preflightResult") diff --git a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupTransportMonitor.kt b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupTransportMonitor.kt index dcfcdb38..53fc0f9f 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupTransportMonitor.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupTransportMonitor.kt @@ -20,9 +20,9 @@ internal class BackupTransportMonitor( private val log = KotlinLogging.logger { } - override fun onEvent(id: Int, category: Int, packageName: String, bundle: Bundle) { + override fun onEvent(id: Int, category: Int, packageName: String?, bundle: Bundle) { super.onEvent(id, category, packageName, bundle) - if (id == LOG_EVENT_ID_NO_DATA_TO_SEND && + if (packageName != null && id == LOG_EVENT_ID_NO_DATA_TO_SEND && category == LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY ) { sendNoDataChanged(packageName) diff --git a/app/src/main/java/com/stevesoltys/seedvault/worker/ApkBackupManager.kt b/app/src/main/java/com/stevesoltys/seedvault/worker/ApkBackupManager.kt index 693a991e..68ee4485 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/worker/ApkBackupManager.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/worker/ApkBackupManager.kt @@ -67,6 +67,7 @@ internal class ApkBackupManager( } } + // TODO we could use BackupMonitor for this. It emits LOG_EVENT_ID_PACKAGE_STOPPED private fun recordNotBackedUpPackages() { nm.onAppsNotBackedUp() packageService.notBackedUpPackages.forEach { packageInfo ->