Fixed groups NPE when creating or editing contact.
Depending on the device state, mGroups may have not been
populated. In this case, we ignore writing groups data.
This may cause data loss of group membership, so the
original bug has been repurposed to fix longer-term.
This fixes http://b/viewIssue?id=1975661
diff --git a/src/com/android/contacts/EditContactActivity.java b/src/com/android/contacts/EditContactActivity.java
index 4d5a669..04ca79a 100644
--- a/src/com/android/contacts/EditContactActivity.java
+++ b/src/com/android/contacts/EditContactActivity.java
@@ -1132,7 +1132,7 @@
mResolver.update(entry.uri, values, null, null);
}
} else if (kind == EditEntry.KIND_GROUP) {
- if (entry.id != 0) {
+ if (entry.id != 0 && mGroups != null) {
for (int g = 0; g < mGroups.length; g++) {
long groupId = getGroupId(mResolver, mGroups[g].toString());
if (mInTheGroup[g]) {
@@ -1259,7 +1259,7 @@
int entryCount = ContactEntryAdapter.countEntries(mSections, false);
for (int i = 0; i < entryCount; i++) {
EditEntry entry = ContactEntryAdapter.getEntry(mSections, i, false);
- if (entry.kind == EditEntry.KIND_GROUP) {
+ if (entry.kind == EditEntry.KIND_GROUP && mGroups != null) {
long contactId = ContentUris.parseId(contactUri);
for (int g = 0; g < mGroups.length; g++) {
if (mInTheGroup[g]) {