diff --git a/src/com/android/exchange/adapter/ContactsSyncAdapter.java b/src/com/android/exchange/adapter/ContactsSyncAdapter.java index 91e5be4dc..7affb7fc7 100644 --- a/src/com/android/exchange/adapter/ContactsSyncAdapter.java +++ b/src/com/android/exchange/adapter/ContactsSyncAdapter.java @@ -104,6 +104,8 @@ public class ContactsSyncAdapter extends AbstractSyncAdapter { return p.parse(); } + // YomiFirstName, YomiLastName, and YomiCompanyName are the names of EAS fields + // Yomi is a shortened form of yomigana, which is a Japanese phonetic rendering. public static final class Yomi { private Yomi() {} @@ -494,6 +496,17 @@ public class ContactsSyncAdapter extends AbstractSyncAdapter { if (companyName != null) { ops.addOrganization(entity, Organization.TYPE_WORK, companyName, title); } + + if (entity != null) { + // We've been removing rows from the list as they've been found in the xml + // Any that are left must have been deleted on the server + ArrayList ncvList = entity.getSubValues(); + for (NamedContentValues ncv: ncvList) { + // These rows need to be deleted... + Uri u = dataUriFromNamedContentValues(ncv); + ops.add(ContentProviderOperation.newDelete(u).build()); + } + } } private void categoriesParser(ContactOperations ops, Entity entity) throws IOException { @@ -776,17 +789,6 @@ public class ContactsSyncAdapter extends AbstractSyncAdapter { } } - /** - * Generate the uri for the data row associated with this NamedContentValues object - * @param ncv the NamedContentValues object - * @return a uri that can be used to refer to this row - */ - private Uri dataUriFromNamedContentValues(NamedContentValues ncv) { - long id = ncv.values.getAsLong(RawContacts._ID); - Uri dataUri = ContentUris.withAppendedId(ncv.uri, id); - return dataUri; - } - /** * Given the list of NamedContentValues for an entity, a mime type, and a subtype, * tries to find a match, returning it @@ -1116,6 +1118,17 @@ public class ContactsSyncAdapter extends AbstractSyncAdapter { } } + /** + * Generate the uri for the data row associated with this NamedContentValues object + * @param ncv the NamedContentValues object + * @return a uri that can be used to refer to this row + */ + public Uri dataUriFromNamedContentValues(NamedContentValues ncv) { + long id = ncv.values.getAsLong(RawContacts._ID); + Uri dataUri = ContentUris.withAppendedId(ncv.uri, id); + return dataUri; + } + @Override public void cleanup(EasSyncService service) { // Mark the changed contacts dirty = 0