refresh the incoming call notification every few secs to keep it visible
This commit is contained in:
parent
772a28eb9e
commit
7cdefe43d5
|
@ -8,6 +8,7 @@ import android.app.Service
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.os.Handler
|
||||||
import android.telecom.Call
|
import android.telecom.Call
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import com.simplemobiletools.commons.helpers.isOreoPlus
|
import com.simplemobiletools.commons.helpers.isOreoPlus
|
||||||
|
@ -17,6 +18,7 @@ import com.simplemobiletools.contacts.pro.helpers.*
|
||||||
import com.simplemobiletools.contacts.pro.objects.CallManager
|
import com.simplemobiletools.contacts.pro.objects.CallManager
|
||||||
|
|
||||||
class DialerCallService : Service() {
|
class DialerCallService : Service() {
|
||||||
|
private val REFRESH_REMINDER_PERIOD = 3000L
|
||||||
private val CALL_NOTIFICATION_ID = 1
|
private val CALL_NOTIFICATION_ID = 1
|
||||||
private val LAUNCH_DIALER_INTENT_ID = 1
|
private val LAUNCH_DIALER_INTENT_ID = 1
|
||||||
private val DISMISS_CALL_INTENT_ID = 2
|
private val DISMISS_CALL_INTENT_ID = 2
|
||||||
|
@ -25,6 +27,7 @@ class DialerCallService : Service() {
|
||||||
private var callNumber = ""
|
private var callNumber = ""
|
||||||
private var callStatus = Call.STATE_NEW
|
private var callStatus = Call.STATE_NEW
|
||||||
private var isIncomingCall = false
|
private var isIncomingCall = false
|
||||||
|
private var reminderRefreshHandler = Handler()
|
||||||
|
|
||||||
override fun onBind(intent: Intent?) = null
|
override fun onBind(intent: Intent?) = null
|
||||||
|
|
||||||
|
@ -46,6 +49,7 @@ class DialerCallService : Service() {
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
stopForeground(true)
|
stopForeground(true)
|
||||||
|
reminderRefreshHandler.removeCallbacksAndMessages(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.O)
|
@TargetApi(Build.VERSION_CODES.O)
|
||||||
|
@ -78,6 +82,12 @@ class DialerCallService : Service() {
|
||||||
.addAction(0, getString(R.string.answer_call), getAnswerCallIntent())
|
.addAction(0, getString(R.string.answer_call), getAnswerCallIntent())
|
||||||
|
|
||||||
startForeground(CALL_NOTIFICATION_ID, notification.build())
|
startForeground(CALL_NOTIFICATION_ID, notification.build())
|
||||||
|
|
||||||
|
reminderRefreshHandler.postDelayed({
|
||||||
|
if (callStatus == Call.STATE_RINGING) {
|
||||||
|
setupNotification()
|
||||||
|
}
|
||||||
|
}, REFRESH_REMINDER_PERIOD)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getLaunchDialerIntent(): PendingIntent {
|
private fun getLaunchDialerIntent(): PendingIntent {
|
||||||
|
|
Loading…
Reference in New Issue