@qusaieilouti99/call-manager 0.1.46 → 0.1.47

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>
@@ -270,6 +270,9 @@ object CallEngine {
270
270
  keepScreenAwake(context, true)
271
271
  resetAudioMode(context)
272
272
 
273
+ // ADDED: Ensure MainActivity shows above lock screen during call
274
+ updateMainActivityLockScreenBypass()
275
+
273
276
  // Emit event
274
277
  emitEvent(CallEventType.CALL_ANSWERED, JSONObject().put("callId", callId))
275
278
  notifyCallStateChanged(context)
@@ -277,6 +280,26 @@ object CallEngine {
277
280
  Log.d(TAG, "Call $callId successfully answered and UI cleaned up")
278
281
  }
279
282
 
283
+ // NEW: Method to update MainActivity lock screen bypass state
284
+ private fun updateMainActivityLockScreenBypass() {
285
+ try {
286
+ // Try to get MainActivity instance through reflection or static reference
287
+ val mainActivityClass = Class.forName("com.pingme2022.MainActivity")
288
+ val getCurrentInstanceMethod = mainActivityClass.getMethod("getCurrentInstance")
289
+ val mainActivityInstance = getCurrentInstanceMethod.invoke(null)
290
+
291
+ if (mainActivityInstance != null) {
292
+ val updateMethod = mainActivityClass.getMethod("updateLockScreenBypass")
293
+ updateMethod.invoke(mainActivityInstance)
294
+ Log.d(TAG, "Updated MainActivity lock screen bypass state")
295
+ } else {
296
+ Log.d(TAG, "MainActivity instance not available for lock screen bypass update")
297
+ }
298
+ } catch (e: Exception) {
299
+ Log.w(TAG, "Could not update MainActivity lock screen bypass: ${e.message}")
300
+ }
301
+ }
302
+
280
303
  fun holdCall(context: Context, callId: String) {
281
304
  Log.d(TAG, "holdCall: $callId")
282
305
  val connection = telecomConnections[callId]
@@ -381,10 +404,9 @@ object CallEngine {
381
404
  keepScreenAwake(context, false)
382
405
  resetAudioMode(context)
383
406
 
384
- // FIXED: Clear lock screen bypass when calls end
385
- clearLockScreenBypass(context)
407
+ // ENHANCED: Clear lock screen bypass when calls end
408
+ updateMainActivityLockScreenBypass()
386
409
  }
387
-
388
410
  // NEW: Function to clear lock screen bypass
389
411
  private fun clearLockScreenBypass(context: Context) {
390
412
  try {
@@ -491,21 +513,45 @@ object CallEngine {
491
513
  context.stopService(intent)
492
514
  }
493
515
 
516
+ // Enhanced bringAppToForeground with better lock screen handling
494
517
  fun bringAppToForeground(context: Context) {
495
518
  val packageName = context.packageName
496
519
  val launchIntent = context.packageManager.getLaunchIntentForPackage(packageName)
497
- launchIntent?.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
520
+ launchIntent?.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
498
521
 
499
522
  // Handle lock screen bypass for active calls
500
523
  if (isCallActive()) {
501
- // Only set lock screen bypass when bringing to foreground during active calls
524
+ // ENHANCED: Add multiple flags for better lock screen bypass
502
525
  launchIntent?.putExtra("BYPASS_LOCK_SCREEN", true)
526
+
527
+ // Add lock screen bypass flags directly to the intent
528
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
529
+ launchIntent?.addFlags(Intent.FLAG_ACTIVITY_SHOW_WHEN_LOCKED or Intent.FLAG_ACTIVITY_TURN_SCREEN_ON)
530
+ } else {
531
+ launchIntent?.addFlags(
532
+ Intent.FLAG_ACTIVITY_SHOW_WHEN_LOCKED or
533
+ Intent.FLAG_ACTIVITY_TURN_SCREEN_ON or
534
+ Intent.FLAG_ACTIVITY_CLEAR_TASK
535
+ )
536
+ }
537
+
503
538
  Log.d(TAG, "App brought to foreground with lock screen bypass for active call")
504
539
  } else {
540
+ launchIntent?.removeExtra("BYPASS_LOCK_SCREEN")
505
541
  Log.d(TAG, "App brought to foreground without lock screen bypass")
506
542
  }
507
543
 
508
- context.startActivity(launchIntent)
544
+ try {
545
+ context.startActivity(launchIntent)
546
+
547
+ // ADDED: Small delay to ensure activity is created before updating bypass
548
+ android.os.Handler(android.os.Looper.getMainLooper()).postDelayed({
549
+ updateMainActivityLockScreenBypass()
550
+ }, 100)
551
+
552
+ } catch (e: Exception) {
553
+ Log.e(TAG, "Failed to bring app to foreground: ${e.message}")
554
+ }
509
555
  }
510
556
 
511
557
  // Rest of the methods remain the same...
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qusaieilouti99/call-manager",
3
- "version": "0.1.46",
3
+ "version": "0.1.47",
4
4
  "description": "Call manager",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",