add an extra check to avoid showing both incoming screen and notification

This commit is contained in:
tibbi 2022-08-08 19:15:12 +02:00
parent 7be52f9af8
commit d4f9fc28b7
2 changed files with 3 additions and 3 deletions

View File

@ -27,11 +27,11 @@ class CallNotificationManager(private val context: Context) {
private val callContactAvatarHelper = CallContactAvatarHelper(context)
@SuppressLint("NewApi")
fun setupNotification() {
fun setupNotification(forceLowPriority: Boolean = false) {
getCallContact(context.applicationContext, CallManager.getPrimaryCall()) { callContact ->
val callContactAvatar = callContactAvatarHelper.getCallContactAvatar(callContact)
val callState = CallManager.getState()
val isHighPriority = context.powerManager.isInteractive && callState == Call.STATE_RINGING
val isHighPriority = context.powerManager.isInteractive && callState == Call.STATE_RINGING && !forceLowPriority
val channelId = if (isHighPriority) "simple_dialer_call_high_priority" else "simple_dialer_call"
if (isOreoPlus()) {
val importance = if (isHighPriority) NotificationManager.IMPORTANCE_HIGH else NotificationManager.IMPORTANCE_DEFAULT

View File

@ -33,7 +33,7 @@ class CallService : InCallService() {
val isScreenLocked = (getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager).isDeviceLocked
if (!powerManager.isInteractive || call.isOutgoing() || isScreenLocked) {
try {
callNotificationManager.setupNotification()
callNotificationManager.setupNotification(true)
startActivity(CallActivity.getStartIntent(this))
} catch (e: ActivityNotFoundException) {
// seems like startActivity can thrown AndroidRuntimeException and ActivityNotFoundException, not yet sure when and why, lets show a notification