Merge pull request #467 from Naveen3Singh/notification_fix
Persistent notification fix
This commit is contained in:
commit
28e2ce0487
|
@ -109,6 +109,9 @@ class CallManager {
|
|||
listener.onStateChanged()
|
||||
}
|
||||
}
|
||||
|
||||
// remove all disconnected calls manually in case they are still here
|
||||
calls.removeAll { it.getStateCompat() == Call.STATE_DISCONNECTED }
|
||||
}
|
||||
|
||||
fun getPrimaryCall(): Call? {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue