Don't assume SAF-based storage is available

it may be WebDAV now
This commit is contained in:
Torsten Grote 2024-04-25 14:13:32 -03:00
parent 0e51c00bca
commit 0b4bd09e7d
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF
2 changed files with 6 additions and 7 deletions

View file

@ -72,6 +72,7 @@ class StoragePluginManager(
get() {
return _storageProperties
}
val isOnRemovableDrive: Boolean get() = storageProperties?.isUsb == true
init {
when (settingsManager.storagePluginType) {

View file

@ -221,8 +221,7 @@ internal class SettingsViewModel(
i.putExtra(EXTRA_START_APP_BACKUP, true)
startForegroundService(app, i)
} else {
val isUsb = settingsManager.getSafStorage()?.isUsb ?: false
AppBackupWorker.scheduleNow(app, reschedule = !isUsb)
AppBackupWorker.scheduleNow(app, reschedule = !pluginManager.isOnRemovableDrive)
}
}
}
@ -301,20 +300,19 @@ internal class SettingsViewModel(
}
fun scheduleAppBackup(existingWorkPolicy: ExistingPeriodicWorkPolicy) {
val storage = settingsManager.getSafStorage() ?: error("no storage available")
if (!storage.isUsb && backupManager.isBackupEnabled) {
if (!pluginManager.isOnRemovableDrive && backupManager.isBackupEnabled) {
AppBackupWorker.schedule(app, settingsManager, existingWorkPolicy)
}
}
fun scheduleFilesBackup() {
val storage = settingsManager.getSafStorage() ?: error("no storage available")
if (!storage.isUsb && settingsManager.isStorageBackupEnabled()) {
if (!pluginManager.isOnRemovableDrive && settingsManager.isStorageBackupEnabled()) {
val requiresNetwork = pluginManager.storageProperties?.requiresNetwork == true
BackupJobService.scheduleJob(
context = app,
jobServiceClass = StorageBackupJobService::class.java,
periodMillis = HOURS.toMillis(24),
networkType = if (storage.requiresNetwork) NETWORK_TYPE_UNMETERED
networkType = if (requiresNetwork) NETWORK_TYPE_UNMETERED
else NETWORK_TYPE_NONE,
deviceIdle = false,
charging = true