mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
Cancel the call notification as soon as possible
https://github.com/SimpleMobileTools/Simple-Dialer/issues/326
This commit is contained in:
@@ -20,7 +20,7 @@ import com.simplemobiletools.dialer.extensions.powerManager
|
|||||||
import com.simplemobiletools.dialer.receivers.CallActionReceiver
|
import com.simplemobiletools.dialer.receivers.CallActionReceiver
|
||||||
|
|
||||||
class CallNotificationManager(private val context: Context) {
|
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 ACCEPT_CALL_CODE = 0
|
||||||
private val DECLINE_CALL_CODE = 1
|
private val DECLINE_CALL_CODE = 1
|
||||||
private val notificationManager = context.notificationManager
|
private val notificationManager = context.notificationManager
|
||||||
@@ -99,7 +99,10 @@ class CallNotificationManager(private val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val notification = builder.build()
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,7 +18,9 @@ class CallService : InCallService() {
|
|||||||
private val callListener = object : Call.Callback() {
|
private val callListener = object : Call.Callback() {
|
||||||
override fun onStateChanged(call: Call, state: Int) {
|
override fun onStateChanged(call: Call, state: Int) {
|
||||||
super.onStateChanged(call, state)
|
super.onStateChanged(call, state)
|
||||||
if (state != Call.STATE_DISCONNECTED) {
|
if (state == Call.STATE_DISCONNECTED || state == Call.STATE_DISCONNECTING) {
|
||||||
|
callNotificationManager.cancelNotification()
|
||||||
|
} else {
|
||||||
callNotificationManager.setupNotification()
|
callNotificationManager.setupNotification()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user