Skip to content

Commit

Permalink
don't crash in BackupMonitor when there is no packageName
Browse files Browse the repository at this point in the history
this can happens when it tells us that restore has finished overall
  • Loading branch information
grote committed Oct 10, 2024
1 parent d1e57a6 commit bbbf545
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions app/src/main/java/com/stevesoltys/seedvault/BackupMonitor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down

0 comments on commit bbbf545

Please sign in to comment.