mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-17 15:33:30 +01:00
Update SQLCipher to 4.13.0
This commit is contained in:
committed by
jeffrey-signal
parent
94e28eddd0
commit
bdc90f3c02
@@ -27,6 +27,8 @@ import androidx.annotation.WorkerThread;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.google.android.gms.security.ProviderInstaller;
|
||||
|
||||
import net.zetetic.database.Logger;
|
||||
|
||||
import org.conscrypt.ConscryptSignal;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.signal.aesgcmprovider.AesGcmProvider;
|
||||
@@ -79,7 +81,6 @@ import org.thoughtcrime.securesms.jobs.RestoreOptimizedMediaJob;
|
||||
import org.thoughtcrime.securesms.jobs.RetrieveProfileJob;
|
||||
import org.thoughtcrime.securesms.jobs.RetrieveRemoteAnnouncementsJob;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.SealedSenderConstraint;
|
||||
import org.thoughtcrime.securesms.jobs.RetryPendingSendsJob;
|
||||
import org.thoughtcrime.securesms.jobs.StoryOnboardingDownloadJob;
|
||||
import org.thoughtcrime.securesms.keyvalue.KeepMessagesDuration;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
@@ -110,6 +111,7 @@ import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig;
|
||||
import org.thoughtcrime.securesms.util.SignalLocalMetrics;
|
||||
import org.thoughtcrime.securesms.util.SignalUncaughtExceptionHandler;
|
||||
import org.thoughtcrime.securesms.util.SqlCipherLogTarget;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.signal.core.util.Util;
|
||||
import org.thoughtcrime.securesms.util.VersionTracker;
|
||||
@@ -161,6 +163,7 @@ public class ApplicationContext extends Application implements AppForegroundObse
|
||||
SignalDatabase.init(this,
|
||||
DatabaseSecretProvider.getOrCreateDatabaseSecret(this),
|
||||
AttachmentSecretProvider.getInstance(this).getOrCreateAttachmentSecret());
|
||||
Logger.setTarget(SqlCipherLogTarget.INSTANCE);
|
||||
})
|
||||
.addBlocking("signal-store", () -> SignalStore.init(this))
|
||||
.addBlocking("logging", () -> {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms.database;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteException;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@@ -27,7 +28,9 @@ public final class SqlCipherDeletingErrorHandler implements DatabaseErrorHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCorruption(SQLiteDatabase db, String message) {
|
||||
public void onCorruption(SQLiteDatabase db, SQLiteException exception) {
|
||||
String message = exception != null ? exception.getMessage() : "Unknown";
|
||||
|
||||
try {
|
||||
Log.e(TAG, "Database '" + databaseName + "' corrupted! Message: " + message + ". Going to try to run some diagnostics.");
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.database
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.database.sqlite.SQLiteException
|
||||
import net.zetetic.database.DatabaseErrorHandler
|
||||
import net.zetetic.database.sqlcipher.SQLiteConnection
|
||||
import net.zetetic.database.sqlcipher.SQLiteDatabase
|
||||
@@ -25,7 +26,7 @@ class SqlCipherErrorHandler(private val application: Application, private val da
|
||||
private val errorHandlingInProgress = AtomicBoolean(false)
|
||||
}
|
||||
|
||||
override fun onCorruption(db: SQLiteDatabase, message: String) {
|
||||
override fun onCorruption(db: SQLiteDatabase, exception: SQLiteException?) {
|
||||
if (errorHandlingInProgress.getAndSet(true)) {
|
||||
Log.w(TAG, "Error handling already in progress, skipping.")
|
||||
return
|
||||
@@ -34,10 +35,10 @@ class SqlCipherErrorHandler(private val application: Application, private val da
|
||||
try {
|
||||
val result: DiagnosticResults = runDiagnostics(application, db)
|
||||
var lines: List<String> = result.logs.split("\n")
|
||||
lines = listOf("Database '$databaseName' corrupted!", "[sqlite] $message", "Diagnostics results:") + lines
|
||||
lines = listOf("Database '$databaseName' corrupted!", "[sqlite] ${exception?.message}", "Diagnostics results:") + lines
|
||||
|
||||
Log.e(TAG, "Database '$databaseName' corrupted!")
|
||||
Log.e(TAG, "[sqlite] $message")
|
||||
Log.e(TAG, "[sqlite] ${exception?.message}")
|
||||
Log.e(TAG, "Diagnostic results:\n ${result.logs}")
|
||||
|
||||
if (result is DiagnosticResults.Success) {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2026 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.thoughtcrime.securesms.util
|
||||
|
||||
import net.zetetic.database.LogTarget
|
||||
import net.zetetic.database.Logger
|
||||
import org.signal.core.util.logging.Log
|
||||
|
||||
object SqlCipherLogTarget : LogTarget {
|
||||
override fun isLoggable(tag: String?, priority: Int): Boolean {
|
||||
// Logger.DEBUG logs are extremely verbose, and include things like status updates on cursors being filled
|
||||
return priority >= Logger.INFO
|
||||
}
|
||||
|
||||
override fun log(priority: Int, tag: String?, message: String?, throwable: Throwable?) {
|
||||
val tag = tag ?: "SqlCipher"
|
||||
when (priority) {
|
||||
Logger.VERBOSE -> Log.v(tag, message, throwable)
|
||||
Logger.DEBUG -> Log.d(tag, message, throwable)
|
||||
Logger.INFO -> Log.i(tag, message, throwable)
|
||||
Logger.WARN -> Log.w(tag, message, throwable)
|
||||
Logger.ERROR -> Log.e(tag, message, throwable)
|
||||
Logger.ASSERT -> Log.e(tag, message, throwable)
|
||||
else -> Log.d(tag, message, throwable)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user