Giter Site home page Giter Site logo

Comments (11)

rfc2822 avatar rfc2822 commented on May 27, 2024

Looks like this belongs here to vcard4android.

I think it should be ignored when the photo can't be inserted because of an I/O error (or a ContactsStorageException should be thrown).

Do you maybe have the original vCard?

from vcard4android.

terix2k12 avatar terix2k12 commented on May 27, 2024

Since it contains personal information I obviously have to remove most of the vCard
Original size on disk is 1.61 MB (1,691,648 bytes)

I can decode, save and inspect the image with base64 -d -i photo.txt > foo.jpeg
It syncs well with Thunderbird / CardBook on Windows, so all in all I think the problem is not with the vCard itself.

For another vCard we deleted the image on serverside but then the same StackTrace came up with a different vCard.
So it looks like the Android device somehow does not like the image for some reason.

Should still not break sync for all other contacts imho.

BEGIN:VCARD
VERSION:3.0
PRODID:-//Sabre//Sabre VObject 4.4.3//EN
UID:PSEUDO-b9ab-4d41-b558-83PSEUDO
FN:Erika Mustermann
ADR;TYPE=HOME:;;;;;;
EMAIL;TYPE=WORK:[email protected]
CATEGORIES:mycategory
PHOTO;ENCODING=b;TYPE=JPEG:/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAYEBQYFBAYGBQYH
 BwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wB
 DAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKC
.............
 z9PH0a7jy/Hp12Hw/QL4Uh+Msi+K3P08fQ3isPuy8enW1cq8v4zRQ/GxcetRYu/Yiy+9Lx26KKK
 KKKKKKKKFtX4Cy1yUUUUUUUUUUUUUUUViiiiiisUVmiiiisUUUUViiiiiiiiiiiiiiiisUUUUUU
 Viiiiiiiiiiiiiiiiiiiiiiiij2oooo9iH47KKKKKKKKKKKKKKKKKKKKKKKKxYu//AP/Z
ORG:organisation GmbH
REV:20231206T105228Z
TEL;TYPE=HOME,VOICE;VALUE=UNKNOWN:+4915112345678
END:VCARD

Hope it helps

from vcard4android.

terix2k12 avatar terix2k12 commented on May 27, 2024

Previous vCard is downloaded with Firefox from Nextcloud, if I forward the vCard from my Android devide it is like this

BEGIN:VCARD
VERSION:2.1
N:Mustermann;Erika;;;
FN:Erika Mustermann
TEL;HOME:+4915112345678
EMAIL;WORK:[email protected]
ORG:organisation GmbH
PHOTO;ENCODING=BASE64;JPEG:/9j/4AAQSkZJRgABAQAAAQABAAD/4gHYSUNDX1BST0ZJTEU
 AAQEAAAHIAAAAAAQwAABtbnRyUkdCIFhZWiAH4AABAAEAAAAAAABhY3NwAAAAAAAAAAAAAAAA
..........
 FA+SZJPn00cyNaeKBkLou0cMdwIJ49PNr8ajpSTyoiBvDAj0luOOAcTwhe90Nq58z6QaHq6qY
 z1NRkdDNLK5uXZqdCWP3JJOBjUPBnndTqDw3aHqqp98qUklMD/BDNJEg/0xqPywMAy6YUvD//
 2Q==

END:VCARD

from vcard4android.

rfc2822 avatar rfc2822 commented on May 27, 2024

Thanks for the info, we will try to reproduce and/or make it so that the photo doesn't break sync.

@sunkup Can you please have a look and try to reproduce it and find a better way of handling the exception?

from vcard4android.

sunkup avatar sunkup commented on May 27, 2024

Since it contains personal information I obviously have to remove most of the vCard

Fair, but without the original image I am unsure how to reproduce this in a timely manner. Or does one of you have some leads I could try? ( also asking @rfc2822 )

I think it should be ignored when the photo can't be inserted because of an I/O error (or a ContactsStorageException should be thrown).

If we catch the IOException and ignore it a ContactsStorageException will be thrown. We can of course throw the ContactsStorageException earlier, but it would be thrown in any case.

Should still not break sync for all other contacts imho.

A ContactsStorageException will, be handled as a hard sync error (databaseError), which are not retried. So the remaining contacts would still not be synced.

If this is to be addressed, it should be a separate issue in DAVx5 then:
Because retrying with soft errors does not seem to help save the photo, we would have to ignore (only log) the thrown ContactsStorageExceptions and maybe tell the user that this contact is problematic, without making the exception into a soft or hard sync error.

from vcard4android.

terix2k12 avatar terix2k12 commented on May 27, 2024

Maybe you can just manually throw the android.system.ErrnoException as in the StackTrace?

If you provide me a more private channel I could provide you with the full vCard.

I'll try to get more information inbetween via ADB or maybe compiling the App myself, it has been quite some time though since I worked with Android 😅

from vcard4android.

sunkup avatar sunkup commented on May 27, 2024

Maybe you can just manually throw the android.system.ErrnoException as in the StackTrace?

Yes. And I could also throw the IOException, but then we would not learn why the Android Contact Storage rejects certain images.

If you provide me a more private channel I could provide you with the full vCard.

You are very welcome to send it via our support page: https://www.davx5.com/support/
Otherwise you may send it to [email protected]

I'll try to get more information inbetween via ADB or maybe compiling the App myself, it has been quite some time though since I worked with Android 😅

I don't think that is necessary, since it's not really an issue with DAVx5 as far as I can see?

from vcard4android.

devvv4ever avatar devvv4ever commented on May 27, 2024

Didn't receive any ticket regarding this yes. @terix2k12 please mention the thread here if you send it!

from vcard4android.

rfc2822 avatar rfc2822 commented on May 27, 2024

A ContactsStorageException will, be handled as a hard sync error (databaseError), which are not retried. So the remaining contacts would still not be synced.

Yes, ContactsStorageException is designed as hard error.

In the current case, I'm voting for ignoring the I/O error when the photo can't be inserted and just log a warning. It may be that Android doesn't understand the photo and this shouldn't prevent synchronization of the contact.

So basically we just need a try/catch around

provider.openAssetFile(uri, "w")?.use { fd ->
fd.createOutputStream()?.use { os ->
os.write(data)
}
}

and log a warning when an (IO?)Exception arrives.

from vcard4android.

sunkup avatar sunkup commented on May 27, 2024

openAssetFile() does not throw an IOException, but FileNotFoundException and RemoteException. So a try/catch around createOutputStream() would suffice.

In any case, doing only this will not prevent the ContactsStorageException from being thrown a few lines later (photoUri will be null):

if (photoUri != null)
Constants.log.log(Level.FINE, "Photo has been inserted: $photoUri")
else
throw ContactsStorageException("Couldn't store contact photo")

We'd have to log the failed photo save here too, instead of throwing the exception.

See d9fd2e9

from vcard4android.

terix2k12 avatar terix2k12 commented on May 27, 2024

@devvv4ever I'd like to speak with the person first, if she will agree to send the image.

My gut feeling is rather, that it is not a problem with the vCard itself. Since the method signature receives a ByteArray, I guess the array breaks somewhere higher in the call stack. -> Still trying to reproduce locally and collect more information. Will come back to you then.

The ContactsStorageException is not even thrown in the first place, right? Because the Exception prevents the code from reaching the (photoUri != null) check you cited.

I can't tell which behavior the ContactSotrageExcetion will have, so this PR looks good to me, since it improves the exception handling in PhotoBuilder.kt It just leaves the photo on Contact as null but will probaly continue syncing the remaining contacts.

from vcard4android.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.