mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-02-15 19:10:44 +01:00
add an extra check to avoid showing both incoming screen and notification
This commit is contained in:
parent
7be52f9af8
commit
d4f9fc28b7
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user