mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-02 08:23:00 +01:00
Add support for app version-based remote configs.
This commit is contained in:
@@ -11,6 +11,7 @@ import org.signal.core.util.gibiBytes
|
||||
import org.signal.core.util.kibiBytes
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.core.util.mebiBytes
|
||||
import org.thoughtcrime.securesms.BuildConfig
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.groups.SelectionLimits
|
||||
import org.thoughtcrime.securesms.jobs.RemoteConfigRefreshJob
|
||||
@@ -521,6 +522,24 @@ object RemoteConfig {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* A config that evaluates to true when the app's version is >= the semantic version string (e.g. "8.2.0") stored in the remote config value.
|
||||
*
|
||||
* Returns false if the remote value is absent, empty, or unparseable.
|
||||
*/
|
||||
@Suppress("SameParameterValue")
|
||||
private fun remoteMinVersion(
|
||||
key: String
|
||||
): Config<Boolean> = remoteValue(
|
||||
key = key,
|
||||
hotSwappable = true,
|
||||
transformer = { value ->
|
||||
val minVersion = SemanticVersion.parse(value.asString(null))
|
||||
val appVersion = SemanticVersion.parse(BuildConfig.VERSION_NAME.substringBefore("-"))
|
||||
minVersion != null && appVersion != null && appVersion >= minVersion
|
||||
}
|
||||
)
|
||||
|
||||
private fun <T> remoteValue(
|
||||
key: String,
|
||||
hotSwappable: Boolean,
|
||||
@@ -1273,10 +1292,8 @@ object RemoteConfig {
|
||||
*/
|
||||
@JvmStatic
|
||||
@get:JvmName("sendMemberLabels")
|
||||
val sendMemberLabels: Boolean by remoteBoolean(
|
||||
key = "android.sendMemberLabels.3",
|
||||
defaultValue = false,
|
||||
hotSwappable = true
|
||||
val sendMemberLabels: Boolean by remoteMinVersion(
|
||||
key = "android.sendMemberLabels.4"
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,6 +9,7 @@ import kotlin.reflect.full.memberProperties
|
||||
/**
|
||||
* Ensures we don't release with forced values which is intended for local development only.
|
||||
*/
|
||||
@Suppress("ClassName")
|
||||
class RemoteConfig_StaticValuesTest {
|
||||
|
||||
@Before
|
||||
@@ -35,7 +36,8 @@ class RemoteConfig_StaticValuesTest {
|
||||
"1",
|
||||
"100",
|
||||
"12345678910111213141516",
|
||||
"*"
|
||||
"*",
|
||||
"1.0.0"
|
||||
)
|
||||
|
||||
val configKeys = RemoteConfig.configsByKey.keys
|
||||
|
||||
Reference in New Issue
Block a user