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

Commit 9547e02d authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

chore: add debug instruction. To remove before merge

parent a9c65f66
Loading
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -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
        }
@@ -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)) {
@@ -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)
@@ -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)
@@ -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)
@@ -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)
+2 −0
Original line number Diff line number Diff line
@@ -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
@@ -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()
            }