mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 14:27:24 +00:00
Merge pull request #1850 from nextcloud/dependabot/gradle/net.zetetic-android-database-sqlcipher-4.5.1
Bump android-database-sqlcipher from 3.5.9 to 4.5.1
This commit is contained in:
commit
db5ba9763f
@ -230,7 +230,7 @@ dependencies {
|
||||
implementation 'org.greenrobot:eventbus:3.3.1'
|
||||
implementation 'io.requery:requery:1.6.1'
|
||||
implementation 'io.requery:requery-android:1.6.1'
|
||||
implementation 'net.zetetic:android-database-sqlcipher:3.5.9'
|
||||
implementation 'net.zetetic:android-database-sqlcipher:4.5.1'
|
||||
kapt 'io.requery:requery-processor:1.6.1'
|
||||
implementation "org.parceler:parceler-api:$parcelerVersion"
|
||||
implementation 'net.orange-box.storebox:storebox-lib:1.4.0'
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Talk application
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Marcel Hibbe
|
||||
* @author Andy Scherzinger
|
||||
@ -9,18 +8,18 @@
|
||||
* Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
|
||||
* Copyright (C) 2017 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.talk.application
|
||||
|
||||
@ -51,6 +50,7 @@ import com.facebook.cache.disk.DiskCacheConfig
|
||||
import com.facebook.drawee.backends.pipeline.Fresco
|
||||
import com.facebook.imagepipeline.core.ImagePipelineConfig
|
||||
import com.nextcloud.talk.BuildConfig
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.components.filebrowser.webdav.DavUtils
|
||||
import com.nextcloud.talk.dagger.modules.BusModule
|
||||
import com.nextcloud.talk.dagger.modules.ContextModule
|
||||
@ -61,6 +61,7 @@ import com.nextcloud.talk.dagger.modules.ViewModelModule
|
||||
import com.nextcloud.talk.jobs.AccountRemovalWorker
|
||||
import com.nextcloud.talk.jobs.CapabilitiesWorker
|
||||
import com.nextcloud.talk.jobs.SignalingSettingsWorker
|
||||
import com.nextcloud.talk.models.database.Models
|
||||
import com.nextcloud.talk.utils.ClosedInterfaceImpl
|
||||
import com.nextcloud.talk.utils.DeviceUtils
|
||||
import com.nextcloud.talk.utils.DisplayUtils
|
||||
@ -74,12 +75,17 @@ import com.vanniktech.emoji.EmojiManager
|
||||
import com.vanniktech.emoji.google.GoogleEmojiProvider
|
||||
import de.cotech.hw.SecurityKeyManager
|
||||
import de.cotech.hw.SecurityKeyManagerConfig
|
||||
import io.requery.android.sqlcipher.SqlCipherDatabaseSource
|
||||
import net.sqlcipher.database.SQLiteDatabase
|
||||
import net.sqlcipher.database.SQLiteDatabaseHook
|
||||
import net.sqlcipher.database.SQLiteOpenHelper
|
||||
import okhttp3.OkHttpClient
|
||||
import org.conscrypt.Conscrypt
|
||||
import org.webrtc.PeerConnectionFactory
|
||||
import org.webrtc.voiceengine.WebRtcAudioManager
|
||||
import org.webrtc.voiceengine.WebRtcAudioUtils
|
||||
import java.security.Security
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
@ -113,6 +119,17 @@ class NextcloudTalkApplication : MultiDexApplication(), LifecycleObserver {
|
||||
lateinit var okHttpClient: OkHttpClient
|
||||
//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
|
||||
private fun initializeWebRtc() {
|
||||
try {
|
||||
@ -153,6 +170,8 @@ class NextcloudTalkApplication : MultiDexApplication(), LifecycleObserver {
|
||||
|
||||
componentApplication.inject(this)
|
||||
|
||||
checkAndUpgradeDbCypher()
|
||||
|
||||
Coil.setImageLoader(buildDefaultImageLoader())
|
||||
setAppTheme(appPreferences.theme)
|
||||
super.onCreate()
|
||||
@ -241,10 +260,52 @@ class NextcloudTalkApplication : MultiDexApplication(), LifecycleObserver {
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun checkAndUpgradeDbCypher() {
|
||||
if (appPreferences.isDbCypherToUpgrade) {
|
||||
val database = object : SqlCipherDatabaseSource(
|
||||
this,
|
||||
Models.DEFAULT,
|
||||
this
|
||||
.resources
|
||||
.getString(R.string.nc_app_product_name)
|
||||
.lowercase(Locale.getDefault())
|
||||
.replace(" ", "_")
|
||||
.trim { it <= ' ' } +
|
||||
".sqlite",
|
||||
this.getString(R.string.nc_talk_database_encryption_key),
|
||||
DatabaseModule.DB_VERSION
|
||||
) {
|
||||
override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
checkAndUpdateCipherMigrationStatus(newVersion, appPreferences)
|
||||
super.onUpgrade(db, oldVersion, newVersion)
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
val field = SQLiteOpenHelper::class.java.getDeclaredField("mHook")
|
||||
field.isAccessible = true
|
||||
field.set(database, hook)
|
||||
} catch (e: NoSuchFieldException) {
|
||||
Log.e("SqlCipherDatabaseSource", "Error accessing mHook field")
|
||||
} catch (e: IllegalAccessException) {
|
||||
Log.e("SqlCipherDatabaseSource", "Error setting mHook field")
|
||||
}
|
||||
|
||||
checkAndUpdateCipherMigrationStatus(database.writableDatabase.version, appPreferences)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkAndUpdateCipherMigrationStatus(version: Int, appPreferences: AppPreferences) {
|
||||
if (version >= CIPHER_V4_MIGRATION && appPreferences.isDbCypherToUpgrade) {
|
||||
appPreferences.isDbCypherToUpgrade = false
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val TAG = NextcloudTalkApplication::class.java.simpleName
|
||||
const val FIFTY_PERCENT = 0.5
|
||||
const val HALF_DAY: Long = 12
|
||||
const val CIPHER_V4_MIGRATION: Int = 7
|
||||
//region Singleton
|
||||
//endregion
|
||||
|
||||
|
@ -1,22 +1,23 @@
|
||||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* Nextcloud Talk application
|
||||
* @author Andy Scherzinger
|
||||
* @author Mario Danic
|
||||
* Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
|
||||
* Copyright (C) 2017 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* @author Mario Danic
|
||||
* Copyright (C) 2017 Mario Danic (mario@lovelyhq.com)
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.talk.dagger.modules;
|
||||
|
||||
@ -39,28 +40,38 @@ import javax.inject.Singleton;
|
||||
|
||||
@Module
|
||||
public class DatabaseModule {
|
||||
public static final int DB_VERSION = 7;
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public SqlCipherDatabaseSource provideSqlCipherDatabaseSource(@NonNull final Context context) {
|
||||
return new SqlCipherDatabaseSource(context, Models.DEFAULT,
|
||||
context.getResources().getString(R.string.nc_app_product_name).toLowerCase()
|
||||
.replace(" ", "_").trim() + ".sqlite",
|
||||
context.getString(R.string.nc_talk_database_encryption_key), 6);
|
||||
return new SqlCipherDatabaseSource(
|
||||
context,
|
||||
Models.DEFAULT,
|
||||
context
|
||||
.getResources()
|
||||
.getString(R.string.nc_app_product_name)
|
||||
.toLowerCase()
|
||||
.replace(" ", "_")
|
||||
.trim()
|
||||
+ ".sqlite",
|
||||
context.getString(R.string.nc_talk_database_encryption_key),
|
||||
DB_VERSION);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public ReactiveEntityStore<Persistable> provideDataStore(@NonNull final SqlCipherDatabaseSource sqlCipherDatabaseSource) {
|
||||
public ReactiveEntityStore<Persistable> provideDataStore(
|
||||
@NonNull final SqlCipherDatabaseSource sqlCipherDatabaseSource) {
|
||||
final Configuration configuration = sqlCipherDatabaseSource.getConfiguration();
|
||||
return ReactiveSupport.toReactiveStore(new EntityDataStore<Persistable>(configuration));
|
||||
return ReactiveSupport.toReactiveStore(new EntityDataStore<>(configuration));
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public AppPreferences providePreferences(@NonNull final Context poContext) {
|
||||
AppPreferences p = StoreBox.create(poContext, AppPreferences.class);
|
||||
p.removeLinkPreviews();
|
||||
return p;
|
||||
AppPreferences preferences = StoreBox.create(poContext, AppPreferences.class);
|
||||
preferences.removeLinkPreviews();
|
||||
return preferences;
|
||||
}
|
||||
}
|
||||
|
@ -281,6 +281,13 @@ public interface AppPreferences {
|
||||
@KeyByResource(R.string.nc_settings_theme_key)
|
||||
@UnregisterChangeListenerMethod
|
||||
void unregisterThemeChangeListener(OnPreferenceValueChangedListener<String> listener);
|
||||
|
||||
@KeyByString("db_cypher_v4_upgrade")
|
||||
@DefaultValue(R.bool.value_true)
|
||||
boolean getIsDbCypherToUpgrade();
|
||||
|
||||
@KeyByString("db_cypher_v4_upgrade")
|
||||
void setIsDbCypherToUpgrade(boolean value);
|
||||
|
||||
@KeyByResource(R.string.nc_settings_phone_book_integration_key)
|
||||
@RegisterChangeListenerMethod
|
||||
|
@ -252,11 +252,11 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||
}
|
||||
}
|
||||
} else if (eventOverallWebSocketMessage.getEventMap().get("type").equals("join")) {
|
||||
List<HashMap<String, Object>> joinEventMap = (List<HashMap<String, Object>>) eventOverallWebSocketMessage.getEventMap().get("join");
|
||||
List<HashMap<String, Object>> joinEventList = (List<HashMap<String, Object>>) eventOverallWebSocketMessage.getEventMap().get("join");
|
||||
HashMap<String, Object> internalHashMap;
|
||||
Participant participant;
|
||||
for (int i = 0; i < joinEventMap.size(); i++) {
|
||||
internalHashMap = joinEventMap.get(i);
|
||||
for (int i = 0; i < joinEventList.size(); i++) {
|
||||
internalHashMap = joinEventList.get(i);
|
||||
HashMap<String, Object> userMap = (HashMap<String, Object>) internalHashMap.get("user");
|
||||
participant = new Participant();
|
||||
String userId = (String) internalHashMap.get("userid");
|
||||
|
@ -1 +1 @@
|
||||
174
|
||||
173
|
@ -1,2 +1,2 @@
|
||||
DO NOT TOUCH; GENERATED BY DRONE
|
||||
<span class="mdl-layout-title">Lint Report: 2 errors and 122 warnings</span>
|
||||
<span class="mdl-layout-title">Lint Report: 2 errors and 123 warnings</span>
|
||||
|
Loading…
Reference in New Issue
Block a user