From faae6edc55d0c20b62257f4e78684a2d90428272 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Wed, 30 Sep 2009 22:09:26 -0700 Subject: [PATCH] Fix problem in which email/phone #'s could get erased erroneously * Fixes #2158960 * Needed to keep track of existing untyped phone/email data Change-Id: I5e58f092a35253ee785521fad6a2be7f1d2f4d6b --- .../exchange/adapter/ContactsSyncAdapter.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/com/android/exchange/adapter/ContactsSyncAdapter.java b/src/com/android/exchange/adapter/ContactsSyncAdapter.java index 3348755ea..3557edc9b 100644 --- a/src/com/android/exchange/adapter/ContactsSyncAdapter.java +++ b/src/com/android/exchange/adapter/ContactsSyncAdapter.java @@ -1330,20 +1330,21 @@ public class ContactsSyncAdapter extends AbstractSyncAdapter { public void addUntyped(Entity entity, ArrayList rows, String mimeType, int type, int maxRows) { // Make a list of all same type rows in the existing entity - ArrayList oldAccounts = new ArrayList(); + ArrayList oldValues = new ArrayList(); + ArrayList entityValues = entity.getSubValues(); if (entity != null) { - oldAccounts = findUntypedData(entity.getSubValues(), type, mimeType); + oldValues = findUntypedData(entityValues, type, mimeType); } // These will be rows needing replacement with new values ArrayList rowsToReplace = new ArrayList(); // The count of existing rows - int numRows = oldAccounts.size(); + int numRows = oldValues.size(); for (UntypedRow row: rows) { boolean found = false; - // If we already have this IM address, mark it - for (NamedContentValues ncv: oldAccounts) { + // If we already have this row, mark it + for (NamedContentValues ncv: oldValues) { ContentValues cv = ncv.values; String data = cv.getAsString(COMMON_DATA_ROW); int rowType = -1; @@ -1352,6 +1353,8 @@ public class ContactsSyncAdapter extends AbstractSyncAdapter { } if (row.isSameAs(rowType, data)) { cv.put(FOUND_DATA_ROW, true); + // Remove this to indicate it's still being used + entityValues.remove(ncv); found = true; break; } @@ -1373,7 +1376,7 @@ public class ContactsSyncAdapter extends AbstractSyncAdapter { // Go through rows needing replacement for (UntypedRow row: rowsToReplace) { - for (NamedContentValues ncv: oldAccounts) { + for (NamedContentValues ncv: oldValues) { ContentValues cv = ncv.values; // Find a row that hasn't been used (i.e. doesn't match current rows) if (!cv.containsKey(FOUND_DATA_ROW)) {