From 848ed51de4441863ac4f7dcce74a774fa4db47ba Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Thu, 8 Sep 2022 17:40:41 -0300 Subject: [PATCH] Expect ApplicationInfo#splitSourceDirs to be null Also handle errors like these a bit better --- .../stevesoltys/seedvault/transport/backup/ApkBackup.kt | 3 ++- .../seedvault/transport/backup/BackupCoordinator.kt | 8 +++++++- .../stevesoltys/seedvault/transport/backup/KVBackup.kt | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/ApkBackup.kt b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/ApkBackup.kt index 60c9c9aa..02208eb0 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/ApkBackup.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/ApkBackup.kt @@ -154,7 +154,8 @@ internal class ApkBackup( streamGetter: suspend (name: String) -> OutputStream, ): List { check(packageInfo.splitNames != null) - val splitSourceDirs = packageInfo.applicationInfo.splitSourceDirs + // attention: though not documented, splitSourceDirs can be null + val splitSourceDirs = packageInfo.applicationInfo.splitSourceDirs ?: emptyArray() check(packageInfo.splitNames.size == splitSourceDirs.size) { "Size Mismatch! ${packageInfo.splitNames.size} != ${splitSourceDirs.size} " + "splitNames is ${packageInfo.splitNames.toList()}, " + diff --git a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinator.kt b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinator.kt index ac779830..5d791fc4 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinator.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinator.kt @@ -381,7 +381,13 @@ internal class BackupCoordinator( } // hook in here to back up APKs of apps that are otherwise not allowed for backup if (isPmBackup && settingsManager.canDoBackupNow()) { - backUpApksOfNotBackedUpPackages() + try { + backUpApksOfNotBackedUpPackages() + } catch (e: Exception) { + Log.e(TAG, "Error backing up APKs of opt-out apps: ", e) + // We are re-throwing this, because we want to know about problems here + throw e + } } } result diff --git a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/KVBackup.kt b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/KVBackup.kt index dd89cad8..060f5431 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/KVBackup.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/KVBackup.kt @@ -209,6 +209,7 @@ internal class KVBackup( else state.db.close() TRANSPORT_OK } catch (e: IOException) { + Log.e(TAG, "Error uploading DB", e) TRANSPORT_ERROR } finally { this.state = null