Skip to content

refactor: Migrate SQLCipher Android to new API #4874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose",
sqldelight-driver-android = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }
sqldelight-driver-jvm = { module = "app.cash.sqldelight:sqlite-driver", version.ref = "sqldelight" }
sqldelight-coroutines = { module = "app.cash.sqldelight:coroutines-extensions", version.ref = "sqldelight" }
sqlcipher = "net.zetetic:android-database-sqlcipher:4.5.4"
sqlcipher = "net.zetetic:sqlcipher-android:4.9.0"
sqlite = "androidx.sqlite:sqlite-ktx:2.5.2"
unifiedpush = "org.unifiedpush.android:connector:3.0.10"
otaliastudios_transcoder = "com.otaliastudios:transcoder:0.11.2"
Expand Down
4 changes: 0 additions & 4 deletions libraries/encrypted-db/consumer-proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,3 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

# Prevent ProGuard from renaming internal SQLCipher classes, which breaks the library.
# From https://github.com/sqlcipher/android-database-sqlcipher#proguard
-keep class net.sqlcipher.** { *; }
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import app.cash.sqldelight.db.SqlSchema
import app.cash.sqldelight.driver.android.AndroidSqliteDriver
import io.element.encrypteddb.passphrase.PassphraseProvider
import net.sqlcipher.database.SupportFactory
import net.zetetic.database.sqlcipher.SupportOpenHelperFactory

/**
* Creates an encrypted version of the [SqlDriver] using SQLCipher's [SupportFactory].
* Creates an encrypted version of the [SqlDriver] using SQLCipher's [SupportOpenHelperFactory].
* @param passphraseProvider Provides the passphrase needed to use the SQLite database with SQLCipher.
*/
class SqlCipherDriverFactory(
Expand All @@ -29,8 +29,9 @@
* @param context Android [Context], used to instantiate the driver.
*/
fun create(schema: SqlSchema<QueryResult.Value<Unit>>, name: String, context: Context): SqlDriver {
System.loadLibrary("sqlcipher")

Check warning on line 32 in libraries/encrypted-db/src/main/kotlin/io/element/encrypteddb/SqlCipherDriverFactory.kt

View check run for this annotation

Codecov / codecov/patch

libraries/encrypted-db/src/main/kotlin/io/element/encrypteddb/SqlCipherDriverFactory.kt#L32

Added line #L32 was not covered by tests
val passphrase = passphraseProvider.getPassphrase()
val factory = SupportFactory(passphrase)
val factory = SupportOpenHelperFactory(passphrase)

Check warning on line 34 in libraries/encrypted-db/src/main/kotlin/io/element/encrypteddb/SqlCipherDriverFactory.kt

View check run for this annotation

Codecov / codecov/patch

libraries/encrypted-db/src/main/kotlin/io/element/encrypteddb/SqlCipherDriverFactory.kt#L34

Added line #L34 was not covered by tests
return AndroidSqliteDriver(schema = schema, context = context, name = name, factory = factory)
}
}
Loading