mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 00:59:49 +01:00
Ensure SQLCipher libraries are loaded.
This commit is contained in:
@@ -227,6 +227,8 @@ public class DatabaseFactory {
|
||||
}
|
||||
|
||||
private DatabaseFactory(@NonNull Context context) {
|
||||
SqlCipherLibraryLoader.load(context);
|
||||
|
||||
DatabaseSecret databaseSecret = DatabaseSecretProvider.getOrCreateDatabaseSecret(context);
|
||||
AttachmentSecret attachmentSecret = AttachmentSecretProvider.getInstance(context).getOrCreateAttachmentSecret();
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.thoughtcrime.securesms.database
|
||||
|
||||
import android.content.Context
|
||||
import net.sqlcipher.database.SQLiteDatabase
|
||||
|
||||
/**
|
||||
* A simple wrapper to load SQLCipher libs exactly once. The exact entry point of database access is non-deterministic because content providers run before
|
||||
* Application#onCreate().
|
||||
*/
|
||||
class SqlCipherLibraryLoader {
|
||||
|
||||
companion object {
|
||||
private var loaded = false
|
||||
private val LOCK = Object()
|
||||
|
||||
@JvmStatic
|
||||
fun load(context: Context) {
|
||||
if (!loaded) {
|
||||
synchronized(LOCK) {
|
||||
if (!loaded) {
|
||||
SQLiteDatabase.loadLibs(context)
|
||||
loaded = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user