mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 02:25:19 +00:00
Merge & update for core changes
This commit is contained in:
commit
45a2ea996b
@ -524,7 +524,7 @@
|
||||
<service
|
||||
android:name="org.thoughtcrime.securesms.loki.api.PushNotificationService"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
||||
</intent-filter>
|
||||
@ -681,7 +681,9 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<!-- Session -->
|
||||
<receiver android:name="org.thoughtcrime.securesms.loki.api.BackgroundPollListener" >
|
||||
<receiver
|
||||
android:name="org.thoughtcrime.securesms.loki.api.BackgroundPollListener"
|
||||
android:enabled="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
|
@ -484,7 +484,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
||||
Context context = this;
|
||||
FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener(task -> {
|
||||
if (!task.isSuccessful()) {
|
||||
Log.w(TAG, "getInstanceId failed", task.getException());
|
||||
Log.w("Loki", "FirebaseInstanceId.getInstance().getInstanceId() failed." + task.getException());
|
||||
return;
|
||||
}
|
||||
String token = task.getResult().getToken();
|
||||
|
@ -9,7 +9,6 @@ import org.whispersystems.libsignal.logging.Log
|
||||
import org.whispersystems.signalservice.internal.util.JsonUtil
|
||||
import org.whispersystems.signalservice.loki.api.PushNotificationAcknowledgement
|
||||
import org.whispersystems.signalservice.loki.api.onionrequests.OnionRequestAPI
|
||||
import java.io.IOException
|
||||
|
||||
object LokiPushNotificationManager {
|
||||
private val tokenExpirationInterval = 12 * 60 * 60 * 1000
|
||||
@ -17,8 +16,8 @@ object LokiPushNotificationManager {
|
||||
private val server by lazy {
|
||||
PushNotificationAcknowledgement.shared.server
|
||||
}
|
||||
private val PNServerPublicKey by lazy {
|
||||
PushNotificationAcknowledgement.shared.PNServerPublicKey
|
||||
private val pnServerPublicKey by lazy {
|
||||
PushNotificationAcknowledgement.pnServerPublicKey
|
||||
}
|
||||
|
||||
enum class ClosedGroupOperation {
|
||||
@ -39,15 +38,14 @@ object LokiPushNotificationManager {
|
||||
val url = "$server/unregister"
|
||||
val body = RequestBody.create(MediaType.get("application/json"), JsonUtil.toJson(parameters))
|
||||
val request = Request.Builder().url(url).post(body)
|
||||
val promise = OnionRequestAPI.sendOnionRequest(request.build(), server, PNServerPublicKey).map { json ->
|
||||
OnionRequestAPI.sendOnionRequest(request.build(), server, pnServerPublicKey).map { json ->
|
||||
val code = json["code"] as? Int
|
||||
if (code != null && code != 0) {
|
||||
TextSecurePreferences.setIsUsingFCM(context, false)
|
||||
} else {
|
||||
Log.d("Loki", "Couldn't disable FCM due to error: ${json["message"] as? String ?: "null"}.")
|
||||
}
|
||||
}
|
||||
promise.fail { exception ->
|
||||
}.fail { exception ->
|
||||
Log.d("Loki", "Couldn't disable FCM due to error: ${exception}.")
|
||||
}
|
||||
// Unsubscribe from all closed groups
|
||||
@ -67,7 +65,7 @@ object LokiPushNotificationManager {
|
||||
val url = "$server/register"
|
||||
val body = RequestBody.create(MediaType.get("application/json"), JsonUtil.toJson(parameters))
|
||||
val request = Request.Builder().url(url).post(body)
|
||||
val promise = OnionRequestAPI.sendOnionRequest(request.build(), server, PNServerPublicKey).map { json ->
|
||||
OnionRequestAPI.sendOnionRequest(request.build(), server, pnServerPublicKey).map { json ->
|
||||
val code = json["code"] as? Int
|
||||
if (code != null && code != 0) {
|
||||
TextSecurePreferences.setIsUsingFCM(context, true)
|
||||
@ -76,8 +74,7 @@ object LokiPushNotificationManager {
|
||||
} else {
|
||||
Log.d("Loki", "Couldn't register for FCM due to error: ${json["message"] as? String ?: "null"}.")
|
||||
}
|
||||
}
|
||||
promise.fail { exception ->
|
||||
}.fail { exception ->
|
||||
Log.d("Loki", "Couldn't register for FCM due to error: ${exception}.")
|
||||
}
|
||||
// Subscribe to all closed groups
|
||||
@ -94,13 +91,12 @@ object LokiPushNotificationManager {
|
||||
val url = "$server/${operation.rawValue}"
|
||||
val body = RequestBody.create(MediaType.get("application/json"), JsonUtil.toJson(parameters))
|
||||
val request = Request.Builder().url(url).post(body)
|
||||
val promise = OnionRequestAPI.sendOnionRequest(request.build(), server, PNServerPublicKey).map { json ->
|
||||
OnionRequestAPI.sendOnionRequest(request.build(), server, pnServerPublicKey).map { json ->
|
||||
val code = json["code"] as? Int
|
||||
if (code == null || code == 0) {
|
||||
Log.d("Loki", "Couldn't subscribe/unsubscribe closed group: $closedGroupPublicKey due to error: ${json["message"] as? String ?: "null"}.")
|
||||
}
|
||||
}
|
||||
promise.fail { exception ->
|
||||
}.fail { exception ->
|
||||
Log.d("Loki", "Couldn't subscribe/unsubscribe closed group: $closedGroupPublicKey due to error: ${exception}.")
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,11 @@
|
||||
package org.thoughtcrime.securesms.loki.api
|
||||
|
||||
import android.R
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.media.RingtoneManager
|
||||
import com.google.firebase.messaging.FirebaseMessagingService
|
||||
import com.google.firebase.messaging.RemoteMessage
|
||||
import org.thoughtcrime.securesms.jobs.PushContentReceiveJob
|
||||
@ -9,6 +15,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope
|
||||
import org.whispersystems.signalservice.internal.util.Base64
|
||||
import org.whispersystems.signalservice.loki.api.MessageWrapper
|
||||
|
||||
|
||||
class PushNotificationService : FirebaseMessagingService() {
|
||||
|
||||
override fun onNewToken(token: String) {
|
||||
@ -19,7 +26,8 @@ class PushNotificationService : FirebaseMessagingService() {
|
||||
}
|
||||
|
||||
override fun onMessageReceived(message: RemoteMessage) {
|
||||
val base64EncodedData = message.data["ENCRYPTED_DATA"]
|
||||
Log.d("Loki", "Received a push notification.")
|
||||
val base64EncodedData = message.data?.get("ENCRYPTED_DATA")
|
||||
val data = base64EncodedData?.let { Base64.decode(it) }
|
||||
if (data != null) {
|
||||
try {
|
||||
|
@ -129,7 +129,7 @@ class ClosedGroupUpdateMessageSendJob private constructor(parameters: Parameters
|
||||
// isClosedGroup can always be false as it's only used in the context of legacy closed groups
|
||||
messageSender.sendMessage(0, address, udAccess.get().targetUnidentifiedAccess,
|
||||
Date().time, serializedContentMessage, false, ttl, false,
|
||||
useFallbackEncryption, false, false)
|
||||
useFallbackEncryption, false, false, false)
|
||||
} catch (e: Exception) {
|
||||
Log.d("Loki", "Failed to send closed group update message to: $destination due to error: $e.")
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ import java.io.IOException
|
||||
import java.util.*
|
||||
|
||||
object ClosedGroupsProtocol {
|
||||
val isSharedSenderKeysEnabled = false
|
||||
val isSharedSenderKeysEnabled = true
|
||||
val groupSizeLimit = 10
|
||||
|
||||
public fun createClosedGroup(context: Context, name: String, members: Collection<String>): Promise<String, Exception> {
|
||||
|
@ -56,7 +56,7 @@ class NullMessageSendJob private constructor(parameters: Parameters, private val
|
||||
try {
|
||||
messageSender.sendMessage(0, address, udAccess.get().targetUnidentifiedAccess,
|
||||
Date().time, serializedContentMessage, false, ttl, false,
|
||||
false, false, false)
|
||||
false, false, false, false)
|
||||
} catch (e: Exception) {
|
||||
Log.d("Loki", "Failed to send null message to: $publicKey due to error: $e.")
|
||||
throw e
|
||||
|
@ -72,7 +72,7 @@ class SessionRequestMessageSendJob private constructor(parameters: Parameters, p
|
||||
try {
|
||||
messageSender.sendMessage(0, address, udAccess.get().targetUnidentifiedAccess,
|
||||
Date().time, serializedContentMessage, false, ttl, false,
|
||||
true, false, false)
|
||||
true, false, false, false)
|
||||
} catch (e: Exception) {
|
||||
Log.d("Loki", "Failed to send session request to: $publicKey due to error: $e.")
|
||||
throw e
|
||||
|
Loading…
Reference in New Issue
Block a user