bitfireAT / vcard4android

Allows usage of vCard resources with the Android contacts provider
GNU General Public License v3.0
11 stars 6 forks source link

Birthdays not synced from Nextcloud 27 to Android 12/13 #24

Closed rfc2822 closed 11 months ago

rfc2822 commented 1 year ago

Discussed in https://github.com/bitfireAT/davx5-ose/discussions/385

Originally posted by **fwiep** August 22, 2023 Hello, Using DAVx5 v4.3.5.2 from F-Droid on several devices, both Android 12.1 (2x custom built LineageOS) and Android 13 (1x stock Samsung UI). Since about one week, all contacts no longer have their birthdays set on the Android device. In the Nextcloud, all is well and all the dates are present and shown on screen. I have tried to clear the Contacts-app cache, even installed an extra (official Google) Contacts app to compare the result. On all three devices, not a single birthday is shown. The Contact app allows me to add a birthday to the contact, but via DAVx5, no birthday gets synchronized. When I edit, say the 'Notes' field of a contact in the Nextcloud, then sync through DAVx5, this modification shows up instantly. How can I get the birthdays back into my Android contacts? How should I debug this issue? I have collected a sync's verbose logfile, but no error is shown. Thanks for your help, FWieP
rfc2822 commented 1 year ago

@ArnyminerZ Can you please have a look (reproduce with a test first)? I think EventBuilder.buildEvent should handle dates with time zone, too (in the when (date) { … }) to support this specific case. Since we can't store time zone info in the contacts provider, we have to convert it into UTC.

ArnyminerZ commented 1 year ago

Reproduced with a copy-paste of testType_Birthday:

@Test
fun testType_BirthdayWithTimezone() {
    EventBuilder(Uri.EMPTY, null, Contact().apply {
        birthDay = Birthday("19510311T000000+0100")
    }, false).build().also { result ->
        assertEquals(CommonDataKinds.Event.TYPE_BIRTHDAY, result[0].values[CommonDataKinds.Event.TYPE])
    }
}
devvv4ever commented 11 months ago

Does unfortunately not seem to be fixed in 4.3.9 yet :-/

This is the vcard:

BEGIN:VCARD
VERSION:3.0
PRODID:-//Sabre//Sabre VObject 4.4.2//EN
UID:LcjQnxjYhKYC9CZtYSgAnkDwrg6QDk-1345-0-0
N:Doe;John;;;
FN:John Doe
BDAY:20010415T000000+0200
ITEM1.ADR:;; ;;;;Nederland
ITEM1.X-ABLABEL:Home
CATEGORIES:_personen
GENDER:M
END:VCARD

From the logs:

2023-10-31 21:53:03 46 [network.HttpClient] <?xml version="1.0"?>
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns"><d:response><d:href>/remote.php/dav/addressbooks/users/frara/contacts/LcjQnxjYhKYC9CZtYSgAnkDwrg6QDk-1345-0-0.vcf</d:href><d:propstat><d:prop><d:getcontenttype>text/vcard; charset=utf-8</d:getcontenttype><d:getetag>&quot;6d9b6a752c6858863a9018759b9dd5ae&quot;</d:getetag><card:address-data>BEGIN:VCARD&#13;
VERSION:4.0&#13;
PRODID:-//Sabre//Sabre VObject 4.5.3//EN&#13;
UID:LcjQnxjYhKYC9CZtYSgAnkDwrg6QDk-1345-0-0&#13;
N:Doe;John;;;&#13;
FN:John Doe&#13;
BDAY:20010415T000000+0200&#13;
ITEM1.ADR:;; ;;;;Nederland&#13;
ITEM1.X-ABLABEL:Home&#13;
CATEGORIES:_personen&#13;
GENDER:M&#13;
END:VCARD&#13;
</card:address-data></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response></d:multistatus>

2023-10-31 21:53:03 46 [network.HttpClient] <-- END HTTP (905-byte body)
2023-10-31 21:53:03 46 [syncadapter.ContactsSyncManager] Processing CardDAV resource LcjQnxjYhKYC9CZtYSgAnkDwrg6QDk-1345-0-0.vcf
2023-10-31 21:53:03 46 [syncadapter.ContactsSyncManager] Creating local contact
    PARAMETER #0 = at.bitfire.vcard4android.Contact@4ce9893[addresses=[LabeledProperty(property=ezvcard.property.Address [ group=ITEM1 | parameters={} | poBoxes=[] | extendedAddresses=[] | streetAddresses=[ ] | localities=[] | regions=[] | postalCodes=[] | countries=[Nederland] ], label=Home)],anniversary=<null>,birthDay=ezvcard.property.Birthday [ group=null | parameters={} | text=null | date=2001-04-15T00:00+02:00 | partialDate=null ],categories=[_personen],customDates=[],displayName=John Doe,emails=[],familyName=Doe,givenName=John,group=false,impps=[],jobDescription=<null>,jobTitle=<null>,members=[],middleName=<null>,nickName=<null>,note=<null>,organization=<null>,phoneNumbers=[],phoneticFamilyName=<null>,phoneticGivenName=<null>,phoneticMiddleName=<null>,prefix=<null>,relations=[],suffix=<null>,uid=LcjQnxjYhKYC9CZtYSgAnkDwrg6QDk-1345-0-0,unknownProperties=BEGIN:VCARD
VERSION:4.0
GENDER:M
END:VCARD
,urls=[]]
2023-10-31 21:53:03 46 [contactrow.EventBuilder] Ignoring date/time without supported (partial) date
    PARAMETER #0 = ezvcard.property.Birthday [ group=null | parameters={} | text=null | date=2001-04-15T00:00+02:00 | partialDate=null ]
2023-10-31 21:53:03 46 [BatchOperation] Committing 5 operations:
2023-10-31 21:53:03 46 [BatchOperation] #0: ContentProviderOperation(type=insert uri=content://com.android.contacts/raw_contacts?caller_is_syncadapter=true&account_name=Contactpersonen%20(fwiep%40fwiep.nl%206A)&account_type=at.bitfire.davdroid.address_book values={dirty=0, sync1=LcjQnxjYhKYC9CZtYSgAnkDwrg6QDk-1345-0-0, sync2=6d9b6a752c6858863a9018759b9dd5ae, sync4=1, account_name=Contactpersonen (fwiep@fwiep.nl 6A), account_type=at.bitfire.davdroid.address_book, deleted=0, sourceid=LcjQnxjYhKYC9CZtYSgAnkDwrg6QDk-1345-0-0.vcf})
2023-10-31 21:53:03 46 [BatchOperation] #1: ContentProviderOperation(type=insert uri=content://com.android.contacts/data?caller_is_syncadapter=true&account_name=Contactpersonen%20(fwiep%40fwiep.nl%206A)&account_type=at.bitfire.davdroid.address_book values={mimetype=vnd.android.cursor.item/name, raw_contact_id=android.content.ContentProviderOperation$BackReference@325f0d0, data1=John Doe, data2=John, data3=Doe, data4=null, data5=null, data6=null, data7=null, data8=null, data9=null})
2023-10-31 21:53:03 46 [BatchOperation] #2: ContentProviderOperation(type=insert uri=content://com.android.contacts/data?caller_is_syncadapter=true&account_name=Contactpersonen%20(fwiep%40fwiep.nl%206A)&account_type=at.bitfire.davdroid.address_book values={mimetype=vnd.android.cursor.item/postal-address_v2, data10=Nederland, raw_contact_id=android.content.ContentProviderOperation$BackReference@76718c9, data1=Nederland, data2=0, data3=Home, data4= , data5=, data6=, data7=, data8=, data9=})
2023-10-31 21:53:03 46 [BatchOperation] #3: ContentProviderOperation(type=insert uri=content://com.android.contacts/data?caller_is_syncadapter=true&account_name=Contactpersonen%20(fwiep%40fwiep.nl%206A)&account_type=at.bitfire.davdroid.address_book values={mimetype=vnd.android.cursor.item/group_membership, raw_contact_id=android.content.ContentProviderOperation$BackReference@4e8fbce, data1=44})
2023-10-31 21:53:03 46 [BatchOperation] #4: ContentProviderOperation(type=insert uri=content://com.android.contacts/data?caller_is_syncadapter=true&account_name=Contactpersonen%20(fwiep%40fwiep.nl%206A)&account_type=at.bitfire.davdroid.address_book values={mimetype=x.davdroid/unknown-properties, raw_contact_id=android.content.ContentProviderOperation$BackReference@3402aef, data1=BEGIN:VCARD
VERSION:4.0
GENDER:M
END:VCARD
})
2023-10-31 21:53:03 46 [BatchOperation] Running 5 operations (0 .. 4)
2023-10-31 21:53:03 46 [BatchOperation] … 5 record(s) affected

I also noticed that there is a "&# 13;" at the end of each line of the processed vcard. Does this has something to do with it?

Please can you check again whats the case with this vcard? @ArnyminerZ

Reference: Zammad #2891

rfc2822 commented 11 months ago

Guess that's becauseVCardDateFormat.parse creates an OffsetDateTime, not a ZonedDateTime:

https://github.com/mangstadt/ez-vcard/blob/d4c9ab9fb11f4ed6d83c32bdaa2089a73043bd9b/src/main/java/ezvcard/util/VCardDateFormat.java#L185

We should

fwiep commented 11 months ago

Hello again,

I had to wait for F-Droid to build and distribute the 4.3.10-ose package. Now I have tested and the problem is not yet fixed - but I think I know why.

If I compare the used library versions in the app's About dialog, I see the same vcard4android version as with 4.3.9-ose (b376d2e), and not version a7a1f42 which contains the most recent fix.

Is this an issue with F-Droid's build process, or is there another way to get a true-full-up-to-date apk for testing?

Thanks and kind regards, FWieP

sunkup commented 11 months ago

@fwiep See https://github.com/bitfireAT/vcard4android/pull/26#issuecomment-1817503478