@qusaieilouti99/call-manager 0.1.12 → 0.1.14
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.
|
@@ -25,11 +25,13 @@ class CallManagerModule(reactContext: ReactApplicationContext) :
|
|
|
25
25
|
|
|
26
26
|
// Register JS event handler
|
|
27
27
|
override fun setEventHandler(callback: Callback) {
|
|
28
|
+
Log.d(TAG, "setEventHandler called, registering JS callback")
|
|
28
29
|
eventHandler = callback
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
// Helper to emit events to JS
|
|
32
33
|
fun emitEvent(event: String, callData: String) {
|
|
34
|
+
Log.d(TAG, "emitEvent: event=$event, callData=$callData")
|
|
33
35
|
eventHandler?.invoke(event, callData)
|
|
34
36
|
}
|
|
35
37
|
|
|
@@ -42,23 +44,28 @@ class CallManagerModule(reactContext: ReactApplicationContext) :
|
|
|
42
44
|
|
|
43
45
|
// 2. End call
|
|
44
46
|
override fun endCall(callId: String) {
|
|
47
|
+
Log.d(TAG, "endCall called with callId=$callId")
|
|
45
48
|
val context = reactApplicationContext
|
|
46
49
|
val intent = Intent(context, CallForegroundService::class.java)
|
|
47
|
-
context.stopService(intent)
|
|
50
|
+
val stopped = context.stopService(intent)
|
|
51
|
+
Log.d(TAG, "CallForegroundService stopped: $stopped")
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
// 3. Answer call
|
|
51
55
|
override fun answerCall(callId: String) {
|
|
56
|
+
Log.d(TAG, "answerCall called with callId=$callId")
|
|
52
57
|
bringAppToForeground()
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
// 4. Silence ringtone
|
|
56
61
|
override fun silenceRingtone() {
|
|
62
|
+
Log.d(TAG, "silenceRingtone called")
|
|
57
63
|
// TODO: Implement ringtone silencing logic if you play a custom ringtone
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
// 5. Reject current and answer new
|
|
61
67
|
override fun rejectCurrentAndAnswerNew(callId: String, callData: String) {
|
|
68
|
+
Log.d(TAG, "rejectCurrentAndAnswerNew called with callId=$callId, callData=$callData")
|
|
62
69
|
endCall(currentCallId ?: "")
|
|
63
70
|
CallNativeHelper.reportIncomingCall(reactApplicationContext, callId, callData)
|
|
64
71
|
}
|
|
@@ -70,10 +77,14 @@ class CallManagerModule(reactContext: ReactApplicationContext) :
|
|
|
70
77
|
val packageName = context.packageName
|
|
71
78
|
val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
|
|
72
79
|
val tasks = activityManager.appTasks
|
|
80
|
+
Log.d(TAG, "bringAppToForeground called. tasks.isNullOrEmpty()=${tasks.isNullOrEmpty()}")
|
|
73
81
|
if (tasks.isNullOrEmpty()) {
|
|
74
82
|
val launchIntent = context.packageManager.getLaunchIntentForPackage(packageName)
|
|
75
83
|
launchIntent?.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
76
84
|
context.startActivity(launchIntent)
|
|
85
|
+
Log.d(TAG, "App brought to foreground via launchIntent")
|
|
86
|
+
} else {
|
|
87
|
+
Log.d(TAG, "App already in foreground or has tasks")
|
|
77
88
|
}
|
|
78
89
|
}
|
|
79
90
|
}
|
package/android/src/main/java/com/qusaieilouti99/callmanager/CallNotificationActionReceiver.kt
CHANGED
|
@@ -7,7 +7,9 @@ import android.util.Log
|
|
|
7
7
|
|
|
8
8
|
class CallNotificationActionReceiver : BroadcastReceiver() {
|
|
9
9
|
override fun onReceive(context: Context, intent: Intent) {
|
|
10
|
+
|
|
10
11
|
val callId = intent.getStringExtra("callId") ?: return
|
|
12
|
+
Log.d("CallNotificationActionReceiver", "onReceive called with action=${intent.action}, callId=$callId")
|
|
11
13
|
val action = intent.action
|
|
12
14
|
|
|
13
15
|
val app = context.applicationContext as? com.facebook.react.ReactApplication
|
|
@@ -17,17 +19,15 @@ class CallNotificationActionReceiver : BroadcastReceiver() {
|
|
|
17
19
|
|
|
18
20
|
when (action) {
|
|
19
21
|
"com.qusaieilouti99.callmanager.ANSWER_CALL" -> {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} else {
|
|
23
|
-
// ReactContext not ready, bring app to foreground
|
|
24
|
-
bringAppToForeground(context)
|
|
25
|
-
}
|
|
22
|
+
Log.d("CallNotificationActionReceiver", "Answer action received")
|
|
23
|
+
bringAppToForeground(context)
|
|
26
24
|
}
|
|
27
25
|
"com.qusaieilouti99.callmanager.DECLINE_CALL" -> {
|
|
26
|
+
Log.d("CallNotificationActionReceiver", "Decline action received")
|
|
28
27
|
module?.endCall(callId)
|
|
29
28
|
}
|
|
30
29
|
}
|
|
30
|
+
|
|
31
31
|
// Cancel notification and stop ringtone
|
|
32
32
|
CallNotificationHelper(context).cancelIncomingCallNotification()
|
|
33
33
|
}
|