Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c0ff8f61 authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Resource detection: separate CalDAV/CardDAV detection; handle...

Resource detection: separate CalDAV/CardDAV detection; handle SocketTimeoutException better; version bump to 2.0.4
parent dbfb74a1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ android {
    defaultConfig {
        applicationId "at.bitfire.davdroid"

        versionCode 244
        versionCode 245
        buildConfigField "long", "buildTime", System.currentTimeMillis() + "L"
        buildConfigField "boolean", "customCerts", "true"

@@ -32,7 +32,7 @@ android {
    flavorDimensions "type"
    productFlavors {
        standard {
            versionName "2.0.3-ose"
            versionName "2.0.4-ose"

            buildConfigField "boolean", "customCerts", "true"
        }
+18 −8
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import org.xbill.DNS.Lookup
import org.xbill.DNS.Type
import java.io.IOException
import java.io.InterruptedIOException
import java.net.SocketTimeoutException
import java.net.URI
import java.net.URISyntaxException
import java.util.*
@@ -70,16 +71,25 @@ class DavResourceFinder(
     * exception, but return an empty Configuration with error logs instead.
     */
    fun findInitialConfiguration(): Configuration {
        var cardDavConfig: Configuration.ServiceInfo?
        var calDavConfig: Configuration.ServiceInfo?
        var cardDavConfig: Configuration.ServiceInfo? = null
        var calDavConfig: Configuration.ServiceInfo? = null

        try {
            try {
                cardDavConfig = findInitialConfiguration(Service.CARDDAV)
            calDavConfig = findInitialConfiguration(Service.CALDAV)
            } catch (e: Exception) {
            log.log(Level.INFO, "Service detection failed", e)
                log.log(Level.INFO, "CardDAV service detection failed", e)
                rethrowIfInterrupted(e)
            }

            // reset results so that an error message will be shown
            try {
                calDavConfig = findInitialConfiguration(Service.CALDAV)
            } catch (e: Exception) {
                log.log(Level.INFO, "CalDAV service detection failed", e)
                rethrowIfInterrupted(e)
            }
        } catch(e: Exception) {
            // we have been interrupted; reset results so that an error message will be shown
            cardDavConfig = null
            calDavConfig = null
        }
@@ -400,7 +410,7 @@ class DavResourceFinder(
     * to stop the current operation.
     */
    private fun rethrowIfInterrupted(e: Exception) {
        if (e is InterruptedIOException || e is InterruptedException)
        if ((e is InterruptedIOException && e !is SocketTimeoutException) || e is InterruptedException)
            throw e
    }