mirror of
https://github.com/bitfireAT/davx5-ose
synced 2024-07-24 03:59:33 +00:00
Don't set account visibility if it was already visible (#102)
This commit is contained in:
parent
f813392c72
commit
5b0788b2e9
|
@ -45,9 +45,14 @@ class JtxSyncAdapterService: SyncAdapterService() {
|
|||
TaskProvider.checkVersion(context, TaskProvider.ProviderName.JtxBoard)
|
||||
|
||||
// make sure account can be seen by task provider
|
||||
if (Build.VERSION.SDK_INT >= 26)
|
||||
AccountManager.get(context).setAccountVisibility(account, TaskProvider.ProviderName.JtxBoard.packageName, AccountManager.VISIBILITY_VISIBLE)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
/* Warning: If setAccountVisibility is called, Android 12 broadcasts the
|
||||
AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION Intent. This cancels running syncs
|
||||
and starts them again! So make sure setAccountVisibility is only called when necessary. */
|
||||
val am = AccountManager.get(context)
|
||||
if (am.getAccountVisibility(account, TaskProvider.ProviderName.JtxBoard.packageName) != AccountManager.VISIBILITY_VISIBLE)
|
||||
am.setAccountVisibility(account, TaskProvider.ProviderName.JtxBoard.packageName, AccountManager.VISIBILITY_VISIBLE)
|
||||
}
|
||||
/* don't run sync if
|
||||
- sync conditions (e.g. "sync only in WiFi") are not met AND
|
||||
- this is is an automatic sync (i.e. manual syncs are run regardless of sync conditions)
|
||||
|
|
Loading…
Reference in a new issue