From 91e854bea0f2cc9f35c539375709fb1b08600cdb Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Tue, 20 Dec 2022 14:59:46 +0600 Subject: [PATCH] 922-Remove_mail_account_remove_broadcast_call issue: https://gitlab.e.foundation/e/os/backlog/-/issues/922 Mail account will handle ACCOUNT_REMOVE broadcast call created from os, no need to call from AccountManager --- .../bitfire/davdroid/MailAccountSyncHelper.kt | 12 -------- .../davdroid/resource/LocalAddressBook.kt | 28 ++----------------- .../davdroid/ui/account/AccountActivity.kt | 3 -- 3 files changed, 2 insertions(+), 41 deletions(-) diff --git a/app/src/main/java/at/bitfire/davdroid/MailAccountSyncHelper.kt b/app/src/main/java/at/bitfire/davdroid/MailAccountSyncHelper.kt index 39ebc1fb7..07675e657 100644 --- a/app/src/main/java/at/bitfire/davdroid/MailAccountSyncHelper.kt +++ b/app/src/main/java/at/bitfire/davdroid/MailAccountSyncHelper.kt @@ -33,18 +33,6 @@ object MailAccountSyncHelper { applicationContext?.sendBroadcast(intent) } - fun onAccountLoggedOut(applicationContext: Context?, email: String?) { - email?.let { - if (!it.contains("@")) { - return@let - } - val intent = getIntent() - intent.action = ACTION_PREFIX + "remove" - intent.putExtra("account", it) - applicationContext?.sendBroadcast(intent) - } - } - private fun getIntent() : Intent { val intent = Intent() intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES) diff --git a/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.kt b/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.kt index 526ad2c4d..71ae52518 100644 --- a/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.kt +++ b/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.kt @@ -8,8 +8,6 @@ import android.accounts.AccountManager import android.content.* import android.os.Build import android.os.Bundle -import android.os.Handler -import android.os.Looper import android.os.RemoteException import android.provider.ContactsContract import android.provider.ContactsContract.CommonDataKinds.GroupMembership @@ -26,7 +24,6 @@ import at.bitfire.davdroid.settings.AccountSettings import at.bitfire.davdroid.syncadapter.AccountUtils import at.bitfire.davdroid.syncadapter.SyncUtils import at.bitfire.vcard4android.* -import at.bitfire.davdroid.MailAccountSyncHelper import java.io.ByteArrayOutputStream import java.util.* @@ -255,34 +252,13 @@ open class LocalAddressBook( } private fun removeAccountForOlderSdk(accountManager: AccountManager, email: String?) { - accountManager.removeAccount(account, { - try { - if (it.result) { - Handler(Looper.getMainLooper()).post { - MailAccountSyncHelper.onAccountLoggedOut(context.applicationContext, email) - } - } - } catch (e: Exception) { - Logger.log.log(Level.SEVERE, "Couldn't remove account", e) - } - }, null) + accountManager.removeAccount(account, null, null) } private fun removeAccount(accountManager: AccountManager, email: String?) { - accountManager.removeAccount(account, null, { - try { - if (it.result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT)) { - Handler(Looper.getMainLooper()).post { - MailAccountSyncHelper.onAccountLoggedOut(context.applicationContext, email) - } - } - } catch (e: Exception) { - Logger.log.log(Level.SEVERE, "Couldn't remove account", e) - } - }, null) + accountManager.removeAccount(account, null, null, null) } - /** * Updates the sync framework settings for this address book: * diff --git a/app/src/main/java/at/bitfire/davdroid/ui/account/AccountActivity.kt b/app/src/main/java/at/bitfire/davdroid/ui/account/AccountActivity.kt index e5522d85a..ac29735e7 100644 --- a/app/src/main/java/at/bitfire/davdroid/ui/account/AccountActivity.kt +++ b/app/src/main/java/at/bitfire/davdroid/ui/account/AccountActivity.kt @@ -38,7 +38,6 @@ import dagger.hilt.android.qualifiers.ApplicationContext import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.launch -import at.bitfire.davdroid.MailAccountSyncHelper import java.util.logging.Level import javax.inject.Inject @@ -140,7 +139,6 @@ class AccountActivity: AppCompatActivity() { try { if (future.result) Handler(Looper.getMainLooper()).post { - MailAccountSyncHelper.onAccountLoggedOut(applicationContext, email) finish() } } catch (e: Exception) { @@ -154,7 +152,6 @@ class AccountActivity: AppCompatActivity() { try { if (future.result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT)) Handler(Looper.getMainLooper()).post { - MailAccountSyncHelper.onAccountLoggedOut(applicationContext, email) finish() } } catch (e: Exception) { -- GitLab