Merge pull request #5369 from k9mail/fix_no_push_accounts

Don't start PushService if there are no Push-enabled accounts
This commit is contained in:
cketti 2021-06-26 21:41:19 +02:00 committed by GitHub
commit 84fc7c3872
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -118,11 +118,12 @@ class PushController internal constructor(
val backgroundSyncDisabledViaSystem = autoSyncManager.isAutoSyncDisabled
val backgroundSyncDisabledInApp = K9.backgroundOps == K9.BACKGROUND_OPS.NEVER
val networkNotAvailable = !connectivityManager.isNetworkAvailable()
val realPushAccounts = getPushAccounts()
val pushAccounts = if (backgroundSyncDisabledViaSystem || backgroundSyncDisabledInApp || networkNotAvailable) {
emptyList()
} else {
getPushAccounts()
realPushAccounts
}
val pushAccountUuids = pushAccounts.map { it.uuid }
@ -155,6 +156,9 @@ class PushController internal constructor(
}
when {
realPushAccounts.isEmpty() -> {
stopServices()
}
backgroundSyncDisabledViaSystem -> {
setPushNotificationState(WAIT_BACKGROUND_SYNC)
startServices()