Fix crash when creating an EncryptedFile in Android 6 (#2853)
This commit is contained in:
parent
09bfc820e4
commit
69d5b564da
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 {
|
||||
val name = "session_database"
|
||||
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 driver = SqlCipherDriverFactory(passphraseProvider)
|
||||
.create(SessionDatabase.Schema, "$name.db", context)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue