diff --git a/app/src/main/java/at/bitfire/davdroid/ui/setup/DavResourceFinder.kt b/app/src/main/java/at/bitfire/davdroid/ui/setup/DavResourceFinder.kt index a86b7697e820460bcc82d29ff2fa030f791eb7b3..e9cbd43732fcd089eef9b98983583d9542a36a0a 100644 --- a/app/src/main/java/at/bitfire/davdroid/ui/setup/DavResourceFinder.kt +++ b/app/src/main/java/at/bitfire/davdroid/ui/setup/DavResourceFinder.kt @@ -31,7 +31,8 @@ import java.util.logging.Logger class DavResourceFinder( val context: Context, - private val loginModel: LoginModel + private val loginModel: LoginModel, + private val blockOnUnauthorizedException: Boolean = false ): AutoCloseable { enum class Service(val wellKnownName: String) { @@ -430,6 +431,10 @@ class DavResourceFinder( encountered401 = true else if ((e is InterruptedIOException && e !is SocketTimeoutException) || e is InterruptedException) throw e + + if (e is UnauthorizedException && blockOnUnauthorizedException) { + throw e + } } diff --git a/app/src/main/java/at/bitfire/davdroid/ui/setup/DetectConfigurationFragment.kt b/app/src/main/java/at/bitfire/davdroid/ui/setup/DetectConfigurationFragment.kt index e90b228947cfce5f2087416072899f483bdccf97..6fb02a7ceb7c5fe096f961a0cc396828a277e34b 100644 --- a/app/src/main/java/at/bitfire/davdroid/ui/setup/DetectConfigurationFragment.kt +++ b/app/src/main/java/at/bitfire/davdroid/ui/setup/DetectConfigurationFragment.kt @@ -40,7 +40,10 @@ class DetectConfigurationFragment: Fragment() { return } - model.detectConfiguration(loginModel).observe(this, { result -> + val accountType = requireActivity().intent.getStringExtra(LoginActivity.SETUP_ACCOUNT_PROVIDER_TYPE) + val isMurenaAccountType = (accountType == LoginActivity.ACCOUNT_PROVIDER_EELO) + + model.detectConfiguration(loginModel, isMurenaAccountType).observe(this, { result -> // save result for next step loginModel.configuration = result @@ -80,7 +83,7 @@ class DetectConfigurationFragment: Fragment() { return (loginModel.baseURI?.host.equals(Constants.EELO_SYNC_HOST) && ECloudAccountHelper.alreadyHasECloudAccount(context)) } - fun detectConfiguration(loginModel: LoginModel): LiveData { + fun detectConfiguration(loginModel: LoginModel, blockOnUnauthorizedException: Boolean): LiveData { synchronized(result) { if (detectionThread != null) // detection already running @@ -93,7 +96,7 @@ class DetectConfigurationFragment: Fragment() { } try { - DavResourceFinder(getApplication(), loginModel).use { finder -> + DavResourceFinder(getApplication(), loginModel, blockOnUnauthorizedException).use { finder -> result.postValue(finder.findInitialConfiguration()) } } catch(e: Exception) {