Skip to content

Commit 9a059ea

Browse files
committed
Add a VectorFeatures to force usage of the library OpusEncoder
1 parent e3b3617 commit 9a059ea

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

vector/src/androidTest/java/im/vector/app/features/voice/VoiceRecorderProviderTests.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ package im.vector.app.features.voice
1919
import android.os.Build
2020
import androidx.test.platform.app.InstrumentationRegistry
2121
import im.vector.app.AndroidVersionTestOverrider
22+
import im.vector.app.features.DefaultVectorFeatures
2223
import org.amshove.kluent.shouldBeInstanceOf
2324
import org.junit.After
2425
import org.junit.Test
2526

2627
class VoiceRecorderProviderTests {
2728

2829
private val context = InstrumentationRegistry.getInstrumentation().targetContext
29-
private val provider = VoiceRecorderProvider(context)
30+
private val provider = VoiceRecorderProvider(context, DefaultVectorFeatures())
3031

3132
@After
3233
fun tearDown() {

vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ class DebugFeaturesStateFactory @Inject constructor(
7070
key = DebugFeatureKeys.allowExternalUnifiedPushDistributors,
7171
factory = VectorFeatures::allowExternalUnifiedPushDistributors
7272
),
73+
createBooleanFeature(
74+
label = "Force usage of OpusEncoder library",
75+
key = DebugFeatureKeys.forceUsageOfOpusEncoder,
76+
factory = VectorFeatures::forceUsageOfOpusEncoder
77+
),
7378
)
7479
)
7580
}

vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class DebugVectorFeatures(
6666
override fun isScreenSharingEnabled(): Boolean = read(DebugFeatureKeys.screenSharing)
6767
?: vectorFeatures.isScreenSharingEnabled()
6868

69+
override fun forceUsageOfOpusEncoder(): Boolean = read(DebugFeatureKeys.forceUsageOfOpusEncoder)
70+
?: vectorFeatures.forceUsageOfOpusEncoder()
71+
6972
fun <T> override(value: T?, key: Preferences.Key<T>) = updatePreferences {
7073
if (value == null) {
7174
it.remove(key)
@@ -123,4 +126,5 @@ object DebugFeatureKeys {
123126
val allowExternalUnifiedPushDistributors = booleanPreferencesKey("allow-external-unified-push-distributors")
124127
val liveLocationSharing = booleanPreferencesKey("live-location-sharing")
125128
val screenSharing = booleanPreferencesKey("screen-sharing")
129+
val forceUsageOfOpusEncoder = booleanPreferencesKey("force-usage-of-opus-encoder")
126130
}

vector/src/main/java/im/vector/app/features/VectorFeatures.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ interface VectorFeatures {
3030
fun isOnboardingCombinedLoginEnabled(): Boolean
3131
fun allowExternalUnifiedPushDistributors(): Boolean
3232
fun isScreenSharingEnabled(): Boolean
33+
fun forceUsageOfOpusEncoder(): Boolean
3334

3435
enum class OnboardingVariant {
3536
LEGACY,
@@ -48,4 +49,5 @@ class DefaultVectorFeatures : VectorFeatures {
4849
override fun isOnboardingCombinedLoginEnabled() = false
4950
override fun allowExternalUnifiedPushDistributors(): Boolean = Config.ALLOW_EXTERNAL_UNIFIED_PUSH_DISTRIBUTORS
5051
override fun isScreenSharingEnabled(): Boolean = true
52+
override fun forceUsageOfOpusEncoder(): Boolean = false
5153
}

vector/src/main/java/im/vector/app/features/voice/VoiceRecorderProvider.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ package im.vector.app.features.voice
1818

1919
import android.content.Context
2020
import android.os.Build
21+
import im.vector.app.features.VectorFeatures
2122
import kotlinx.coroutines.Dispatchers
2223
import javax.inject.Inject
2324

2425
class VoiceRecorderProvider @Inject constructor(
2526
private val context: Context,
27+
private val vectorFeatures: VectorFeatures,
2628
) {
2729
fun provideVoiceRecorder(): VoiceRecorder {
28-
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
30+
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && vectorFeatures.forceUsageOfOpusEncoder().not()) {
2931
VoiceRecorderQ(context)
3032
} else {
3133
VoiceRecorderL(context, Dispatchers.IO)

0 commit comments

Comments
 (0)