Merge "Ensure there is always a photo and name values deltas" into ub-contactsdialer-a-dev
diff --git a/src/com/android/contacts/editor/KindSectionDataList.java b/src/com/android/contacts/editor/KindSectionDataList.java
index 7a7dec2..07c8158 100644
--- a/src/com/android/contacts/editor/KindSectionDataList.java
+++ b/src/com/android/contacts/editor/KindSectionDataList.java
@@ -105,11 +105,13 @@
// Just return the first writable entry.
for (KindSectionData kindSectionData : this) {
if (kindSectionData.getAccountType().areContactsWritable()) {
- RawContactModifier.ensureKindExists(kindSectionData.getRawContactDelta(),
- kindSectionData.getAccountType(),
- ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE);
vlog(mimeType + ": falling back to first kind section data to write");
- return new Pair<>(kindSectionData, kindSectionData.getValuesDeltas().get(0));
+ RawContactModifier.ensureKindExists(kindSectionData.getRawContactDelta(),
+ kindSectionData.getAccountType(), mimeType);
+ if (kindSectionData.getValuesDeltas() != null &&
+ !kindSectionData.getValuesDeltas().isEmpty()) {
+ return new Pair<>(kindSectionData, kindSectionData.getValuesDeltas().get(0));
+ }
}
}