mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Add contact and key sync message receive support.
This commit is contained in:
committed by
Greyson Parrelli
parent
c5028720e3
commit
c548816daa
@@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.keyvalue;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.whispersystems.libsignal.util.guava.Preconditions;
|
||||
import org.whispersystems.signalservice.api.storage.SignalStorageManifest;
|
||||
import org.whispersystems.signalservice.api.storage.StorageKey;
|
||||
|
||||
@@ -14,6 +15,7 @@ public class StorageServiceValues extends SignalStoreValues {
|
||||
private static final String LAST_SYNC_TIME = "storage.last_sync_time";
|
||||
private static final String NEEDS_ACCOUNT_RESTORE = "storage.needs_account_restore";
|
||||
private static final String MANIFEST = "storage.manifest";
|
||||
private static final String SYNC_STORAGE_KEY = "storage.syncStorageKey";
|
||||
|
||||
StorageServiceValues(@NonNull KeyValueStore store) {
|
||||
super(store);
|
||||
@@ -29,6 +31,9 @@ public class StorageServiceValues extends SignalStoreValues {
|
||||
}
|
||||
|
||||
public synchronized StorageKey getOrCreateStorageKey() {
|
||||
if (getStore().containsKey(SYNC_STORAGE_KEY)) {
|
||||
return new StorageKey(getBlob(SYNC_STORAGE_KEY, null));
|
||||
}
|
||||
return SignalStore.kbsValues().getOrCreateMasterKey().deriveStorageServiceKey();
|
||||
}
|
||||
|
||||
@@ -61,4 +66,14 @@ public class StorageServiceValues extends SignalStoreValues {
|
||||
return SignalStorageManifest.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void setStorageKeyFromPrimary(@NonNull StorageKey storageKey) {
|
||||
Preconditions.checkState(SignalStore.account().isLinkedDevice(), "Can only set storage key directly on linked devices");
|
||||
putBlob(SYNC_STORAGE_KEY, storageKey.serialize());
|
||||
}
|
||||
|
||||
public void clearStorageKeyFromPrimary() {
|
||||
Preconditions.checkState(SignalStore.account().isLinkedDevice(), "Can only clear storage key directly on linked devices");
|
||||
remove(SYNC_STORAGE_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user