mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Add an encrypted key-value store.
SignalStore is backed by SQLCipher and is intended to be used instead of TextSecurePreferences moving forward.
This commit is contained in:
@@ -8,6 +8,7 @@ import org.thoughtcrime.securesms.BuildConfig;
|
||||
import org.thoughtcrime.securesms.IncomingMessageProcessor;
|
||||
import org.thoughtcrime.securesms.gcm.MessageRetriever;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
||||
import org.thoughtcrime.securesms.keyvalue.KeyValueStore;
|
||||
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
||||
import org.thoughtcrime.securesms.recipients.LiveRecipientCache;
|
||||
import org.thoughtcrime.securesms.service.IncomingMessageObserver;
|
||||
@@ -41,6 +42,7 @@ public class ApplicationDependencies {
|
||||
private static LiveRecipientCache recipientCache;
|
||||
private static JobManager jobManager;
|
||||
private static FrameRateTracker frameRateTracker;
|
||||
private static KeyValueStore keyValueStore;
|
||||
|
||||
public static synchronized void init(@NonNull Application application, @NonNull Provider provider) {
|
||||
if (ApplicationDependencies.application != null || ApplicationDependencies.provider != null) {
|
||||
@@ -157,6 +159,16 @@ public class ApplicationDependencies {
|
||||
return frameRateTracker;
|
||||
}
|
||||
|
||||
public static synchronized @NonNull KeyValueStore getKeyValueStore() {
|
||||
assertInitialization();
|
||||
|
||||
if (keyValueStore == null) {
|
||||
keyValueStore = provider.provideKeyValueStore();
|
||||
}
|
||||
|
||||
return keyValueStore;
|
||||
}
|
||||
|
||||
private static void assertInitialization() {
|
||||
if (application == null || provider == null) {
|
||||
throw new UninitializedException();
|
||||
@@ -173,6 +185,7 @@ public class ApplicationDependencies {
|
||||
@NonNull LiveRecipientCache provideRecipientCache();
|
||||
@NonNull JobManager provideJobManager();
|
||||
@NonNull FrameRateTracker provideFrameRateTracker();
|
||||
@NonNull KeyValueStore provideKeyValueStore();
|
||||
}
|
||||
|
||||
private static class UninitializedException extends IllegalStateException {
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.thoughtcrime.securesms.jobmanager.JobMigrator;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.JsonDataSerializer;
|
||||
import org.thoughtcrime.securesms.jobs.FastJobStorage;
|
||||
import org.thoughtcrime.securesms.jobs.JobManagerFactories;
|
||||
import org.thoughtcrime.securesms.keyvalue.KeyValueStore;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.push.SecurityEventListener;
|
||||
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
||||
@@ -119,6 +120,11 @@ public class ApplicationDependencyProvider implements ApplicationDependencies.Pr
|
||||
return new FrameRateTracker(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull KeyValueStore provideKeyValueStore() {
|
||||
return new KeyValueStore(context);
|
||||
}
|
||||
|
||||
private static class DynamicCredentialsProvider implements CredentialsProvider {
|
||||
|
||||
private final Context context;
|
||||
|
||||
Reference in New Issue
Block a user