I have a sync adapter which is observing Contacts Provider and has an associated custom account. Below you can see all rows of the "accounts" table of "contacts2.db"
Initially I had a Google contact with the display name "Atakan Kaya". Then I created an app named TestingContacts which synchronizes contacts by fetching google ones, and adding the same raw contact with the "TestingContacts" account. For that I followed the official tutorial. I add a raw contact and two data rows; one having the display name, and one having the phone number. I do not add any aggregation exceptions since the name and the phone number are the same both for the Google and TestingContacts raw contact and the framework should automatically aggregate these two raw contacts into one contact (and yes it does). Below is the raw contacts table:
And the contacts table:
You can see that name_raw_contact_id references the Google raw contact.
Here is how it looks like in contacts app:
Then, I change the name of the google contact from "Atakan Kaya" to "Atakan". But as soon as I save it, the name on the contact list does not change! However, if I get back to the Edit Contact Screen, I can see that it is changed for Google contact.
This is a very strange problem for the user. Because that name field is the only editable name field for that contact and no matter how the user changes it, the new name is not reflected in the list.
I investigated the contacts2.db, and here is the raw contacts table:
And here is the contacts table:
You can see that editing the name caused a change in the name_raw_contact_id column. I changed the name of the Google contact and now the display name source changed to the TestingContacts raw contact which is of course not editable! So, why this behaviour?
And more interestingly, I've checked my sync adapter configurations:
<?xml version="1.0" encoding="utf-8"?>
<sync-adapter
xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="com.android.contacts"
android:accountType="com.atakankaya.testingcontacts"
android:userVisible="false"
android:supportsUploading="true"
android:allowParallelSyncs="false"
android:isAlwaysSyncable="true"/>
And if I change the android:supportsUploading to false, then this strange behaviour is gone but this means that any changes made on contact list will not trigger the sync adapter! And that's absolutely not what I want.
This issue happens on multiple devices/api levels.
So, why do we have this strange behaviour and how can I use the sync adapter preventing this issue but without disabling it?