Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync workers: use data type enum instead of specific authority #1177

Merged
merged 28 commits into from
Dec 26, 2024
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e777a4c
Introduce SyncDataType for Workers
rfc2822 Dec 17, 2024
71f0ca1
Fix tests, remove SyncWorkerManager.enqueueOneTime(authority)
rfc2822 Dec 17, 2024
a08db1a
Merge branch 'main-ose' into sync-domains-2
rfc2822 Dec 24, 2024
a0e45c0
TasksAppManager.currentProviderFlow(): return Flow instead of StateFlow
rfc2822 Dec 24, 2024
f9b8e0b
Simplify TasksAppManager and TasksAppWatcher
rfc2822 Dec 24, 2024
335a1a0
[WIP] AutomaticSyncManager
rfc2822 Dec 24, 2024
c81bcf7
Merge branch 'main-ose' into sync-domains-2
rfc2822 Dec 24, 2024
1ca0f55
[WIP] AutomaticSyncManager
rfc2822 Dec 25, 2024
02b1a3f
Merge branch 'main-ose' into sync-domains-2
rfc2822 Dec 25, 2024
27be589
AccountSettings: optimize imports
rfc2822 Dec 25, 2024
67bc53f
SyncWorkManager: remove deprecated methods
rfc2822 Dec 25, 2024
38ee3ba
AutomaticSyncManager: disable unused authorities in sync framework
rfc2822 Dec 25, 2024
99364fe
Add migration draft
rfc2822 Dec 25, 2024
96779b4
AccountSettings: minor changes
rfc2822 Dec 25, 2024
e7c3abd
Migration, BaseSyncWorker: use sync data type
rfc2822 Dec 25, 2024
2729055
Tests, set default sync interval when tasks app is installed, notify …
rfc2822 Dec 25, 2024
52f9441
Remove deprecated AccountSettings methods
rfc2822 Dec 25, 2024
a63322e
Merge branch 'main-ose' into sync-domains-2
rfc2822 Dec 25, 2024
d7b5c4a
Merge branch 'main-ose' into sync-domains-2
rfc2822 Dec 25, 2024
802a587
AccountSettings: actually increase version number
rfc2822 Dec 25, 2024
3a44c0a
Use automaticSyncManager.updateAutomaticSync where applicable; better…
rfc2822 Dec 26, 2024
294073e
KDoc
rfc2822 Dec 26, 2024
dc50917
Remove deprecated SyncWorkerManager.syncAuthorities; fix cancelAllWork
rfc2822 Dec 26, 2024
9cf5b22
AccountSettings: minor changes
rfc2822 Dec 26, 2024
226464f
TasksAppManager: show notification on missing permissions; always upd…
rfc2822 Dec 26, 2024
e114511
AutomaticSyncWorker: only provide updateAutomaticSync() as public method
rfc2822 Dec 26, 2024
ba200d0
AccountSettings: simplify setSyncInterval
rfc2822 Dec 26, 2024
78c6194
AutomaticSyncManager: disable automatic task sync when no tasks provi…
rfc2822 Dec 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove deprecated SyncWorkerManager.syncAuthorities; fix cancelAllWork
  • Loading branch information
rfc2822 committed Dec 26, 2024
commit dc50917e3303b5925f176437966060488a3f54ee
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import androidx.work.WorkInfo
import androidx.work.WorkManager
import androidx.work.WorkQuery
import androidx.work.WorkRequest
import at.bitfire.davdroid.R
import at.bitfire.davdroid.push.PushNotificationManager
import at.bitfire.davdroid.sync.SyncDataType
import at.bitfire.davdroid.sync.TasksAppManager
Expand Down Expand Up @@ -249,8 +248,10 @@ class SyncWorkerManager @Inject constructor(
*/
fun cancelAllWork(account: Account) {
val workManager = WorkManager.getInstance(context)
for (dataType in SyncDataType.entries)
for (dataType in SyncDataType.entries) {
workManager.cancelUniqueWork(OneTimeSyncWorker.workerName(account, dataType))
workManager.cancelUniqueWork(PeriodicSyncWorker.workerName(account, dataType))
}
}

/**
Expand Down Expand Up @@ -284,30 +285,4 @@ class SyncWorkerManager @Inject constructor(
}
}

/**
* Returns a list of all available sync authorities:
*
* 1. calendar authority
* 2. address books authority
* 3. current tasks authority (if available)
*
* Checking the availability of authorities may be relatively expensive, so the
* result should be cached for the current operation.
*
* @return list of available sync authorities for DAVx5 accounts
*/
@Deprecated("Use SyncDataType.entries instead")
fun syncAuthorities(): List<String> {
val result = mutableListOf(
CalendarContract.AUTHORITY,
context.getString(R.string.address_books_authority)
)

tasksAppManager.get().currentProvider()?.let { taskProvider ->
result += taskProvider.authority
}

return result
}

}
Loading