From de6a124bf2ae1cb3672d3688a0c2a1e77bd11832 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 24 Apr 2017 11:23:35 +0100 Subject: [PATCH] Remove unnecessary InvalidAccountException Based on commit d4e386441091ae3a84382f2088dfad03ea80c666 from DAVdroid. --- .../com/etesync/syncadapter/HttpClient.java | 10 +++++----- .../syncadapter/CalendarSyncManager.java | 16 +++++++-------- .../syncadapter/ContactsSyncManager.java | 20 +++++++++---------- .../syncadapter/syncadapter/SyncManager.java | 3 +-- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/com/etesync/syncadapter/HttpClient.java b/app/src/main/java/com/etesync/syncadapter/HttpClient.java index cef0db3d..3d7c6533 100644 --- a/app/src/main/java/com/etesync/syncadapter/HttpClient.java +++ b/app/src/main/java/com/etesync/syncadapter/HttpClient.java @@ -8,13 +8,15 @@ package com.etesync.syncadapter; -import android.accounts.Account; import android.content.Context; import android.database.sqlite.SQLiteOpenHelper; import android.os.Build; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import com.etesync.syncadapter.model.ServiceDB; +import com.etesync.syncadapter.model.Settings; + import java.io.IOException; import java.net.InetSocketAddress; import java.net.Proxy; @@ -25,8 +27,6 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; -import com.etesync.syncadapter.model.ServiceDB; -import com.etesync.syncadapter.model.Settings; import okhttp3.Interceptor; import okhttp3.OkHttpClient; import okhttp3.Request; @@ -56,7 +56,7 @@ public class HttpClient { return builder.build(); } - public static OkHttpClient create(@Nullable Context context, @NonNull AccountSettings settings, @NonNull final Logger logger) throws InvalidAccountException { + public static OkHttpClient create(@Nullable Context context, @NonNull AccountSettings settings, @NonNull final Logger logger) { return create(context, logger, Constants.serviceUrl.getHost(), settings.getAuthToken()); } @@ -64,7 +64,7 @@ public class HttpClient { return defaultBuilder(context, logger).build(); } - public static OkHttpClient create(@NonNull Context context, @NonNull AccountSettings settings) throws InvalidAccountException { + public static OkHttpClient create(@NonNull Context context, @NonNull AccountSettings settings) { return create(context, settings, App.log); } diff --git a/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarSyncManager.java b/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarSyncManager.java index 58712d84..00b4a807 100644 --- a/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarSyncManager.java +++ b/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarSyncManager.java @@ -13,16 +13,9 @@ import android.content.Context; import android.content.SyncResult; import android.os.Bundle; -import org.apache.commons.codec.Charsets; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; - import com.etesync.syncadapter.AccountSettings; import com.etesync.syncadapter.App; import com.etesync.syncadapter.Constants; -import com.etesync.syncadapter.InvalidAccountException; import com.etesync.syncadapter.R; import com.etesync.syncadapter.journalmanager.Exceptions; import com.etesync.syncadapter.journalmanager.JournalEntryManager; @@ -31,6 +24,13 @@ import com.etesync.syncadapter.model.SyncEntry; import com.etesync.syncadapter.resource.LocalCalendar; import com.etesync.syncadapter.resource.LocalEvent; import com.etesync.syncadapter.resource.LocalResource; + +import org.apache.commons.codec.Charsets; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + import at.bitfire.ical4android.CalendarStorageException; import at.bitfire.ical4android.Event; import at.bitfire.ical4android.InvalidCalendarException; @@ -45,7 +45,7 @@ public class CalendarSyncManager extends SyncManager { final private HttpUrl remote; - public CalendarSyncManager(Context context, Account account, AccountSettings settings, Bundle extras, String authority, SyncResult result, LocalCalendar calendar, HttpUrl remote) throws InvalidAccountException, Exceptions.IntegrityException, Exceptions.GenericCryptoException { + public CalendarSyncManager(Context context, Account account, AccountSettings settings, Bundle extras, String authority, SyncResult result, LocalCalendar calendar, HttpUrl remote) throws Exceptions.IntegrityException, Exceptions.GenericCryptoException { super(context, account, settings, extras, authority, result, calendar.getName(), CollectionInfo.Type.CALENDAR, account.name); localCollection = calendar; this.remote = remote; diff --git a/app/src/main/java/com/etesync/syncadapter/syncadapter/ContactsSyncManager.java b/app/src/main/java/com/etesync/syncadapter/syncadapter/ContactsSyncManager.java index 57ad8e9b..a8e2917f 100644 --- a/app/src/main/java/com/etesync/syncadapter/syncadapter/ContactsSyncManager.java +++ b/app/src/main/java/com/etesync/syncadapter/syncadapter/ContactsSyncManager.java @@ -18,19 +18,10 @@ import android.os.Build; import android.os.Bundle; import android.provider.ContactsContract; -import org.apache.commons.codec.Charsets; -import org.apache.commons.io.IOUtils; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.logging.Level; - import com.etesync.syncadapter.AccountSettings; import com.etesync.syncadapter.App; import com.etesync.syncadapter.Constants; import com.etesync.syncadapter.HttpClient; -import com.etesync.syncadapter.InvalidAccountException; import com.etesync.syncadapter.R; import com.etesync.syncadapter.journalmanager.Exceptions; import com.etesync.syncadapter.journalmanager.JournalEntryManager; @@ -40,6 +31,15 @@ import com.etesync.syncadapter.resource.LocalAddressBook; import com.etesync.syncadapter.resource.LocalContact; import com.etesync.syncadapter.resource.LocalGroup; import com.etesync.syncadapter.resource.LocalResource; + +import org.apache.commons.codec.Charsets; +import org.apache.commons.io.IOUtils; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.logging.Level; + import at.bitfire.ical4android.CalendarStorageException; import at.bitfire.vcard4android.Contact; import at.bitfire.vcard4android.ContactsStorageException; @@ -60,7 +60,7 @@ public class ContactsSyncManager extends SyncManager { final private ContentProviderClient provider; final private HttpUrl remote; - public ContactsSyncManager(Context context, Account account, AccountSettings settings, Bundle extras, String authority, ContentProviderClient provider, SyncResult result, LocalAddressBook localAddressBook, HttpUrl principal) throws InvalidAccountException, Exceptions.IntegrityException, Exceptions.GenericCryptoException, ContactsStorageException { + public ContactsSyncManager(Context context, Account account, AccountSettings settings, Bundle extras, String authority, ContentProviderClient provider, SyncResult result, LocalAddressBook localAddressBook, HttpUrl principal) throws Exceptions.IntegrityException, Exceptions.GenericCryptoException, ContactsStorageException { super(context, account, settings, extras, authority, result, localAddressBook.getURL(), CollectionInfo.Type.ADDRESS_BOOK, localAddressBook.getMainAccount().name); this.provider = provider; this.remote = principal; diff --git a/app/src/main/java/com/etesync/syncadapter/syncadapter/SyncManager.java b/app/src/main/java/com/etesync/syncadapter/syncadapter/SyncManager.java index 25067e1f..441730f5 100644 --- a/app/src/main/java/com/etesync/syncadapter/syncadapter/SyncManager.java +++ b/app/src/main/java/com/etesync/syncadapter/syncadapter/SyncManager.java @@ -18,7 +18,6 @@ import com.etesync.syncadapter.AccountSettings; import com.etesync.syncadapter.App; import com.etesync.syncadapter.Constants; import com.etesync.syncadapter.HttpClient; -import com.etesync.syncadapter.InvalidAccountException; import com.etesync.syncadapter.NotificationHelper; import com.etesync.syncadapter.R; import com.etesync.syncadapter.journalmanager.Crypto; @@ -97,7 +96,7 @@ abstract public class SyncManager { private List localDeleted; private LocalResource[] localDirty; - public SyncManager(Context context, Account account, AccountSettings settings, Bundle extras, String authority, SyncResult syncResult, String journalUid, CollectionInfo.Type serviceType, String accountName) throws InvalidAccountException, Exceptions.IntegrityException, Exceptions.GenericCryptoException { + public SyncManager(Context context, Account account, AccountSettings settings, Bundle extras, String authority, SyncResult syncResult, String journalUid, CollectionInfo.Type serviceType, String accountName) throws Exceptions.IntegrityException, Exceptions.GenericCryptoException { this.context = context; this.account = account; this.settings = settings;