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

Commit 355cc650 authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

Merge branch '3657-a15-mailapp-bugfix' into 'main'

Ensure proper mail account removal

See merge request !176
parents 35b674b2 93be0d28
Loading
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,12 @@
    <permission android:name="foundation.e.accountmanager.permission.ADD_ACCOUNT"
    <permission android:name="foundation.e.accountmanager.permission.ADD_ACCOUNT"
        android:protectionLevel="signature" />
        android:protectionLevel="signature" />


    <!-- permission for broadcast related to account changes event (added/removed) -->
    <permission
        android:name="foundation.e.accountmanager.permission.ACCOUNT_EVENTS"
        android:protectionLevel="signature"/>
    <uses-permission android:name="foundation.e.accountmanager.permission.ACCOUNT_EVENTS"/>

    <!-- android.permission-group.LOCATION -->
    <!-- android.permission-group.LOCATION -->
    <!-- getting the WiFi name (for "sync in Wifi only") requires
    <!-- getting the WiFi name (for "sync in Wifi only") requires
      - coarse location (Android 8.1)
      - coarse location (Android 8.1)
+9 −1
Original line number Original line Diff line number Diff line
@@ -26,11 +26,19 @@ object MailAccountSyncHelper {
    private const val MAIL_PACKAGE = "foundation.e.mail"
    private const val MAIL_PACKAGE = "foundation.e.mail"
    private const val MAIL_RECEIVER_CLASS = "com.fsck.k9.account.AccountSyncReceiver"
    private const val MAIL_RECEIVER_CLASS = "com.fsck.k9.account.AccountSyncReceiver"
    private const val ACTION_PREFIX = "foundation.e.accountmanager.account."
    private const val ACTION_PREFIX = "foundation.e.accountmanager.account."
    private const val ACCOUNT_EVENTS_PERMISSION = "foundation.e.accountmanager.permission.ACCOUNT_EVENTS"


    fun syncMailAccounts(applicationContext: Context?) {
    fun syncMailAccounts(applicationContext: Context?) {
        val intent = getIntent()
        val intent = getIntent()
        intent.action = ACTION_PREFIX + "create"
        intent.action = ACTION_PREFIX + "create"
        applicationContext?.sendBroadcast(intent)
        applicationContext?.sendBroadcast(intent, ACCOUNT_EVENTS_PERMISSION)
    }

    fun notifyAccountRemoved(context: Context, accountRemovedIntent: Intent) {
        val intent = getIntent()
        intent.action = ACTION_PREFIX + "removed"
        intent.putExtras(accountRemovedIntent)
        context.sendBroadcast(intent, ACCOUNT_EVENTS_PERMISSION)
    }
    }


    private fun getIntent() : Intent {
    private fun getIntent() : Intent {
+2 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ import android.accounts.AccountManager
import android.content.BroadcastReceiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Context
import android.content.Intent
import android.content.Intent
import at.bitfire.davdroid.MailAccountSyncHelper
import at.bitfire.davdroid.settings.AccountSettings
import at.bitfire.davdroid.settings.AccountSettings
import at.bitfire.davdroid.syncadapter.AccountUtils
import at.bitfire.davdroid.syncadapter.AccountUtils
import at.bitfire.davdroid.ui.signout.OpenIdEndSessionActivity
import at.bitfire.davdroid.ui.signout.OpenIdEndSessionActivity
@@ -43,6 +44,7 @@ class AccountRemovedReceiver : BroadcastReceiver() {
            context = context,
            context = context,
            accountName = accountName
            accountName = accountName
        )
        )
        MailAccountSyncHelper.notifyAccountRemoved(context.applicationContext, intent)
    }
    }


    private fun clearOidcSession(
    private fun clearOidcSession(