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:
commit
84fc7c3872
1 changed files with 5 additions and 1 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue