2015-03-03 11:44:49 -08:00
|
|
|
package org.thoughtcrime.securesms.crypto;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore;
|
|
|
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
2016-03-23 10:34:41 -07:00
|
|
|
import org.whispersystems.libsignal.SignalProtocolAddress;
|
|
|
|
import org.whispersystems.libsignal.state.SessionStore;
|
|
|
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
2015-03-03 11:44:49 -08:00
|
|
|
|
|
|
|
public class SessionUtil {
|
|
|
|
|
|
|
|
public static boolean hasSession(Context context, MasterSecret masterSecret, Recipient recipient) {
|
|
|
|
return hasSession(context, masterSecret, recipient.getNumber());
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean hasSession(Context context, MasterSecret masterSecret, @NonNull String number) {
|
2016-03-23 10:34:41 -07:00
|
|
|
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
|
|
|
|
SignalProtocolAddress axolotlAddress = new SignalProtocolAddress(number, SignalServiceAddress.DEFAULT_DEVICE_ID);
|
2015-03-03 11:44:49 -08:00
|
|
|
|
|
|
|
return sessionStore.containsSession(axolotlAddress);
|
|
|
|
}
|
|
|
|
}
|