From fcedd170003262224df73d32b6d03bfb988c6cc8 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Wed, 23 Nov 2022 21:19:01 +0600 Subject: [PATCH] 858-Pass_correct_exception_on_accountSettings_init_call issue: https://gitlab.e.foundation/e/os/backlog/-/issues/858 --- .../bitfire/davdroid/settings/AccountSettings.kt | 2 +- .../at/bitfire/davdroid/syncadapter/SyncUtils.kt | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/at/bitfire/davdroid/settings/AccountSettings.kt b/app/src/main/java/at/bitfire/davdroid/settings/AccountSettings.kt index 120b9523b..e84c119c4 100644 --- a/app/src/main/java/at/bitfire/davdroid/settings/AccountSettings.kt +++ b/app/src/main/java/at/bitfire/davdroid/settings/AccountSettings.kt @@ -223,7 +223,7 @@ class AccountSettings( context.getString(R.string.account_type), context.getString(R.string.google_account_type), context.getString(R.string.eelo_account_type) -> account = argAccount else -> - throw IllegalArgumentException("Account type not supported") + throw IllegalArgumentException("Account type not supported. AccountType: ${argAccount.type}") } // synchronize because account migration must only be run one time diff --git a/app/src/main/java/at/bitfire/davdroid/syncadapter/SyncUtils.kt b/app/src/main/java/at/bitfire/davdroid/syncadapter/SyncUtils.kt index c9e9bc5ab..4b3278562 100644 --- a/app/src/main/java/at/bitfire/davdroid/syncadapter/SyncUtils.kt +++ b/app/src/main/java/at/bitfire/davdroid/syncadapter/SyncUtils.kt @@ -34,6 +34,7 @@ import dagger.hilt.EntryPoint import dagger.hilt.InstallIn import dagger.hilt.android.EntryPointAccessors import dagger.hilt.components.SingletonComponent +import java.util.logging.Level object SyncUtils { @@ -111,8 +112,18 @@ object SyncUtils { val isSyncable = ContentResolver.getIsSyncable(account, providerName.authority) // may be -1 (unknown state) val shallBeSyncable = hasCalDAV && providerName == currentProvider if ((shallBeSyncable && isSyncable != 1) || (!shallBeSyncable && isSyncable != 0)) { - // enable/disable sync - setSyncableFromSettings(context, account, providerName.authority, shallBeSyncable) + try { + // enable/disable sync + setSyncableFromSettings( + context, + account, + providerName.authority, + shallBeSyncable + ) + } catch (e: IllegalArgumentException) { + Logger.log.log(Level.WARNING, "Account type not supported", e) + continue + } // if sync has just been enabled: check whether additional permissions are required if (shallBeSyncable && !PermissionUtils.havePermissions(context, providerName.permissions)) @@ -138,6 +149,7 @@ object SyncUtils { settings.setSyncInterval(authority, interval) } catch (e: InvalidAccountException) { // account has already been removed + Logger.log.log(Level.WARNING, "Account is not present", e) } } else { Logger.log.info("Disabling $authority sync for $account") -- GitLab