- Always send "started" event to main activity after baresip is started

- No need to send "ua added" events to main activity
This commit is contained in:
Juha Heinanen
2021-01-21 17:10:49 +02:00
parent 31fa509d34
commit ad66007d58
2 changed files with 24 additions and 30 deletions

View File

@ -427,11 +427,6 @@ class BaresipService: Service() {
else
status.add(R.drawable.dot_yellow)
}
val intent = Intent("service event")
intent.putExtra("event", "ua added")
intent.putExtra("params", arrayListOf(uap))
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
updateStatusNotification()
}
@Keep
@ -862,13 +857,11 @@ class BaresipService: Service() {
@Keep
fun started() {
Log.d(LOG_TAG, "Received 'started' from baresip")
if (callActionUri != "") {
val intent = Intent("service event")
intent.putExtra("event", "started")
intent.putExtra("params", arrayListOf(callActionUri))
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
callActionUri = ""
}
val intent = Intent("service event")
intent.putExtra("event", "started")
intent.putExtra("params", arrayListOf(callActionUri))
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
callActionUri = ""
}
@Keep

View File

@ -718,18 +718,26 @@ class MainActivity : AppCompatActivity() {
if (event == "started") {
val callActionUri = params[0]
Log.d("Baresip", "Handling service event 'started' with '$callActionUri'")
var ua = UserAgent.ofDomain(Utils.uriHostPart(callActionUri))
if (ua == null)
if (BaresipService.uas.size > 0) {
ua = BaresipService.uas[0]
} else {
Log.w("Baresip", "No UAs to make the call to $callActionUri")
return
uaAdapter.notifyDataSetChanged()
if (callActionUri != "") {
var ua = UserAgent.ofDomain(Utils.uriHostPart(callActionUri))
if (ua == null)
if (BaresipService.uas.size > 0) {
ua = BaresipService.uas[0]
} else {
Log.w("Baresip", "No UAs to make the call to '$callActionUri'")
return
}
spinToAor(ua.account.aor)
ua.account.resumeUri = callActionUri
callUri.setText(callActionUri)
callButton.performClick()
} else {
if (aorSpinner.selectedItemPosition == -1) {
aorSpinner.setSelection(0)
aorSpinner.tag = UserAgent.uas()[0].account.aor
}
spinToAor(ua.account.aor)
ua.account.resumeUri = callActionUri
callUri.setText(callActionUri)
callButton.performClick()
}
return
}
if (event == "stopped") {
@ -769,13 +777,6 @@ class MainActivity : AppCompatActivity() {
for (account_index in UserAgent.uas().indices) {
if (UserAgent.uas()[account_index].account.aor == aor) {
when (ev[0]) {
"ua added" -> {
uaAdapter.notifyDataSetChanged()
if (aorSpinner.selectedItemPosition == -1) {
aorSpinner.setSelection(0)
aorSpinner.tag = UserAgent.uas()[0].account.aor
}
}
"registered", "unregistering" -> {
uaAdapter.notifyDataSetChanged()
}