Merge pull request #441 from grote/splitSourceDirs-npe
Handle null better for Android 13
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 60c9c9a..02208eb 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 @@
streamGetter: suspend (name: String) -> OutputStream,
): List<ApkSplit> {
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 ac77983..5d791fc 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 @@
}
// 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 dd89cad..060f543 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 @@
else state.db.close()
TRANSPORT_OK
} catch (e: IOException) {
+ Log.e(TAG, "Error uploading DB", e)
TRANSPORT_ERROR
} finally {
this.state = null
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 6eb6007..d35971f 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
@@ -43,7 +43,7 @@
* @param currentBackupPackage The name of the package that now being backed up.
* @param backupProgress Current progress of backup for the package.
*/
- override fun onUpdate(currentBackupPackage: String, backupProgress: BackupProgress) {
+ override fun onUpdate(currentBackupPackage: String?, backupProgress: BackupProgress) {
showProgressNotification(currentBackupPackage)
}
@@ -57,7 +57,7 @@
* that was initialized
* @param status Zero on success; a nonzero error code if the backup operation failed.
*/
- override fun onResult(target: String, status: Int) {
+ override fun onResult(target: String?, status: Int) {
if (isLoggable(TAG, INFO)) {
Log.i(TAG, "Completed. Target: $target, status: $status")
}
@@ -81,8 +81,8 @@
nm.onBackupFinished(success, numBackedUp)
}
- private fun showProgressNotification(packageName: String) {
- if (currentPackage == packageName) return
+ private fun showProgressNotification(packageName: String?) {
+ if (packageName == null || currentPackage == packageName) return
if (isLoggable(TAG, INFO)) {
"Showing progress notification for $currentPackage $numPackages/$expectedPackages".let {