@stream-io/react-native-callingx 0.1.0-beta.7 → 0.1.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +7 -1
- package/android/src/main/AndroidManifest.xml +31 -1
- package/android/src/main/java/io/getstream/rn/callingx/CallEventBroadcastReceiver.kt +17 -0
- package/android/src/main/java/io/getstream/rn/callingx/CallRegistrationStore.kt +145 -0
- package/android/src/main/java/io/getstream/rn/callingx/CallService.kt +301 -83
- package/android/src/main/java/io/getstream/rn/callingx/CallingxModuleImpl.kt +148 -390
- package/android/src/main/java/io/getstream/rn/callingx/StreamMessagingService.kt +48 -0
- package/android/src/main/java/io/getstream/rn/callingx/model/Call.kt +1 -0
- package/android/src/main/java/io/getstream/rn/callingx/notifications/CallNotificationManager.kt +188 -48
- package/android/src/main/java/io/getstream/rn/callingx/notifications/NotificationIntentFactory.kt +14 -8
- package/android/src/main/java/io/getstream/rn/callingx/notifications/NotificationReceiverActivity.kt +12 -1
- package/android/src/main/java/io/getstream/rn/callingx/notifications/NotificationReceiverService.kt +7 -0
- package/android/src/main/java/io/getstream/rn/callingx/repo/CallRepository.kt +38 -19
- package/android/src/main/java/io/getstream/rn/callingx/repo/LegacyCallRepository.kt +64 -55
- package/android/src/main/java/io/getstream/rn/callingx/repo/TelecomCallRepository.kt +241 -195
- package/android/src/main/java/io/getstream/rn/callingx/utils/CallEventBus.kt +61 -0
- package/android/src/main/java/io/getstream/rn/callingx/utils/SettingsStore.kt +51 -0
- package/android/src/newarch/java/io/getstream/rn/callingx/CallingxModule.kt +12 -3
- package/android/src/oldarch/java/io/getstream/rn/callingx/CallingxModule.kt +13 -3
- package/dist/module/CallingxModule.js +20 -24
- package/dist/module/CallingxModule.js.map +1 -1
- package/dist/module/spec/NativeCallingx.js.map +1 -1
- package/dist/module/utils/constants.js +24 -14
- package/dist/module/utils/constants.js.map +1 -1
- package/dist/typescript/src/CallingxModule.d.ts +4 -2
- package/dist/typescript/src/CallingxModule.d.ts.map +1 -1
- package/dist/typescript/src/spec/NativeCallingx.d.ts +7 -4
- package/dist/typescript/src/spec/NativeCallingx.d.ts.map +1 -1
- package/dist/typescript/src/types.d.ts +33 -5
- package/dist/typescript/src/types.d.ts.map +1 -1
- package/dist/typescript/src/utils/constants.d.ts +2 -3
- package/dist/typescript/src/utils/constants.d.ts.map +1 -1
- package/ios/AudioSessionManager.swift +2 -2
- package/ios/Callingx.mm +41 -17
- package/ios/CallingxImpl.swift +213 -83
- package/ios/Settings.swift +2 -2
- package/ios/UUIDStorage.swift +10 -10
- package/ios/VoipNotificationsManager.swift +8 -8
- package/package.json +4 -2
- package/src/CallingxModule.ts +20 -21
- package/src/spec/NativeCallingx.ts +10 -6
- package/src/types.ts +36 -4
- package/src/utils/constants.ts +23 -12
- /package/android/src/main/java/io/getstream/rn/callingx/{ResourceUtils.kt → utils/ResourceUtils.kt} +0 -0
- /package/android/src/main/java/io/getstream/rn/callingx/{Utils.kt → utils/Utils.kt} +0 -0
|
@@ -3,8 +3,8 @@ package io.getstream.rn.callingx.repo
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import android.net.Uri
|
|
5
5
|
import android.os.Bundle
|
|
6
|
+
import android.telecom.DisconnectCause
|
|
6
7
|
import android.util.Log
|
|
7
|
-
import androidx.core.telecom.CallAttributesCompat
|
|
8
8
|
import io.getstream.rn.callingx.model.Call
|
|
9
9
|
import io.getstream.rn.callingx.model.CallAction
|
|
10
10
|
import kotlinx.coroutines.Job
|
|
@@ -21,17 +21,28 @@ class LegacyCallRepository(context: Context) : CallRepository(context) {
|
|
|
21
21
|
private const val TAG = "[Callingx] LegacyCallRepository"
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
private var
|
|
24
|
+
private var observeCallsJob: Job? = null
|
|
25
25
|
|
|
26
26
|
override fun getTag(): String = TAG
|
|
27
27
|
|
|
28
28
|
override fun setListener(listener: Listener?) {
|
|
29
29
|
this._listener = listener
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
observeCallsJob?.cancel()
|
|
31
|
+
observeCallsJob = scope.launch {
|
|
32
|
+
var previousCalls: Map<String, Call.Registered> = emptyMap()
|
|
33
33
|
try {
|
|
34
|
-
|
|
34
|
+
calls.collect { currentCalls ->
|
|
35
|
+
// Notify about changes per call
|
|
36
|
+
for ((callId, call) in currentCalls) {
|
|
37
|
+
_listener?.onCallStateChanged(callId, call)
|
|
38
|
+
}
|
|
39
|
+
for ((callId, _) in previousCalls) {
|
|
40
|
+
if (!currentCalls.containsKey(callId)) {
|
|
41
|
+
_listener?.onCallStateChanged(callId, Call.None)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
previousCalls = currentCalls
|
|
45
|
+
}
|
|
35
46
|
} catch (e: Exception) {
|
|
36
47
|
Log.e(TAG, "[repository] setListener: Error collecting call state", e)
|
|
37
48
|
}
|
|
@@ -39,10 +50,10 @@ class LegacyCallRepository(context: Context) : CallRepository(context) {
|
|
|
39
50
|
}
|
|
40
51
|
|
|
41
52
|
override fun release() {
|
|
42
|
-
|
|
53
|
+
_calls.value = emptyMap()
|
|
43
54
|
|
|
44
|
-
|
|
45
|
-
|
|
55
|
+
observeCallsJob?.cancel()
|
|
56
|
+
observeCallsJob = null
|
|
46
57
|
_listener = null
|
|
47
58
|
|
|
48
59
|
scope.cancel()
|
|
@@ -55,42 +66,42 @@ class LegacyCallRepository(context: Context) : CallRepository(context) {
|
|
|
55
66
|
isIncoming: Boolean,
|
|
56
67
|
isVideo: Boolean,
|
|
57
68
|
displayOptions: Bundle?,
|
|
58
|
-
) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
val attributes = createCallAttributes(displayName, address, isIncoming, isVideo)
|
|
69
|
-
val actionSource = Channel<CallAction>()
|
|
70
|
-
|
|
71
|
-
_currentCall.value =
|
|
72
|
-
Call.Registered(
|
|
73
|
-
id = callId,
|
|
74
|
-
isActive = false,
|
|
75
|
-
isOnHold = false,
|
|
76
|
-
callAttributes = attributes,
|
|
77
|
-
displayOptions = displayOptions,
|
|
78
|
-
isMuted = false,
|
|
79
|
-
errorCode = null,
|
|
80
|
-
currentCallEndpoint = null,
|
|
81
|
-
availableCallEndpoints = emptyList(),
|
|
82
|
-
actionSource = actionSource,
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
_listener?.onCallRegistered(callId, isIncoming)
|
|
69
|
+
) = registrationMutex.withLock {
|
|
70
|
+
// Check if this specific call is already registered
|
|
71
|
+
if (_calls.value.containsKey(callId)) {
|
|
72
|
+
Log.w(
|
|
73
|
+
TAG,
|
|
74
|
+
"[repository] registerCall: Call $callId already registered, ignoring duplicate"
|
|
75
|
+
)
|
|
76
|
+
return@withLock
|
|
77
|
+
}
|
|
86
78
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
79
|
+
val attributes = createCallAttributes(displayName, address, isIncoming, isVideo)
|
|
80
|
+
val actionSource = Channel<CallAction>()
|
|
81
|
+
|
|
82
|
+
val registeredCall = Call.Registered(
|
|
83
|
+
id = callId,
|
|
84
|
+
isPending = false,
|
|
85
|
+
isActive = false,
|
|
86
|
+
isOnHold = false,
|
|
87
|
+
callAttributes = attributes,
|
|
88
|
+
displayOptions = displayOptions,
|
|
89
|
+
isMuted = false,
|
|
90
|
+
errorCode = null,
|
|
91
|
+
currentCallEndpoint = null,
|
|
92
|
+
availableCallEndpoints = emptyList(),
|
|
93
|
+
actionSource = actionSource,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
addCall(callId, registeredCall)
|
|
97
|
+
_listener?.onCallRegistered(callId, isIncoming)
|
|
98
|
+
|
|
99
|
+
// Process actions without telecom SDK
|
|
100
|
+
scope.launch {
|
|
101
|
+
try {
|
|
102
|
+
actionSource.consumeAsFlow().collect { action -> processActionLegacy(callId, action) }
|
|
103
|
+
} catch (e: Exception) {
|
|
104
|
+
Log.e(TAG, "[repository] registerCall: Error consuming actions for $callId", e)
|
|
94
105
|
}
|
|
95
106
|
}
|
|
96
107
|
}
|
|
@@ -105,30 +116,28 @@ class LegacyCallRepository(context: Context) : CallRepository(context) {
|
|
|
105
116
|
super.updateCall(callId, displayName, address, isVideo, displayOptions)
|
|
106
117
|
}
|
|
107
118
|
|
|
108
|
-
private fun processActionLegacy(action: CallAction) {
|
|
119
|
+
private fun processActionLegacy(callId: String, action: CallAction) {
|
|
109
120
|
when (action) {
|
|
110
121
|
is CallAction.Answer -> {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
(
|
|
114
|
-
_listener?.onIsCallAnswered(
|
|
122
|
+
updateCallById(callId) { copy(isActive = true, isOnHold = false) }
|
|
123
|
+
val call = _calls.value[callId]
|
|
124
|
+
if (call != null) {
|
|
125
|
+
_listener?.onIsCallAnswered(callId, EventSource.APP)
|
|
115
126
|
}
|
|
116
127
|
}
|
|
117
128
|
is CallAction.Disconnect -> {
|
|
118
|
-
val call =
|
|
129
|
+
val call = _calls.value[callId]
|
|
119
130
|
if (call != null) {
|
|
120
|
-
|
|
121
|
-
Call.Unregistered(call.id, call.callAttributes, action.cause)
|
|
122
|
-
// In legacy mode, all actions are initiated from the app
|
|
131
|
+
removeCall(callId)
|
|
123
132
|
_listener?.onIsCallDisconnected(
|
|
124
|
-
|
|
133
|
+
callId,
|
|
125
134
|
action.cause,
|
|
126
135
|
EventSource.APP
|
|
127
136
|
)
|
|
128
137
|
}
|
|
129
138
|
}
|
|
130
139
|
is CallAction.ToggleMute -> {
|
|
131
|
-
|
|
140
|
+
updateCallById(callId) { copy(isMuted = action.isMute) }
|
|
132
141
|
}
|
|
133
142
|
// Handle other actions...
|
|
134
143
|
else -> {
|