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
This commit is contained in:
parent
1e3ac08a3f
commit
faae6edc55
@ -1330,20 +1330,21 @@ public class ContactsSyncAdapter extends AbstractSyncAdapter {
|
|||||||
public void addUntyped(Entity entity, ArrayList<UntypedRow> rows, String mimeType,
|
public void addUntyped(Entity entity, ArrayList<UntypedRow> rows, String mimeType,
|
||||||
int type, int maxRows) {
|
int type, int maxRows) {
|
||||||
// Make a list of all same type rows in the existing entity
|
// Make a list of all same type rows in the existing entity
|
||||||
ArrayList<NamedContentValues> oldAccounts = new ArrayList<NamedContentValues>();
|
ArrayList<NamedContentValues> oldValues = new ArrayList<NamedContentValues>();
|
||||||
|
ArrayList<NamedContentValues> entityValues = entity.getSubValues();
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
oldAccounts = findUntypedData(entity.getSubValues(), type, mimeType);
|
oldValues = findUntypedData(entityValues, type, mimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
// These will be rows needing replacement with new values
|
// These will be rows needing replacement with new values
|
||||||
ArrayList<UntypedRow> rowsToReplace = new ArrayList<UntypedRow>();
|
ArrayList<UntypedRow> rowsToReplace = new ArrayList<UntypedRow>();
|
||||||
|
|
||||||
// The count of existing rows
|
// The count of existing rows
|
||||||
int numRows = oldAccounts.size();
|
int numRows = oldValues.size();
|
||||||
for (UntypedRow row: rows) {
|
for (UntypedRow row: rows) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
// If we already have this IM address, mark it
|
// If we already have this row, mark it
|
||||||
for (NamedContentValues ncv: oldAccounts) {
|
for (NamedContentValues ncv: oldValues) {
|
||||||
ContentValues cv = ncv.values;
|
ContentValues cv = ncv.values;
|
||||||
String data = cv.getAsString(COMMON_DATA_ROW);
|
String data = cv.getAsString(COMMON_DATA_ROW);
|
||||||
int rowType = -1;
|
int rowType = -1;
|
||||||
@ -1352,6 +1353,8 @@ public class ContactsSyncAdapter extends AbstractSyncAdapter {
|
|||||||
}
|
}
|
||||||
if (row.isSameAs(rowType, data)) {
|
if (row.isSameAs(rowType, data)) {
|
||||||
cv.put(FOUND_DATA_ROW, true);
|
cv.put(FOUND_DATA_ROW, true);
|
||||||
|
// Remove this to indicate it's still being used
|
||||||
|
entityValues.remove(ncv);
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1373,7 +1376,7 @@ public class ContactsSyncAdapter extends AbstractSyncAdapter {
|
|||||||
|
|
||||||
// Go through rows needing replacement
|
// Go through rows needing replacement
|
||||||
for (UntypedRow row: rowsToReplace) {
|
for (UntypedRow row: rowsToReplace) {
|
||||||
for (NamedContentValues ncv: oldAccounts) {
|
for (NamedContentValues ncv: oldValues) {
|
||||||
ContentValues cv = ncv.values;
|
ContentValues cv = ncv.values;
|
||||||
// Find a row that hasn't been used (i.e. doesn't match current rows)
|
// Find a row that hasn't been used (i.e. doesn't match current rows)
|
||||||
if (!cv.containsKey(FOUND_DATA_ROW)) {
|
if (!cv.containsKey(FOUND_DATA_ROW)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user