@qusaieilouti99/call-manager 0.1.40 → 0.1.42

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.
@@ -1,67 +1,22 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android">
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.margelo.nitro.qusaieilouti99.callmanager">
2
3
 
3
- <!-- REQUIRED FOR TELECOM API (Self-managed connections) -->
4
+ <!-- Essential permissions that the library requires -->
4
5
  <uses-permission android:name="android.permission.MANAGE_OWN_CALLS" />
5
- <!-- Required for recording audio in calls -->
6
+ <uses-permission android:name="android.permission.BIND_TELECOM_CONNECTION_SERVICE" />
6
7
  <uses-permission android:name="android.permission.RECORD_AUDIO" />
7
- <!-- Required for changing audio routes like speakerphone -->
8
8
  <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
9
- <!-- For keeping screen awake during calls -->
10
9
  <uses-permission android:name="android.permission.WAKE_LOCK" />
11
- <!-- For vibrating the device (e.g., incoming call) -->
12
10
  <uses-permission android:name="android.permission.VIBRATE" />
11
+ <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
12
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
13
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
14
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL" />
13
15
 
14
- <!-- Bluetooth permissions for audio routing -->
15
- <!-- For Android 11 (API 30) and lower -->
16
+ <!-- Bluetooth permissions -->
16
17
  <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
17
18
  <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
18
- <!-- For Android 12 (API 31) and higher -->
19
19
  <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
20
20
 
21
- <!-- Required for foreground service on older devices (< Android P) -->
22
- <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
23
- <!-- Required for foreground service with phoneCall type on Android 12 (API 31) and higher -->
24
- <uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL" />
25
-
26
- <application>
27
- <!-- Your CallActivity for full-screen incoming call UI -->
28
- <activity
29
- android:name=".CallActivity"
30
- android:exported="true"
31
- android:showOnLockScreen="true"
32
- android:turnScreenOn="true"
33
- android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
34
- android:screenOrientation="portrait"
35
- android:launchMode="singleTop"
36
- android:excludeFromRecents="true"
37
- android:taskAffinity=""
38
- android:windowSoftInputMode="adjustResize">
39
- <intent-filter>
40
- <action android:name="android.intent.action.VIEW"/>
41
- <category android:name="android.intent.category.DEFAULT"/>
42
- </intent-filter>
43
- </activity>
44
-
45
- <!-- The ConnectionService, crucial for Telecom API integration -->
46
- <service
47
- android:name=".MyConnectionService"
48
- android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"
49
- android:exported="true">
50
- <intent-filter>
51
- <action android:name="android.telecom.ConnectionService" />
52
- </intent-filter>
53
- </service>
54
-
55
- <!-- The foreground service to keep the call alive in the background -->
56
- <service
57
- android:name=".CallForegroundService"
58
- android:enabled="true"
59
- android:exported="false"
60
- android:foregroundServiceType="phoneCall" />
61
-
62
- <!-- Receiver for notification actions (Answer/Decline) -->
63
- <receiver
64
- android:name=".CallNotificationActionReceiver"
65
- android:exported="false" />
66
- </application>
21
+ <!-- No components needed here - they're declared in app manifest -->
67
22
  </manifest>
@@ -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 ---
@@ -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. Bringing app to foreground.")
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" -> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qusaieilouti99/call-manager",
3
- "version": "0.1.40",
3
+ "version": "0.1.42",
4
4
  "description": "Call manager",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",