Fix crash when creating an EncryptedFile in Android 6 (#2853)
This commit is contained in:
parent
d103872f42
commit
822705195f
2 changed files with 8 additions and 0 deletions
1
changelog.d/2846.bugfix
Normal file
1
changelog.d/2846.bugfix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Fix a crash when trying to create an `EncryptedFile` in Android 6.
|
||||||
|
|
@ -35,6 +35,13 @@ object SessionStorageModule {
|
||||||
fun provideMatrixDatabase(@ApplicationContext context: Context): SessionDatabase {
|
fun provideMatrixDatabase(@ApplicationContext context: Context): SessionDatabase {
|
||||||
val name = "session_database"
|
val name = "session_database"
|
||||||
val secretFile = context.getDatabasePath("$name.key")
|
val secretFile = context.getDatabasePath("$name.key")
|
||||||
|
|
||||||
|
// Make sure the parent directory of the key file exists, otherwise it will crash in older Android versions
|
||||||
|
val parentDir = secretFile.parentFile
|
||||||
|
if (parentDir != null && !parentDir.exists()) {
|
||||||
|
parentDir.mkdirs()
|
||||||
|
}
|
||||||
|
|
||||||
val passphraseProvider = RandomSecretPassphraseProvider(context, secretFile)
|
val passphraseProvider = RandomSecretPassphraseProvider(context, secretFile)
|
||||||
val driver = SqlCipherDriverFactory(passphraseProvider)
|
val driver = SqlCipherDriverFactory(passphraseProvider)
|
||||||
.create(SessionDatabase.Schema, "$name.db", context)
|
.create(SessionDatabase.Schema, "$name.db", context)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue