@@ -247,7 +247,7 @@ class CallActivity : CallBaseActivity() {
247247 private val cameraSwitchHandler = Handler ()
248248
249249 private val callTimeHandler = Handler (Looper .getMainLooper())
250-
250+
251251 // Track if we're intentionally leaving the call
252252 private var isIntentionallyLeavingCall = false
253253
@@ -327,7 +327,7 @@ class CallActivity : CallBaseActivity() {
327327 ) { permissionMap: Map <String , Boolean > ->
328328 // Log permission results
329329 Log .d(TAG , " Permission request completed with results: $permissionMap " )
330-
330+
331331 val rationaleList: MutableList <String > = ArrayList ()
332332 val audioPermission = permissionMap[Manifest .permission.RECORD_AUDIO ]
333333 if (audioPermission != null ) {
@@ -383,9 +383,7 @@ class CallActivity : CallBaseActivity() {
383383 } else {
384384 true // Older Android versions have permission by default
385385 }
386-
387- Log .d(TAG , " DEBUGNotification permission granted: $notificationPermissionGranted , isConnectionEstablished: $isConnectionEstablished " )
388-
386+
389387 if (! isConnectionEstablished) {
390388 Log .d(TAG , " Proceeding with prepareCall() despite notification permission status" )
391389 prepareCall()
@@ -416,10 +414,10 @@ class CallActivity : CallBaseActivity() {
416414 Log .d(TAG , " onCreate" )
417415 super .onCreate(savedInstanceState)
418416 sharedApplication!! .componentApplication.inject(this )
419-
417+
420418 // Register broadcast receiver for ending call from notification
421419 val endCallFilter = IntentFilter (END_CALL_FROM_NOTIFICATION )
422-
420+
423421 // Use the proper utility function with ReceiverFlag for Android 14+ compatibility
424422 // This receiver is for internal app use only (notification actions), so it should NOT be exported
425423 registerPermissionHandlerBroadcastReceiver(
@@ -429,7 +427,7 @@ class CallActivity : CallBaseActivity() {
429427 null ,
430428 ReceiverFlag .NotExported
431429 )
432-
430+
433431 Log .d(TAG , " Broadcast receiver registered successfully" )
434432
435433 callViewModel = ViewModelProvider (this , viewModelFactory)[CallViewModel ::class .java]
@@ -1059,7 +1057,7 @@ class CallActivity : CallBaseActivity() {
10591057 permissionsToRequest.add(Manifest .permission.BLUETOOTH_CONNECT )
10601058 }
10611059 }
1062-
1060+
10631061 // Check notification permission for Android 13+ (API 33+)
10641062 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .TIRAMISU ) {
10651063 if (permissionUtil!! .isPostNotificationsPermissionGranted()) {
@@ -1103,20 +1101,23 @@ class CallActivity : CallBaseActivity() {
11031101 Log .d(TAG , " Starting foreground service with notification permission" )
11041102 CallForegroundService .start(applicationContext, conversationName, intent.extras)
11051103 } else {
1106- Log .w(TAG , " Notification permission not granted - call will work but without persistent notification" )
1104+ Log .w(
1105+ TAG ,
1106+ " Notification permission not granted - call will work but without persistent notification"
1107+ )
11071108 // Show warning to user that notification permission is missing (10 seconds)
11081109 Snackbar .make(
11091110 binding!! .root,
11101111 resources.getString(R .string.nc_notification_permission_hint),
1111- 10000
1112+ SEC_10
11121113 ).show()
11131114 }
11141115 } else {
11151116 // Android 12 and below - notification permission is automatically granted
11161117 Log .d(TAG , " Starting foreground service (Android 12-)" )
11171118 CallForegroundService .start(applicationContext, conversationName, intent.extras)
11181119 }
1119-
1120+
11201121 if (! microphoneOn) {
11211122 onMicrophoneClick()
11221123 }
@@ -1127,7 +1128,7 @@ class CallActivity : CallBaseActivity() {
11271128 // The call should not hang just because notification permission was denied
11281129 // Always proceed with call setup regardless of notification permission
11291130 Log .d(TAG , " Ensuring call proceeds even without notification permission" )
1130-
1131+
11311132 if (isVoiceOnlyCall) {
11321133 binding!! .selfVideoViewWrapper.visibility = View .GONE
11331134 } else if (permissionUtil!! .isCameraPermissionGranted()) {
@@ -1155,11 +1156,7 @@ class CallActivity : CallBaseActivity() {
11551156 for (rationale in rationaleList) {
11561157 rationalesWithLineBreaks.append(rationale).append(" \n\n " )
11571158 }
1158-
1159- // Log when permission rationale dialog is shown
1160- Log .d(TAG , " Showing permission rationale dialog for permissions: $permissionsToRequest " )
1161- Log .d(TAG , " Rationale includes notification permission: ${permissionsToRequest.contains(Manifest .permission.POST_NOTIFICATIONS )} " )
1162-
1159+
11631160 val dialogBuilder = MaterialAlertDialogBuilder (this )
11641161 .setTitle(R .string.nc_permissions_rationale_dialog_title)
11651162 .setMessage(rationalesWithLineBreaks)
@@ -1173,7 +1170,7 @@ class CallActivity : CallBaseActivity() {
11731170 if (permissionsToRequest.contains(Manifest .permission.POST_NOTIFICATIONS )) {
11741171 Log .w(TAG , " Notification permission specifically dismissed - proceeding with call anyway" )
11751172 }
1176-
1173+
11771174 // Proceed with call even when notification permission is dismissed
11781175 if (! isConnectionEstablished) {
11791176 Log .d(TAG , " Proceeding with prepareCall() after dismissing notification permission" )
@@ -1452,7 +1449,7 @@ class CallActivity : CallBaseActivity() {
14521449 Log .d(TAG , " onDestroy called" )
14531450 Log .d(TAG , " onDestroy: isIntentionallyLeavingCall=$isIntentionallyLeavingCall " )
14541451 Log .d(TAG , " onDestroy: currentCallStatus=$currentCallStatus " )
1455-
1452+
14561453 if (signalingMessageReceiver != null ) {
14571454 signalingMessageReceiver!! .removeListener(localParticipantMessageListener)
14581455 signalingMessageReceiver!! .removeListener(offerMessageListener)
@@ -1474,20 +1471,20 @@ class CallActivity : CallBaseActivity() {
14741471 if (isIntentionallyLeavingCall || currentCallStatus == = CallStatus .LEAVING ) {
14751472 CallForegroundService .stop(applicationContext)
14761473 }
1477-
1474+
14781475 Log .d(TAG , " onDestroy: Releasing proximity sensor - updating to IDLE state" )
14791476 powerManagerUtils!! .updatePhoneState(PowerManagerUtils .PhoneState .IDLE )
14801477 Log .d(TAG , " onDestroy: Proximity sensor released" )
1481-
1478+
14821479 // Unregister receiver
14831480 try {
14841481 Log .d(TAG , " Unregistering endCallFromNotificationReceiver..." )
14851482 unregisterReceiver(endCallFromNotificationReceiver)
14861483 Log .d(TAG , " endCallFromNotificationReceiver unregistered successfully" )
1487- } catch (e: Exception ) {
1484+ } catch (e: IllegalArgumentException ) {
14881485 Log .w(TAG , " Failed to unregister endCallFromNotificationReceiver" , e)
14891486 }
1490-
1487+
14911488 super .onDestroy()
14921489 }
14931490
@@ -2064,7 +2061,7 @@ class CallActivity : CallBaseActivity() {
20642061 Log .d(TAG , " hangup! shutDownView=$shutDownView , endCallForAll=$endCallForAll " )
20652062 Log .d(TAG , " hangup! isIntentionallyLeavingCall=$isIntentionallyLeavingCall " )
20662063 Log .d(TAG , " hangup! powerManagerUtils state before cleanup: ${powerManagerUtils != null } " )
2067-
2064+
20682065 if (shutDownView) {
20692066 setCallState(CallStatus .LEAVING )
20702067 }
@@ -3228,6 +3225,7 @@ class CallActivity : CallBaseActivity() {
32283225
32293226 private const val CALLING_TIMEOUT : Long = 45000
32303227 private const val PULSE_ANIMATION_DURATION : Int = 310
3228+ private const val SEC_10 = 10000
32313229
32323230 private const val DELAY_ON_ERROR_STOP_THRESHOLD : Int = 16
32333231
0 commit comments