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;
|
2017-07-26 09:59:15 -07:00
|
|
|
import org.thoughtcrime.securesms.database.Address;
|
2016-03-23 10:34:41 -07:00
|
|
|
import org.whispersystems.libsignal.SignalProtocolAddress;
|
2017-06-06 18:03:09 -07:00
|
|
|
import org.whispersystems.libsignal.state.SessionRecord;
|
2016-03-23 10:34:41 -07:00
|
|
|
import org.whispersystems.libsignal.state.SessionStore;
|
|
|
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
2015-03-03 11:44:49 -08:00
|
|
|
|
2017-06-06 18:03:09 -07:00
|
|
|
import java.util.List;
|
|
|
|
|
2015-03-03 11:44:49 -08:00
|
|
|
public class SessionUtil {
|
|
|
|
|
2018-01-24 19:17:44 -08:00
|
|
|
public static boolean hasSession(Context context, @NonNull Address address) {
|
2018-02-18 16:43:18 -08:00
|
|
|
SessionStore sessionStore = new TextSecureSessionStore(context);
|
2017-07-26 09:59:15 -07:00
|
|
|
SignalProtocolAddress axolotlAddress = new SignalProtocolAddress(address.serialize(), SignalServiceAddress.DEFAULT_DEVICE_ID);
|
2015-03-03 11:44:49 -08:00
|
|
|
|
|
|
|
return sessionStore.containsSession(axolotlAddress);
|
|
|
|
}
|
2017-06-06 18:03:09 -07:00
|
|
|
|
|
|
|
public static void archiveSiblingSessions(Context context, SignalProtocolAddress address) {
|
2018-02-18 16:43:18 -08:00
|
|
|
TextSecureSessionStore sessionStore = new TextSecureSessionStore(context);
|
|
|
|
sessionStore.archiveSiblingSessions(address);
|
2017-07-05 13:12:59 -07:00
|
|
|
}
|
2017-06-06 18:03:09 -07:00
|
|
|
|
2017-07-05 13:12:59 -07:00
|
|
|
public static void archiveAllSessions(Context context) {
|
|
|
|
new TextSecureSessionStore(context).archiveAllSessions();
|
2017-06-06 18:03:09 -07:00
|
|
|
}
|
2018-02-18 16:43:18 -08:00
|
|
|
|
2015-03-03 11:44:49 -08:00
|
|
|
}
|