mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-23 00:29:59 +01:00
Inline useBinaryId remote config.
This commit is contained in:
committed by
jeffrey-signal
parent
73c3d141e3
commit
e85637a58d
-1
@@ -190,7 +190,6 @@ public class ApplicationDependencyProvider implements AppDependencies.Provider {
|
||||
RemoteConfig.maxEnvelopeSizeBytes(),
|
||||
RemoteConfig.maxIncrementalMacsPerEnvelope(),
|
||||
RemoteConfig::useMessageSendRestFallback,
|
||||
RemoteConfig.useBinaryId(),
|
||||
new PreKeyRepository(
|
||||
keysApi,
|
||||
protocolStore.aci(),
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientUtil;
|
||||
import org.thoughtcrime.securesms.util.AppForegroundObserver;
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
||||
import org.whispersystems.signalservice.api.crypto.AttachmentCipherStreamUtil;
|
||||
@@ -150,7 +149,7 @@ public class MultiDeviceContactUpdateJob extends BaseJob {
|
||||
|
||||
Uri updateUri = null;
|
||||
try {
|
||||
DeviceContactsOutputStream out = new DeviceContactsOutputStream(writeDetails.outputStream, RemoteConfig.useBinaryId());
|
||||
DeviceContactsOutputStream out = new DeviceContactsOutputStream(writeDetails.outputStream);
|
||||
Recipient recipient = Recipient.resolved(recipientId);
|
||||
|
||||
if (recipient.getRegistered() == RecipientTable.RegisteredState.NOT_REGISTERED) {
|
||||
@@ -215,7 +214,7 @@ public class MultiDeviceContactUpdateJob extends BaseJob {
|
||||
|
||||
Uri updateUri = null;
|
||||
try {
|
||||
DeviceContactsOutputStream out = new DeviceContactsOutputStream(writeDetails.outputStream, RemoteConfig.useBinaryId());
|
||||
DeviceContactsOutputStream out = new DeviceContactsOutputStream(writeDetails.outputStream);
|
||||
List<Recipient> recipients = SignalDatabase.recipients().getRecipientsForMultiDeviceSync();
|
||||
Map<RecipientId, Integer> inboxPositions = SignalDatabase.threads().getInboxPositions();
|
||||
Set<RecipientId> archived = SignalDatabase.threads().getArchivedRecipients();
|
||||
|
||||
+1
-2
@@ -15,7 +15,6 @@ import org.thoughtcrime.securesms.jobmanager.impl.SealedSenderConstraint;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.net.NotPushRegisteredException;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
||||
import org.whispersystems.signalservice.api.crypto.AttachmentCipherStreamUtil;
|
||||
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException;
|
||||
@@ -78,7 +77,7 @@ public class MultiDeviceProfileKeyUpdateJob extends BaseJob {
|
||||
}
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
DeviceContactsOutputStream out = new DeviceContactsOutputStream(baos, RemoteConfig.useBinaryId());
|
||||
DeviceContactsOutputStream out = new DeviceContactsOutputStream(baos);
|
||||
|
||||
out.write(new DeviceContact(Optional.ofNullable(SignalStore.account().getAci()),
|
||||
Optional.ofNullable(SignalStore.account().getE164()),
|
||||
|
||||
@@ -161,7 +161,7 @@ object MessageDecryptor {
|
||||
|
||||
val envelope = if (cipherResult?.metadata?.sourceServiceId != null) {
|
||||
envelope.newBuilder()
|
||||
.sourceServiceIdBinary(if (RemoteConfig.useBinaryId) cipherResult.metadata.sourceServiceId.toByteString() else null)
|
||||
.sourceServiceIdBinary(cipherResult.metadata.sourceServiceId.toByteString())
|
||||
.sourceDeviceId(cipherResult.metadata.sourceDeviceId)
|
||||
.build()
|
||||
} else {
|
||||
|
||||
@@ -18,7 +18,6 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.recipients.Recipient.Companion.trustedPush
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncModels.localToRemoteRecord
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig
|
||||
import org.whispersystems.signalservice.api.storage.SignalContactRecord
|
||||
import org.whispersystems.signalservice.api.storage.StorageId
|
||||
import org.whispersystems.signalservice.api.storage.signalAci
|
||||
@@ -238,8 +237,8 @@ class ContactRecordProcessor(
|
||||
pniSignatureVerified = remote.proto.pniSignatureVerified || local.proto.pniSignatureVerified
|
||||
note = remote.proto.note.nullIfBlank() ?: ""
|
||||
avatarColor = if (SignalStore.account.isPrimaryDevice) local.proto.avatarColor else remote.proto.avatarColor
|
||||
aciBinary = if (RemoteConfig.useBinaryId) local.proto.aciBinary.nullIfEmpty() ?: remote.proto.aciBinary else ByteString.EMPTY
|
||||
pniBinary = if (RemoteConfig.useBinaryId) mergedPni?.toByteStringWithoutPrefix() ?: byteArrayOf().toByteString() else ByteString.EMPTY
|
||||
aciBinary = local.proto.aciBinary.nullIfEmpty() ?: remote.proto.aciBinary
|
||||
pniBinary = mergedPni?.toByteStringWithoutPrefix() ?: byteArrayOf().toByteString()
|
||||
}.build().toSignalContactRecord(StorageId.forContact(keyGenerator.generate()))
|
||||
|
||||
val matchesRemote = doParamsMatch(remote, merged)
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.notifications.profiles.NotificationProfile
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress
|
||||
import org.whispersystems.signalservice.api.storage.IAPSubscriptionId
|
||||
import org.whispersystems.signalservice.api.storage.SignalCallLinkRecord
|
||||
@@ -140,7 +139,7 @@ object StorageSyncModels {
|
||||
contact = AccountRecord.PinnedConversation.Contact(
|
||||
serviceId = "",
|
||||
e164 = settings.e164 ?: "",
|
||||
serviceIdBinary = settings.serviceId?.toByteString().takeIf { RemoteConfig.useBinaryId } ?: ByteString.EMPTY
|
||||
serviceIdBinary = settings.serviceId?.toByteString() ?: ByteString.EMPTY
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -217,8 +216,8 @@ object StorageSyncModels {
|
||||
nickname = recipient.nickname.takeUnless { it.isEmpty }?.let { ContactRecord.Name(given = it.givenName, family = it.familyName) }
|
||||
note = recipient.note ?: ""
|
||||
avatarColor = localToRemoteAvatarColor(recipient.avatarColor)
|
||||
aciBinary = recipient.aci?.toByteString()?.takeIf { RemoteConfig.useBinaryId } ?: ByteString.EMPTY
|
||||
pniBinary = recipient.pni?.toByteStringWithoutPrefix()?.takeIf { RemoteConfig.useBinaryId } ?: ByteString.EMPTY
|
||||
aciBinary = recipient.aci?.toByteString() ?: ByteString.EMPTY
|
||||
pniBinary = recipient.pni?.toByteStringWithoutPrefix() ?: ByteString.EMPTY
|
||||
}.build().toSignalContactRecord(StorageId.forContact(rawStorageId))
|
||||
}
|
||||
|
||||
@@ -304,14 +303,10 @@ object StorageSyncModels {
|
||||
identifier = UuidUtil.toByteArray(record.distributionId.asUuid()).toByteString()
|
||||
name = record.name
|
||||
recipientServiceIds = emptyList()
|
||||
recipientServiceIdsBinary = if (RemoteConfig.useBinaryId) {
|
||||
record.getMembersToSync()
|
||||
.map { Recipient.resolved(it) }
|
||||
.filter { it.hasServiceId }
|
||||
.map { it.requireServiceId().toByteString() }
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
recipientServiceIdsBinary = record.getMembersToSync()
|
||||
.map { Recipient.resolved(it) }
|
||||
.filter { it.hasServiceId }
|
||||
.map { it.requireServiceId().toByteString() }
|
||||
allowsReplies = record.allowsReplies
|
||||
isBlockList = record.privacyMode.isBlockList
|
||||
}.build().toSignalStoryDistributionListRecord(StorageId.forStoryDistributionList(rawStorageId))
|
||||
@@ -515,7 +510,7 @@ object StorageSyncModels {
|
||||
contact = RemoteRecipient.Contact(
|
||||
serviceId = "",
|
||||
e164 = recipient.e164 ?: "",
|
||||
serviceIdBinary = recipient.serviceId?.toByteString().takeIf { RemoteConfig.useBinaryId } ?: ByteString.EMPTY
|
||||
serviceIdBinary = recipient.serviceId?.toByteString() ?: ByteString.EMPTY
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1208,15 +1208,6 @@ object RemoteConfig {
|
||||
hotSwappable = true
|
||||
)
|
||||
|
||||
/** Whether or not to send over binary service ids (alongside string service ids). */
|
||||
@JvmStatic
|
||||
@get:JvmName("useBinaryId")
|
||||
val useBinaryId: Boolean by remoteBoolean(
|
||||
key = "android.useBinaryServiceId.2",
|
||||
defaultValue = true,
|
||||
hotSwappable = false
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("backupsMegaphone")
|
||||
val backupsMegaphone: Boolean by remoteBoolean(
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.thoughtcrime.securesms.database.RecipientTable
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.testutil.EmptyLogger
|
||||
import org.thoughtcrime.securesms.testutil.MockAppDependenciesRule
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig
|
||||
import org.whispersystems.signalservice.api.storage.SignalContactRecord
|
||||
import org.whispersystems.signalservice.api.storage.StorageId
|
||||
import org.whispersystems.signalservice.internal.storage.protos.ContactRecord
|
||||
@@ -45,15 +44,11 @@ class ContactRecordProcessorTest {
|
||||
every { SignalStore.account.isPrimaryDevice } returns true
|
||||
every { SignalStore.account.e164 } returns "+11234567890"
|
||||
|
||||
mockkObject(RemoteConfig)
|
||||
every { RemoteConfig.useBinaryId } returns true
|
||||
|
||||
recipientTable = mockk(relaxed = true)
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
unmockkObject(RemoteConfig)
|
||||
unmockkObject(SignalStore)
|
||||
}
|
||||
|
||||
|
||||
+12
-15
@@ -191,7 +191,6 @@ public class SignalServiceMessageSender {
|
||||
private final long maxEnvelopeSize;
|
||||
private final int maxIncrementalMacsPerEnvelope;
|
||||
private final BooleanSupplier useRestFallback;
|
||||
private final boolean useBinaryId;
|
||||
|
||||
public SignalServiceMessageSender(PushServiceSocket pushServiceSocket,
|
||||
SignalServiceDataStore store,
|
||||
@@ -203,7 +202,6 @@ public class SignalServiceMessageSender {
|
||||
long maxEnvelopeSize,
|
||||
int maxIncrementalMacsPerEnvelope,
|
||||
BooleanSupplier useRestFallback,
|
||||
boolean useBinaryId,
|
||||
PreKeyRepository preKeyRepository)
|
||||
{
|
||||
CredentialsProvider credentialsProvider = pushServiceSocket.getCredentialsProvider();
|
||||
@@ -224,7 +222,6 @@ public class SignalServiceMessageSender {
|
||||
this.keysApi = keysApi;
|
||||
this.preKeyRepository = preKeyRepository;
|
||||
this.useRestFallback = useRestFallback;
|
||||
this.useBinaryId = useBinaryId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1058,7 +1055,7 @@ public class SignalServiceMessageSender {
|
||||
DataMessage.Quote.Builder quoteBuilder = new DataMessage.Quote.Builder()
|
||||
.id(message.getQuote().get().getId())
|
||||
.text(message.getQuote().get().getText())
|
||||
.authorAciBinary(useBinaryId ? message.getQuote().get().getAuthor().toByteString() : null)
|
||||
.authorAciBinary(message.getQuote().get().getAuthor().toByteString())
|
||||
.type(message.getQuote().get().getType().getProtoType());
|
||||
|
||||
List<SignalServiceDataMessage.Mention> mentions = message.getQuote().get().getMentions();
|
||||
@@ -1166,7 +1163,7 @@ public class SignalServiceMessageSender {
|
||||
.emoji(message.getReaction().get().getEmoji())
|
||||
.remove(message.getReaction().get().isRemove())
|
||||
.targetSentTimestamp(message.getReaction().get().getTargetSentTimestamp())
|
||||
.targetAuthorAciBinary(useBinaryId ? message.getReaction().get().getTargetAuthor().toByteString() : null);
|
||||
.targetAuthorAciBinary(message.getReaction().get().getTargetAuthor().toByteString());
|
||||
|
||||
builder.reaction(reactionBuilder.build());
|
||||
builder.requiredProtocolVersion(Math.max(DataMessage.ProtocolVersion.REACTIONS.getValue(), builder.requiredProtocolVersion));
|
||||
@@ -1210,7 +1207,7 @@ public class SignalServiceMessageSender {
|
||||
SignalServiceDataMessage.StoryContext storyContext = message.getStoryContext().get();
|
||||
|
||||
builder.storyContext(new DataMessage.StoryContext.Builder()
|
||||
.authorAciBinary(useBinaryId ? storyContext.getAuthorServiceId().toByteString() : null)
|
||||
.authorAciBinary(storyContext.getAuthorServiceId().toByteString())
|
||||
.sentTimestamp(storyContext.getSentTimestamp())
|
||||
.build());
|
||||
}
|
||||
@@ -1434,7 +1431,7 @@ public class SignalServiceMessageSender {
|
||||
}
|
||||
|
||||
unidentifiedDeliveryStatuses.add(new SyncMessage.Sent.UnidentifiedDeliveryStatus.Builder()
|
||||
.destinationServiceIdBinary(useBinaryId ? result.getAddress().getServiceId().toByteString() : null)
|
||||
.destinationServiceIdBinary(result.getAddress().getServiceId().toByteString())
|
||||
.unidentified(false)
|
||||
.destinationPniIdentityKey(identity)
|
||||
.build());
|
||||
@@ -1443,7 +1440,7 @@ public class SignalServiceMessageSender {
|
||||
sentMessage.unidentifiedStatus(unidentifiedDeliveryStatuses);
|
||||
|
||||
if (recipient.isPresent()) {
|
||||
sentMessage.destinationServiceIdBinary(useBinaryId ? recipient.get().getServiceId().toByteString() : null);
|
||||
sentMessage.destinationServiceIdBinary(recipient.get().getServiceId().toByteString());
|
||||
if (recipient.get().getNumber().isPresent()) {
|
||||
sentMessage.destinationE164(recipient.get().getNumber().get());
|
||||
}
|
||||
@@ -1482,7 +1479,7 @@ public class SignalServiceMessageSender {
|
||||
private SyncMessage.Sent.StoryMessageRecipient createStoryMessageRecipient(SignalServiceStoryMessageRecipient storyMessageRecipient) {
|
||||
return new SyncMessage.Sent.StoryMessageRecipient.Builder()
|
||||
.distributionListIds(storyMessageRecipient.getDistributionListIds())
|
||||
.destinationServiceIdBinary(useBinaryId ? storyMessageRecipient.getSignalServiceAddress().getServiceId().toByteString() : null)
|
||||
.destinationServiceIdBinary(storyMessageRecipient.getSignalServiceAddress().getServiceId().toByteString())
|
||||
.isAllowedToReply(storyMessageRecipient.isAllowedToReply())
|
||||
.build();
|
||||
}
|
||||
@@ -1495,7 +1492,7 @@ public class SignalServiceMessageSender {
|
||||
readMessages.stream()
|
||||
.map(readMessage -> new SyncMessage.Read.Builder()
|
||||
.timestamp(readMessage.getTimestamp())
|
||||
.senderAciBinary(useBinaryId ? readMessage.getSenderAci().toByteString() : null)
|
||||
.senderAciBinary(readMessage.getSenderAci().toByteString())
|
||||
.build())
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
@@ -1511,7 +1508,7 @@ public class SignalServiceMessageSender {
|
||||
readMessages.stream()
|
||||
.map(readMessage -> new SyncMessage.Viewed.Builder()
|
||||
.timestamp(readMessage.getTimestamp())
|
||||
.senderAciBinary(useBinaryId ? readMessage.getSender().toByteString() : null)
|
||||
.senderAciBinary(readMessage.getSender().toByteString())
|
||||
.build())
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
@@ -1525,7 +1522,7 @@ public class SignalServiceMessageSender {
|
||||
|
||||
builder.viewOnceOpen(new SyncMessage.ViewOnceOpen.Builder()
|
||||
.timestamp(readMessage.getTimestamp())
|
||||
.senderAciBinary(useBinaryId ? readMessage.getSender().toByteString() : null)
|
||||
.senderAciBinary(readMessage.getSender().toByteString())
|
||||
.build());
|
||||
|
||||
return container.syncMessage(builder.build()).build();
|
||||
@@ -1536,7 +1533,7 @@ public class SignalServiceMessageSender {
|
||||
SyncMessage.Builder syncMessage = createSyncMessageBuilder();
|
||||
SyncMessage.Blocked.Builder blockedMessage = new SyncMessage.Blocked.Builder();
|
||||
|
||||
blockedMessage.acisBinary(useBinaryId ? blocked.individuals.stream().filter(a -> a.getAci() != null).map(a -> a.getAci().toByteString()).collect(Collectors.toList()) : Collections.emptyList());
|
||||
blockedMessage.acisBinary(blocked.individuals.stream().filter(a -> a.getAci() != null).map(a -> a.getAci().toByteString()).collect(Collectors.toList()));
|
||||
blockedMessage.numbers(blocked.individuals.stream().filter(a -> a.getE164() != null).map(a -> a.getE164()).collect(Collectors.toList()));
|
||||
blockedMessage.groupIds(blocked.groupIds.stream().map(ByteString::of).collect(Collectors.toList()));
|
||||
|
||||
@@ -1633,7 +1630,7 @@ public class SignalServiceMessageSender {
|
||||
}
|
||||
|
||||
if (message.getPerson().isPresent()) {
|
||||
responseMessage.threadAciBinary(useBinaryId ? message.getPerson().get().toByteString() : null);
|
||||
responseMessage.threadAciBinary(message.getPerson().get().toByteString());
|
||||
}
|
||||
|
||||
switch (message.getType()) {
|
||||
@@ -1726,7 +1723,7 @@ public class SignalServiceMessageSender {
|
||||
|
||||
verifiedMessageBuilder.nullMessage(ByteString.of(nullMessage));
|
||||
verifiedMessageBuilder.identityKey(ByteString.of(verifiedMessage.getIdentityKey().serialize()));
|
||||
verifiedMessageBuilder.destinationAciBinary(useBinaryId ? verifiedMessage.getDestination().getServiceId().toByteString() : null);
|
||||
verifiedMessageBuilder.destinationAciBinary(verifiedMessage.getDestination().getServiceId().toByteString());
|
||||
|
||||
|
||||
switch (verifiedMessage.getVerified()) {
|
||||
|
||||
+2
-5
@@ -16,11 +16,8 @@ import okio.ByteString;
|
||||
|
||||
public class DeviceContactsOutputStream extends ChunkedOutputStream {
|
||||
|
||||
private final boolean useBinaryId;
|
||||
|
||||
public DeviceContactsOutputStream(OutputStream out, boolean useBinaryId) {
|
||||
public DeviceContactsOutputStream(OutputStream out) {
|
||||
super(out);
|
||||
this.useBinaryId = useBinaryId;
|
||||
}
|
||||
|
||||
public void write(DeviceContact contact) throws IOException {
|
||||
@@ -42,7 +39,7 @@ public class DeviceContactsOutputStream extends ChunkedOutputStream {
|
||||
ContactDetails.Builder contactDetails = new ContactDetails.Builder();
|
||||
|
||||
if (contact.getAci().isPresent()) {
|
||||
contactDetails.aciBinary(useBinaryId ? contact.getAci().get().toByteString() : null);
|
||||
contactDetails.aciBinary(contact.getAci().get().toByteString());
|
||||
}
|
||||
|
||||
if (contact.getE164().isPresent()) {
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class DeviceContactsInputStreamTest {
|
||||
@Test
|
||||
public void read() throws IOException, InvalidInputException {
|
||||
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
|
||||
DeviceContactsOutputStream output = new DeviceContactsOutputStream(byteArrayOut, true);
|
||||
DeviceContactsOutputStream output = new DeviceContactsOutputStream(byteArrayOut);
|
||||
Optional<ACI> aciFirst = Optional.of(ACI.from(UUID.randomUUID()));
|
||||
Optional<String> e164First = Optional.of("+1404555555");
|
||||
Optional<ACI> aciSecond = Optional.of(ACI.from(UUID.randomUUID()));
|
||||
|
||||
Reference in New Issue
Block a user