Merge pull request #5155 from nextcloud/chore/5103/support16kbPageSizes

Support 16 KB page sizes
This commit is contained in:
Marcel Hibbe 2025-07-16 15:49:17 +02:00 committed by GitHub
commit e00ded45de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 18 additions and 132 deletions

View File

@ -252,7 +252,7 @@ dependencies {
compileOnly 'javax.annotation:javax.annotation-api:1.3.2' compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
implementation 'org.greenrobot:eventbus:3.3.1' implementation 'org.greenrobot:eventbus:3.3.1'
implementation 'net.zetetic:android-database-sqlcipher:4.5.4' implementation 'net.zetetic:sqlcipher-android:4.9.0'
implementation "androidx.room:room-runtime:${roomVersion}" implementation "androidx.room:room-runtime:${roomVersion}"
implementation "androidx.room:room-rxjava2:${roomVersion}" implementation "androidx.room:room-rxjava2:${roomVersion}"

View File

@ -253,10 +253,6 @@ class MainActivity :
startActivity(chatIntent) startActivity(chatIntent)
} }
} else { } else {
if (!appPreferences.isDbRoomMigrated) {
appPreferences.isDbRoomMigrated = true
}
userManager.users.subscribe(object : SingleObserver<List<User>> { userManager.users.subscribe(object : SingleObserver<List<User>> {
override fun onSubscribe(d: Disposable) { override fun onSubscribe(d: Disposable) {
// unused atm // unused atm

View File

@ -58,8 +58,6 @@ import com.vanniktech.emoji.EmojiManager
import com.vanniktech.emoji.google.GoogleEmojiProvider import com.vanniktech.emoji.google.GoogleEmojiProvider
import de.cotech.hw.SecurityKeyManager import de.cotech.hw.SecurityKeyManager
import de.cotech.hw.SecurityKeyManagerConfig import de.cotech.hw.SecurityKeyManagerConfig
import net.sqlcipher.database.SQLiteDatabase
import net.sqlcipher.database.SQLiteDatabaseHook
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import org.conscrypt.Conscrypt import org.conscrypt.Conscrypt
import org.webrtc.PeerConnectionFactory import org.webrtc.PeerConnectionFactory
@ -103,18 +101,6 @@ class NextcloudTalkApplication :
lateinit var okHttpClient: OkHttpClient lateinit var okHttpClient: OkHttpClient
//endregion //endregion
val hook: SQLiteDatabaseHook = object : SQLiteDatabaseHook {
override fun preKey(database: SQLiteDatabase) {
// unused atm
}
override fun postKey(database: SQLiteDatabase) {
Log.i("TalkApplication", "DB cipher_migrate START")
database.rawExecSQL("PRAGMA cipher_migrate;")
Log.i("TalkApplication", "DB cipher_migrate END")
}
}
//region private methods //region private methods
private fun initializeWebRtc() { private fun initializeWebRtc() {
try { try {

View File

@ -42,9 +42,8 @@ public class DatabaseModule {
@Provides @Provides
@Singleton @Singleton
public TalkDatabase provideTalkDatabase(@NonNull final Context context, public TalkDatabase provideTalkDatabase(@NonNull final Context context) {
@NonNull final AppPreferences appPreferences) { return TalkDatabase.getInstance(context);
return TalkDatabase.getInstance(context, appPreferences);
} }
@Provides @Provides

View File

@ -9,7 +9,6 @@
package com.nextcloud.talk.data.source.local package com.nextcloud.talk.data.source.local
import android.content.Context import android.content.Context
import android.util.Log
import androidx.room.AutoMigration import androidx.room.AutoMigration
import androidx.room.Database import androidx.room.Database
import androidx.room.Room import androidx.room.Room
@ -37,10 +36,7 @@ import com.nextcloud.talk.data.storage.ArbitraryStoragesDao
import com.nextcloud.talk.data.storage.model.ArbitraryStorageEntity import com.nextcloud.talk.data.storage.model.ArbitraryStorageEntity
import com.nextcloud.talk.data.user.UsersDao import com.nextcloud.talk.data.user.UsersDao
import com.nextcloud.talk.data.user.model.UserEntity import com.nextcloud.talk.data.user.model.UserEntity
import com.nextcloud.talk.utils.preferences.AppPreferences import net.zetetic.database.sqlcipher.SupportOpenHelperFactory
import net.sqlcipher.database.SQLiteDatabase
import net.sqlcipher.database.SQLiteDatabaseHook
import net.sqlcipher.database.SupportFactory
import java.util.Locale import java.util.Locale
@Database( @Database(
@ -70,7 +66,6 @@ import java.util.Locale
SendStatusConverter::class SendStatusConverter::class
) )
abstract class TalkDatabase : RoomDatabase() { abstract class TalkDatabase : RoomDatabase() {
abstract fun usersDao(): UsersDao abstract fun usersDao(): UsersDao
abstract fun conversationsDao(): ConversationsDao abstract fun conversationsDao(): ConversationsDao
abstract fun chatMessagesDao(): ChatMessagesDao abstract fun chatMessagesDao(): ChatMessagesDao
@ -79,27 +74,21 @@ abstract class TalkDatabase : RoomDatabase() {
companion object { companion object {
const val TAG = "TalkDatabase" const val TAG = "TalkDatabase"
const val SQL_CIPHER_LIBRARY = "sqlcipher"
@Volatile @Volatile
private var instance: TalkDatabase? = null private var instance: TalkDatabase? = null
@JvmStatic @JvmStatic
fun getInstance(context: Context, appPreferences: AppPreferences): TalkDatabase = fun getInstance(context: Context): TalkDatabase =
instance ?: synchronized(this) { instance ?: synchronized(this) {
instance ?: build(context, appPreferences).also { instance = it } instance ?: build(context).also { instance = it }
} }
private fun build(context: Context, appPreferences: AppPreferences): TalkDatabase { private fun build(context: Context): TalkDatabase {
val passCharArray = context.getString(R.string.nc_talk_database_encryption_key).toCharArray() val passCharArray = context.getString(R.string.nc_talk_database_encryption_key).toCharArray()
val passphrase: ByteArray = SQLiteDatabase.getBytes(passCharArray) val passphrase: ByteArray = getBytesFromChars(passCharArray)
val factory = SupportOpenHelperFactory(passphrase)
val factory = if (appPreferences.isDbRoomMigrated) {
Log.i(TAG, "No cipher migration needed")
SupportFactory(passphrase)
} else {
Log.i(TAG, "Add cipher migration hook")
SupportFactory(passphrase, getCipherMigrationHook())
}
val dbName = context val dbName = context
.resources .resources
@ -109,6 +98,8 @@ abstract class TalkDatabase : RoomDatabase() {
.trim() + .trim() +
".sqlite" ".sqlite"
System.loadLibrary(SQL_CIPHER_LIBRARY)
return Room return Room
.databaseBuilder(context.applicationContext, TalkDatabase::class.java, dbName) .databaseBuilder(context.applicationContext, TalkDatabase::class.java, dbName)
// comment out openHelperFactory to view the database entries in Android Studio for debugging // comment out openHelperFactory to view the database entries in Android Studio for debugging
@ -126,7 +117,7 @@ abstract class TalkDatabase : RoomDatabase() {
) )
.allowMainThreadQueries() .allowMainThreadQueries()
.addCallback( .addCallback(
object : RoomDatabase.Callback() { object : Callback() {
override fun onOpen(db: SupportSQLiteDatabase) { override fun onOpen(db: SupportSQLiteDatabase) {
super.onOpen(db) super.onOpen(db)
db.execSQL("PRAGMA defer_foreign_keys = 1") db.execSQL("PRAGMA defer_foreign_keys = 1")
@ -136,17 +127,6 @@ abstract class TalkDatabase : RoomDatabase() {
.build() .build()
} }
private fun getCipherMigrationHook(): SQLiteDatabaseHook = private fun getBytesFromChars(chars: CharArray): ByteArray = String(chars).toByteArray(Charsets.UTF_8)
object : SQLiteDatabaseHook {
override fun preKey(database: SQLiteDatabase) {
// unused atm
}
override fun postKey(database: SQLiteDatabase) {
Log.i(TAG, "DB cipher_migrate START")
database.rawExecSQL("PRAGMA cipher_migrate;")
Log.i(TAG, "DB cipher_migrate END")
}
}
} }
} }

View File

@ -143,10 +143,6 @@ public interface AppPreferences {
void setDbCypherToUpgrade(boolean value); void setDbCypherToUpgrade(boolean value);
boolean getIsDbRoomMigrated();
void setIsDbRoomMigrated(boolean value);
void setPhoneBookIntegrationLastRun(long currentTimeMillis); void setPhoneBookIntegrationLastRun(long currentTimeMillis);
long getPhoneBookIntegrationLastRun(Long defaultValue); long getPhoneBookIntegrationLastRun(Long defaultValue);

View File

@ -388,18 +388,6 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
} }
} }
override fun getIsDbRoomMigrated(): Boolean =
runBlocking {
async { readBoolean(DB_ROOM_MIGRATED).first() }
}.getCompleted()
override fun setIsDbRoomMigrated(value: Boolean) =
runBlocking<Unit> {
async {
writeBoolean(DB_ROOM_MIGRATED, value)
}
}
override fun getShowRegularNotificationWarning(): Boolean = override fun getShowRegularNotificationWarning(): Boolean =
runBlocking { runBlocking {
async { readBoolean(SHOW_REGULAR_NOTIFICATION_WARNING, true).first() } async { readBoolean(SHOW_REGULAR_NOTIFICATION_WARNING, true).first() }

View File

@ -1036,24 +1036,6 @@ EEIhZlI/ojefaZkRseFrtl3X
=pJaU =pJaU
-----END PGP PUBLIC KEY BLOCK----- -----END PGP PUBLIC KEY BLOCK-----
pub A6EA2E2BF22E0543
uid Tobias Warneke (for development purposes) <t.warneke@gmx.net>
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQGNBFJQhigBDADpuhND/VUQwJT0nnJxfjAIur59hyaZZ3Ph/KIgmCneyq7lzYO6
xa1ucH8mqNBVNLLBhs4CjihBddU/ZKTX3WnZyhQKQMZr3Tg+TCNFmAR4/hnZ3NjZ
N5N5gUj/dqVI2rIvypIuxUApl88BYMsxYpn2+8FKeMd8oBJLqFRJ3WNjB4Op2tRO
XRWoxs1ypubS/IV1zkphHHpi6VSABlTyTWu4kXEj/1/GpsdtHRa9kvdWw7yKQbnM
XuwOxtzZFJcyu0P2jYVfHHvxcjxuklc9edmCGdNxgKIoo0LXZOeFIi6OWtwzD0pn
O6ovJ+PL9QscMdnQlPwsiCwjNUNue20GBv3aUIYc+Z8Gq0SqSan5V0IiKRHMJkzd
FAhnpkSFBvHhPJn07BCcb1kctqL+xnLxIdi7arq3WNA/6bJjsojc/x3FdIvORIeP
sqejhtL8mCBvbMAMHSBrFxclMp+HSz2ouHEEPIQam0KeN8t1yEqIy3/aYKMzHj9c
C3s8XOaBCbJbKpMAEQEAAbQ9VG9iaWFzIFdhcm5la2UgKGZvciBkZXZlbG9wbWVu
dCBwdXJwb3NlcykgPHQud2FybmVrZUBnbXgubmV0Pg==
=q1C6
-----END PGP PUBLIC KEY BLOCK-----
pub A730529CA355A63E pub A730529CA355A63E
uid Jukka Zitting <jukka@apache.org> uid Jukka Zitting <jukka@apache.org>
@ -3802,50 +3784,6 @@ pIXjPlQ0i6kV0h8KapE1Uo005JYgeg==
=ASmD =ASmD
-----END PGP PUBLIC KEY BLOCK----- -----END PGP PUBLIC KEY BLOCK-----
pub 1DE461528F1F1B2A
uid Julian Reschke (CODE SIGNING KEY) <reschke@apache.org>
sub D4569BDF799A59AB
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFd7wYcBEAC1jmtowY8q/BXHFr4bOvA4WtniUcECC36dHmQzd3LrG8zdDPK4
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EqFLHh1yX4I+if5VODD2nEzXFDzE=
=d5S6
-----END PGP PUBLIC KEY BLOCK-----
pub 1F7A8F87B9D8F501 pub 1F7A8F87B9D8F501
uid Download <download@jetbrains.com> uid Download <download@jetbrains.com>

View File

@ -164,7 +164,10 @@
<trusting group="ch.qos.logback"/> <trusting group="ch.qos.logback"/>
<trusting group="org.slf4j"/> <trusting group="org.slf4j"/>
</trusted-key> </trusted-key>
<trusted-key id="61DEBD732F3F07771269972E2F87304808D40CEC" group="net.zetetic" name="android-database-sqlcipher" version="4.5.4"/> <trusted-key id="61DEBD732F3F07771269972E2F87304808D40CEC">
<trusting name="android-database-sqlcipher" group="net.zetetic" version="4.5.4"/>
<trusting name="sqlcipher-android" group="net.zetetic" version="4.9.0"/>
</trusted-key>
<trusted-key id="64B9B09F164AA0BF88742EB61188B69F6D6259CA" group="com.google.accompanist"/> <trusted-key id="64B9B09F164AA0BF88742EB61188B69F6D6259CA" group="com.google.accompanist"/>
<trusted-key id="666A4692CE11B7B3F4EB7B3410066A9707090CF9" group="org.javassist" name="javassist" version="3.26.0-GA"/> <trusted-key id="666A4692CE11B7B3F4EB7B3410066A9707090CF9" group="org.javassist" name="javassist" version="3.26.0-GA"/>
<trusted-key id="694621A7227D8D5289699830ABE9F3126BB741C1" group="^com[.]google($|([.].*))" regex="true"/> <trusted-key id="694621A7227D8D5289699830ABE9F3126BB741C1" group="^com[.]google($|([.].*))" regex="true"/>