From 3637fc95db777121d7069f3ef7a514d0e0f48980 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 3 Apr 2019 22:24:42 +0100 Subject: [PATCH] Sync: catch and report SSLHandshakeExceptions. They were not being reported as part of the general code because SSLException inherits from IOException which is handled differently. --- .../com/etesync/syncadapter/syncadapter/SyncManager.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/etesync/syncadapter/syncadapter/SyncManager.kt b/app/src/main/java/com/etesync/syncadapter/syncadapter/SyncManager.kt index f2565947..0b7ce64e 100644 --- a/app/src/main/java/com/etesync/syncadapter/syncadapter/SyncManager.kt +++ b/app/src/main/java/com/etesync/syncadapter/syncadapter/SyncManager.kt @@ -31,13 +31,13 @@ import com.etesync.syncadapter.ui.DebugInfoActivity import com.etesync.syncadapter.ui.ViewCollectionActivity import io.requery.Persistable import io.requery.sql.EntityDataStore -import okhttp3.OkHttpClient import org.jetbrains.anko.defaultSharedPreferences import java.io.Closeable import java.io.FileNotFoundException import java.io.IOException import java.util.* import java.util.logging.Level +import javax.net.ssl.SSLHandshakeException abstract class SyncManager> @Throws(Exceptions.IntegrityException::class, Exceptions.GenericCryptoException::class) constructor(protected val context: Context, protected val account: Account, protected val settings: AccountSettings, protected val extras: Bundle, protected val authority: String, protected val syncResult: SyncResult, journalUid: String, protected val serviceType: CollectionInfo.Type, accountName: String): Closeable { @@ -184,6 +184,13 @@ constructor(protected val context: Context, protected val account: Account, prot notifyUserOnSync() Logger.log.info("Finished sync with CTag=$remoteCTag") + } catch (e: SSLHandshakeException) { + syncResult.stats.numIoExceptions++ + + notificationManager.setThrowable(e) + val detailsIntent = notificationManager.detailsIntent + detailsIntent.putExtra(KEY_ACCOUNT, account) + notificationManager.notify(syncErrorTitle, context.getString(syncPhase)) } catch (e: IOException) { Logger.log.log(Level.WARNING, "I/O exception during sync, trying again later", e) syncResult.stats.numIoExceptions++