mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-25 10:09:30 +00:00
Update to libsignal-service 2.5.10
// FREEBIE
This commit is contained in:
@@ -42,8 +42,8 @@ public class SignalProtocolStoreImpl implements SignalProtocolStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveIdentity(SignalProtocolAddress address, IdentityKey identityKey) {
|
||||
identityKeyStore.saveIdentity(address, identityKey);
|
||||
public boolean saveIdentity(SignalProtocolAddress address, IdentityKey identityKey) {
|
||||
return identityKeyStore.saveIdentity(address, identityKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,8 +42,8 @@ public class TextSecureIdentityKeyStore implements IdentityKeyStore {
|
||||
return TextSecurePreferences.getLocalRegistrationId(context);
|
||||
}
|
||||
|
||||
public void saveIdentity(SignalProtocolAddress address, IdentityKey identityKey,
|
||||
boolean blockingApproval, boolean nonBlockingApproval)
|
||||
public boolean saveIdentity(SignalProtocolAddress address, IdentityKey identityKey,
|
||||
boolean blockingApproval, boolean nonBlockingApproval)
|
||||
{
|
||||
synchronized (LOCK) {
|
||||
IdentityDatabase identityDatabase = DatabaseFactory.getIdentityDatabase(context);
|
||||
@@ -54,27 +54,29 @@ public class TextSecureIdentityKeyStore implements IdentityKeyStore {
|
||||
if (!identityRecord.isPresent()) {
|
||||
Log.w(TAG, "Saving new identity...");
|
||||
identityDatabase.saveIdentity(recipientId, identityKey, true, System.currentTimeMillis(), blockingApproval, nonBlockingApproval);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!identityRecord.get().getIdentityKey().equals(identityKey)) {
|
||||
Log.w(TAG, "Replacing existing identity...");
|
||||
identityDatabase.saveIdentity(recipientId, identityKey, false, System.currentTimeMillis(), blockingApproval, nonBlockingApproval);
|
||||
IdentityUtil.markIdentityUpdate(context, recipients.getPrimaryRecipient());
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isBlockingApprovalRequired(identityRecord.get()) || isNonBlockingApprovalRequired(identityRecord.get())) {
|
||||
Log.w(TAG, "Setting approval status...");
|
||||
identityDatabase.setApproval(recipientId, blockingApproval, nonBlockingApproval);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveIdentity(SignalProtocolAddress address, IdentityKey identityKey) {
|
||||
saveIdentity(address, identityKey, !TextSecurePreferences.isSendingIdentityApprovalRequired(context), false);
|
||||
public boolean saveIdentity(SignalProtocolAddress address, IdentityKey identityKey) {
|
||||
return saveIdentity(address, identityKey, !TextSecurePreferences.isSendingIdentityApprovalRequired(context), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.storage.TextSecureIdentityKeyStore;
|
||||
import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
@@ -20,6 +21,8 @@ import org.whispersystems.libsignal.IdentityKey;
|
||||
import org.whispersystems.libsignal.InvalidKeyException;
|
||||
import org.whispersystems.libsignal.SignalProtocolAddress;
|
||||
import org.whispersystems.libsignal.state.IdentityKeyStore;
|
||||
import org.whispersystems.libsignal.state.SessionRecord;
|
||||
import org.whispersystems.libsignal.state.SessionStore;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessagePipe;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageReceiver;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
@@ -89,8 +92,18 @@ public class RetrieveProfileJob extends ContextJob implements InjectableType {
|
||||
}
|
||||
|
||||
synchronized (SESSION_LOCK) {
|
||||
IdentityKeyStore identityKeyStore = new TextSecureIdentityKeyStore(context);
|
||||
identityKeyStore.saveIdentity(new SignalProtocolAddress(recipient.getNumber(), 1), identityKey);
|
||||
IdentityKeyStore identityKeyStore = new TextSecureIdentityKeyStore(context);
|
||||
SessionStore sessionStore = new TextSecureSessionStore(context);
|
||||
SignalProtocolAddress address = new SignalProtocolAddress(number, 1);
|
||||
|
||||
if (identityKeyStore.saveIdentity(address, identityKey)) {
|
||||
if (sessionStore.containsSession(address)) {
|
||||
SessionRecord sessionRecord = sessionStore.loadSession(address);
|
||||
sessionRecord.archiveCurrentState();
|
||||
|
||||
sessionStore.storeSession(address, sessionRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user