Expect ApplicationInfo#splitSourceDirs to be null

Also handle errors like these a bit better
This commit is contained in:
Torsten Grote 2022-09-08 17:40:41 -03:00
parent f5c58363ef
commit 848ed51de4
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF
3 changed files with 10 additions and 2 deletions

View file

@ -154,7 +154,8 @@ internal class ApkBackup(
streamGetter: suspend (name: String) -> OutputStream, streamGetter: suspend (name: String) -> OutputStream,
): List<ApkSplit> { ): List<ApkSplit> {
check(packageInfo.splitNames != null) 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) { check(packageInfo.splitNames.size == splitSourceDirs.size) {
"Size Mismatch! ${packageInfo.splitNames.size} != ${splitSourceDirs.size} " + "Size Mismatch! ${packageInfo.splitNames.size} != ${splitSourceDirs.size} " +
"splitNames is ${packageInfo.splitNames.toList()}, " + "splitNames is ${packageInfo.splitNames.toList()}, " +

View file

@ -381,7 +381,13 @@ internal class BackupCoordinator(
} }
// hook in here to back up APKs of apps that are otherwise not allowed for backup // hook in here to back up APKs of apps that are otherwise not allowed for backup
if (isPmBackup && settingsManager.canDoBackupNow()) { if (isPmBackup && settingsManager.canDoBackupNow()) {
try {
backUpApksOfNotBackedUpPackages() 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 result

View file

@ -209,6 +209,7 @@ internal class KVBackup(
else state.db.close() else state.db.close()
TRANSPORT_OK TRANSPORT_OK
} catch (e: IOException) { } catch (e: IOException) {
Log.e(TAG, "Error uploading DB", e)
TRANSPORT_ERROR TRANSPORT_ERROR
} finally { } finally {
this.state = null this.state = null