diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 565198d5..ce1530a6 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -18,6 +18,7 @@
+
+
+
+
+
+
@@ -260,9 +273,8 @@
android:name=".services.MyOutgoingCallService"
android:exported="true"
android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE">
-
-
+
diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/MyConnection.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/MyConnection.kt
new file mode 100644
index 00000000..0c584146
--- /dev/null
+++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/MyConnection.kt
@@ -0,0 +1,33 @@
+package com.simplemobiletools.contacts.pro.helpers
+
+import android.annotation.TargetApi
+import android.content.Context
+import android.os.Build
+import android.telecom.Connection
+import android.telecom.DisconnectCause
+
+@TargetApi(Build.VERSION_CODES.M)
+class MyConnection(val context: Context) : Connection() {
+ override fun onAnswer() {
+ super.onAnswer()
+ setActive()
+ }
+
+ override fun onReject() {
+ super.onReject()
+ setDisconnected(DisconnectCause(DisconnectCause.LOCAL))
+ destroy()
+ }
+
+ override fun onAbort() {
+ super.onAbort()
+ setDisconnected(DisconnectCause(DisconnectCause.REMOTE))
+ destroy()
+ }
+
+ override fun onDisconnect() {
+ super.onDisconnect()
+ setDisconnected(DisconnectCause(DisconnectCause.CANCELED))
+ destroy()
+ }
+}
diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/services/DialerCallService.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/services/DialerCallService.kt
index fcd7ef0d..c0324594 100644
--- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/services/DialerCallService.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/services/DialerCallService.kt
@@ -47,7 +47,7 @@ class DialerCallService : Service() {
if (isOreoPlus()) {
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val name = resources.getString(R.string.app_name)
- val importance = NotificationManager.IMPORTANCE_LOW
+ val importance = NotificationManager.IMPORTANCE_HIGH
NotificationChannel(channelId, name, importance).apply {
enableLights(false)
enableVibration(false)
diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/services/MyIncomingCallService.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/services/MyIncomingCallService.kt
index 43fc6a3b..0c6f6bd8 100644
--- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/services/MyIncomingCallService.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/services/MyIncomingCallService.kt
@@ -6,11 +6,10 @@ import android.os.Build
import android.telecom.Call
import android.telecom.InCallService
import androidx.localbroadcastmanager.content.LocalBroadcastManager
-import com.simplemobiletools.contacts.pro.activities.DialerActivity
import com.simplemobiletools.contacts.pro.helpers.CALL_NUMBER
import com.simplemobiletools.contacts.pro.helpers.CALL_STATUS
import com.simplemobiletools.contacts.pro.helpers.DIALER_INTENT_FILTER
-import com.simplemobiletools.contacts.pro.helpers.INCOMING_CALL
+import com.simplemobiletools.contacts.pro.helpers.IS_INCOMING_CALL
import com.simplemobiletools.contacts.pro.objects.CallManager
@TargetApi(Build.VERSION_CODES.M)
@@ -27,12 +26,13 @@ class MyIncomingCallService : InCallService() {
handle
}
- Intent(this, DialerActivity::class.java).apply {
- action = INCOMING_CALL
+ Intent(this, DialerCallService::class.java).apply {
putExtra(CALL_STATUS, call.state)
putExtra(CALL_NUMBER, callerNumber)
- startActivity(this)
+ putExtra(IS_INCOMING_CALL, true)
+ startService(this)
}
+
CallManager.updateCall(call)
}
@@ -46,6 +46,11 @@ class MyIncomingCallService : InCallService() {
override fun onStateChanged(call: Call, state: Int) {
CallManager.updateCall(call)
sendCallToActivity(call)
+ if (state == Call.STATE_DISCONNECTED) {
+ Intent(applicationContext, DialerCallService::class.java).apply {
+ stopService(this)
+ }
+ }
}
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/services/MyOutgoingCallService.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/services/MyOutgoingCallService.kt
index ffa42441..9e8427fa 100644
--- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/services/MyOutgoingCallService.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/services/MyOutgoingCallService.kt
@@ -1,10 +1,18 @@
package com.simplemobiletools.contacts.pro.services
import android.annotation.TargetApi
+import android.net.Uri
import android.os.Build
-import android.telecom.ConnectionService
+import android.telecom.*
+import com.simplemobiletools.contacts.pro.helpers.MyConnection
@TargetApi(Build.VERSION_CODES.M)
class MyOutgoingCallService : ConnectionService() {
-
+ override fun onCreateIncomingConnection(connectionManagerPhoneAccount: PhoneAccountHandle, request: ConnectionRequest): Connection {
+ val connection = MyConnection(applicationContext)
+ val phoneNumber = request.extras.get(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS) as Uri
+ connection.setAddress(phoneNumber, TelecomManager.PRESENTATION_ALLOWED)
+ connection.setRinging()
+ return connection
+ }
}