/** * Build an {@link RawContactDelta} using the given {@link RawContact} as a * starting point; the "before" snapshot. */ public static RawContactDelta fromBefore(RawContact before) { final RawContactDelta rawContactDelta = new RawContactDelta(); rawContactDelta.mValues = ValuesDelta.fromBefore(before.getValues()); rawContactDelta.mValues.setIdColumn(RawContacts._ID); for (final ContentValues values : before.getContentValues()) { rawContactDelta.addEntry(ValuesDelta.fromBefore(values)); } return rawContactDelta; }
/** * Build a list of {@link ContentProviderOperation} that will assert any * "before" state hasn't changed. This is maintained separately so that all * asserts can take place before any updates occur. */ public void buildAssert(ArrayList<ContentProviderOperation> buildInto) { final Builder builder = buildAssertHelper(); if (builder != null) { buildInto.add(builder.build()); } }
@Override public boolean equals(Object object) { if (object instanceof RawContactDelta) { final RawContactDelta other = (RawContactDelta)object; // Equality failed if parent values different if (!other.mValues.equals(mValues)) return false; for (ArrayList<ValuesDelta> mimeEntries : mEntries.values()) { for (ValuesDelta child : mimeEntries) { // Equality failed if any children unmatched if (!other.containsEntry(child)) return false; } } // Passed all tests, so equal return true; } return false; }
/** @hide Public only for testing. */ public static void migrateGenericWithoutTypeColumn( RawContactDelta oldState, RawContactDelta newState, DataKind newDataKind) { final ArrayList<ValuesDelta> mimeEntries = ensureEntryMaxSize(newState, newDataKind, oldState.getMimeEntries(newDataKind.mimeType)); if (mimeEntries == null || mimeEntries.isEmpty()) { return; } for (ValuesDelta entry : mimeEntries) { ContentValues values = entry.getAfter(); if (values != null) { newState.addEntry(ValuesDelta.fromAfter(values)); } } }
if (local == null) local = new RawContactDelta(); final ValuesDelta localEntry = local.getEntry(childId); final ValuesDelta merged = ValuesDelta.mergeAfter(localEntry, remoteEntry); local.addEntry(merged);
delta.buildAssert(diff); final boolean isInsert = delta.isContactInsert(); backRefs[rawContactIndex++] = isInsert ? firstBatch : -1; delta.buildDiff(diff);
delta.buildAssertWrapper(diffWrapper); final boolean isInsert = delta.isContactInsert(); backRefs[rawContactIndex++] = isInsert ? firstBatch : -1; delta.buildDiffWrapper(diffWrapper);
possibleAdd(buildInto, builder); possibleAdd(buildInto, builder); if (addedOperations && isContactUpdate) { builder = buildSetAggregationMode(beforeId, RawContacts.AGGREGATION_MODE_SUSPENDED); buildInto.add(firstIndex, builder.build()); builder = buildSetAggregationMode(beforeId, RawContacts.AGGREGATION_MODE_DEFAULT); buildInto.add(builder.build()); } else if (isContactInsert) {
possibleAddWrapper(buildInto, bw); possibleAddWrapper(buildInto, bw); buildSetAggregationMode(beforeId, RawContacts.AGGREGATION_MODE_SUSPENDED); buildInto.add(firstIndex, new CPOWrapper(builder.build(), CompatUtils.TYPE_UPDATE)); builder = buildSetAggregationMode(beforeId, RawContacts.AGGREGATION_MODE_DEFAULT); buildInto.add(new CPOWrapper(builder.build(), CompatUtils.TYPE_UPDATE)); } else if (isContactInsert) {
DataKind newDataKind) { final ContentValues values = oldState.getPrimaryEntry(StructuredName.CONTENT_ITEM_TYPE).getAfter(); if (values == null) { return; newState.addEntry(ValuesDelta.fromAfter(values));
public void readFromParcel(Parcel source) { final ClassLoader loader = getClass().getClassLoader(); final int size = source.readInt(); mValues = source.<ValuesDelta> readParcelable(loader); mContactsQueryUri = source.<Uri> readParcelable(loader); for (int i = 0; i < size; i++) { final ValuesDelta child = source.<ValuesDelta> readParcelable(loader); this.addEntry(child); } }
public void addAll(Iterator<?> iterator) { // Perform background query to pull contact details while (iterator.hasNext()) { // Read all contacts into local deltas to prepare for edits Object nextObject = iterator.next(); final RawContact before = nextObject instanceof Entity ? RawContact.createFrom((Entity) nextObject) : (RawContact) nextObject; final RawContactDelta rawContactDelta = RawContactDelta.fromBefore(before); add(rawContactDelta); } }
DataKind newDataKind, Integer defaultYear) { final ArrayList<ValuesDelta> mimeEntries = ensureEntryMaxSize(newState, newDataKind, oldState.getMimeEntries(Event.CONTENT_ITEM_TYPE)); if (mimeEntries == null || mimeEntries.isEmpty()) { return; newState.addEntry(ValuesDelta.fromAfter(values)); } else {
/** * Insert a new child of kind {@link DataKind} into the given * {@link RawContactDelta}, marked with the given {@link EditType}. */ public static ValuesDelta insertChild(RawContactDelta state, DataKind kind, EditType type) { // Bail early if invalid kind if (kind == null) return null; final ContentValues after = new ContentValues(); // Our parent CONTACT_ID is provided later after.put(Data.MIMETYPE, kind.mimeType); // Fill-in with any requested default values if (kind.defaultValues != null) { after.putAll(kind.defaultValues); } if (kind.typeColumn != null && type != null) { // Set type, if provided after.put(kind.typeColumn, type.rawValue); } final ValuesDelta child = ValuesDelta.fromAfter(after); state.addEntry(child); return child; }
migrateStructuredName(context, oldState, newState, kind); } else { List<ValuesDelta> entryList = oldState.getMimeEntries(mimeType); if (entryList != null && !entryList.isEmpty()) { for (ValuesDelta entry : entryList) { ContentValues values = entry.getAfter(); if (values != null) { newState.addEntry(ValuesDelta.fromAfter(values));
/** * For compatibility purpose, this method is copied from {@link #buildAssert} and takes an * ArrayList of CPOWrapper as parameter. */ public void buildAssertWrapper(ArrayList<CPOWrapper> buildInto) { final Builder builder = buildAssertHelper(); if (builder != null) { buildInto.add(new CPOWrapper(builder.build(), CompatUtils.TYPE_ASSERT)); } }
final ArrayList<ValuesDelta> mimeEntries = oldState.getMimeEntries(newDataKind.mimeType); if (mimeEntries == null || mimeEntries.isEmpty()) { return; newState.addEntry(ValuesDelta.fromAfter(values)); totalCount++;
ArrayList<ValuesDelta> entries = state.getMimeEntries(mimeType); state.addEntry(entry); state.addEntry(entry); } else if (Note.CONTENT_ITEM_TYPE.equals(mimeType)){
DataKind newDataKind) { final ArrayList<ValuesDelta> mimeEntries = ensureEntryMaxSize(newState, newDataKind, oldState.getMimeEntries(StructuredPostal.CONTENT_ITEM_TYPE)); if (mimeEntries == null || mimeEntries.isEmpty()) { return; newState.addEntry(ValuesDelta.fromAfter(values));