Merge pull request #1018 from session-foundation/release/1.21.1

Bring 1.21.1 back to dev
pull/1710/head
SessionHero01 1 month ago committed by GitHub
commit e95fa6cc03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -83,7 +83,8 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/
'apt-get update --allow-releaseinfo-change', 'apt-get update --allow-releaseinfo-change',
'apt-get install -y ninja-build openjdk-17-jdk', 'apt-get install -y ninja-build openjdk-17-jdk',
'update-java-alternatives -s java-1.17.0-openjdk-amd64', 'update-java-alternatives -s java-1.17.0-openjdk-amd64',
'./gradlew assemblePlayDebug', './gradlew assemblePlayDebug assembleWebsiteDebug',
'./gradlew -Phuawei=1 assembleHuaweiDebug',
'./scripts/drone-static-upload.sh' './scripts/drone-static-upload.sh'
], ],
} }

@ -15,8 +15,8 @@ configurations.configureEach {
exclude module: "commons-logging" exclude module: "commons-logging"
} }
def canonicalVersionCode = 396 def canonicalVersionCode = 397
def canonicalVersionName = "1.21.0" def canonicalVersionName = "1.21.1"
def postFixSize = 10 def postFixSize = 10
def abiPostFix = ['armeabi-v7a' : 1, def abiPostFix = ['armeabi-v7a' : 1,

@ -25,6 +25,12 @@ class HuaweiTokenFetcher @Inject constructor(
this.token.value = token this.token.value = token
} }
override suspend fun resetToken() {
withContext(Dispatchers.Default) {
HmsInstanceId.getInstance(context).deleteToken(APP_ID, TOKEN_SCOPE)
}
}
init { init {
GlobalScope.launch { GlobalScope.launch {
val instanceId = HmsInstanceId.getInstance(context) val instanceId = HmsInstanceId.getInstance(context)
@ -32,6 +38,5 @@ class HuaweiTokenFetcher @Inject constructor(
instanceId.getToken(APP_ID, TOKEN_SCOPE) instanceId.getToken(APP_ID, TOKEN_SCOPE)
} }
} }
} }
} }

@ -38,7 +38,6 @@ import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.ProcessLifecycleOwner; import androidx.lifecycle.ProcessLifecycleOwner;
import androidx.work.Configuration; import androidx.work.Configuration;
import com.google.firebase.messaging.FirebaseMessaging;
import com.squareup.phrase.Phrase; import com.squareup.phrase.Phrase;
import org.conscrypt.Conscrypt; import org.conscrypt.Conscrypt;

@ -3,7 +3,6 @@ package org.thoughtcrime.securesms.util
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.Application import android.app.Application
import android.content.Intent import android.content.Intent
import com.google.firebase.messaging.FirebaseMessaging
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
@ -15,11 +14,12 @@ import org.thoughtcrime.securesms.dependencies.ConfigFactory
import org.thoughtcrime.securesms.home.HomeActivity import org.thoughtcrime.securesms.home.HomeActivity
import javax.inject.Inject import javax.inject.Inject
import androidx.core.content.edit import androidx.core.content.edit
import kotlinx.coroutines.tasks.await import org.session.libsession.messaging.notifications.TokenFetcher
class ClearDataUtils @Inject constructor( class ClearDataUtils @Inject constructor(
private val application: Application, private val application: Application,
private val configFactory: ConfigFactory, private val configFactory: ConfigFactory,
private val tokenFetcher: TokenFetcher,
) { ) {
// Method to clear the local data - returns true on success otherwise false // Method to clear the local data - returns true on success otherwise false
@SuppressLint("ApplySharedPref") @SuppressLint("ApplySharedPref")
@ -36,9 +36,9 @@ class ClearDataUtils @Inject constructor(
// The token deletion is nice but not critical, so don't let it block the rest of the process // The token deletion is nice but not critical, so don't let it block the rest of the process
runCatching { runCatching {
FirebaseMessaging.getInstance().deleteToken().await() tokenFetcher.resetToken()
}.onFailure { e -> }.onFailure { e ->
Log.w("ClearDataUtils", "Failed to delete Firebase token: ${e.message}", e) Log.w("ClearDataUtils", "Failed to reset push notification token: ${e.message}", e)
} }
} }
} }

@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.notifications
import com.google.firebase.messaging.FirebaseMessaging import com.google.firebase.messaging.FirebaseMessaging
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.tasks.await
import org.session.libsession.messaging.notifications.TokenFetcher import org.session.libsession.messaging.notifications.TokenFetcher
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@ -19,4 +20,8 @@ class FirebaseTokenFetcher @Inject constructor(): TokenFetcher {
override fun onNewToken(token: String) { override fun onNewToken(token: String) {
this.token.value = token this.token.value = token
} }
override suspend fun resetToken() {
FirebaseMessaging.getInstance().deleteToken().await()
}
} }

@ -5,7 +5,7 @@ import dagger.Module
import dagger.Provides import dagger.Provides
import dagger.hilt.InstallIn import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton import org.session.libsession.messaging.notifications.TokenFetcher
@Module @Module
@InstallIn(SingletonComponent::class) @InstallIn(SingletonComponent::class)

@ -1,9 +1,15 @@
package org.thoughtcrime.securesms.notifications package org.thoughtcrime.securesms.notifications
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import org.session.libsession.messaging.notifications.TokenFetcher
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@Singleton @Singleton
class NoOpTokenFetcher @Inject constructor() : TokenFetcher { class NoOpTokenFetcher @Inject constructor() : TokenFetcher {
override suspend fun fetch(): String? = null override val token: StateFlow<String?> = MutableStateFlow(null)
override fun onNewToken(token: String) {}
override suspend fun resetToken() {}
} }

@ -12,4 +12,5 @@ interface TokenFetcher {
val token: StateFlow<String?> val token: StateFlow<String?>
fun onNewToken(token: String) fun onNewToken(token: String)
suspend fun resetToken()
} }

Loading…
Cancel
Save