Loading app/src/main/kotlin/at/bitfire/davdroid/receiver/BootCompletedReceiver.kt +28 −12 Original line number Diff line number Diff line Loading @@ -24,6 +24,10 @@ import at.bitfire.davdroid.ui.NotificationUtils import at.bitfire.davdroid.ui.NotificationUtils.CHANNEL_GENERAL import at.bitfire.davdroid.ui.NotificationUtils.NOTIFY_SWITCH_TO_OPENID import at.bitfire.davdroid.ui.NotificationUtils.notifyIfPossible import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.launch /** * There are circumstances when Android drops automatic sync of accounts and resets them Loading @@ -34,16 +38,23 @@ import at.bitfire.davdroid.ui.NotificationUtils.notifyIfPossible */ class BootCompletedReceiver: BroadcastReceiver() { private val job = SupervisorJob() private val scope = CoroutineScope(job + Dispatchers.IO) override fun onReceive(context: Context, intent: Intent) { Logger.log.info("Device has been rebooted; checking sync intervals etc.") val pendingResult = goAsync() scope.launch { try { val eAccountType = context.getString(R.string.eelo_account_type) val accountManager = AccountManager.get(context) val canNotify = canNotify(context) AccountUtils.getMainAccounts(context) .forEach { val needReLogin = eAccountType == it.type && !isLoggedWithOpenId(it, accountManager) val needReLogin = eAccountType == it.type && !isLoggedWithOpenId(it, accountManager) if (canNotify && needReLogin) { notifySwitchToOpenId(it, context) Loading @@ -52,6 +63,11 @@ class BootCompletedReceiver: BroadcastReceiver() { accountSettings.initSync() } } } finally { pendingResult.finish() job.cancel() } } } private fun isLoggedWithOpenId(account: Account, accountManager: AccountManager): Boolean { Loading Loading
app/src/main/kotlin/at/bitfire/davdroid/receiver/BootCompletedReceiver.kt +28 −12 Original line number Diff line number Diff line Loading @@ -24,6 +24,10 @@ import at.bitfire.davdroid.ui.NotificationUtils import at.bitfire.davdroid.ui.NotificationUtils.CHANNEL_GENERAL import at.bitfire.davdroid.ui.NotificationUtils.NOTIFY_SWITCH_TO_OPENID import at.bitfire.davdroid.ui.NotificationUtils.notifyIfPossible import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.launch /** * There are circumstances when Android drops automatic sync of accounts and resets them Loading @@ -34,16 +38,23 @@ import at.bitfire.davdroid.ui.NotificationUtils.notifyIfPossible */ class BootCompletedReceiver: BroadcastReceiver() { private val job = SupervisorJob() private val scope = CoroutineScope(job + Dispatchers.IO) override fun onReceive(context: Context, intent: Intent) { Logger.log.info("Device has been rebooted; checking sync intervals etc.") val pendingResult = goAsync() scope.launch { try { val eAccountType = context.getString(R.string.eelo_account_type) val accountManager = AccountManager.get(context) val canNotify = canNotify(context) AccountUtils.getMainAccounts(context) .forEach { val needReLogin = eAccountType == it.type && !isLoggedWithOpenId(it, accountManager) val needReLogin = eAccountType == it.type && !isLoggedWithOpenId(it, accountManager) if (canNotify && needReLogin) { notifySwitchToOpenId(it, context) Loading @@ -52,6 +63,11 @@ class BootCompletedReceiver: BroadcastReceiver() { accountSettings.initSync() } } } finally { pendingResult.finish() job.cancel() } } } private fun isLoggedWithOpenId(account: Account, accountManager: AccountManager): Boolean { Loading