From b6d052e58d5ebf4ecd82e7656ba5ca14d7fba95e Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 30 Jun 2022 16:46:32 +0100 Subject: [PATCH] lifting voip setting to a voip config --- .../main/java/im/vector/app/config/Config.kt | 7 ++++++- vector/build.gradle | 4 ---- .../vector/app/core/di/ConfigurationModule.kt | 6 ++++++ .../app/features/call/webrtc/VoipConfig.kt | 21 +++++++++++++++++++ .../features/call/webrtc/WebRtcCallManager.kt | 3 ++- 5 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/features/call/webrtc/VoipConfig.kt diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index 9398cd1457..a15ac198b9 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -55,6 +55,12 @@ object Config { */ val ONBOARDING_VARIANT = OnboardingVariant.FTUE_AUTH + /** + * If set, MSC3086 asserted identity messages sent on VoIP calls will cause the call to appear in the room corresponding to the asserted identity. + * This *must* only be set in trusted environments. + */ + const val HANDLE_CALL_ASSERTED_IDENTITY_EVENTS = false + /** * The analytics configuration to use for the Debug build type. * Can be disabled by providing Analytics.Disabled @@ -113,7 +119,6 @@ sealed interface Analytics { ) : Analytics } - enum class OnboardingVariant { LEGACY, LOGIN_2, diff --git a/vector/build.gradle b/vector/build.gradle index f9a81eb76c..0aaf46a6b2 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -156,10 +156,6 @@ android { buildConfigField "String", "GIT_BRANCH_NAME", "\"${gitBranchName()}\"" buildConfigField "String", "BUILD_NUMBER", "\"${buildNumber}\"" - // If set, MSC3086 asserted identity messages sent on VoIP calls will cause the call to appear in the room corresponding to the asserted identity. - // This *must* only be set in trusted environments. - buildConfigField "Boolean", "handleCallAssertedIdentityEvents", "false" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" // Keep abiFilter for the universalApk diff --git a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt index c8469957f6..296f0be070 100644 --- a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt @@ -25,6 +25,7 @@ import im.vector.app.config.Analytics import im.vector.app.config.Config import im.vector.app.config.KeySharingStrategy import im.vector.app.features.analytics.AnalyticsConfig +import im.vector.app.features.call.webrtc.VoipConfig import im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy import im.vector.app.features.home.room.detail.composer.voice.VoiceMessageConfig import im.vector.app.features.location.LocationSharingConfig @@ -69,4 +70,9 @@ object ConfigurationModule { fun providesLocationSharingConfig() = LocationSharingConfig( mapTilerKey = Config.LOCATION_MAP_TILER_KEY, ) + + @Provides + fun providesVoipConfig() = VoipConfig( + handleCallAssertedIdentityEvents = Config.HANDLE_CALL_ASSERTED_IDENTITY_EVENTS + ) } diff --git a/vector/src/main/java/im/vector/app/features/call/webrtc/VoipConfig.kt b/vector/src/main/java/im/vector/app/features/call/webrtc/VoipConfig.kt new file mode 100644 index 0000000000..03a9312999 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/call/webrtc/VoipConfig.kt @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.call.webrtc + +data class VoipConfig( + val handleCallAssertedIdentityEvents: Boolean +) diff --git a/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCallManager.kt b/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCallManager.kt index b35ab774be..634c61a7b2 100644 --- a/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCallManager.kt +++ b/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCallManager.kt @@ -74,6 +74,7 @@ class WebRtcCallManager @Inject constructor( private val activeSessionDataSource: ActiveSessionDataSource, private val analyticsTracker: AnalyticsTracker, private val unifiedPushHelper: UnifiedPushHelper, + private val voipConfig: VoipConfig, ) : CallListener, DefaultLifecycleObserver { @@ -444,7 +445,7 @@ class WebRtcCallManager @Inject constructor( } override fun onCallAssertedIdentityReceived(callAssertedIdentityContent: CallAssertedIdentityContent) { - if (!BuildConfig.handleCallAssertedIdentityEvents) { + if (!voipConfig.handleCallAssertedIdentityEvents) { return } val call = callsByCallId[callAssertedIdentityContent.callId]