From 59da135e15756675e9ac6b7ff761eab59299a1dd Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Fri, 9 Oct 2009 14:34:01 -0700 Subject: [PATCH] Allow photo changes to be uploaded to Exchange (fixes #2179082) Change-Id: I5de51a4313c43dbe4e3d12d4d0e11b20adedaa8f --- .../exchange/adapter/ContactsSyncAdapter.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/com/android/exchange/adapter/ContactsSyncAdapter.java b/src/com/android/exchange/adapter/ContactsSyncAdapter.java index fff64000d..122835482 100644 --- a/src/com/android/exchange/adapter/ContactsSyncAdapter.java +++ b/src/com/android/exchange/adapter/ContactsSyncAdapter.java @@ -1628,6 +1628,15 @@ public class ContactsSyncAdapter extends AbstractSyncAdapter { } } + private void sendPhoto(Serializer s, ContentValues cv) throws IOException { + if (cv.containsKey(Photo.PHOTO)) { + byte[] bytes = cv.getAsByteArray(Photo.PHOTO); + byte[] encodedBytes = Base64.encodeBase64(bytes); + String pic = new String(encodedBytes); + s.data(Tags.CONTACTS_PICTURE, pic); + } + } + private void sendOrganization(Serializer s, ContentValues cv) throws IOException { if (cv.containsKey(Organization.TITLE)) { s.data(Tags.CONTACTS_JOB_TITLE, cv.getAsString(Organization.TITLE)); @@ -1854,8 +1863,7 @@ public class ContactsSyncAdapter extends AbstractSyncAdapter { } else if (mimeType.equals(Note.CONTENT_ITEM_TYPE)) { sendNote(s, cv); } else if (mimeType.equals(Photo.CONTENT_ITEM_TYPE)) { - // For now, the user can change the photo, but the change won't be - // uploaded. + sendPhoto(s, cv); } else { userLog("Contacts upsync, unknown data: ", mimeType); }