Compare commits

...

3 Commits

Author SHA1 Message Date
Ricki Hirner
c1fbeb8de1 Version bump to 2.0.2 2018-08-15 13:09:16 +02:00
Ricki Hirner
633f6d9629 DAVdroid address book sync: only sync address book sub-accounts of current account 2018-08-15 13:07:34 +02:00
Ricki Hirner
04c5c8fa9e Fix crash in resource detection 2018-08-15 12:43:00 +02:00
5 changed files with 27 additions and 12 deletions

View File

@@ -12,7 +12,7 @@ apply plugin: 'kotlin-android-extensions'
apply plugin: 'org.jetbrains.dokka-android'
ext {
baseVersionName = '2.0.1'
baseVersionName = '2.0.2'
}
android {
@@ -23,7 +23,7 @@ android {
applicationId "at.bitfire.davdroid"
resValue "string", "packageID", applicationId
versionCode 242
versionCode 243
buildConfigField "long", "buildTime", System.currentTimeMillis() + "L"
minSdkVersion 19 // Android 4.4

View File

@@ -67,7 +67,7 @@ class LocalAddressBook(
return addressBook
}
fun findAll(context: Context, provider: ContentProviderClient, mainAccount: Account?) = AccountManager.get(context)
fun findAll(context: Context, provider: ContentProviderClient?, mainAccount: Account?) = AccountManager.get(context)
.getAccountsByType(context.getString(R.string.account_type_address_book))
.map { LocalAddressBook(context, it, provider) }
.filter { mainAccount == null || it.mainAccount == mainAccount }

View File

@@ -9,7 +9,6 @@ package at.bitfire.davdroid.syncadapter
import android.Manifest
import android.accounts.Account
import android.accounts.AccountManager
import android.content.*
import android.content.pm.PackageManager
import android.database.DatabaseUtils
@@ -18,7 +17,6 @@ import android.os.Bundle
import android.provider.ContactsContract
import android.support.v4.content.ContextCompat
import at.bitfire.davdroid.AccountSettings
import at.bitfire.davdroid.R
import at.bitfire.davdroid.log.Logger
import at.bitfire.davdroid.model.CollectionInfo
import at.bitfire.davdroid.model.ServiceDB
@@ -49,10 +47,9 @@ class AddressBooksSyncAdapterService : SyncAdapterService() {
if (!extras.containsKey(ContentResolver.SYNC_EXTRAS_MANUAL) && !checkSyncConditions(accountSettings))
return
updateLocalAddressBooks(provider, account, syncResult)
updateLocalAddressBooks(account, syncResult)
val accountManager = AccountManager.get(context)
for (addressBookAccount in accountManager.getAccountsByType(context.getString(R.string.account_type_address_book))) {
for (addressBookAccount in LocalAddressBook.findAll(context, null, account).map { it.account }) {
Logger.log.log(Level.INFO, "Running sync for address book", addressBookAccount)
val syncExtras = Bundle(extras)
syncExtras.putBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_SETTINGS, true)
@@ -66,7 +63,7 @@ class AddressBooksSyncAdapterService : SyncAdapterService() {
Logger.log.info("Address book sync complete")
}
private fun updateLocalAddressBooks(provider: ContentProviderClient, account: Account, syncResult: SyncResult) {
private fun updateLocalAddressBooks(account: Account, syncResult: SyncResult) {
ServiceDB.OpenHelper(context).use { dbHelper ->
val db = dbHelper.readableDatabase

View File

@@ -65,9 +65,24 @@ class DavResourceFinder(
}
/**
* Finds the initial configuration, i.e. runs the auto-detection process. Must not throw an
* exception, but return an empty Configuration with error logs instead.
*/
fun findInitialConfiguration(): Configuration {
val cardDavConfig = findInitialConfiguration(Service.CARDDAV)
val calDavConfig = findInitialConfiguration(Service.CALDAV)
var cardDavConfig: Configuration.ServiceInfo?
var calDavConfig: Configuration.ServiceInfo?
try {
cardDavConfig = findInitialConfiguration(Service.CARDDAV)
calDavConfig = findInitialConfiguration(Service.CALDAV)
} catch(e: Exception) {
log.log(Level.INFO, "Service detection failed", e)
// reset results so that an error message will be shown
cardDavConfig = null
calDavConfig = null
}
return Configuration(
loginInfo.credentials,
@@ -380,6 +395,10 @@ class DavResourceFinder(
return principal
}
/**
* Re-throws the exception if it signals that the current thread was interrupted
* to stop the current operation.
*/
private fun rethrowIfInterrupted(e: Exception) {
if (e is InterruptedIOException || e is InterruptedException)
throw e

View File

@@ -16,7 +16,6 @@
<string name="account_title_address_book">DAVdroid Address book</string>
<string name="address_books_authority" translatable="false">at.bitfire.davdroid.addressbooks</string>
<string name="address_books_authority_title">Address books</string>
<string name="copied_to_clipboard">Copied to clipboard</string>
<string name="help">Help</string>
<string name="manage_accounts">Manage accounts</string>
<string name="please_wait">Please wait …</string>