diff --git a/app/build.gradle b/app/build.gradle index 48ed18bc2c..f45317006a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -143,7 +143,7 @@ dependencies { testImplementation 'org.robolectric:shadows-multidex:4.2' } -def canonicalVersionCode = 169 +def canonicalVersionCode = 170 def canonicalVersionName = "1.10.7" def postFixSize = 10 diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java index 034fd7f521..d6c62f8f15 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java @@ -56,9 +56,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { private static final int lokiV22 = 43; private static final int lokiV23 = 44; private static final int lokiV24 = 45; + private static final int lokiV25 = 46; // Loki - onUpgrade(...) must be updated to use Loki version numbers if Signal makes any database changes - private static final int DATABASE_VERSION = lokiV24; + private static final int DATABASE_VERSION = lokiV25; private static final String DATABASE_NAME = "signal.db"; private final Context context; @@ -291,6 +292,12 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { db.execSQL(LokiAPIDatabase.getCreateSwarmTableCommand()); } + if (oldVersion < lokiV25) { + String jobTable = SessionJobDatabase.sessionJobTable; + db.execSQL("DROP TABLE " + jobTable); + db.execSQL(SessionJobDatabase.getCreateSessionJobTableCommand()); + } + db.setTransactionSuccessful(); } finally { db.endTransaction(); diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/database/SessionJobDatabase.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/database/SessionJobDatabase.kt index 55409e1a5e..6d070865ac 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/database/SessionJobDatabase.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/database/SessionJobDatabase.kt @@ -14,7 +14,7 @@ import org.thoughtcrime.securesms.loki.utilities.* class SessionJobDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper) { companion object { - private const val sessionJobTable = "session_job_database" + const val sessionJobTable = "session_job_database" const val jobID = "job_id" const val jobType = "job_type" const val failureCount = "failure_count" diff --git a/libsession/build.gradle b/libsession/build.gradle index bc78036b1e..6763e0cff5 100644 --- a/libsession/build.gradle +++ b/libsession/build.gradle @@ -28,7 +28,7 @@ dependencies { implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' implementation 'com.annimon:stream:1.1.8' implementation 'com.makeramen:roundedimageview:2.1.0' - implementation 'com.esotericsoftware:kryo:4.0.1' + implementation 'com.esotericsoftware:kryo:5.1.1' implementation "com.google.protobuf:protobuf-java:$protobufVersion" implementation "com.fasterxml.jackson.core:jackson-databind:$jacksonDatabindVersion" implementation "org.whispersystems:curve25519-java:$curve25519Version" diff --git a/libsession/src/main/java/org/session/libsession/messaging/jobs/AttachmentUploadJob.kt b/libsession/src/main/java/org/session/libsession/messaging/jobs/AttachmentUploadJob.kt index 2928b3a9dc..00432d3ff3 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/jobs/AttachmentUploadJob.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/jobs/AttachmentUploadJob.kt @@ -158,7 +158,7 @@ class AttachmentUploadJob(val attachmentID: Long, val threadID: String, val mess .putString(THREAD_ID_KEY, threadID) .putByteArray(MESSAGE_KEY, serializedMessage) .putString(MESSAGE_SEND_JOB_ID_KEY, messageSendJobID) - .build(); + .build() } override fun getFactoryKey(): String { @@ -172,7 +172,7 @@ class AttachmentUploadJob(val attachmentID: Long, val threadID: String, val mess val kryo = Kryo() kryo.isRegistrationRequired = false val input = Input(serializedMessage) - val message: Message = kryo.readObject(input, Message::class.java) + val message = kryo.readObject(input, Message::class.java) input.close() return AttachmentUploadJob( data.getLong(ATTACHMENT_ID_KEY), diff --git a/libsession/src/main/java/org/session/libsession/messaging/jobs/MessageSendJob.kt b/libsession/src/main/java/org/session/libsession/messaging/jobs/MessageSendJob.kt index 71a28ffdb4..87fead7c58 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/jobs/MessageSendJob.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/jobs/MessageSendJob.kt @@ -88,17 +88,16 @@ class MessageSendJob(val message: Message, val destination: Destination) : Job { override fun serialize(): Data { val kryo = Kryo() kryo.isRegistrationRequired = false - val output = Output(ByteArray(4096), MAX_BUFFER_SIZE) // Message - kryo.writeClassAndObject(output, message) - output.close() - val serializedMessage = output.toBytes() - output.clear() + val messageOutput = Output(ByteArray(4096), MAX_BUFFER_SIZE) + kryo.writeClassAndObject(messageOutput, message) + messageOutput.close() + val serializedMessage = messageOutput.toBytes() // Destination - kryo.writeClassAndObject(output, destination) - output.close() - val serializedDestination = output.toBytes() - output.clear() + val destinationOutput = Output(ByteArray(4096), MAX_BUFFER_SIZE) + kryo.writeClassAndObject(destinationOutput, destination) + destinationOutput.close() + val serializedDestination = destinationOutput.toBytes() // Serialize return Data.Builder() .putByteArray(MESSAGE_KEY, serializedMessage) @@ -116,6 +115,7 @@ class MessageSendJob(val message: Message, val destination: Destination) : Job { val serializedMessage = data.getByteArray(MESSAGE_KEY) val serializedDestination = data.getByteArray(DESTINATION_KEY) val kryo = Kryo() + kryo.isRegistrationRequired = false // Message val messageInput = Input(serializedMessage) val message: Message diff --git a/libsession/src/main/java/org/session/libsession/messaging/jobs/NotifyPNServerJob.kt b/libsession/src/main/java/org/session/libsession/messaging/jobs/NotifyPNServerJob.kt index f11f194891..5b3225b117 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/jobs/NotifyPNServerJob.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/jobs/NotifyPNServerJob.kt @@ -67,7 +67,9 @@ class NotifyPNServerJob(val message: SnodeMessage) : Job { val output = Output(serializedMessage) kryo.writeObject(output, message) output.close() - return Data.Builder().putByteArray(MESSAGE_KEY, serializedMessage).build(); + return Data.Builder() + .putByteArray(MESSAGE_KEY, serializedMessage) + .build(); } override fun getFactoryKey(): String { @@ -81,7 +83,7 @@ class NotifyPNServerJob(val message: SnodeMessage) : Job { val kryo = Kryo() kryo.isRegistrationRequired = false val input = Input(serializedMessage) - val message: SnodeMessage = kryo.readObject(input, SnodeMessage::class.java) + val message = kryo.readObject(input, SnodeMessage::class.java) input.close() return NotifyPNServerJob(message) }