Update UI state for some system apps if they have NO_DATA

Instead of showing 'Waiting to be backed up...'
This commit is contained in:
Torsten Grote 2024-09-25 17:47:21 -03:00
parent 8d949e2d64
commit b4c84272ff
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF

View file

@ -30,6 +30,7 @@ import com.stevesoltys.seedvault.metadata.PackageState.UNKNOWN_ERROR
import com.stevesoltys.seedvault.repo.AppBackupManager import com.stevesoltys.seedvault.repo.AppBackupManager
import com.stevesoltys.seedvault.settings.SettingsManager import com.stevesoltys.seedvault.settings.SettingsManager
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
import com.stevesoltys.seedvault.ui.systemData
import org.calyxos.seedvault.core.backends.isOutOfSpace import org.calyxos.seedvault.core.backends.isOutOfSpace
import java.io.IOException import java.io.IOException
import java.util.concurrent.TimeUnit.DAYS import java.util.concurrent.TimeUnit.DAYS
@ -76,6 +77,9 @@ internal class BackupCoordinator(
calledClearBackupData = false, calledClearBackupData = false,
cancelReason = UNKNOWN_ERROR cancelReason = UNKNOWN_ERROR
) )
private val launchableSystemApps by lazy {
packageService.launchableSystemApps.map { it.activityInfo.packageName }.toSet()
}
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
// Transport initialization and quota // Transport initialization and quota
@ -268,12 +272,13 @@ internal class BackupCoordinator(
suspend fun cancelFullBackup() { suspend fun cancelFullBackup() {
val packageInfo = full.currentPackageInfo val packageInfo = full.currentPackageInfo
?: error("Cancelling full backup, but no current package") ?: error("Cancelling full backup, but no current package")
Log.i( val packageName = packageInfo.packageName
TAG, "Cancel full backup of ${packageInfo.packageName}" + Log.i(TAG, "Cancel full backup of $packageName because of ${state.cancelReason}")
" because of ${state.cancelReason}" // don't bother with remembering state for boring system apps that have no data
) val ignoreApp = state.cancelReason == NO_DATA &&
// don't bother with system apps that have no data packageInfo.isSystemApp() &&
val ignoreApp = state.cancelReason == NO_DATA && packageInfo.isSystemApp() packageName !in systemData.keys && // don't ignore our special system apps
packageName !in launchableSystemApps // don't ignore launchable system apps
if (!ignoreApp) onPackageBackupError(packageInfo, BackupType.FULL) if (!ignoreApp) onPackageBackupError(packageInfo, BackupType.FULL)
full.cancelFullBackup() full.cancelFullBackup()
} }