- 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:
@@ -427,11 +427,6 @@ class BaresipService: Service() {
|
|||||||
else
|
else
|
||||||
status.add(R.drawable.dot_yellow)
|
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
|
@Keep
|
||||||
@@ -862,13 +857,11 @@ class BaresipService: Service() {
|
|||||||
@Keep
|
@Keep
|
||||||
fun started() {
|
fun started() {
|
||||||
Log.d(LOG_TAG, "Received 'started' from baresip")
|
Log.d(LOG_TAG, "Received 'started' from baresip")
|
||||||
if (callActionUri != "") {
|
val intent = Intent("service event")
|
||||||
val intent = Intent("service event")
|
intent.putExtra("event", "started")
|
||||||
intent.putExtra("event", "started")
|
intent.putExtra("params", arrayListOf(callActionUri))
|
||||||
intent.putExtra("params", arrayListOf(callActionUri))
|
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
|
||||||
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
|
callActionUri = ""
|
||||||
callActionUri = ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Keep
|
@Keep
|
||||||
|
|||||||
@@ -718,18 +718,26 @@ class MainActivity : AppCompatActivity() {
|
|||||||
if (event == "started") {
|
if (event == "started") {
|
||||||
val callActionUri = params[0]
|
val callActionUri = params[0]
|
||||||
Log.d("Baresip", "Handling service event 'started' with '$callActionUri'")
|
Log.d("Baresip", "Handling service event 'started' with '$callActionUri'")
|
||||||
var ua = UserAgent.ofDomain(Utils.uriHostPart(callActionUri))
|
uaAdapter.notifyDataSetChanged()
|
||||||
if (ua == null)
|
if (callActionUri != "") {
|
||||||
if (BaresipService.uas.size > 0) {
|
var ua = UserAgent.ofDomain(Utils.uriHostPart(callActionUri))
|
||||||
ua = BaresipService.uas[0]
|
if (ua == null)
|
||||||
} else {
|
if (BaresipService.uas.size > 0) {
|
||||||
Log.w("Baresip", "No UAs to make the call to $callActionUri")
|
ua = BaresipService.uas[0]
|
||||||
return
|
} 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
|
return
|
||||||
}
|
}
|
||||||
if (event == "stopped") {
|
if (event == "stopped") {
|
||||||
@@ -769,13 +777,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
for (account_index in UserAgent.uas().indices) {
|
for (account_index in UserAgent.uas().indices) {
|
||||||
if (UserAgent.uas()[account_index].account.aor == aor) {
|
if (UserAgent.uas()[account_index].account.aor == aor) {
|
||||||
when (ev[0]) {
|
when (ev[0]) {
|
||||||
"ua added" -> {
|
|
||||||
uaAdapter.notifyDataSetChanged()
|
|
||||||
if (aorSpinner.selectedItemPosition == -1) {
|
|
||||||
aorSpinner.setSelection(0)
|
|
||||||
aorSpinner.tag = UserAgent.uas()[0].account.aor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"registered", "unregistering" -> {
|
"registered", "unregistering" -> {
|
||||||
uaAdapter.notifyDataSetChanged()
|
uaAdapter.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user