@qusaieilouti99/call-manager 0.1.59 → 0.1.61

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.
@@ -365,47 +365,51 @@ object CallEngine {
365
365
  }
366
366
 
367
367
  val isVideoCall = callType == "Video"
368
-
369
368
  if (!canMakeMultipleCalls && activeCalls.isNotEmpty()) {
370
- activeCalls.values.forEach {
371
- if (it.state == CallState.ACTIVE) {
372
- holdCallInternal(it.callId, heldBySystem = false)
373
- }
374
- }
369
+ activeCalls.values.filter { it.state == CallState.ACTIVE }
370
+ .forEach { holdCallInternal(it.callId, heldBySystem = false) }
375
371
  }
376
372
 
373
+ // Track dialing state
377
374
  activeCalls[callId] = CallInfo(callId, callType, targetName, null, CallState.DIALING)
378
375
  currentCallId = callId
379
- Log.d(TAG, "Call $callId added to activeCalls. State: DIALING, callType: $callType")
376
+ Log.d(TAG, "Call $callId added to activeCalls. State: DIALING")
380
377
 
381
378
  registerPhoneAccount()
382
379
  val telecomManager = context.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
383
380
  val phoneAccountHandle = getPhoneAccountHandle()
384
381
  val addressUri = Uri.fromParts(PhoneAccount.SCHEME_TEL, targetName, null)
385
382
 
386
- val extras = Bundle().apply {
387
- putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle)
383
+ // 1) build a bundle of ONLY your own keys
384
+ val outgoingExtras = Bundle().apply {
388
385
  putString(MyConnectionService.EXTRA_CALL_ID, callId)
389
386
  putString(MyConnectionService.EXTRA_CALL_TYPE, callType)
390
387
  putString(MyConnectionService.EXTRA_DISPLAY_NAME, targetName)
391
388
  putBoolean(MyConnectionService.EXTRA_IS_VIDEO_CALL_BOOLEAN, isVideoCall)
389
+ metadata?.let { putString("metadata", it) }
390
+ }
391
+
392
+ // 2) wrap under the single Telecom‐honored key
393
+ val extras = Bundle().apply {
394
+ putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle)
395
+ putBundle(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, outgoingExtras)
392
396
  putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, isVideoCall)
393
397
  }
394
398
 
395
399
  try {
396
400
  telecomManager.placeCall(addressUri, extras)
397
- startForegroundService() // Fixed: Always start foreground service
401
+ startForegroundService()
398
402
  requestAudioFocus()
399
403
  startRingback()
400
404
  bringAppToForeground()
401
405
  keepScreenAwake(true)
402
406
  setInitialAudioRoute(callType)
403
- Log.d(TAG, "Successfully reported outgoing call to TelecomManager via placeCall for $callId")
407
+ Log.d(TAG, "Successfully reported outgoing call to TelecomManager")
404
408
  } catch (e: SecurityException) {
405
- Log.e(TAG, "SecurityException: Failed to start outgoing call via placeCall. Check MANAGE_OWN_CALLS permission: ${e.message}", e)
409
+ Log.e(TAG, "SecurityException placing outgoing call: ${e.message}", e)
406
410
  endCallInternal(callId)
407
411
  } catch (e: Exception) {
408
- Log.e(TAG, "Failed to start outgoing call via placeCall: ${e.message}", e)
412
+ Log.e(TAG, "Failed to start outgoing call: ${e.message}", e)
409
413
  endCallInternal(callId)
410
414
  }
411
415
 
@@ -171,11 +171,23 @@ class CallForegroundService : Service() {
171
171
  }
172
172
 
173
173
  override fun onTaskRemoved(rootIntent: Intent?) {
174
- Log.d(TAG, "onTaskRemoved: User swiped app from recents. Ending all calls.")
174
+ // Figure out which Activity’s task was just removed:
175
+ val removed = rootIntent?.component?.className
176
+ Log.d(TAG, "onTaskRemoved: removedActivity=$removed")
177
+
178
+ // If it was our lock-screen CallActivity, ignore —
179
+ // we only want to clean up when the MAIN app task is swiped away.
180
+ if (removed == CallActivity::class.java.name) {
181
+ Log.d(TAG, "CallActivity was removed; keeping call alive.")
182
+ return
183
+ }
184
+
185
+ // Otherwise (e.g. MainActivity removed), tear everything down:
186
+ Log.d(TAG, "Main task removed; ending all calls.")
175
187
  CallEngine.onApplicationTerminate()
176
- super.onTaskRemoved(rootIntent)
177
188
  stopSelf()
178
- }
189
+ super.onTaskRemoved(rootIntent)
190
+ }
179
191
 
180
192
  override fun onDestroy() {
181
193
  super.onDestroy()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qusaieilouti99/call-manager",
3
- "version": "0.1.59",
3
+ "version": "0.1.61",
4
4
  "description": "Call manager",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",