diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPService.java b/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPService.java index 31412770e1..3335d77dfb 100755 --- a/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPService.java @@ -4229,7 +4229,14 @@ private void showIncomingNotification(String name, TLObject userOrChat, boolean builder.addAction(R.drawable.ic_call, answerTitle, answerPendingIntent); incomingNotification = builder.getNotification(); } - startForeground(ID_INCOMING_CALL_NOTIFICATION, incomingNotification); + if (Build.VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKE) { + if (PermissionUtils.isAudioPermissionGranted()) { + startForeground(ID_INCOMING_CALL_NOTIFICATION, incomingNotification, + ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE | ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK | ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA); + } + } else { + startForeground(ID_INCOMING_CALL_NOTIFICATION, incomingNotification); + } startRingtoneAndVibration(); } diff --git a/TMessagesProj/src/main/java/top/qwq2333/nullgram/utils/PermissionUtils.kt b/TMessagesProj/src/main/java/top/qwq2333/nullgram/utils/PermissionUtils.kt index bc403bbace..70a5db9359 100644 --- a/TMessagesProj/src/main/java/top/qwq2333/nullgram/utils/PermissionUtils.kt +++ b/TMessagesProj/src/main/java/top/qwq2333/nullgram/utils/PermissionUtils.kt @@ -55,6 +55,7 @@ object PermissionUtils { @JvmStatic fun isAudioPermissionGranted(): Boolean = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { isPermissionGranted(Manifest.permission.READ_MEDIA_AUDIO) && isPermissionGranted(Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED) + && isPermissionGranted(Manifest.permission.FOREGROUND_SERVICE_MICROPHONE) } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { isPermissionGranted(Manifest.permission.READ_MEDIA_AUDIO) } else { @@ -135,6 +136,7 @@ object PermissionUtils { activity, BasePermissionsActivity.REQUEST_CODE_EXTERNAL_STORAGE, Manifest.permission.READ_MEDIA_AUDIO, + Manifest.permission.FOREGROUND_SERVICE_MICROPHONE, Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED ) } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {