@qusaieilouti99/call-manager 0.1.38 → 0.1.39
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.
|
@@ -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 or PhoneAccount.
|
|
670
|
+
.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED or PhoneAccount.CAPABILITY_HOLD)
|
|
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
|
|