Add call log event proto updates.
This commit is contained in:
parent
989bd662c6
commit
6f46331772
6 changed files with 48 additions and 17 deletions
|
@ -43,8 +43,9 @@ class CallLogRepository(
|
|||
|
||||
fun markAllCallEventsRead() {
|
||||
SignalExecutors.BOUNDED_IO.execute {
|
||||
val latestCall = SignalDatabase.calls.getLatestCall() ?: return@execute
|
||||
SignalDatabase.calls.markAllCallEventsRead()
|
||||
ApplicationDependencies.getJobManager().add(CallLogEventSendJob.forMarkedAsRead(System.currentTimeMillis()))
|
||||
ApplicationDependencies.getJobManager().add(CallLogEventSendJob.forMarkedAsRead(latestCall))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,10 +96,10 @@ class CallLogRepository(
|
|||
fun deleteAllCallLogsOnOrBeforeNow(): Single<Int> {
|
||||
return Single.fromCallable {
|
||||
SignalDatabase.rawDatabase.withinTransaction {
|
||||
val latestTimestamp = SignalDatabase.calls.getLatestTimestamp()
|
||||
SignalDatabase.calls.deleteNonAdHocCallEventsOnOrBefore(latestTimestamp)
|
||||
SignalDatabase.callLinks.deleteNonAdminCallLinksOnOrBefore(latestTimestamp)
|
||||
ApplicationDependencies.getJobManager().add(CallLogEventSendJob.forClearHistory(latestTimestamp))
|
||||
val latestCall = SignalDatabase.calls.getLatestCall() ?: return@withinTransaction
|
||||
SignalDatabase.calls.deleteNonAdHocCallEventsOnOrBefore(latestCall.timestamp)
|
||||
SignalDatabase.callLinks.deleteNonAdminCallLinksOnOrBefore(latestCall.timestamp)
|
||||
ApplicationDependencies.getJobManager().add(CallLogEventSendJob.forClearHistory(latestCall))
|
||||
}
|
||||
|
||||
SignalDatabase.callLinks.getAllAdminCallLinksExcept(emptySet())
|
||||
|
|
|
@ -947,12 +947,12 @@ class CallTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTabl
|
|||
/**
|
||||
* Gets the most recent timestamp from the [TIMESTAMP] column
|
||||
*/
|
||||
fun getLatestTimestamp(): Long {
|
||||
fun getLatestCall(): Call? {
|
||||
val statement = """
|
||||
SELECT $TIMESTAMP FROM $TABLE_NAME ORDER BY $TIMESTAMP DESC LIMIT 1
|
||||
SELECT * FROM $TABLE_NAME ORDER BY $TIMESTAMP DESC LIMIT 1
|
||||
""".trimIndent()
|
||||
|
||||
return readableDatabase.query(statement).readToSingleLong(-1)
|
||||
return readableDatabase.query(statement).readToSingleObject { Call.deserialize(it) }
|
||||
}
|
||||
|
||||
fun deleteNonAdHocCallEventsOnOrBefore(timestamp: Long) {
|
||||
|
|
|
@ -5,10 +5,15 @@
|
|||
|
||||
package org.thoughtcrime.securesms.jobs
|
||||
|
||||
import androidx.annotation.WorkerThread
|
||||
import okio.ByteString
|
||||
import okio.ByteString.Companion.toByteString
|
||||
import org.thoughtcrime.securesms.database.CallTable
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.jobs.protos.CallLogEventSendJobData
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage
|
||||
import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException
|
||||
import org.whispersystems.signalservice.api.push.exceptions.ServerRejectedException
|
||||
|
@ -27,8 +32,9 @@ class CallLogEventSendJob private constructor(
|
|||
companion object {
|
||||
const val KEY = "CallLogEventSendJob"
|
||||
|
||||
@WorkerThread
|
||||
fun forClearHistory(
|
||||
timestamp: Long
|
||||
call: CallTable.Call
|
||||
) = CallLogEventSendJob(
|
||||
Parameters.Builder()
|
||||
.setQueue("CallLogEventSendJob")
|
||||
|
@ -37,13 +43,16 @@ class CallLogEventSendJob private constructor(
|
|||
.addConstraint(NetworkConstraint.KEY)
|
||||
.build(),
|
||||
SyncMessage.CallLogEvent(
|
||||
timestamp = timestamp,
|
||||
timestamp = call.timestamp,
|
||||
callId = call.callId,
|
||||
conversationId = Recipient.resolved(call.peer).requireCallConversationId().toByteString(),
|
||||
type = SyncMessage.CallLogEvent.Type.CLEAR
|
||||
)
|
||||
)
|
||||
|
||||
@WorkerThread
|
||||
fun forMarkedAsRead(
|
||||
timestamp: Long
|
||||
call: CallTable.Call
|
||||
) = CallLogEventSendJob(
|
||||
Parameters.Builder()
|
||||
.setQueue("CallLogEventSendJob")
|
||||
|
@ -52,7 +61,9 @@ class CallLogEventSendJob private constructor(
|
|||
.addConstraint(NetworkConstraint.KEY)
|
||||
.build(),
|
||||
SyncMessage.CallLogEvent(
|
||||
timestamp = timestamp,
|
||||
timestamp = call.timestamp,
|
||||
callId = call.callId,
|
||||
conversationId = Recipient.resolved(call.peer).requireCallConversationId().toByteString(),
|
||||
type = SyncMessage.CallLogEvent.Type.MARKED_AS_READ
|
||||
)
|
||||
)
|
||||
|
|
|
@ -29,6 +29,8 @@ import androidx.camera.core.ZoomState
|
|||
import androidx.camera.core.resolutionselector.AspectRatioStrategy
|
||||
import androidx.camera.core.resolutionselector.ResolutionSelector
|
||||
import androidx.camera.core.resolutionselector.ResolutionStrategy
|
||||
import androidx.camera.extensions.ExtensionMode
|
||||
import androidx.camera.extensions.ExtensionsManager
|
||||
import androidx.camera.lifecycle.ProcessCameraProvider
|
||||
import androidx.camera.video.FallbackStrategy
|
||||
import androidx.camera.video.FileDescriptorOutputOptions
|
||||
|
@ -56,8 +58,6 @@ import org.thoughtcrime.securesms.util.visible
|
|||
import java.util.concurrent.Executor
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import androidx.camera.extensions.ExtensionMode
|
||||
import androidx.camera.extensions.ExtensionsManager
|
||||
|
||||
/**
|
||||
* This is a class to manage the camera resource, and relies on the AndroidX CameraX library.
|
||||
|
@ -145,7 +145,7 @@ class SignalCameraController(
|
|||
return
|
||||
}
|
||||
|
||||
val extCameraSelector = if (extensionsManager.isExtensionAvailable(cameraSelector, ExtensionMode.AUTO)) {
|
||||
val extCameraSelector = if (extensionsManager.isExtensionAvailable(cameraSelector, ExtensionMode.AUTO)) {
|
||||
Log.d(TAG, "Using CameraX ExtensionMode.AUTO")
|
||||
extensionsManager.getExtensionEnabledCameraSelector(
|
||||
cameraSelector,
|
||||
|
|
|
@ -1221,6 +1221,18 @@ public class Recipient {
|
|||
return Objects.requireNonNull(callLinkRoomId);
|
||||
}
|
||||
|
||||
public @NonNull byte[] requireCallConversationId() {
|
||||
if (isPushGroup()) {
|
||||
return requireGroupId().getDecodedId();
|
||||
} else if (isCallLink()) {
|
||||
return requireCallLinkRoomId().encodeForProto().toByteArray();
|
||||
} else if (isIndividual()) {
|
||||
return requireServiceId().toByteArray();
|
||||
} else {
|
||||
throw new IllegalStateException("Recipient does not support conversation id");
|
||||
}
|
||||
}
|
||||
|
||||
public PhoneNumberSharingState getPhoneNumberSharing() {
|
||||
return phoneNumberSharing;
|
||||
}
|
||||
|
|
|
@ -641,8 +641,15 @@ message SyncMessage {
|
|||
MARKED_AS_READ = 1;
|
||||
}
|
||||
|
||||
optional Type type = 1;
|
||||
optional uint64 timestamp = 2;
|
||||
optional Type type = 1;
|
||||
optional uint64 timestamp = 2;
|
||||
/* Data identifying a conversation. The service ID for 1:1, the group ID for
|
||||
* group, or the room ID for an ad-hoc call. See also
|
||||
* `CallEvent/conversationId`. */
|
||||
optional bytes conversationId = 3;
|
||||
/* An identifier for a call. Generated directly for 1:1, or derived from
|
||||
* the era ID for group and ad-hoc calls. See also `CallEvent/callId`. */
|
||||
optional uint64 callId = 4;
|
||||
}
|
||||
|
||||
optional Sent sent = 1;
|
||||
|
|
Loading…
Add table
Reference in a new issue