@qusaieilouti99/call-manager 0.1.38 → 0.1.40
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/src/main/java/com/margelo/nitro/qusaieilouti99/callmanager/CallEngine.kt +5 -15
- package/android/src/main/java/com/margelo/nitro/qusaieilouti99/callmanager/CallManager.kt +6 -12
- package/android/src/main/java/com/margelo/nitro/qusaieilouti99/callmanager/MyConnection.kt +12 -13
- package/package.json +1 -1
|
@@ -53,7 +53,7 @@ object CallEngine {
|
|
|
53
53
|
val callId: String,
|
|
54
54
|
val callData: String,
|
|
55
55
|
var state: CallState,
|
|
56
|
-
val callType: String = "Audio"
|
|
56
|
+
val callType: String = "Audio"
|
|
57
57
|
)
|
|
58
58
|
|
|
59
59
|
enum class CallState {
|
|
@@ -123,7 +123,6 @@ object CallEngine {
|
|
|
123
123
|
return result
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
// This is for INCOMING calls using TelecomManager.addNewIncomingCall
|
|
127
126
|
fun reportIncomingCall(context: Context, callId: String, callData: String) {
|
|
128
127
|
appContext = context.applicationContext
|
|
129
128
|
Log.d(TAG, "reportIncomingCall: $callId, $callData")
|
|
@@ -150,7 +149,7 @@ object CallEngine {
|
|
|
150
149
|
Log.d(TAG, "Call $callId added to activeCalls. State: INCOMING, callType: $parsedCallType")
|
|
151
150
|
|
|
152
151
|
showIncomingCallUI(context, callId, callerName, parsedCallType)
|
|
153
|
-
registerPhoneAccount(context)
|
|
152
|
+
registerPhoneAccount(context)
|
|
154
153
|
val telecomManager = context.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
|
|
155
154
|
val phoneAccountHandle = getPhoneAccountHandle(context)
|
|
156
155
|
val extras = Bundle().apply {
|
|
@@ -158,7 +157,6 @@ object CallEngine {
|
|
|
158
157
|
putBoolean(MyConnectionService.EXTRA_IS_VIDEO_CALL_BOOLEAN, isVideoCallBoolean)
|
|
159
158
|
}
|
|
160
159
|
try {
|
|
161
|
-
// This API is fundamental for INCOMING call integration with Telecom.
|
|
162
160
|
telecomManager.addNewIncomingCall(phoneAccountHandle, extras)
|
|
163
161
|
startForegroundService(context)
|
|
164
162
|
Log.d(TAG, "Successfully reported incoming call to TelecomManager for $callId")
|
|
@@ -198,25 +196,20 @@ object CallEngine {
|
|
|
198
196
|
currentCallId = callId
|
|
199
197
|
Log.d(TAG, "Call $callId added to activeCalls. State: DIALING, callType: $parsedCallType")
|
|
200
198
|
|
|
201
|
-
registerPhoneAccount(context)
|
|
199
|
+
registerPhoneAccount(context)
|
|
202
200
|
val telecomManager = context.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
|
|
203
201
|
val phoneAccountHandle = getPhoneAccountHandle(context)
|
|
204
202
|
|
|
205
|
-
|
|
206
|
-
val addressUri = Uri.fromParts(PhoneAccount.SCHEME_TEL, callId, null) // Using callId as a unique identifier for URI
|
|
203
|
+
val addressUri = Uri.fromParts(PhoneAccount.SCHEME_TEL, callId, null)
|
|
207
204
|
|
|
208
205
|
val extras = Bundle().apply {
|
|
209
|
-
// Essential for self-managed apps using placeCall
|
|
210
206
|
putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle)
|
|
211
|
-
// Pass additional data for your ConnectionService to retrieve
|
|
212
207
|
putString(MyConnectionService.EXTRA_CALL_DATA, callData)
|
|
213
208
|
putBoolean(MyConnectionService.EXTRA_IS_VIDEO_CALL_BOOLEAN, isVideoCallBoolean)
|
|
214
|
-
// Hint for initial speakerphone state
|
|
215
209
|
putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, isVideoCallBoolean)
|
|
216
210
|
}
|
|
217
211
|
|
|
218
212
|
try {
|
|
219
|
-
// CORRECT API for self-managed outgoing calls that interact with Telecom
|
|
220
213
|
telecomManager.placeCall(addressUri, extras)
|
|
221
214
|
startForegroundService(context)
|
|
222
215
|
Log.d(TAG, "Successfully reported outgoing call to TelecomManager via placeCall for $callId")
|
|
@@ -269,7 +262,6 @@ object CallEngine {
|
|
|
269
262
|
|
|
270
263
|
fun holdCall(context: Context, callId: String) {
|
|
271
264
|
Log.d(TAG, "holdCall: $callId")
|
|
272
|
-
// Always attempt to inform Telecom if a Connection object exists for this callId
|
|
273
265
|
val connection = telecomConnections[callId]
|
|
274
266
|
connection?.setOnHold()
|
|
275
267
|
emitEvent(CallEventType.CALL_HELD, JSONObject().put("callId", callId))
|
|
@@ -279,7 +271,6 @@ object CallEngine {
|
|
|
279
271
|
fun unholdCall(context: Context, callId: String) {
|
|
280
272
|
Log.d(TAG, "unholdCall: $callId")
|
|
281
273
|
activeCalls[callId]?.state = CallState.ACTIVE
|
|
282
|
-
// Always attempt to inform Telecom if a Connection object exists for this callId
|
|
283
274
|
val connection = telecomConnections[callId]
|
|
284
275
|
connection?.setActive()
|
|
285
276
|
emitEvent(CallEventType.CALL_UNHELD, JSONObject().put("callId", callId))
|
|
@@ -317,7 +308,6 @@ object CallEngine {
|
|
|
317
308
|
|
|
318
309
|
cancelIncomingCallUI(context)
|
|
319
310
|
|
|
320
|
-
// Only disconnect from Telecom if a Connection object exists for this callId
|
|
321
311
|
val connection = telecomConnections[callId]
|
|
322
312
|
if (connection != null) {
|
|
323
313
|
connection.setDisconnected(DisconnectCause(DisconnectCause.LOCAL))
|
|
@@ -677,7 +667,7 @@ object CallEngine {
|
|
|
677
667
|
val phoneAccountHandle = getPhoneAccountHandle(context)
|
|
678
668
|
if (telecomManager.getPhoneAccount(phoneAccountHandle) == null) {
|
|
679
669
|
val phoneAccount = PhoneAccount.builder(phoneAccountHandle, "PingMe Call")
|
|
680
|
-
.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED
|
|
670
|
+
.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED)
|
|
681
671
|
.build()
|
|
682
672
|
try {
|
|
683
673
|
telecomManager.registerPhoneAccount(phoneAccount)
|
|
@@ -51,20 +51,14 @@ class CallManager : HybridCallManagerSpec() {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
override fun addListener(
|
|
54
|
-
listener:
|
|
55
|
-
):
|
|
54
|
+
listener: (event: CallEventType, payload: String) -> Unit
|
|
55
|
+
): () -> Unit {
|
|
56
56
|
Log.d(TAG, "addListener called with listener: $listener")
|
|
57
|
-
|
|
57
|
+
// Wrap the listener in your event system
|
|
58
58
|
CallEngine.setEventHandler(listener)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
CallEngine.setEventHandler(null)
|
|
63
|
-
currentListener = null
|
|
64
|
-
Log.d(TAG, "Listener removed.")
|
|
65
|
-
} else {
|
|
66
|
-
Log.d(TAG, "Attempted to remove a listener that was not current.")
|
|
67
|
-
}
|
|
59
|
+
return {
|
|
60
|
+
CallEngine.setEventHandler(null)
|
|
61
|
+
Log.d(TAG, "Listener removed.")
|
|
68
62
|
}
|
|
69
63
|
}
|
|
70
64
|
|
|
@@ -2,12 +2,12 @@ package com.margelo.nitro.qusaieilouti99.callmanager
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import android.net.Uri
|
|
5
|
-
import android.os.Bundle
|
|
5
|
+
import android.os.Bundle
|
|
6
6
|
import android.telecom.Connection
|
|
7
7
|
import android.telecom.DisconnectCause
|
|
8
|
-
import android.telecom.CallAudioState
|
|
8
|
+
import android.telecom.CallAudioState
|
|
9
9
|
import android.telecom.VideoProfile
|
|
10
|
-
import android.util.Log
|
|
10
|
+
import android.util.Log
|
|
11
11
|
import org.json.JSONObject
|
|
12
12
|
import java.util.UUID
|
|
13
13
|
|
|
@@ -20,7 +20,6 @@ class MyConnection(
|
|
|
20
20
|
const val TAG = "MyConnection"
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
// Changed to internal val to allow access from MyConnectionService for logging
|
|
24
23
|
internal val callId: String = try {
|
|
25
24
|
JSONObject(callDataJson).optString("callId", UUID.randomUUID().toString())
|
|
26
25
|
} catch (e: Exception) {
|
|
@@ -33,7 +32,9 @@ class MyConnection(
|
|
|
33
32
|
JSONObject(callDataJson).optString("callType", "Audio")
|
|
34
33
|
} catch (e: Exception) { "Audio" }
|
|
35
34
|
|
|
35
|
+
// Set connection properties and capabilities
|
|
36
36
|
connectionProperties = Connection.PROPERTY_SELF_MANAGED
|
|
37
|
+
connectionCapabilities = Connection.CAPABILITY_SUPPORT_HOLD or Connection.CAPABILITY_MUTE // Added hold and mute capabilities
|
|
37
38
|
|
|
38
39
|
if (currentCallType == "Video") {
|
|
39
40
|
Log.d(TAG, "MyConnection for callId $callId initialized as VIDEO call.")
|
|
@@ -107,13 +108,13 @@ class MyConnection(
|
|
|
107
108
|
override fun onPlayDtmfTone(digit: Char) {
|
|
108
109
|
super.onPlayDtmfTone(digit)
|
|
109
110
|
Log.d(TAG, "Playing DTMF tone: $digit for callId: $callId")
|
|
110
|
-
// NOTE: DTMF_TONE is not in your current CallEventType
|
|
111
|
+
// NOTE: DTMF_TONE is not in your current CallEventType enum.
|
|
111
112
|
// If you need to emit this event, you MUST add 'DTMF_TONE' to your CallEventType.ts
|
|
112
113
|
// and re-run nitro-codegen. For now, it's commented out to prevent compilation error.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
CallEngine.emitEvent(
|
|
115
|
+
CallEventType.DTMF_TONE,
|
|
116
|
+
JSONObject().put("callId", callId).put("digit", digit.toString())
|
|
117
|
+
)
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
override fun onStopDtmfTone() {
|
|
@@ -121,10 +122,8 @@ class MyConnection(
|
|
|
121
122
|
Log.d(TAG, "Stopping DTMF tone for callId: $callId")
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
Log.d(TAG, "Connection event: $event, extras: $extras for callId: $callId")
|
|
127
|
-
}
|
|
125
|
+
// REMOVED: onConnectionEvent override since it doesn't exist in the base Connection class
|
|
126
|
+
// If you need connection events, you can send them via sendConnectionEvent() method
|
|
128
127
|
|
|
129
128
|
override fun onShowIncomingCallUi() {
|
|
130
129
|
super.onShowIncomingCallUi()
|