mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-29 06:19:20 +00:00
Reorganize session store load/store operations.
This commit is contained in:
@@ -27,9 +27,12 @@ import org.thoughtcrime.securesms.util.DynamicLanguage;
|
||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
||||
import org.whispersystems.libaxolotl.IdentityKey;
|
||||
import org.whispersystems.libaxolotl.state.SessionRecord;
|
||||
import org.whispersystems.libaxolotl.state.SessionStore;
|
||||
import org.whispersystems.textsecure.crypto.IdentityKeyParcelable;
|
||||
import org.whispersystems.textsecure.crypto.MasterSecret;
|
||||
import org.whispersystems.textsecure.storage.Session;
|
||||
import org.whispersystems.textsecure.storage.RecipientDevice;
|
||||
import org.whispersystems.textsecure.storage.TextSecureSessionStore;
|
||||
|
||||
/**
|
||||
* Activity for verifying identity keys.
|
||||
@@ -92,7 +95,7 @@ public class VerifyIdentityActivity extends KeyScanningActivity {
|
||||
}
|
||||
|
||||
if (identityKey == null) {
|
||||
identityKey = Session.getRemoteIdentityKey(this, masterSecret, recipient);
|
||||
identityKey = getRemoteIdentityKey(masterSecret, recipient);
|
||||
}
|
||||
|
||||
if (identityKey == null) {
|
||||
@@ -128,7 +131,7 @@ public class VerifyIdentityActivity extends KeyScanningActivity {
|
||||
|
||||
@Override
|
||||
protected void initiateScan() {
|
||||
IdentityKey identityKey = Session.getRemoteIdentityKey(this, masterSecret, recipient);
|
||||
IdentityKey identityKey = getRemoteIdentityKey(masterSecret, recipient);
|
||||
|
||||
if (identityKey == null) {
|
||||
Toast.makeText(this, R.string.VerifyIdentityActivity_recipient_has_no_identity_key_exclamation,
|
||||
@@ -150,7 +153,7 @@ public class VerifyIdentityActivity extends KeyScanningActivity {
|
||||
|
||||
@Override
|
||||
protected IdentityKey getIdentityKeyToCompare() {
|
||||
return Session.getRemoteIdentityKey(this, masterSecret, recipient);
|
||||
return getRemoteIdentityKey(masterSecret, recipient);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,4 +180,16 @@ public class VerifyIdentityActivity extends KeyScanningActivity {
|
||||
protected String getVerifiedTitle() {
|
||||
return getString(R.string.VerifyIdentityActivity_verified_exclamation);
|
||||
}
|
||||
|
||||
private IdentityKey getRemoteIdentityKey(MasterSecret masterSecret, Recipient recipient) {
|
||||
SessionStore sessionStore = new TextSecureSessionStore(this, masterSecret);
|
||||
SessionRecord record = sessionStore.get(recipient.getRecipientId(),
|
||||
RecipientDevice.DEFAULT_DEVICE_ID);
|
||||
|
||||
if (record == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return record.getSessionState().getRemoteIdentityKey();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user