mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-03 11:42:23 +00:00
Only show one session reset prompt at a time
This commit is contained in:
@@ -82,6 +82,9 @@ public interface MmsSmsColumns {
|
||||
protected static final long ENCRYPTION_REMOTE_DUPLICATE_BIT = 0x04000000;
|
||||
protected static final long ENCRYPTION_REMOTE_LEGACY_BIT = 0x02000000;
|
||||
|
||||
// Loki
|
||||
protected static final long ENCRYPTION_LOKI_SESSION_RESTORE_SENT_BIT = 0x09000000; // Type that determines if we've sent a session reset after receiving `ENCRYPTION_REMOTE_NO_SESSION_BIT`
|
||||
|
||||
public static boolean isDraftMessageType(long type) {
|
||||
return (type & BASE_TYPE_MASK) == BASE_DRAFT_TYPE;
|
||||
}
|
||||
@@ -230,6 +233,10 @@ public interface MmsSmsColumns {
|
||||
return (type & ENCRYPTION_REMOTE_NO_SESSION_BIT) != 0;
|
||||
}
|
||||
|
||||
public static boolean isLokiSessionRestoreSentType(long type) {
|
||||
return (type & ENCRYPTION_LOKI_SESSION_RESTORE_SENT_BIT) != 0;
|
||||
}
|
||||
|
||||
public static boolean isLegacyType(long type) {
|
||||
return (type & ENCRYPTION_REMOTE_LEGACY_BIT) != 0 ||
|
||||
(type & ENCRYPTION_REMOTE_BIT) != 0;
|
||||
|
||||
@@ -47,6 +47,7 @@ import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -251,6 +252,10 @@ public class SmsDatabase extends MessagingDatabase {
|
||||
updateTypeBitmask(id, Types.ENCRYPTION_MASK, Types.ENCRYPTION_REMOTE_NO_SESSION_BIT);
|
||||
}
|
||||
|
||||
public void markAsLokiSessionRestoreSent(long id) {
|
||||
updateTypeBitmask(id, Types.ENCRYPTION_MASK, Types.ENCRYPTION_LOKI_SESSION_RESTORE_SENT_BIT);
|
||||
}
|
||||
|
||||
public void markAsLegacyVersion(long id) {
|
||||
updateTypeBitmask(id, Types.ENCRYPTION_MASK, Types.ENCRYPTION_REMOTE_LEGACY_BIT);
|
||||
}
|
||||
@@ -727,6 +732,21 @@ public class SmsDatabase extends MessagingDatabase {
|
||||
else return record;
|
||||
}
|
||||
|
||||
public List<SmsMessageRecord> getMessages(long threadId) {
|
||||
SQLiteDatabase db = databaseHelper.getReadableDatabase();
|
||||
Cursor cursor = db.query(TABLE_NAME, MESSAGE_PROJECTION, THREAD_ID + " = ?", new String[]{ threadId + "" }, null, null, null);
|
||||
Reader reader = new Reader(cursor);
|
||||
List<SmsMessageRecord> records = new ArrayList<>();
|
||||
SmsMessageRecord record = reader.getNext();
|
||||
while (record != null) {
|
||||
records.add(record);
|
||||
record = reader.getNext();
|
||||
}
|
||||
|
||||
reader.close();
|
||||
return records;
|
||||
}
|
||||
|
||||
public Cursor getMessageCursor(long messageId) {
|
||||
SQLiteDatabase db = databaseHelper.getReadableDatabase();
|
||||
Cursor cursor = db.query(TABLE_NAME, MESSAGE_PROJECTION, ID_WHERE, new String[] {messageId + ""}, null, null, null);
|
||||
|
||||
Reference in New Issue
Block a user