Merge pull request #441 from grote/splitSourceDirs-npe
Handle null better for Android 13
This commit is contained in:
commit
a0d14910f6
4 changed files with 14 additions and 6 deletions
|
@ -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()}, " +
|
||||||
|
|
|
@ -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()) {
|
||||||
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
|
result
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -43,7 +43,7 @@ internal class NotificationBackupObserver(
|
||||||
* @param currentBackupPackage The name of the package that now being backed up.
|
* @param currentBackupPackage The name of the package that now being backed up.
|
||||||
* @param backupProgress Current progress of backup for the package.
|
* @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)
|
showProgressNotification(currentBackupPackage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ internal class NotificationBackupObserver(
|
||||||
* that was initialized
|
* that was initialized
|
||||||
* @param status Zero on success; a nonzero error code if the backup operation failed.
|
* @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)) {
|
if (isLoggable(TAG, INFO)) {
|
||||||
Log.i(TAG, "Completed. Target: $target, status: $status")
|
Log.i(TAG, "Completed. Target: $target, status: $status")
|
||||||
}
|
}
|
||||||
|
@ -81,8 +81,8 @@ internal class NotificationBackupObserver(
|
||||||
nm.onBackupFinished(success, numBackedUp)
|
nm.onBackupFinished(success, numBackedUp)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showProgressNotification(packageName: String) {
|
private fun showProgressNotification(packageName: String?) {
|
||||||
if (currentPackage == packageName) return
|
if (packageName == null || currentPackage == packageName) return
|
||||||
|
|
||||||
if (isLoggable(TAG, INFO)) {
|
if (isLoggable(TAG, INFO)) {
|
||||||
"Showing progress notification for $currentPackage $numPackages/$expectedPackages".let {
|
"Showing progress notification for $currentPackage $numPackages/$expectedPackages".let {
|
||||||
|
|
Loading…
Reference in a new issue