Add the ability to have separate ACI and PNI protocol stores.

This commit is contained in:
Greyson Parrelli
2022-01-26 16:22:19 -05:00
committed by Cody Henthorne
parent dd7a2834bc
commit 33f4bb0000
33 changed files with 204 additions and 188 deletions

View File

@@ -11,10 +11,7 @@ import org.signal.zkgroup.receipts.ClientZkReceiptOperations;
import org.thoughtcrime.securesms.KbsEnclave;
import org.thoughtcrime.securesms.components.TypingStatusRepository;
import org.thoughtcrime.securesms.components.TypingStatusSender;
import org.thoughtcrime.securesms.crypto.storage.SignalSenderKeyStore;
import org.thoughtcrime.securesms.crypto.storage.TextSecureIdentityKeyStore;
import org.thoughtcrime.securesms.crypto.storage.TextSecurePreKeyStore;
import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore;
import org.thoughtcrime.securesms.crypto.storage.SignalServiceDataStoreImpl;
import org.thoughtcrime.securesms.database.DatabaseObserver;
import org.thoughtcrime.securesms.database.PendingRetryReceiptCache;
import org.thoughtcrime.securesms.groups.GroupsV2Authorization;
@@ -101,10 +98,7 @@ public class ApplicationDependencies {
private static volatile PendingRetryReceiptCache pendingRetryReceiptCache;
private static volatile SignalWebSocket signalWebSocket;
private static volatile MessageNotifier messageNotifier;
private static volatile TextSecureIdentityKeyStore identityStore;
private static volatile TextSecureSessionStore sessionStore;
private static volatile TextSecurePreKeyStore preKeyStore;
private static volatile SignalSenderKeyStore senderKeyStore;
private static volatile SignalServiceDataStoreImpl protocolStore;
private static volatile GiphyMp4Cache giphyMp4Cache;
private static volatile SimpleExoPlayerPool exoPlayerPool;
private static volatile AudioManagerCompat audioManagerCompat;
@@ -525,48 +519,16 @@ public class ApplicationDependencies {
return signalWebSocket;
}
public static @NonNull TextSecureIdentityKeyStore getIdentityStore() {
if (identityStore == null) {
public static @NonNull SignalServiceDataStoreImpl getProtocolStore() {
if (protocolStore == null) {
synchronized (LOCK) {
if (identityStore == null) {
identityStore = provider.provideIdentityStore();
if (protocolStore == null) {
protocolStore = provider.provideProtocolStore();
}
}
}
return identityStore;
}
public static @NonNull TextSecureSessionStore getSessionStore() {
if (sessionStore == null) {
synchronized (LOCK) {
if (sessionStore == null) {
sessionStore = provider.provideSessionStore();
}
}
}
return sessionStore;
}
public static @NonNull TextSecurePreKeyStore getPreKeyStore() {
if (preKeyStore == null) {
synchronized (LOCK) {
if (preKeyStore == null) {
preKeyStore = provider.providePreKeyStore();
}
}
}
return preKeyStore;
}
public static @NonNull SignalSenderKeyStore getSenderKeyStore() {
if (senderKeyStore == null) {
synchronized (LOCK) {
if (senderKeyStore == null) {
senderKeyStore = provider.provideSenderKeyStore();
}
}
}
return senderKeyStore;
return protocolStore;
}
public static @NonNull GiphyMp4Cache getGiphyMp4Cache() {
@@ -663,10 +625,7 @@ public class ApplicationDependencies {
@NonNull PendingRetryReceiptManager providePendingRetryReceiptManager();
@NonNull PendingRetryReceiptCache providePendingRetryReceiptCache();
@NonNull SignalWebSocket provideSignalWebSocket();
@NonNull TextSecureIdentityKeyStore provideIdentityStore();
@NonNull TextSecureSessionStore provideSessionStore();
@NonNull TextSecurePreKeyStore providePreKeyStore();
@NonNull SignalSenderKeyStore provideSenderKeyStore();
@NonNull SignalServiceDataStoreImpl provideProtocolStore();
@NonNull GiphyMp4Cache provideGiphyMp4Cache();
@NonNull SimpleExoPlayerPool provideExoPlayerPool();
@NonNull AudioManagerCompat provideAndroidCallAudioManager();

View File

@@ -1,7 +1,6 @@
package org.thoughtcrime.securesms.dependencies;
import android.app.Application;
import android.content.Context;
import android.os.Handler;
import android.os.HandlerThread;
@@ -14,7 +13,8 @@ import org.thoughtcrime.securesms.BuildConfig;
import org.thoughtcrime.securesms.components.TypingStatusRepository;
import org.thoughtcrime.securesms.components.TypingStatusSender;
import org.thoughtcrime.securesms.crypto.ReentrantSessionLock;
import org.thoughtcrime.securesms.crypto.storage.SignalProtocolStoreImpl;
import org.thoughtcrime.securesms.crypto.storage.SignalServiceDataStoreImpl;
import org.thoughtcrime.securesms.crypto.storage.SignalServiceAccountDataStoreImpl;
import org.thoughtcrime.securesms.crypto.storage.SignalSenderKeyStore;
import org.thoughtcrime.securesms.crypto.storage.TextSecureIdentityKeyStore;
import org.thoughtcrime.securesms.crypto.storage.TextSecurePreKeyStore;
@@ -116,7 +116,7 @@ public class ApplicationDependencyProvider implements ApplicationDependencies.Pr
public @NonNull SignalServiceMessageSender provideSignalServiceMessageSender(@NonNull SignalWebSocket signalWebSocket) {
return new SignalServiceMessageSender(provideSignalServiceNetworkAccess().getConfiguration(),
new DynamicCredentialsProvider(),
new SignalProtocolStoreImpl(context),
provideProtocolStore(),
ReentrantSessionLock.INSTANCE,
BuildConfig.SIGNAL_AGENT,
signalWebSocket,
@@ -274,23 +274,13 @@ public class ApplicationDependencyProvider implements ApplicationDependencies.Pr
}
@Override
public @NonNull TextSecureIdentityKeyStore provideIdentityStore() {
return new TextSecureIdentityKeyStore(context);
}
@Override
public @NonNull TextSecureSessionStore provideSessionStore() {
return new TextSecureSessionStore(context);
}
@Override
public @NonNull TextSecurePreKeyStore providePreKeyStore() {
return new TextSecurePreKeyStore(context);
}
@Override
public @NonNull SignalSenderKeyStore provideSenderKeyStore() {
return new SignalSenderKeyStore(context);
public @NonNull SignalServiceDataStoreImpl provideProtocolStore() {
SignalServiceAccountDataStoreImpl aci = new SignalServiceAccountDataStoreImpl(context,
new TextSecurePreKeyStore(context),
new TextSecureIdentityKeyStore(context),
new TextSecureSessionStore(context),
new SignalSenderKeyStore(context));
return new SignalServiceDataStoreImpl(context, aci, aci);
}
@Override