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

Commit 3f5956fd authored by Abhishek Aggarwal's avatar Abhishek Aggarwal
Browse files

AccountManager: on upgrade remove recently contacted address book

parent 5f811897
Loading
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -98,6 +98,8 @@ class AccountSettings(

        const val SYNC_INTERVAL_MANUALLY = -1L

        const val CONTACTS_APP_INTERACTION = "z-app-generated--contactsinteraction--recent/"

        fun initialUserData(credentials: Credentials, baseURL: String?): Bundle {
            val bundle = Bundle(2)
            bundle.putString(KEY_SETTINGS_VERSION, CURRENT_VERSION.toString())
@@ -316,6 +318,15 @@ class AccountSettings(
    @Suppress("unused","FunctionName")
    private fun update_10_11() {
        setGroupMethod(GroupMethod.CATEGORIES)
        val db = AppDatabase.getInstance(context)
        val service = db.serviceDao().getByAccountAndType(account.name, Service.TYPE_CARDDAV)
        if (service != null) {
            for (collection in db.collectionDao().getByServiceAndSync(service.id)) {
                if(collection.url.toString().contains(CONTACTS_APP_INTERACTION)) {
                    db.collectionDao().delete(collection)
                }
            }
        }
    }

    @Suppress("unused","FunctionName")
+5 −1
Original line number Diff line number Diff line
@@ -66,8 +66,12 @@ class EeloAddressBooksSyncAdapterService : SyncAdapterService() {

            val remoteAddressBooks = mutableMapOf<HttpUrl, Collection>()
            if (service != null)
                for (collection in db.collectionDao().getByServiceAndSync(service.id))
                for (collection in db.collectionDao().getByServiceAndSync(service.id)) {
                    if(collection.url.toString().contains(AccountSettings.CONTACTS_APP_INTERACTION)) {
                        db.collectionDao().delete(collection)
                    }
                    remoteAddressBooks[collection.url] = collection
                }

            if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
                if (remoteAddressBooks.isEmpty())