Expect BackupObserver to be called with null packages

This commit is contained in:
Torsten Grote 2022-09-08 17:45:17 -03:00
parent 848ed51de4
commit dfc9aeee28
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF

View file

@ -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 {