@qusaieilouti99/call-manager 0.1.49 → 0.1.51
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.
|
@@ -108,7 +108,7 @@ object CallEngine {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
fun emitEvent(type: CallEventType, data: JSONObject) {
|
|
112
112
|
Log.d(TAG, "Emitting event: $type, data: $data")
|
|
113
113
|
val dataString = data.toString()
|
|
114
114
|
if (eventHandler != null) {
|
|
@@ -347,6 +347,9 @@ object CallEngine {
|
|
|
347
347
|
|
|
348
348
|
updateLockScreenBypass()
|
|
349
349
|
|
|
350
|
+
// Update foreground notification with call info
|
|
351
|
+
updateForegroundNotification(context)
|
|
352
|
+
|
|
350
353
|
// Emit event with full call data instead of just callId
|
|
351
354
|
emitEvent(CallEventType.CALL_ANSWERED, JSONObject().apply {
|
|
352
355
|
put("callId", callId)
|
|
@@ -851,7 +854,21 @@ object CallEngine {
|
|
|
851
854
|
// --- Service Management ---
|
|
852
855
|
fun startForegroundService(context: Context) {
|
|
853
856
|
Log.d(TAG, "Starting CallForegroundService.")
|
|
857
|
+
|
|
858
|
+
// Find the current active call to pass its info
|
|
859
|
+
val currentCall = activeCalls.values.find {
|
|
860
|
+
it.state == CallState.ACTIVE || it.state == CallState.INCOMING || it.state == CallState.DIALING
|
|
861
|
+
}
|
|
862
|
+
|
|
854
863
|
val intent = Intent(context, CallForegroundService::class.java)
|
|
864
|
+
|
|
865
|
+
if (currentCall != null) {
|
|
866
|
+
intent.putExtra("callId", currentCall.callId)
|
|
867
|
+
intent.putExtra("callData", currentCall.callData)
|
|
868
|
+
intent.putExtra("state", currentCall.state.name)
|
|
869
|
+
Log.d(TAG, "Starting foreground service with call info: ${currentCall.callId}")
|
|
870
|
+
}
|
|
871
|
+
|
|
855
872
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
856
873
|
context.startForegroundService(intent)
|
|
857
874
|
} else {
|
package/android/src/main/java/com/margelo/nitro/qusaieilouti99/callmanager/CallForegroundService.kt
CHANGED
|
@@ -30,20 +30,20 @@ class CallForegroundService : Service() {
|
|
|
30
30
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
|
31
31
|
Log.d(TAG, "Service onStartCommand")
|
|
32
32
|
|
|
33
|
-
if
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
// Check if we have call info in the intent
|
|
34
|
+
val callId = intent?.getStringExtra("callId")
|
|
35
|
+
val callData = intent?.getStringExtra("callData")
|
|
36
|
+
val state = intent?.getStringExtra("state")
|
|
37
|
+
|
|
38
|
+
val notification = if (callId != null && callData != null && state != null) {
|
|
39
|
+
Log.d(TAG, "Building enhanced notification with call info: $callId")
|
|
40
|
+
buildEnhancedNotification(callId, callData, state)
|
|
41
41
|
} else {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
startForeground(NOTIFICATION_ID, notification)
|
|
42
|
+
Log.d(TAG, "Building basic notification - no call info available")
|
|
43
|
+
buildBasicNotification()
|
|
45
44
|
}
|
|
46
45
|
|
|
46
|
+
startForeground(NOTIFICATION_ID, notification)
|
|
47
47
|
return START_STICKY
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -56,12 +56,12 @@ class CallForegroundService : Service() {
|
|
|
56
56
|
Log.d(TAG, "Building basic foreground notification.")
|
|
57
57
|
|
|
58
58
|
return NotificationCompat.Builder(this, CHANNEL_ID)
|
|
59
|
-
.setContentTitle("Call
|
|
60
|
-
.setContentText("
|
|
59
|
+
.setContentTitle("Call Service")
|
|
60
|
+
.setContentText("Call service is running...")
|
|
61
61
|
.setSmallIcon(android.R.drawable.sym_call_incoming)
|
|
62
62
|
.setOngoing(true)
|
|
63
63
|
.setCategory(NotificationCompat.CATEGORY_CALL)
|
|
64
|
-
.setPriority(NotificationCompat.
|
|
64
|
+
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
|
65
65
|
.setWhen(System.currentTimeMillis())
|
|
66
66
|
.build()
|
|
67
67
|
}
|
|
@@ -117,37 +117,58 @@ class CallForegroundService : Service() {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
val statusText = when (state) {
|
|
120
|
-
"ACTIVE" -> "
|
|
120
|
+
"ACTIVE" -> "$callerName"
|
|
121
121
|
"HELD" -> "$callerName (on hold)"
|
|
122
122
|
"DIALING" -> "Calling $callerName..."
|
|
123
|
-
|
|
123
|
+
"INCOMING" -> "Incoming call from $callerName"
|
|
124
|
+
else -> callerName
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
val titleText = when (state) {
|
|
128
|
+
"ACTIVE" -> "$callType Call Active"
|
|
129
|
+
"HELD" -> "$callType Call Held"
|
|
130
|
+
"DIALING" -> "Outgoing $callType Call"
|
|
131
|
+
"INCOMING" -> "Incoming $callType Call"
|
|
132
|
+
else -> "$callType Call"
|
|
124
133
|
}
|
|
125
134
|
|
|
126
|
-
val
|
|
127
|
-
.setContentTitle(
|
|
135
|
+
val notificationBuilder = NotificationCompat.Builder(this, CHANNEL_ID)
|
|
136
|
+
.setContentTitle(titleText)
|
|
128
137
|
.setContentText(statusText)
|
|
129
138
|
.setSmallIcon(android.R.drawable.sym_call_incoming)
|
|
130
139
|
.setOngoing(true)
|
|
131
140
|
.setCategory(NotificationCompat.CATEGORY_CALL)
|
|
132
141
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
|
133
142
|
.setWhen(System.currentTimeMillis())
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
143
|
+
|
|
144
|
+
// Add actions for ACTIVE and HELD calls only
|
|
145
|
+
if (state == "ACTIVE" || state == "HELD") {
|
|
146
|
+
notificationBuilder
|
|
147
|
+
.addAction(
|
|
148
|
+
if (isHeld) android.R.drawable.ic_media_play else android.R.drawable.ic_media_pause,
|
|
149
|
+
holdText,
|
|
150
|
+
holdPendingIntent
|
|
151
|
+
)
|
|
152
|
+
.addAction(
|
|
153
|
+
android.R.drawable.sym_call_outgoing,
|
|
154
|
+
"End Call",
|
|
155
|
+
endCallPendingIntent
|
|
156
|
+
)
|
|
157
|
+
} else if (state == "DIALING") {
|
|
158
|
+
// For dialing calls, only show end call
|
|
159
|
+
notificationBuilder.addAction(
|
|
140
160
|
android.R.drawable.sym_call_outgoing,
|
|
141
161
|
"End Call",
|
|
142
162
|
endCallPendingIntent
|
|
143
163
|
)
|
|
164
|
+
}
|
|
144
165
|
|
|
145
166
|
// Set content intent to open the main app
|
|
146
167
|
mainPendingIntent?.let {
|
|
147
|
-
|
|
168
|
+
notificationBuilder.setContentIntent(it)
|
|
148
169
|
}
|
|
149
170
|
|
|
150
|
-
return
|
|
171
|
+
return notificationBuilder.build()
|
|
151
172
|
}
|
|
152
173
|
|
|
153
174
|
private fun createNotificationChannel() {
|