Delete rows that are unused when changes are synced down
diff --git a/src/com/android/exchange/adapter/ContactsSyncAdapter.java b/src/com/android/exchange/adapter/ContactsSyncAdapter.java
index 91e5be4..7affb7f 100644
--- a/src/com/android/exchange/adapter/ContactsSyncAdapter.java
+++ b/src/com/android/exchange/adapter/ContactsSyncAdapter.java
@@ -104,6 +104,8 @@
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 @@
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<NamedContentValues> 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 {
@@ -777,17 +790,6 @@
}
/**
- * 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
* @param list the list of NCV's from the contact entity
@@ -1116,6 +1118,17 @@
}
}
+ /**
+ * 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