rns-nativecall 0.5.4 → 0.5.6
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.
|
@@ -12,34 +12,46 @@ class AcceptCallActivity : Activity() {
|
|
|
12
12
|
|
|
13
13
|
val extras = intent.extras
|
|
14
14
|
val dataMap = mutableMapOf<String, String>()
|
|
15
|
+
|
|
16
|
+
// Extract data into our map
|
|
15
17
|
extras?.keySet()?.forEach { key ->
|
|
16
18
|
extras.get(key)?.let { dataMap[key] = it.toString() }
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
val uuid = dataMap["callUuid"]
|
|
20
22
|
|
|
21
|
-
//
|
|
22
|
-
NativeCallManager.stopRingtone()
|
|
23
|
-
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
23
|
+
// FIX: Only call these if uuid is not null to satisfy the compiler
|
|
24
24
|
if (uuid != null) {
|
|
25
|
+
// 1. Kill background tasks immediately
|
|
26
|
+
CallMessagingService.stopBackupTimer(uuid)
|
|
27
|
+
|
|
28
|
+
val stopHeadlessIntent = Intent(this, CallHeadlessTask::class.java)
|
|
29
|
+
stopService(stopHeadlessIntent)
|
|
30
|
+
|
|
31
|
+
// 2. Stop UI/Ringtone and Notification
|
|
32
|
+
NativeCallManager.stopRingtone()
|
|
33
|
+
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
25
34
|
notificationManager.cancel(uuid.hashCode())
|
|
26
|
-
}
|
|
27
35
|
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
// 3. SYNC WITH CALLMODULE: Save data for getInitialCallData()
|
|
37
|
+
CallModule.setPendingCallData(dataMap)
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
// 4. SYNC WITH CALLMODULE: Emit event for the active Bridge
|
|
40
|
+
CallModule.sendEventToJS("onCallAccepted", dataMap)
|
|
33
41
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
// 5. Launch Main App with data
|
|
43
|
+
val launchIntent = packageManager.getLaunchIntentForPackage(packageName)
|
|
44
|
+
launchIntent?.apply {
|
|
45
|
+
// Using Intent.FLAG_ACTIVITY_NEW_TASK to ensure it opens correctly from a "killed" state
|
|
46
|
+
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
|
47
|
+
putExtras(extras ?: Bundle())
|
|
48
|
+
putExtra("navigatingToCall", true)
|
|
49
|
+
putExtra("callUuid", uuid) // Explicitly pass uuid again for easy access in JS
|
|
50
|
+
}
|
|
51
|
+
startActivity(launchIntent)
|
|
40
52
|
}
|
|
41
|
-
startActivity(launchIntent)
|
|
42
53
|
|
|
54
|
+
// Always finish the trampoline activity
|
|
43
55
|
finish()
|
|
44
56
|
}
|
|
45
57
|
}
|
|
@@ -4,46 +4,43 @@ import android.content.BroadcastReceiver
|
|
|
4
4
|
import android.content.Context
|
|
5
5
|
import android.content.Intent
|
|
6
6
|
import android.app.NotificationManager
|
|
7
|
-
import android.os.Bundle
|
|
8
7
|
|
|
9
8
|
class CallActionReceiver : BroadcastReceiver() {
|
|
10
9
|
override fun onReceive(context: Context, intent: Intent) {
|
|
10
|
+
val uuid = intent.getStringExtra("EXTRA_CALL_UUID") ?: return
|
|
11
|
+
val action = intent.action ?: return
|
|
12
|
+
|
|
13
|
+
// 1. KILL THE BACKUP TIMER (Stop MessagingService from re-triggering)
|
|
14
|
+
CallMessagingService.stopBackupTimer(uuid)
|
|
15
|
+
|
|
16
|
+
// 2. STOP THE HEADLESS SERVICE (Stop JS from initializing WebRTC)
|
|
17
|
+
val stopHeadlessIntent = Intent(context, CallHeadlessTask::class.java)
|
|
18
|
+
context.stopService(stopHeadlessIntent)
|
|
19
|
+
|
|
20
|
+
// 3. STOP NATIVE UI
|
|
11
21
|
NativeCallManager.stopRingtone()
|
|
12
|
-
|
|
13
|
-
val extras = intent.extras
|
|
14
|
-
val uuid = intent.getStringExtra("EXTRA_CALL_UUID")
|
|
15
|
-
val action = intent.action
|
|
16
|
-
|
|
17
22
|
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
18
|
-
|
|
19
|
-
notificationManager.cancel(uuid.hashCode())
|
|
20
|
-
}
|
|
23
|
+
notificationManager.cancel(uuid.hashCode())
|
|
21
24
|
|
|
22
25
|
val dataMap = mutableMapOf<String, String>()
|
|
23
|
-
extras?.keySet()?.forEach { key ->
|
|
24
|
-
extras
|
|
26
|
+
intent.extras?.keySet()?.forEach { key ->
|
|
27
|
+
intent.extras?.get(key)?.let { dataMap[key] = it.toString() }
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
if (action?.contains("ACTION_ACCEPT") == true) {
|
|
29
|
-
// Save data for cold-start polling (getInitialCallData)
|
|
30
|
+
if (action.contains("ACTION_ACCEPT")) {
|
|
30
31
|
CallModule.setPendingCallData(dataMap)
|
|
31
|
-
|
|
32
|
-
// Emit to active bridge
|
|
33
32
|
CallModule.sendEventToJS("onCallAccepted", dataMap)
|
|
34
33
|
|
|
35
|
-
// Open the app
|
|
36
34
|
val launchIntent = context.packageManager.getLaunchIntentForPackage(context.packageName)
|
|
37
35
|
launchIntent?.apply {
|
|
38
36
|
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
|
39
|
-
putExtras(extras ?: Bundle())
|
|
37
|
+
putExtras(intent.extras ?: android.os.Bundle())
|
|
40
38
|
putExtra("navigatingToCall", true)
|
|
41
39
|
}
|
|
42
40
|
context.startActivity(launchIntent)
|
|
43
41
|
|
|
44
|
-
} else if (action
|
|
45
|
-
//
|
|
46
|
-
// as we don't open the app.
|
|
42
|
+
} else if (action.contains("ACTION_REJECT")) {
|
|
43
|
+
// Tell JS call is dead
|
|
47
44
|
CallModule.sendEventToJS("onCallRejected", dataMap)
|
|
48
45
|
}
|
|
49
46
|
}
|
|
@@ -21,6 +21,14 @@ class CallMessagingService : FirebaseMessagingService() {
|
|
|
21
21
|
companion object {
|
|
22
22
|
private val handler = Handler(Looper.getMainLooper())
|
|
23
23
|
private val pendingNotifications = mutableMapOf<String, Runnable>()
|
|
24
|
+
|
|
25
|
+
@JvmStatic
|
|
26
|
+
fun stopBackupTimer(uuid: String) {
|
|
27
|
+
pendingNotifications[uuid]?.let {
|
|
28
|
+
handler.removeCallbacks(it)
|
|
29
|
+
pendingNotifications.remove(uuid)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
// Helper to check app state
|
|
@@ -76,6 +84,8 @@ class CallMessagingService : FirebaseMessagingService() {
|
|
|
76
84
|
}
|
|
77
85
|
}
|
|
78
86
|
|
|
87
|
+
|
|
88
|
+
|
|
79
89
|
private fun showMissedCallNotification(context: Context, data: Map<String, String>, uuid: String) {
|
|
80
90
|
val name = data["name"] ?: "Unknown"
|
|
81
91
|
val callType = data["callType"] ?: "video"
|
package/package.json
CHANGED