Fix crash when processing group updates with remapped members.
This commit is contained in:
parent
8c34357cc6
commit
b69ffe4e15
1 changed files with 10 additions and 4 deletions
|
@ -581,7 +581,7 @@ private static final String[] GROUP_PROJECTION = {
|
|||
throw new AssertionError("V2 master key but no group state");
|
||||
}
|
||||
groupId.requireV2();
|
||||
groupMembers = getV2GroupMembers(context, groupState);
|
||||
groupMembers = getV2GroupMembers(context, groupState, true);
|
||||
contentValues.put(V2_MASTER_KEY, groupMasterKey.serialize());
|
||||
contentValues.put(V2_REVISION, groupState.getRevision());
|
||||
contentValues.put(V2_DECRYPTED_GROUP, groupState.toByteArray());
|
||||
|
@ -720,7 +720,7 @@ private static final String[] GROUP_PROJECTION = {
|
|||
contentValues.put(UNMIGRATED_V1_MEMBERS, unmigratedV1Members.isEmpty() ? null : RecipientId.toSerializedList(unmigratedV1Members));
|
||||
}
|
||||
|
||||
List<RecipientId> groupMembers = getV2GroupMembers(context, decryptedGroup);
|
||||
List<RecipientId> groupMembers = getV2GroupMembers(context, decryptedGroup, true);
|
||||
contentValues.put(TITLE, title);
|
||||
contentValues.put(V2_REVISION, decryptedGroup.getRevision());
|
||||
contentValues.put(V2_DECRYPTED_GROUP, decryptedGroup.toByteArray());
|
||||
|
@ -894,12 +894,18 @@ private static final String[] GROUP_PROJECTION = {
|
|||
return groupMembers;
|
||||
}
|
||||
|
||||
private static @NonNull List<RecipientId> getV2GroupMembers(@NonNull Context context, @NonNull DecryptedGroup decryptedGroup) {
|
||||
private static @NonNull List<RecipientId> getV2GroupMembers(@NonNull Context context, @NonNull DecryptedGroup decryptedGroup, boolean shouldRetry) {
|
||||
List<UUID> uuids = DecryptedGroupUtil.membersToUuidList(decryptedGroup.getMembersList());
|
||||
List<RecipientId> ids = uuidsToRecipientIds(uuids);
|
||||
|
||||
if (RemappedRecords.getInstance().areAnyRemapped(ids)) {
|
||||
if (shouldRetry) {
|
||||
Log.w(TAG, "Found remapped records where we shouldn't. Clearing cache and trying again.");
|
||||
RecipientId.clearCache();
|
||||
return getV2GroupMembers(context, decryptedGroup, false);
|
||||
} else {
|
||||
throw new IllegalStateException("Remapped records in group membership!");
|
||||
}
|
||||
} else {
|
||||
return ids;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue