Merge branch 'dev' into variable-rate-polling

This commit is contained in:
Niels Andriesse 2021-05-21 10:07:41 +10:00
commit 2a756375a8
7 changed files with 26 additions and 17 deletions

View File

@ -143,7 +143,7 @@ dependencies {
testImplementation 'org.robolectric:shadows-multidex:4.2' testImplementation 'org.robolectric:shadows-multidex:4.2'
} }
def canonicalVersionCode = 169 def canonicalVersionCode = 170
def canonicalVersionName = "1.10.7" def canonicalVersionName = "1.10.7"
def postFixSize = 10 def postFixSize = 10

View File

@ -56,9 +56,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
private static final int lokiV22 = 43; private static final int lokiV22 = 43;
private static final int lokiV23 = 44; private static final int lokiV23 = 44;
private static final int lokiV24 = 45; 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 // 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 static final String DATABASE_NAME = "signal.db";
private final Context context; private final Context context;
@ -291,6 +292,12 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
db.execSQL(LokiAPIDatabase.getCreateSwarmTableCommand()); db.execSQL(LokiAPIDatabase.getCreateSwarmTableCommand());
} }
if (oldVersion < lokiV25) {
String jobTable = SessionJobDatabase.sessionJobTable;
db.execSQL("DROP TABLE " + jobTable);
db.execSQL(SessionJobDatabase.getCreateSessionJobTableCommand());
}
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {
db.endTransaction(); db.endTransaction();

View File

@ -14,7 +14,7 @@ import org.thoughtcrime.securesms.loki.utilities.*
class SessionJobDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper) { class SessionJobDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper) {
companion object { companion object {
private const val sessionJobTable = "session_job_database" const val sessionJobTable = "session_job_database"
const val jobID = "job_id" const val jobID = "job_id"
const val jobType = "job_type" const val jobType = "job_type"
const val failureCount = "failure_count" const val failureCount = "failure_count"

View File

@ -28,7 +28,7 @@ dependencies {
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'com.annimon:stream:1.1.8' implementation 'com.annimon:stream:1.1.8'
implementation 'com.makeramen:roundedimageview:2.1.0' 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.google.protobuf:protobuf-java:$protobufVersion"
implementation "com.fasterxml.jackson.core:jackson-databind:$jacksonDatabindVersion" implementation "com.fasterxml.jackson.core:jackson-databind:$jacksonDatabindVersion"
implementation "org.whispersystems:curve25519-java:$curve25519Version" implementation "org.whispersystems:curve25519-java:$curve25519Version"

View File

@ -158,7 +158,7 @@ class AttachmentUploadJob(val attachmentID: Long, val threadID: String, val mess
.putString(THREAD_ID_KEY, threadID) .putString(THREAD_ID_KEY, threadID)
.putByteArray(MESSAGE_KEY, serializedMessage) .putByteArray(MESSAGE_KEY, serializedMessage)
.putString(MESSAGE_SEND_JOB_ID_KEY, messageSendJobID) .putString(MESSAGE_SEND_JOB_ID_KEY, messageSendJobID)
.build(); .build()
} }
override fun getFactoryKey(): String { override fun getFactoryKey(): String {
@ -172,7 +172,7 @@ class AttachmentUploadJob(val attachmentID: Long, val threadID: String, val mess
val kryo = Kryo() val kryo = Kryo()
kryo.isRegistrationRequired = false kryo.isRegistrationRequired = false
val input = Input(serializedMessage) val input = Input(serializedMessage)
val message: Message = kryo.readObject(input, Message::class.java) val message = kryo.readObject(input, Message::class.java)
input.close() input.close()
return AttachmentUploadJob( return AttachmentUploadJob(
data.getLong(ATTACHMENT_ID_KEY), data.getLong(ATTACHMENT_ID_KEY),

View File

@ -88,17 +88,16 @@ class MessageSendJob(val message: Message, val destination: Destination) : Job {
override fun serialize(): Data { override fun serialize(): Data {
val kryo = Kryo() val kryo = Kryo()
kryo.isRegistrationRequired = false kryo.isRegistrationRequired = false
val output = Output(ByteArray(4096), MAX_BUFFER_SIZE)
// Message // Message
kryo.writeClassAndObject(output, message) val messageOutput = Output(ByteArray(4096), MAX_BUFFER_SIZE)
output.close() kryo.writeClassAndObject(messageOutput, message)
val serializedMessage = output.toBytes() messageOutput.close()
output.clear() val serializedMessage = messageOutput.toBytes()
// Destination // Destination
kryo.writeClassAndObject(output, destination) val destinationOutput = Output(ByteArray(4096), MAX_BUFFER_SIZE)
output.close() kryo.writeClassAndObject(destinationOutput, destination)
val serializedDestination = output.toBytes() destinationOutput.close()
output.clear() val serializedDestination = destinationOutput.toBytes()
// Serialize // Serialize
return Data.Builder() return Data.Builder()
.putByteArray(MESSAGE_KEY, serializedMessage) .putByteArray(MESSAGE_KEY, serializedMessage)
@ -116,6 +115,7 @@ class MessageSendJob(val message: Message, val destination: Destination) : Job {
val serializedMessage = data.getByteArray(MESSAGE_KEY) val serializedMessage = data.getByteArray(MESSAGE_KEY)
val serializedDestination = data.getByteArray(DESTINATION_KEY) val serializedDestination = data.getByteArray(DESTINATION_KEY)
val kryo = Kryo() val kryo = Kryo()
kryo.isRegistrationRequired = false
// Message // Message
val messageInput = Input(serializedMessage) val messageInput = Input(serializedMessage)
val message: Message val message: Message

View File

@ -67,7 +67,9 @@ class NotifyPNServerJob(val message: SnodeMessage) : Job {
val output = Output(serializedMessage) val output = Output(serializedMessage)
kryo.writeObject(output, message) kryo.writeObject(output, message)
output.close() output.close()
return Data.Builder().putByteArray(MESSAGE_KEY, serializedMessage).build(); return Data.Builder()
.putByteArray(MESSAGE_KEY, serializedMessage)
.build();
} }
override fun getFactoryKey(): String { override fun getFactoryKey(): String {
@ -81,7 +83,7 @@ class NotifyPNServerJob(val message: SnodeMessage) : Job {
val kryo = Kryo() val kryo = Kryo()
kryo.isRegistrationRequired = false kryo.isRegistrationRequired = false
val input = Input(serializedMessage) val input = Input(serializedMessage)
val message: SnodeMessage = kryo.readObject(input, SnodeMessage::class.java) val message = kryo.readObject(input, SnodeMessage::class.java)
input.close() input.close()
return NotifyPNServerJob(message) return NotifyPNServerJob(message)
} }