@qusaieilouti99/call-manager 0.1.39 → 0.1.41
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 +18 -2
- package/android/src/main/java/com/margelo/nitro/qusaieilouti99/callmanager/CallNotificationActionReceiver.kt +15 -1
- package/android/src/main/java/com/margelo/nitro/qusaieilouti99/callmanager/MyConnection.kt +12 -13
- package/package.json +1 -1
|
@@ -100,6 +100,10 @@ object CallEngine {
|
|
|
100
100
|
Log.d(TAG, "Removed Telecom Connection for callId: $callId. Total: ${telecomConnections.size}")
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
fun getTelecomConnection(callId: String): Connection? {
|
|
104
|
+
return telecomConnections[callId]
|
|
105
|
+
}
|
|
106
|
+
|
|
103
107
|
// --- Public API ---
|
|
104
108
|
|
|
105
109
|
fun setCanMakeMultipleCalls(allow: Boolean) {
|
|
@@ -438,8 +442,20 @@ object CallEngine {
|
|
|
438
442
|
val packageName = context.packageName
|
|
439
443
|
val launchIntent = context.packageManager.getLaunchIntentForPackage(packageName)
|
|
440
444
|
launchIntent?.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
445
|
+
|
|
446
|
+
// If there are active calls, add the lock screen bypass flags
|
|
447
|
+
if (isCallActive()) {
|
|
448
|
+
launchIntent?.addFlags(
|
|
449
|
+
Intent.FLAG_ACTIVITY_SHOW_WHEN_LOCKED or
|
|
450
|
+
Intent.FLAG_ACTIVITY_TURN_SCREEN_ON or
|
|
451
|
+
Intent.FLAG_ACTIVITY_DISMISS_KEYGUARD
|
|
452
|
+
)
|
|
453
|
+
Log.d(TAG, "App brought to foreground with lock screen bypass flags due to active call")
|
|
454
|
+
} else {
|
|
455
|
+
Log.d(TAG, "App brought to foreground via normal launchIntent")
|
|
456
|
+
}
|
|
457
|
+
|
|
441
458
|
context.startActivity(launchIntent)
|
|
442
|
-
Log.d(TAG, "App brought to foreground via launchIntent")
|
|
443
459
|
}
|
|
444
460
|
|
|
445
461
|
// --- Audio Device Management ---
|
|
@@ -667,7 +683,7 @@ object CallEngine {
|
|
|
667
683
|
val phoneAccountHandle = getPhoneAccountHandle(context)
|
|
668
684
|
if (telecomManager.getPhoneAccount(phoneAccountHandle) == null) {
|
|
669
685
|
val phoneAccount = PhoneAccount.builder(phoneAccountHandle, "PingMe Call")
|
|
670
|
-
.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED
|
|
686
|
+
.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED)
|
|
671
687
|
.build()
|
|
672
688
|
try {
|
|
673
689
|
telecomManager.registerPhoneAccount(phoneAccount)
|
|
@@ -12,9 +12,23 @@ class CallNotificationActionReceiver : BroadcastReceiver() {
|
|
|
12
12
|
override fun onReceive(context: Context, intent: Intent) {
|
|
13
13
|
val callId = intent.getStringExtra("callId") ?: return
|
|
14
14
|
Log.d(TAG, "onReceive called with action=${intent.action}, callId=$callId")
|
|
15
|
+
|
|
15
16
|
when (intent.action) {
|
|
16
17
|
"com.qusaieilouti99.callmanager.ANSWER_CALL" -> {
|
|
17
|
-
Log.d(TAG, "Answer action received for callId: $callId.
|
|
18
|
+
Log.d(TAG, "Answer action received for callId: $callId. Answering call via Telecom.")
|
|
19
|
+
|
|
20
|
+
// Get the telecom connection and answer it
|
|
21
|
+
val connection = CallEngine.getTelecomConnection(callId)
|
|
22
|
+
if (connection != null) {
|
|
23
|
+
// This will trigger MyConnection.onAnswer() which handles the rest
|
|
24
|
+
connection.onAnswer()
|
|
25
|
+
Log.d(TAG, "Call answered via Telecom connection for callId: $callId")
|
|
26
|
+
} else {
|
|
27
|
+
Log.e(TAG, "No Telecom connection found for callId: $callId. Falling back to direct answer.")
|
|
28
|
+
// Fallback: answer directly via CallEngine
|
|
29
|
+
CallEngine.answerCall(context, callId)
|
|
30
|
+
}
|
|
31
|
+
|
|
18
32
|
CallEngine.bringAppToForeground(context)
|
|
19
33
|
}
|
|
20
34
|
"com.qusaieilouti99.callmanager.DECLINE_CALL" -> {
|
|
@@ -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()
|