@qusaieilouti99/call-manager 0.1.45 → 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.
|
@@ -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
|
-
//
|
|
385
|
-
|
|
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
|
-
//
|
|
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
|
-
|
|
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...
|