From d70ac0343b106e17591b23f114e7713e1bb38321 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Thu, 19 Sep 2024 14:51:09 +0200 Subject: [PATCH 1/8] task: add debug instruction and if statement --- .../kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt b/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt index c370730a..8abb10de 100644 --- a/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt +++ b/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt @@ -894,7 +894,11 @@ abstract class SyncManager, out CollectionType: L val contentIntent: Intent var viewItemAction: NotificationCompat.Action? = null - if (account.type in AccountUtils.getMainAccountTypes(context) + Logger.log.info("VINCENT: Account type: "+ account.type) + + if ( + (account.type in AccountUtils.getMainAccountTypes(context) + || account.type == context.getString(R.string.account_type_eelo_address_book)) && (e is UnauthorizedException || e is NotFoundException)) { contentIntent = Intent(context, SettingsActivity::class.java) -- GitLab From f659a723bf52ea9383c6d58b61398c3e3c4577a2 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Thu, 19 Sep 2024 17:28:39 +0200 Subject: [PATCH 2/8] task: update version number to be sure the APK is good --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 166c179c..0904d436 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,7 +23,7 @@ android { defaultConfig { applicationId "foundation.e.accountmanager" - versionCode 403090003 + versionCode 403090004 versionName '4.3.9' buildConfigField "long", "buildTime", System.currentTimeMillis() + "L" -- GitLab From 4705f15dfcce23513238b5aad37a951c1ebebe6d Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Thu, 19 Sep 2024 17:35:10 +0200 Subject: [PATCH 3/8] task: add more debug --- .../kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt b/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt index 8abb10de..33581080 100644 --- a/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt +++ b/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt @@ -901,6 +901,11 @@ abstract class SyncManager, out CollectionType: L || account.type == context.getString(R.string.account_type_eelo_address_book)) && (e is UnauthorizedException || e is NotFoundException)) { + + Logger.log.info("VINCENT: authority: $authority == ${ContactsContract.AUTHORITY} ?" ) + Logger.log.info("VINCENT: main account ${mainAccount.type} & ${mainAccount.name}" ) + Logger.log.info("VINCENT: main account ${account.type} & ${account.name}" ) + contentIntent = Intent(context, SettingsActivity::class.java) contentIntent.putExtra(SettingsActivity.EXTRA_ACCOUNT, if (authority == ContactsContract.AUTHORITY) @@ -908,6 +913,7 @@ abstract class SyncManager, out CollectionType: L else account) } else { + Logger.log.info("VINCENT: show buildDebugInfoIntent for notification") contentIntent = buildDebugInfoIntent(e, local, remote) if (local != null) viewItemAction = buildViewItemAction(local) -- GitLab From 0040cd5ebf910fe596775eee76ce6dfc9d8ce088 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 23 Sep 2024 16:46:29 +0200 Subject: [PATCH 4/8] task: update debug logging to get more interesting input --- .../bitfire/davdroid/syncadapter/SyncManager.kt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt b/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt index 33581080..f31b2dcb 100644 --- a/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt +++ b/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt @@ -901,17 +901,21 @@ abstract class SyncManager, out CollectionType: L || account.type == context.getString(R.string.account_type_eelo_address_book)) && (e is UnauthorizedException || e is NotFoundException)) { - - Logger.log.info("VINCENT: authority: $authority == ${ContactsContract.AUTHORITY} ?" ) + Logger.log.info("VINCENT: exception is: ${e.javaClass.simpleName}") + Logger.log.info("VINCENT: authority: $authority vs ${ContactsContract.AUTHORITY} ?" ) Logger.log.info("VINCENT: main account ${mainAccount.type} & ${mainAccount.name}" ) - Logger.log.info("VINCENT: main account ${account.type} & ${account.name}" ) + Logger.log.info("VINCENT: account ${account.type} & ${account.name}" ) contentIntent = Intent(context, SettingsActivity::class.java) contentIntent.putExtra(SettingsActivity.EXTRA_ACCOUNT, - if (authority == ContactsContract.AUTHORITY) + if (authority == ContactsContract.AUTHORITY) { + Logger.log.info("VINCENT: use main account") mainAccount - else - account) + } + else { + Logger.log.info("VINCENT: use account") + account + }) } else { Logger.log.info("VINCENT: show buildDebugInfoIntent for notification") contentIntent = buildDebugInfoIntent(e, local, remote) @@ -932,6 +936,7 @@ abstract class SyncManager, out CollectionType: L priority = NotificationCompat.PRIORITY_DEFAULT } + Logger.log.info("VINCENT: TAG: $tag & ID: ${NotificationUtils.NOTIFY_SYNC_ERROR}") val builder = NotificationUtils.newBuilder(context, channel) builder .setSmallIcon(R.drawable.ic_sync_problem_notify) .setContentTitle(title) -- GitLab From 63edf61352403ba769639a6f77265557abeb84ef Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 24 Sep 2024 15:44:16 +0200 Subject: [PATCH 5/8] task: update logging again and make all notif to have intent against main account --- .../at/bitfire/davdroid/syncadapter/SyncManager.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt b/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt index f31b2dcb..e54e423a 100644 --- a/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt +++ b/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt @@ -900,22 +900,22 @@ abstract class SyncManager, out CollectionType: L (account.type in AccountUtils.getMainAccountTypes(context) || account.type == context.getString(R.string.account_type_eelo_address_book)) && (e is UnauthorizedException || e is NotFoundException)) { - + Logger.log.info ("VINCENT: notif title: $title") Logger.log.info("VINCENT: exception is: ${e.javaClass.simpleName}") Logger.log.info("VINCENT: authority: $authority vs ${ContactsContract.AUTHORITY} ?" ) Logger.log.info("VINCENT: main account ${mainAccount.type} & ${mainAccount.name}" ) Logger.log.info("VINCENT: account ${account.type} & ${account.name}" ) contentIntent = Intent(context, SettingsActivity::class.java) - contentIntent.putExtra(SettingsActivity.EXTRA_ACCOUNT, - if (authority == ContactsContract.AUTHORITY) { + contentIntent.putExtra(SettingsActivity.EXTRA_ACCOUNT, mainAccount) + /*if (authority == ContactsContract.AUTHORITY) { Logger.log.info("VINCENT: use main account") mainAccount } else { Logger.log.info("VINCENT: use account") account - }) + })*/ } else { Logger.log.info("VINCENT: show buildDebugInfoIntent for notification") contentIntent = buildDebugInfoIntent(e, local, remote) @@ -936,7 +936,7 @@ abstract class SyncManager, out CollectionType: L priority = NotificationCompat.PRIORITY_DEFAULT } - Logger.log.info("VINCENT: TAG: $tag & ID: ${NotificationUtils.NOTIFY_SYNC_ERROR}") + Logger.log.info("VINCENT: TAG: $tag & ID: ${NotificationUtils.NOTIFY_SYNC_ERROR} & Title: $title") val builder = NotificationUtils.newBuilder(context, channel) builder .setSmallIcon(R.drawable.ic_sync_problem_notify) .setContentTitle(title) -- GitLab From b9fd8cecfa1bc289db259156fb730233e9a6f375 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 24 Sep 2024 17:32:49 +0200 Subject: [PATCH 6/8] fix: skip Murena adress book notification about authentification failed Prevent notification that open debug intent --- .../davdroid/syncadapter/SyncManager.kt | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt b/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt index e54e423a..55fe1c68 100644 --- a/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt +++ b/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt @@ -894,30 +894,18 @@ abstract class SyncManager, out CollectionType: L val contentIntent: Intent var viewItemAction: NotificationCompat.Action? = null - Logger.log.info("VINCENT: Account type: "+ account.type) - - if ( - (account.type in AccountUtils.getMainAccountTypes(context) - || account.type == context.getString(R.string.account_type_eelo_address_book)) - && (e is UnauthorizedException || e is NotFoundException)) { - Logger.log.info ("VINCENT: notif title: $title") - Logger.log.info("VINCENT: exception is: ${e.javaClass.simpleName}") - Logger.log.info("VINCENT: authority: $authority vs ${ContactsContract.AUTHORITY} ?" ) - Logger.log.info("VINCENT: main account ${mainAccount.type} & ${mainAccount.name}" ) - Logger.log.info("VINCENT: account ${account.type} & ${account.name}" ) + + if (e is UnauthorizedException || e is NotFoundException) { + //prevent publication of notification (with debug intent) if it is Murena adress book account + if (account.type !in AccountUtils.getMainAccountTypes(context)) return contentIntent = Intent(context, SettingsActivity::class.java) - contentIntent.putExtra(SettingsActivity.EXTRA_ACCOUNT, mainAccount) - /*if (authority == ContactsContract.AUTHORITY) { - Logger.log.info("VINCENT: use main account") - mainAccount - } - else { - Logger.log.info("VINCENT: use account") - account - })*/ + contentIntent.putExtra(SettingsActivity.EXTRA_ACCOUNT, + if (authority == ContactsContract.AUTHORITY) + mainAccount + else + account) } else { - Logger.log.info("VINCENT: show buildDebugInfoIntent for notification") contentIntent = buildDebugInfoIntent(e, local, remote) if (local != null) viewItemAction = buildViewItemAction(local) @@ -936,7 +924,6 @@ abstract class SyncManager, out CollectionType: L priority = NotificationCompat.PRIORITY_DEFAULT } - Logger.log.info("VINCENT: TAG: $tag & ID: ${NotificationUtils.NOTIFY_SYNC_ERROR} & Title: $title") val builder = NotificationUtils.newBuilder(context, channel) builder .setSmallIcon(R.drawable.ic_sync_problem_notify) .setContentTitle(title) -- GitLab From b294da345bab5371c9f13ee0163212f4e425a6ef Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 24 Sep 2024 18:36:58 +0200 Subject: [PATCH 7/8] fix: update the fix to make it working --- .../kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt b/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt index 55fe1c68..68296fb8 100644 --- a/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt +++ b/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt @@ -895,9 +895,10 @@ abstract class SyncManager, out CollectionType: L var viewItemAction: NotificationCompat.Action? = null - if (e is UnauthorizedException || e is NotFoundException) { - //prevent publication of notification (with debug intent) if it is Murena adress book account - if (account.type !in AccountUtils.getMainAccountTypes(context)) return + if ( + (account.type in AccountUtils.getMainAccountTypes(context) + || account.type == context.getString(R.string.account_type_eelo_address_book)) + && (e is UnauthorizedException || e is NotFoundException)) { contentIntent = Intent(context, SettingsActivity::class.java) contentIntent.putExtra(SettingsActivity.EXTRA_ACCOUNT, -- GitLab From 4ab8f6f2922886b2a5ed122409d0c5f50548c626 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 25 Sep 2024 13:40:06 +0200 Subject: [PATCH 8/8] refactor: apply Sayantan's suggestion. Extract if statement into a variable --- .../at/bitfire/davdroid/syncadapter/SyncManager.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt b/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt index 68296fb8..eb36c641 100644 --- a/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt +++ b/app/src/main/kotlin/at/bitfire/davdroid/syncadapter/SyncManager.kt @@ -901,11 +901,14 @@ abstract class SyncManager, out CollectionType: L && (e is UnauthorizedException || e is NotFoundException)) { contentIntent = Intent(context, SettingsActivity::class.java) - contentIntent.putExtra(SettingsActivity.EXTRA_ACCOUNT, - if (authority == ContactsContract.AUTHORITY) - mainAccount - else - account) + + val contentAccount = if (authority == ContactsContract.AUTHORITY) { + mainAccount + } else { + account + } + contentIntent.putExtra(SettingsActivity.EXTRA_ACCOUNT, contentAccount) + } else { contentIntent = buildDebugInfoIntent(e, local, remote) if (local != null) -- GitLab