Cancel the call notification as soon as possible

https://github.com/SimpleMobileTools/Simple-Dialer/issues/326
This commit is contained in:
Naveen
2022-10-22 02:26:09 +05:30
parent 764f4a7e66
commit 8699a6d281
2 changed files with 8 additions and 3 deletions

View File

@@ -20,7 +20,7 @@ import com.simplemobiletools.dialer.extensions.powerManager
import com.simplemobiletools.dialer.receivers.CallActionReceiver
class CallNotificationManager(private val context: Context) {
private val CALL_NOTIFICATION_ID = 1
private val CALL_NOTIFICATION_ID = 42
private val ACCEPT_CALL_CODE = 0
private val DECLINE_CALL_CODE = 1
private val notificationManager = context.notificationManager
@@ -99,7 +99,10 @@ class CallNotificationManager(private val context: Context) {
}
val notification = builder.build()
notificationManager.notify(CALL_NOTIFICATION_ID, notification)
// it's rare but possible for the call state to change by now
if (CallManager.getState() == callState) {
notificationManager.notify(CALL_NOTIFICATION_ID, notification)
}
}
}

View File

@@ -18,7 +18,9 @@ class CallService : InCallService() {
private val callListener = object : Call.Callback() {
override fun onStateChanged(call: Call, state: Int) {
super.onStateChanged(call, state)
if (state != Call.STATE_DISCONNECTED) {
if (state == Call.STATE_DISCONNECTED || state == Call.STATE_DISCONNECTING) {
callNotificationManager.cancelNotification()
} else {
callNotificationManager.setupNotification()
}
}