Loading app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt +13 −9 Original line number Diff line number Diff line Loading @@ -183,7 +183,7 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L val authState = accountSettings.credentials().authState if (authState == null || !authState.needsTokenRefresh) { Log.d("SyncManager.performSync()", "perform sync doesn't need to refresh token") Log.d("Vincent", "perform sync doesn't need to refresh token") performSync(DEFAULT_RETRY_AFTER, DEFAULT_SECOND_RETRY_AFTER, DEFAULT_MAX_RETRY_TIME) return } Loading Loading @@ -381,15 +381,16 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L return@unwrapExceptions } // all others else -> { // Caught HTTP 401 : user need to relogin/update credentials // In this case we want to show a notification to indicate it to the user is UnauthorizedException -> { if (e is UnauthorizedException) { Log.d("Vincent", "caught unauthorized exception "+e.message) notifyException(e, local, remote) //notifyException(e, local, remote) } // all others else -> { // sometimes sync is kicked in when no network is not available. // In this case, we don't want to show notification to users. if (!NetworkUtils.isConnectedToNetwork(context)) { Loading Loading @@ -876,6 +877,7 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L Log.d("Vincent", "user not authorized anymore") Logger.log.log(Level.SEVERE, "Not authorized anymore", e) } is HttpException, is DavException -> { Logger.log.log(Level.SEVERE, "HTTP/DAV exception", e) message = context.getString(R.string.sync_error_http_dav, e.localizedMessage) Loading @@ -899,6 +901,7 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L if (account.type in AccountUtils.getMainAccountTypes(context) && (e is UnauthorizedException || e is NotFoundException)) { Log.d("vincent", "Add intent to the notification ") contentIntent = Intent(context, SettingsActivity::class.java) contentIntent.putExtra(SettingsActivity.EXTRA_ACCOUNT, if (authority == ContactsContract.AUTHORITY) Loading @@ -906,6 +909,7 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L else account) } else { Log.d("vincent", "Not an accountType in MainAccountType or not unauthorizedException or NotfoundException") contentIntent = buildDebugInfoIntent(e, local, remote) if (local != null) viewItemAction = buildViewItemAction(local) Loading @@ -923,7 +927,7 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L channel = NotificationUtils.CHANNEL_SYNC_ERRORS priority = NotificationCompat.PRIORITY_DEFAULT } Log.d("vincent", "about to build the notification if possible") val builder = NotificationUtils.newBuilder(context, channel) builder .setSmallIcon(R.drawable.ic_sync_problem_notify) .setContentTitle(localCollection.title) Loading app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncWorker.kt +2 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ import android.net.wifi.WifiManager import android.os.Build import android.provider.CalendarContract import android.provider.ContactsContract import android.util.Log import androidx.annotation.IntDef import androidx.concurrent.futures.CallbackToFutureAdapter import androidx.core.app.NotificationCompat Loading Loading @@ -382,6 +383,7 @@ class SyncWorker @AssistedInject constructor( if (isCookiePresent && result.stats.numAuthExceptions > 0) { // probably the session is outDated. retry without the sessionCookie Log.d("vincent", "SyncWorker. Cookie is present so clearCookies & retry") accountSettings.clearCookie() return Result.retry() } Loading Loading
app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt +13 −9 Original line number Diff line number Diff line Loading @@ -183,7 +183,7 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L val authState = accountSettings.credentials().authState if (authState == null || !authState.needsTokenRefresh) { Log.d("SyncManager.performSync()", "perform sync doesn't need to refresh token") Log.d("Vincent", "perform sync doesn't need to refresh token") performSync(DEFAULT_RETRY_AFTER, DEFAULT_SECOND_RETRY_AFTER, DEFAULT_MAX_RETRY_TIME) return } Loading Loading @@ -381,15 +381,16 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L return@unwrapExceptions } // all others else -> { // Caught HTTP 401 : user need to relogin/update credentials // In this case we want to show a notification to indicate it to the user is UnauthorizedException -> { if (e is UnauthorizedException) { Log.d("Vincent", "caught unauthorized exception "+e.message) notifyException(e, local, remote) //notifyException(e, local, remote) } // all others else -> { // sometimes sync is kicked in when no network is not available. // In this case, we don't want to show notification to users. if (!NetworkUtils.isConnectedToNetwork(context)) { Loading Loading @@ -876,6 +877,7 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L Log.d("Vincent", "user not authorized anymore") Logger.log.log(Level.SEVERE, "Not authorized anymore", e) } is HttpException, is DavException -> { Logger.log.log(Level.SEVERE, "HTTP/DAV exception", e) message = context.getString(R.string.sync_error_http_dav, e.localizedMessage) Loading @@ -899,6 +901,7 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L if (account.type in AccountUtils.getMainAccountTypes(context) && (e is UnauthorizedException || e is NotFoundException)) { Log.d("vincent", "Add intent to the notification ") contentIntent = Intent(context, SettingsActivity::class.java) contentIntent.putExtra(SettingsActivity.EXTRA_ACCOUNT, if (authority == ContactsContract.AUTHORITY) Loading @@ -906,6 +909,7 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L else account) } else { Log.d("vincent", "Not an accountType in MainAccountType or not unauthorizedException or NotfoundException") contentIntent = buildDebugInfoIntent(e, local, remote) if (local != null) viewItemAction = buildViewItemAction(local) Loading @@ -923,7 +927,7 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L channel = NotificationUtils.CHANNEL_SYNC_ERRORS priority = NotificationCompat.PRIORITY_DEFAULT } Log.d("vincent", "about to build the notification if possible") val builder = NotificationUtils.newBuilder(context, channel) builder .setSmallIcon(R.drawable.ic_sync_problem_notify) .setContentTitle(localCollection.title) Loading
app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncWorker.kt +2 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ import android.net.wifi.WifiManager import android.os.Build import android.provider.CalendarContract import android.provider.ContactsContract import android.util.Log import androidx.annotation.IntDef import androidx.concurrent.futures.CallbackToFutureAdapter import androidx.core.app.NotificationCompat Loading Loading @@ -382,6 +383,7 @@ class SyncWorker @AssistedInject constructor( if (isCookiePresent && result.stats.numAuthExceptions > 0) { // probably the session is outDated. retry without the sessionCookie Log.d("vincent", "SyncWorker. Cookie is present so clearCookies & retry") accountSettings.clearCookie() return Result.retry() } Loading