adding some initial outgoing call related things
This commit is contained in:
parent
758799b87c
commit
8ecfae906e
4 changed files with 33 additions and 2 deletions
|
@ -245,7 +245,7 @@
|
|||
</provider>
|
||||
|
||||
<service
|
||||
android:name=".services.MyCallService"
|
||||
android:name=".services.MyIncomingCallService"
|
||||
android:permission="android.permission.BIND_INCALL_SERVICE">
|
||||
<meta-data
|
||||
android:name="android.telecom.IN_CALL_SERVICE_UI"
|
||||
|
@ -256,6 +256,16 @@
|
|||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".services.MyOutgoingCallService"
|
||||
android:exported="true"
|
||||
android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.telecomm.ConnectionService"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".services.DialerCallService"
|
||||
android:exported="false"/>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.simplemobiletools.contacts.pro.activities
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
@ -13,6 +14,7 @@ import android.os.Bundle
|
|||
import android.os.Handler
|
||||
import android.os.PowerManager
|
||||
import android.telecom.Call
|
||||
import android.telecom.TelecomManager
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.contacts.pro.R
|
||||
|
@ -49,6 +51,7 @@ class DialerActivity : SimpleActivity(), SensorEventListener {
|
|||
callNumber = Uri.decode(intent.dataString).substringAfter("tel:")
|
||||
initViews()
|
||||
tryFillingOtherEndsName()
|
||||
initOutgoingCall()
|
||||
} else if (action == INCOMING_CALL && extras?.containsKey(CALL_NUMBER) == true && extras.containsKey(CALL_STATUS)) {
|
||||
isIncomingCall = true
|
||||
callNumber = intent.getStringExtra(CALL_NUMBER)
|
||||
|
@ -125,6 +128,13 @@ class DialerActivity : SimpleActivity(), SensorEventListener {
|
|||
dialer_label.setText(if (isIncomingCall) R.string.incoming_call else R.string.calling)
|
||||
}
|
||||
|
||||
private fun initOutgoingCall() {
|
||||
val telecomManager = getSystemService(Context.TELECOM_SERVICE) as TelecomManager
|
||||
val uri = Uri.fromParts("tel:", callNumber, null)
|
||||
val extras = Bundle()
|
||||
telecomManager.placeCall(uri, extras)
|
||||
}
|
||||
|
||||
private fun startNotificationService() {
|
||||
Intent(this, DialerCallService::class.java).apply {
|
||||
putExtra(CALL_NUMBER, callNumber)
|
||||
|
@ -222,6 +232,7 @@ class DialerActivity : SimpleActivity(), SensorEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressLint("WakelockTimeout")
|
||||
private fun turnOffScreen() {
|
||||
if (proximityWakeLock?.isHeld == false) {
|
||||
proximityWakeLock!!.acquire()
|
||||
|
|
|
@ -14,7 +14,7 @@ import com.simplemobiletools.contacts.pro.helpers.INCOMING_CALL
|
|||
import com.simplemobiletools.contacts.pro.objects.CallManager
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
class MyCallService : InCallService() {
|
||||
class MyIncomingCallService : InCallService() {
|
||||
|
||||
override fun onCallAdded(call: Call) {
|
||||
super.onCallAdded(call)
|
|
@ -0,0 +1,10 @@
|
|||
package com.simplemobiletools.contacts.pro.services
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.os.Build
|
||||
import android.telecom.ConnectionService
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
class MyOutgoingCallService : ConnectionService() {
|
||||
|
||||
}
|
Loading…
Reference in a new issue