Disable framework scheduling when scheduling backup, because another transport may have re-enabled it

This commit is contained in:
Torsten Grote 2024-06-18 11:15:50 -03:00
parent 878492088d
commit 484767bf16
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF
2 changed files with 6 additions and 0 deletions

View file

@ -18,6 +18,7 @@ import android.net.NetworkRequest
import android.net.Uri
import android.os.BadParcelableException
import android.os.Process.myUid
import android.os.UserHandle
import android.provider.Settings
import android.util.Log
import android.widget.Toast
@ -308,6 +309,8 @@ internal class SettingsViewModel(
}
fun scheduleAppBackup(existingWorkPolicy: ExistingPeriodicWorkPolicy) {
// disable framework scheduling, because another transport may have enabled it
backupManager.setFrameworkSchedulingEnabledForUser(UserHandle.myUserId(), false)
if (!pluginManager.isOnRemovableDrive && backupManager.isBackupEnabled) {
AppBackupWorker.schedule(app, settingsManager, existingWorkPolicy)
}

View file

@ -8,6 +8,7 @@ package com.stevesoltys.seedvault.ui.storage
import android.app.Application
import android.app.backup.IBackupManager
import android.app.job.JobInfo
import android.os.UserHandle
import android.util.Log
import androidx.lifecycle.viewModelScope
import androidx.work.ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE
@ -100,6 +101,8 @@ internal class BackupStorageViewModel(
private fun scheduleBackupWorkers() {
val storage = storagePluginManager.storageProperties ?: error("no storage available")
// disable framework scheduling, because another transport may have enabled it
backupManager.setFrameworkSchedulingEnabledForUser(UserHandle.myUserId(), false)
if (!storage.isUsb) {
if (backupManager.isBackupEnabled) {
AppBackupWorker.schedule(app, settingsManager, CANCEL_AND_REENQUEUE)