@qusaieilouti99/call-manager 0.1.110 → 0.1.112

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.
@@ -28,6 +28,7 @@ import android.widget.LinearLayout
28
28
  import android.widget.TextView
29
29
  import java.net.HttpURLConnection
30
30
  import java.net.URL
31
+ import android.view.KeyEvent
31
32
 
32
33
  class CallActivity : Activity(), CallEngine.CallEndListener {
33
34
 
@@ -48,6 +49,17 @@ class CallActivity : Activity(), CallEngine.CallEndListener {
48
49
  finishCallActivity()
49
50
  }
50
51
 
52
+ override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
53
+ if (keyCode == KeyEvent.KEYCODE_VOLUME_UP ||
54
+ keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
55
+ keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) {
56
+ // silence the ring immediately
57
+ CallEngine.stopRingtone()
58
+ return true
59
+ }
60
+ return super.onKeyDown(keyCode, event)
61
+ }
62
+
51
63
  override fun onCreate(savedInstanceState: Bundle?) {
52
64
  super.onCreate(savedInstanceState)
53
65
  val isSamsungBypass = intent.getBooleanExtra(
@@ -352,7 +352,6 @@ object CallEngine {
352
352
  startRingback()
353
353
  bringAppToForeground()
354
354
  keepScreenAwake(true)
355
- setInitialAudioRoute(callType)
356
355
  Log.d(TAG, "Successfully reported outgoing call to TelecomManager")
357
356
  } catch (e: Exception) {
358
357
  Log.e(TAG, "Failed to start outgoing call: ${e.message}", e)
@@ -419,7 +418,7 @@ object CallEngine {
419
418
  return
420
419
  }
421
420
 
422
- setAudioMode()
421
+
423
422
  activeCalls[callId] = callInfo.copy(state = CallState.ACTIVE)
424
423
  currentCallId = callId
425
424
  Log.d(TAG, "Call $callId set to ACTIVE state (system manages audio focus)")
@@ -441,6 +440,9 @@ object CallEngine {
441
440
  keepScreenAwake(true)
442
441
  updateLockScreenBypass()
443
442
 
443
+ // then pick your route:
444
+ setInitialAudioRoute(callInfo.callType)
445
+
444
446
  if (isLocalAnswer) {
445
447
  emitCallAnsweredWithMetadata(callId)
446
448
  } else {
@@ -733,9 +735,7 @@ object CallEngine {
733
735
  audioManager = ctx.getSystemService(Context.AUDIO_SERVICE) as AudioManager
734
736
  }
735
737
  val am = audioManager!!
736
-
737
- // 1) must be in COMMUNICATION mode before switching routes
738
- am.mode = AudioManager.MODE_IN_COMMUNICATION
738
+ setAudioMode()
739
739
 
740
740
  when (route) {
741
741
  "Speaker" -> {
@@ -970,7 +970,6 @@ object CallEngine {
970
970
  }
971
971
 
972
972
  playRingtone()
973
- setInitialAudioRoute(callType)
974
973
  }
975
974
 
976
975
  /**
@@ -1243,6 +1242,13 @@ object CallEngine {
1243
1242
  private fun playRingtone() {
1244
1243
  val context = requireContext()
1245
1244
 
1245
+ audioManager = audioManager ?: context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
1246
+ // 0) ensure the ring plays out loud on the speaker
1247
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
1248
+ audioManager?.mode = AudioManager.MODE_RINGTONE
1249
+ }
1250
+ audioManager?.isSpeakerphoneOn = true
1251
+
1246
1252
  // 1) start repeating vibration
1247
1253
  vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as? Vibrator
1248
1254
  vibrator?.let { v ->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qusaieilouti99/call-manager",
3
- "version": "0.1.110",
3
+ "version": "0.1.112",
4
4
  "description": "Call manager",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",