Implement shared sender keys database

This commit is contained in:
nielsandriesse
2020-08-06 16:32:14 +10:00
parent d125197db0
commit 9c3814df9c
3 changed files with 117 additions and 3 deletions

View File

@@ -41,6 +41,7 @@ import org.thoughtcrime.securesms.loki.database.LokiPreKeyBundleDatabase;
import org.thoughtcrime.securesms.loki.database.LokiPreKeyRecordDatabase;
import org.thoughtcrime.securesms.loki.database.LokiThreadDatabase;
import org.thoughtcrime.securesms.loki.database.LokiUserDatabase;
import org.thoughtcrime.securesms.loki.database.SharedSenderKeysDatabase;
import org.thoughtcrime.securesms.notifications.NotificationChannels;
import org.thoughtcrime.securesms.service.KeyCachingService;
import org.thoughtcrime.securesms.util.GroupUtil;
@@ -85,8 +86,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
private static final int lokiV9 = 30;
private static final int lokiV10 = 31;
private static final int lokiV11 = 32;
private static final int lokiV12 = 33;
private static final int DATABASE_VERSION = lokiV11; // Loki - onUpgrade(...) must be updated to use Loki version numbers if Signal makes any database changes
private static final int DATABASE_VERSION = lokiV12; // Loki - onUpgrade(...) must be updated to use Loki version numbers if Signal makes any database changes
private static final String DATABASE_NAME = "signal.db";
private final Context context;
@@ -157,6 +159,8 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
db.execSQL(LokiThreadDatabase.getCreatePublicChatTableCommand());
db.execSQL(LokiUserDatabase.getCreateDisplayNameTableCommand());
db.execSQL(LokiUserDatabase.getCreateServerDisplayNameTableCommand());
db.execSQL(SharedSenderKeysDatabase.getCreateClosedGroupRatchetsTableCommand());
db.execSQL(SharedSenderKeysDatabase.getCreateClosedGroupPrivateKeysTableCommand());
executeStatements(db, SmsDatabase.CREATE_INDEXS);
executeStatements(db, MmsDatabase.CREATE_INDEXS);
@@ -603,6 +607,11 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
db.execSQL(LokiAPIDatabase.getCreateOpenGroupPublicKeyDBCommand());
}
if (oldVersion < lokiV12) {
db.execSQL(SharedSenderKeysDatabase.getCreateClosedGroupRatchetsTableCommand());
db.execSQL(SharedSenderKeysDatabase.getCreateClosedGroupPrivateKeysTableCommand());
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();