Handle also DIAL action

This commit is contained in:
Juha Heinanen
2023-05-02 14:35:16 +03:00
parent 5c5ada4d5c
commit 18f24380f4
2 changed files with 16 additions and 11 deletions
+1 -1
View File
@@ -61,9 +61,9 @@
<action android:name="android.intent.action.CALL" /> <action android:name="android.intent.action.CALL" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tel" />
<data android:scheme="sip" /> <data android:scheme="sip" />
<data android:scheme="sips" /> <data android:scheme="sips" />
<data android:scheme="tel" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
@@ -8,6 +8,7 @@ import android.app.KeyguardManager
import android.app.NotificationManager import android.app.NotificationManager
import android.content.* import android.content.*
import android.content.Intent.ACTION_CALL import android.content.Intent.ACTION_CALL
import android.content.Intent.ACTION_DIAL
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.content.res.Configuration.ORIENTATION_PORTRAIT import android.content.res.Configuration.ORIENTATION_PORTRAIT
import android.media.AudioManager import android.media.AudioManager
@@ -652,7 +653,7 @@ class MainActivity : AppCompatActivity() {
atStartup = intent.hasExtra("onStartup") atStartup = intent.hasExtra("onStartup")
if (intent?.action == ACTION_CALL) { if (intent?.action == ACTION_CALL || intent?.action == ACTION_DIAL) {
if (BaresipService.isServiceRunning) if (BaresipService.isServiceRunning)
callAction(intent) callAction(intent)
else else
@@ -823,15 +824,18 @@ class MainActivity : AppCompatActivity() {
resumeAction = "" resumeAction = ""
resumeUri = "" resumeUri = ""
if (intent.action == ACTION_CALL) { Log.d(TAG, "onNewIntent with intent.action '${intent.action}'")
Log.d(TAG, "onNewIntent $ACTION_CALL ${intent.data}")
callAction(intent) when (intent.action) {
} else { ACTION_DIAL, ACTION_CALL -> {
val action = intent.getStringExtra("action") callAction(intent)
Log.d(TAG, "onNewIntent action `$action'") }
if (action != null) { else -> {
intent.removeExtra("action") val action = intent.getStringExtra("action")
handleIntent(intent, action) if (action != null) {
intent.removeExtra("action")
handleIntent(intent, action)
}
} }
} }
} }
@@ -840,6 +844,7 @@ class MainActivity : AppCompatActivity() {
if (Call.inCall() || BaresipService.uas.size == 0) if (Call.inCall() || BaresipService.uas.size == 0)
return return
val uri: Uri? = intent.data val uri: Uri? = intent.data
Log.d(TAG, "callAction to $uri")
if (uri != null) { if (uri != null) {
when (uri.scheme) { when (uri.scheme) {
"sip" -> { "sip" -> {