mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Add initial support for Group Calling.
This commit is contained in:
@@ -6,6 +6,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import org.signal.storageservice.protos.groups.GroupExternalCredential;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedGroupJoinInfo;
|
||||
import org.signal.zkgroup.VerificationFailedException;
|
||||
@@ -25,7 +26,9 @@ import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class GroupManager {
|
||||
|
||||
@@ -390,6 +393,19 @@ public final class GroupManager {
|
||||
new GroupManagerV2(context).sendNoopGroupUpdate(groupMasterKey, currentState);
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
public static @NonNull GroupExternalCredential getGroupExternalCredential(@NonNull Context context,
|
||||
@NonNull GroupId.V2 groupId)
|
||||
throws IOException, VerificationFailedException
|
||||
{
|
||||
return new GroupManagerV2(context).getGroupExternalCredential(groupId);
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
public static @NonNull Map<UUID, UuidCiphertext> getUuidCipherTexts(@NonNull Context context, @NonNull GroupId.V2 groupId) {
|
||||
return new GroupManagerV2(context).getUuidCipherTexts(groupId);
|
||||
}
|
||||
|
||||
public static class GroupActionResult {
|
||||
private final Recipient groupRecipient;
|
||||
private final long threadId;
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.google.protobuf.InvalidProtocolBufferException;
|
||||
|
||||
import org.signal.storageservice.protos.groups.AccessControl;
|
||||
import org.signal.storageservice.protos.groups.GroupChange;
|
||||
import org.signal.storageservice.protos.groups.GroupExternalCredential;
|
||||
import org.signal.storageservice.protos.groups.Member;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedGroupChange;
|
||||
@@ -22,6 +23,7 @@ import org.signal.storageservice.protos.groups.local.DecryptedPendingMember;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedRequestingMember;
|
||||
import org.signal.zkgroup.InvalidInputException;
|
||||
import org.signal.zkgroup.VerificationFailedException;
|
||||
import org.signal.zkgroup.groups.ClientZkGroupCipher;
|
||||
import org.signal.zkgroup.groups.GroupMasterKey;
|
||||
import org.signal.zkgroup.groups.GroupSecretParams;
|
||||
import org.signal.zkgroup.groups.UuidCiphertext;
|
||||
@@ -30,7 +32,6 @@ import org.signal.zkgroup.profiles.ProfileKeyCredential;
|
||||
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2Context;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
@@ -69,8 +70,10 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@@ -109,6 +112,35 @@ final class GroupManagerV2 {
|
||||
authorization.getAuthorizationForToday(Recipient.self().requireUuid(), groupSecretParams));
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
@NonNull GroupExternalCredential getGroupExternalCredential(@NonNull GroupId.V2 groupId)
|
||||
throws IOException, VerificationFailedException
|
||||
{
|
||||
GroupMasterKey groupMasterKey = DatabaseFactory.getGroupDatabase(context)
|
||||
.requireGroup(groupId)
|
||||
.requireV2GroupProperties()
|
||||
.getGroupMasterKey();
|
||||
|
||||
GroupSecretParams groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupMasterKey);
|
||||
|
||||
return groupsV2Api.getGroupExternalCredential(authorization.getAuthorizationForToday(Recipient.self().requireUuid(), groupSecretParams));
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
@NonNull Map<UUID, UuidCiphertext> getUuidCipherTexts(@NonNull GroupId.V2 groupId) {
|
||||
GroupDatabase.GroupRecord groupRecord = DatabaseFactory.getGroupDatabase(context).requireGroup(groupId);
|
||||
GroupMasterKey groupMasterKey = groupRecord.requireV2GroupProperties().getGroupMasterKey();
|
||||
ClientZkGroupCipher clientZkGroupCipher = new ClientZkGroupCipher(GroupSecretParams.deriveFromMasterKey(groupMasterKey));
|
||||
List<Recipient> recipients = Recipient.resolvedList(groupRecord.getMembers());
|
||||
|
||||
Map<UUID, UuidCiphertext> uuidCipherTexts = new HashMap<>();
|
||||
for (Recipient recipient : recipients) {
|
||||
uuidCipherTexts.put(recipient.requireUuid(), clientZkGroupCipher.encryptUuid(recipient.requireUuid()));
|
||||
}
|
||||
|
||||
return uuidCipherTexts;
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
GroupCreator create() throws GroupChangeBusyException {
|
||||
return new GroupCreator(GroupsV2ProcessingLock.acquireGroupProcessingLock());
|
||||
|
||||
Reference in New Issue
Block a user