Handle null returns from insertChild
insertChild() returns null whenever kind is null. Don't crash in these cases.
Bug:12490438
Change-Id: Idf1cd8fa9d6dfe6a2f91f3ff656663f0692f4a3f
diff --git a/src/com/android/contacts/detail/ContactDetailFragment.java b/src/com/android/contacts/detail/ContactDetailFragment.java
index abaa8eb..629e36b 100644
--- a/src/com/android/contacts/detail/ContactDetailFragment.java
+++ b/src/com/android/contacts/detail/ContactDetailFragment.java
@@ -2066,6 +2066,7 @@
GroupMembership.CONTENT_ITEM_TYPE);
final ValuesDelta entry = RawContactModifier.insertChild(rawContactEntityDelta,
groupMembershipKind);
+ if (entry == null) return;
entry.setGroupRowId(defaultGroupId);
// and fire off the intent. we don't need a callback, as the database listener
diff --git a/src/com/android/contacts/editor/GroupMembershipView.java b/src/com/android/contacts/editor/GroupMembershipView.java
index db389fb..510d257 100644
--- a/src/com/android/contacts/editor/GroupMembershipView.java
+++ b/src/com/android/contacts/editor/GroupMembershipView.java
@@ -369,7 +369,9 @@
long groupId = item.getGroupId();
if (item.isChecked() && !hasMembership(groupId)) {
ValuesDelta entry = RawContactModifier.insertChild(mState, mKind);
- entry.setGroupRowId(groupId);
+ if (entry != null) {
+ entry.setGroupRowId(groupId);
+ }
}
}
diff --git a/src/com/android/contacts/editor/RawContactEditorView.java b/src/com/android/contacts/editor/RawContactEditorView.java
index c9d3c33..7fcdb7d 100644
--- a/src/com/android/contacts/editor/RawContactEditorView.java
+++ b/src/com/android/contacts/editor/RawContactEditorView.java
@@ -391,7 +391,9 @@
long defaultGroupId = getDefaultGroupId();
if (defaultGroupId != -1) {
ValuesDelta entry = RawContactModifier.insertChild(mState, mGroupMembershipKind);
- entry.setGroupRowId(defaultGroupId);
+ if (entry != null) {
+ entry.setGroupRowId(defaultGroupId);
+ }
}
}
}