@qusaieilouti99/call-manager 0.1.91 → 0.1.93

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.
@@ -916,13 +916,91 @@ object CallEngine {
916
916
  }
917
917
  }
918
918
 
919
- // **SAMSUNG FIX**: Enhanced showIncomingCallUI method
920
919
  private fun showIncomingCallUI(callId: String, callerName: String, callType: String) {
921
920
  val context = requireContext()
922
921
  Log.d(TAG, "Showing incoming call UI for $callId")
922
+
923
+ // **SIMPLE LOGIC**: If locked -> overlay, if unlocked -> notification
924
+ if (isDeviceLocked(context)) {
925
+ Log.d(TAG, "Device is locked - using overlay approach")
926
+ showCallActivityOverlay(context, callId, callerName, callType)
927
+ } else {
928
+ Log.d(TAG, "Device is unlocked - using standard notification")
929
+ showStandardNotification(context, callId, callerName, callType)
930
+ }
931
+
932
+ playRingtone()
933
+ setInitialAudioRoute(callType)
934
+ }
935
+
936
+ /**
937
+ * Simple check if device is locked
938
+ */
939
+ private fun isDeviceLocked(context: Context): Boolean {
940
+ val keyguardManager = context.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
941
+ val isLocked = keyguardManager.isKeyguardLocked
942
+ Log.d(TAG, "Device locked status: $isLocked")
943
+ return isLocked
944
+ }
945
+
946
+ /**
947
+ * Shows the call activity directly as overlay (when device is locked)
948
+ */
949
+ private fun showCallActivityOverlay(context: Context, callId: String, callerName: String, callType: String) {
950
+ val overlayIntent = Intent(context, CallActivity::class.java).apply {
951
+ addFlags(
952
+ Intent.FLAG_ACTIVITY_NEW_TASK or
953
+ Intent.FLAG_ACTIVITY_CLEAR_TASK or
954
+ Intent.FLAG_ACTIVITY_NO_ANIMATION or
955
+ Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
956
+ )
957
+ putExtra("callId", callId)
958
+ putExtra("callerName", callerName)
959
+ putExtra("callType", callType)
960
+ putExtra("LOCK_SCREEN_MODE", true) // Flag to identify lock screen mode
961
+ }
962
+
963
+ try {
964
+ // Wake the screen when device is locked
965
+ val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager
966
+ val wakeLock = powerManager.newWakeLock(
967
+ PowerManager.SCREEN_BRIGHT_WAKE_LOCK or PowerManager.ACQUIRE_CAUSES_WAKEUP,
968
+ "CallEngine:LockScreenWake"
969
+ )
970
+ wakeLock.acquire(5000)
971
+
972
+ // Launch the activity overlay
973
+ context.startActivity(overlayIntent)
974
+ Log.d(TAG, "Successfully launched CallActivity overlay for locked device")
975
+
976
+ // **NO NOTIFICATION** when using overlay
977
+
978
+ } catch (e: Exception) {
979
+ Log.e(TAG, "Overlay failed, falling back to notification: ${e.message}")
980
+ // If overlay fails, fall back to notification
981
+ showStandardNotification(context, callId, callerName, callType)
982
+ }
983
+ }
984
+
985
+ /**
986
+ * Shows standard notification with full-screen intent (when device is unlocked)
987
+ */
988
+ private fun showStandardNotification(context: Context, callId: String, callerName: String, callType: String) {
923
989
  createNotificationChannel()
924
- val notificationManager =
925
- context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
990
+ val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
991
+
992
+ val fullScreenIntent = Intent(context, CallActivity::class.java).apply {
993
+ addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
994
+ putExtra("callId", callId)
995
+ putExtra("callerName", callerName)
996
+ putExtra("callType", callType)
997
+ // No lock screen flag - standard notification mode
998
+ }
999
+
1000
+ val fullScreenPendingIntent = PendingIntent.getActivity(
1001
+ context, callId.hashCode(), fullScreenIntent,
1002
+ PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
1003
+ )
926
1004
 
927
1005
  val answerIntent = Intent(context, CallNotificationActionReceiver::class.java).apply {
928
1006
  action = "com.qusaieilouti99.callmanager.ANSWER_CALL"
@@ -942,29 +1020,6 @@ object CallEngine {
942
1020
  PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
943
1021
  )
944
1022
 
945
- // **SAMSUNG FIX**: Enhanced full-screen intent
946
-
947
- // First, wake up the screen using PowerManager
948
- val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager
949
- val wakeLock = powerManager.newWakeLock(
950
- PowerManager.SCREEN_BRIGHT_WAKE_LOCK or PowerManager.ACQUIRE_CAUSES_WAKEUP,
951
- "CallEngine:IncomingCallWake"
952
- )
953
- wakeLock.acquire(5000) // 5 sec
954
- val fullScreenIntent = Intent(context, CallActivity::class.java).apply {
955
- addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
956
- putExtra("callId", callId)
957
- putExtra("callerName", callerName)
958
- putExtra("callType", callType)
959
- // **SAMSUNG SPECIFIC**: Add Samsung lock screen bypass flag
960
- putExtra("SAMSUNG_LOCK_SCREEN_BYPASS", true)
961
- }
962
- val fullScreenPendingIntent = PendingIntent.getActivity(
963
- context, 2, fullScreenIntent,
964
- PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
965
- )
966
-
967
- // **SAMSUNG FIX**: Enhanced notification
968
1023
  val notification = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
969
1024
  val person = android.app.Person.Builder()
970
1025
  .setName(callerName)
@@ -984,30 +1039,25 @@ object CallEngine {
984
1039
  .setAutoCancel(false)
985
1040
  .setCategory(Notification.CATEGORY_CALL)
986
1041
  .setPriority(Notification.PRIORITY_MAX)
987
- // **SAMSUNG SPECIFIC**: Add lock screen visibility
988
1042
  .setVisibility(Notification.VISIBILITY_PUBLIC)
989
- .setPublicVersion(null)
990
1043
  .build()
991
1044
  } else {
992
1045
  Notification.Builder(context, NOTIF_CHANNEL_ID)
993
1046
  .setSmallIcon(android.R.drawable.sym_call_incoming)
994
1047
  .setContentTitle("Incoming Call")
995
1048
  .setContentText(callerName)
996
- .setPriority(Notification.PRIORITY_HIGH)
1049
+ .setPriority(Notification.PRIORITY_MAX)
997
1050
  .setCategory(Notification.CATEGORY_CALL)
998
1051
  .setFullScreenIntent(fullScreenPendingIntent, true)
999
1052
  .addAction(android.R.drawable.sym_action_call, "Answer", answerPendingIntent)
1000
1053
  .addAction(android.R.drawable.ic_menu_close_clear_cancel, "Decline", declinePendingIntent)
1001
1054
  .setOngoing(true)
1002
1055
  .setAutoCancel(false)
1003
- // **SAMSUNG SPECIFIC**: Add lock screen visibility
1004
1056
  .setVisibility(Notification.VISIBILITY_PUBLIC)
1005
1057
  .build()
1006
1058
  }
1007
1059
 
1008
1060
  notificationManager.notify(NOTIF_ID, notification)
1009
- playRingtone()
1010
- setInitialAudioRoute(callType)
1011
1061
  }
1012
1062
 
1013
1063
  fun cancelIncomingCallUI() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qusaieilouti99/call-manager",
3
- "version": "0.1.91",
3
+ "version": "0.1.93",
4
4
  "description": "Call manager",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",