Skip to content

Commit

Permalink
chore: optional calling [WPB-9999] (#3043)
Browse files Browse the repository at this point in the history
* chore: nullable calling instance

* uncommented poc test

* added error logs when failed to load library

* review fixes

* reverted unnecessary changes
  • Loading branch information
Garzas authored and MohamadJaara committed Oct 18, 2024
1 parent 5752ff4 commit 865b381
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,6 @@ interface Calling : Library {
)

companion object {
val INSTANCE by lazy { Native.load("avs", Calling::class.java)!! }
val INSTANCE: Calling by lazy { Native.load("avs", Calling::class.java)!! }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import com.wire.kalium.logic.feature.call.usecase.GetCallConversationTypeProvide
import com.wire.kalium.logic.feature.message.MessageSender
import com.wire.kalium.logic.featureFlags.KaliumConfigs
import com.wire.kalium.logic.util.CurrentPlatform
import com.wire.kalium.logic.util.DummyCallManager
import com.wire.kalium.logic.util.PlatformContext
import com.wire.kalium.logic.util.PlatformType
import com.wire.kalium.network.NetworkStateObserver
Expand Down Expand Up @@ -95,27 +96,31 @@ actual class GlobalCallManager(
networkStateObserver: NetworkStateObserver,
kaliumConfigs: KaliumConfigs
): CallManager {
return callManagerHolder.computeIfAbsent(userId) {
CallManagerImpl(
calling = calling,
callRepository = callRepository,
userRepository = userRepository,
currentClientIdProvider = currentClientIdProvider,
selfConversationIdProvider = selfConversationIdProvider,
callMapper = callMapper,
messageSender = messageSender,
conversationRepository = conversationRepository,
federatedIdMapper = federatedIdMapper,
qualifiedIdMapper = qualifiedIdMapper,
videoStateChecker = videoStateChecker,
conversationClientsInCallUpdater = conversationClientsInCallUpdater,
getCallConversationType = getCallConversationType,
networkStateObserver = networkStateObserver,
mediaManagerService = mediaManager,
flowManagerService = flowManager,
userConfigRepository = userConfigRepository,
kaliumConfigs = kaliumConfigs
)
if (kaliumConfigs.enableCalling) {
return callManagerHolder.computeIfAbsent(userId) {
CallManagerImpl(
calling = calling,
callRepository = callRepository,
userRepository = userRepository,
currentClientIdProvider = currentClientIdProvider,
selfConversationIdProvider = selfConversationIdProvider,
callMapper = callMapper,
messageSender = messageSender,
conversationRepository = conversationRepository,
federatedIdMapper = federatedIdMapper,
qualifiedIdMapper = qualifiedIdMapper,
videoStateChecker = videoStateChecker,
conversationClientsInCallUpdater = conversationClientsInCallUpdater,
getCallConversationType = getCallConversationType,
networkStateObserver = networkStateObserver,
mediaManagerService = mediaManager,
flowManagerService = flowManager,
userConfigRepository = userConfigRepository,
kaliumConfigs = kaliumConfigs
)
}
} else {
return DummyCallManager()
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.kalium.logic.util

import com.wire.kalium.calling.ConversationTypeCalling
import com.wire.kalium.logic.data.call.CallClientList
import com.wire.kalium.logic.data.call.CallType
import com.wire.kalium.logic.data.call.EpochInfo
import com.wire.kalium.logic.data.call.Participant
import com.wire.kalium.logic.data.call.TestVideoType
import com.wire.kalium.logic.data.call.VideoState
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.message.Message
import com.wire.kalium.logic.data.message.MessageContent
import com.wire.kalium.logic.feature.call.CallManager

@Suppress("EmptyFunctionBlock", "TooManyFunctions")
class DummyCallManager : CallManager {
override suspend fun onCallingMessageReceived(message: Message.Signaling, content: MessageContent.Calling) {}

override suspend fun startCall(
conversationId: ConversationId,
callType: CallType,
conversationTypeCalling: ConversationTypeCalling,
isAudioCbr: Boolean
) {
}

override suspend fun answerCall(conversationId: ConversationId, isAudioCbr: Boolean) {}

override suspend fun endCall(conversationId: ConversationId) {}

override suspend fun rejectCall(conversationId: ConversationId) {}

override suspend fun muteCall(shouldMute: Boolean) {}

override suspend fun setVideoSendState(conversationId: ConversationId, videoState: VideoState) {}

override suspend fun requestVideoStreams(conversationId: ConversationId, callClients: CallClientList) {}

override suspend fun updateEpochInfo(conversationId: ConversationId, epochInfo: EpochInfo) {}

override suspend fun updateConversationClients(conversationId: ConversationId, clients: String) {}

override suspend fun reportProcessNotifications(isStarted: Boolean) {}

override suspend fun setTestVideoType(testVideoType: TestVideoType) {}

override suspend fun setTestPreviewActive(shouldEnable: Boolean) {}

override suspend fun setTestRemoteVideoStates(conversationId: ConversationId, participants: List<Participant>) {}

override suspend fun cancelJobs() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ data class KaliumConfigs(
// if null there will be no limit and all team members will be fetched
// preferably it should be a multiple of TeamRepository.FETCH_TEAM_MEMBER_PAGE_SIZE
val limitTeamMembersFetchDuringSlowSync: Int? = null,
val maxRemoteSearchResultCount: Int = 30
val maxRemoteSearchResultCount: Int = 30,
val enableCalling: Boolean = true
)

sealed interface BuildFileRestrictionState {
Expand Down
4 changes: 2 additions & 2 deletions tango-tests/src/integrationTest/kotlin/PocIntegrationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class PocIntegrationTest {
}
}

@Ignore("needs to be checked and fix")
@Test
fun givenEmailAndPasswordWhenLoggingInThenRegisterClientAndLogout() = runTest {
val mockedRequests = mutableListOf<TestRequestHandler>().apply {
Expand Down Expand Up @@ -137,7 +136,8 @@ class PocIntegrationTest {
isMLSSupportEnabled = true,
wipeOnDeviceRemoval = true,
mockedRequests = mockedRequests,
mockNetworkStateObserver = TestNetworkStateObserver.DEFAULT_TEST_NETWORK_STATE_OBSERVER
mockNetworkStateObserver = TestNetworkStateObserver.DEFAULT_TEST_NETWORK_STATE_OBSERVER,
enableCalling = false
),
userAgent = "Wire Integration Tests"
)
Expand Down

0 comments on commit 865b381

Please sign in to comment.