- Fixed possible crash when destroyed baresip app is started again
- Show notice when account to be created already exists - Made level of log messages more consistent
This commit is contained in:
@@ -34,11 +34,13 @@ class AccountsActivity : AppCompatActivity() {
|
|||||||
var aor = newAorView.text.toString().trim()
|
var aor = newAorView.text.toString().trim()
|
||||||
if (!aor.startsWith("sip:")) aor = "sip:$aor"
|
if (!aor.startsWith("sip:")) aor = "sip:$aor"
|
||||||
if (!Utils.checkAorUri(aor)) {
|
if (!Utils.checkAorUri(aor)) {
|
||||||
Log.e("Baresip", "Invalid SIP Address of Record $aor")
|
Log.d("Baresip", "Invalid SIP Address of Record $aor")
|
||||||
Utils.alertView(this, "Notice",
|
Utils.alertView(this, "Notice",
|
||||||
"Invalid SIP Address of Record: $aor")
|
"Invalid SIP Address of Record: $aor")
|
||||||
} else if (Account.exists(aor)) {
|
} else if (Account.exists(aor)) {
|
||||||
Log.e("Baresip", "Account $aor already exists")
|
Log.d("Baresip", "Account $aor already exists")
|
||||||
|
Utils.alertView(this, "Notice",
|
||||||
|
"Account $aor already exists")
|
||||||
} else {
|
} else {
|
||||||
val ua = UserAgent.uaAlloc("<$aor>;stunserver=\"stun:stun.l.google.com:19302\";regq=0.5;pubint=0;regint=0")
|
val ua = UserAgent.uaAlloc("<$aor>;stunserver=\"stun:stun.l.google.com:19302\";regq=0.5;pubint=0;regint=0")
|
||||||
if (ua == null) {
|
if (ua == null) {
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ class BaresipService: Service() {
|
|||||||
} else {
|
} else {
|
||||||
val peerUri = call.peerURI
|
val peerUri = call.peerURI
|
||||||
val aor = call.ua.account.aor
|
val aor = call.ua.account.aor
|
||||||
Log.i(LOG_TAG, "Aor $aor rejected incoming call $callp from $peerUri")
|
Log.d(LOG_TAG, "Aor $aor rejected incoming call $callp from $peerUri")
|
||||||
Api.ua_hangup(call.ua.uap, callp, 486, "Rejected")
|
Api.ua_hangup(call.ua.uap, callp, 486, "Rejected")
|
||||||
CallHistory.add(CallHistory(aor, peerUri, "in", false))
|
CallHistory.add(CallHistory(aor, peerUri, "in", false))
|
||||||
CallHistory.save(filesPath)
|
CallHistory.save(filesPath)
|
||||||
@@ -280,12 +280,14 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
Log.d(LOG_TAG, "In onDestroy restart baresip killed by Android")
|
Log.d(LOG_TAG, "At Baresip Service onDestroy")
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
cleanService()
|
cleanService()
|
||||||
|
if (isServiceRunning) {
|
||||||
val broadcastIntent = Intent("com.tutpro.baresip.Restart")
|
val broadcastIntent = Intent("com.tutpro.baresip.Restart")
|
||||||
sendBroadcast(broadcastIntent)
|
sendBroadcast(broadcastIntent)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Keep
|
@Keep
|
||||||
fun uaAdd(uap: String) {
|
fun uaAdd(uap: String) {
|
||||||
@@ -346,7 +348,7 @@ class BaresipService: Service() {
|
|||||||
"call incoming" -> {
|
"call incoming" -> {
|
||||||
val peerUri = Api.call_peeruri(callp)
|
val peerUri = Api.call_peeruri(callp)
|
||||||
if (Call.calls().size > 0) {
|
if (Call.calls().size > 0) {
|
||||||
Log.i(LOG_TAG, "Auto-rejecting incoming call $uap/$callp/$peerUri")
|
Log.d(LOG_TAG, "Auto-rejecting incoming call $uap/$callp/$peerUri")
|
||||||
Api.ua_hangup(uap, callp, 486, "Busy Here")
|
Api.ua_hangup(uap, callp, 486, "Busy Here")
|
||||||
CallHistory.add(CallHistory(aor, peerUri, "in", false))
|
CallHistory.add(CallHistory(aor, peerUri, "in", false))
|
||||||
CallHistory.save(filesPath)
|
CallHistory.save(filesPath)
|
||||||
@@ -401,7 +403,7 @@ class BaresipService: Service() {
|
|||||||
nm.cancel(CALL_NOTIFICATION_ID)
|
nm.cancel(CALL_NOTIFICATION_ID)
|
||||||
val call = Call.find(callp)
|
val call = Call.find(callp)
|
||||||
if (call == null) {
|
if (call == null) {
|
||||||
Log.w(LOG_TAG, "Established AoR $aor call $callp is not found")
|
Log.w(LOG_TAG, "Call $callp that is established is not found")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Log.d(LOG_TAG, "AoR $aor call $callp established")
|
Log.d(LOG_TAG, "AoR $aor call $callp established")
|
||||||
@@ -420,7 +422,7 @@ class BaresipService: Service() {
|
|||||||
"call verified", "call secure" -> {
|
"call verified", "call secure" -> {
|
||||||
val call = Call.find(callp)
|
val call = Call.find(callp)
|
||||||
if (call == null) {
|
if (call == null) {
|
||||||
Log.e("Baresip", "Call $callp that is verified is not found")
|
Log.w("Baresip", "Call $callp that is verified is not found")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (ev[0] == "call secure") {
|
if (ev[0] == "call secure") {
|
||||||
@@ -525,7 +527,7 @@ class BaresipService: Service() {
|
|||||||
try {
|
try {
|
||||||
text = String(msg, StandardCharsets.UTF_8)
|
text = String(msg, StandardCharsets.UTF_8)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(LOG_TAG, "UTF-8 decode failed")
|
Log.w(LOG_TAG, "UTF-8 decode failed")
|
||||||
}
|
}
|
||||||
Log.d(LOG_TAG, "Message event for $uap from $peer")
|
Log.d(LOG_TAG, "Message event for $uap from $peer")
|
||||||
val ua = UserAgent.find(uap)
|
val ua = UserAgent.find(uap)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class CallHistory(val aor: String, val peerURI: String, val direction: String,
|
|||||||
oos.close()
|
oos.close()
|
||||||
fos.close()
|
fos.close()
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Log.w("Baresip", "OutputStream exception: " + e.toString())
|
Log.e("Baresip", "OutputStream exception: " + e.toString())
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ class CallHistory(val aor: String, val peerURI: String, val direction: String,
|
|||||||
ois.close()
|
ois.close()
|
||||||
fis.close()
|
fis.close()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.w("Baresip", "InputStream exception: - " + e.toString())
|
Log.e("Baresip", "InputStream exception: - " + e.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class ChatActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
val userAgent = Account.findUa(aor)
|
val userAgent = Account.findUa(aor)
|
||||||
if (userAgent == null) {
|
if (userAgent == null) {
|
||||||
Log.e("Baresip", "MessageActivity did not find ua of $aor")
|
Log.w("Baresip", "MessageActivity did not find ua of $aor")
|
||||||
val i = Intent()
|
val i = Intent()
|
||||||
setResult(Activity.RESULT_CANCELED, i)
|
setResult(Activity.RESULT_CANCELED, i)
|
||||||
finish()
|
finish()
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ class ChatsActivity: AppCompatActivity() {
|
|||||||
oos.close()
|
oos.close()
|
||||||
fos.close()
|
fos.close()
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Log.w("Baresip", "OutputStream exception: " + e.toString())
|
Log.e("Baresip", "OutputStream exception: " + e.toString())
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,7 +259,7 @@ class ChatsActivity: AppCompatActivity() {
|
|||||||
ois.close()
|
ois.close()
|
||||||
fis.close()
|
fis.close()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.w("Baresip", "InputStream exception: - " + e.toString())
|
Log.e("Baresip", "InputStream exception: - " + e.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class ContactListAdapter(private val cxt: Context, private val rows: ArrayList<C
|
|||||||
i.putExtra("action", "message")
|
i.putExtra("action", "message")
|
||||||
val ua = Account.findUa(aor)
|
val ua = Account.findUa(aor)
|
||||||
if (ua == null) {
|
if (ua == null) {
|
||||||
Log.e("Baresip", "onClickListener did not find AoR $aor")
|
Log.w("Baresip", "onClickListener did not find AoR $aor")
|
||||||
} else {
|
} else {
|
||||||
i.putExtra("uap", ua.uap)
|
i.putExtra("uap", ua.uap)
|
||||||
i.putExtra("peer", Contact.contacts()[pos].uri)
|
i.putExtra("peer", Contact.contacts()[pos].uri)
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
"")
|
"")
|
||||||
if (calls.size > 0) {
|
if (calls.size > 0) {
|
||||||
if (Api.cmd_exec("zrtp_unverify " + calls[0].zid) != 0) {
|
if (Api.cmd_exec("zrtp_unverify " + calls[0].zid) != 0) {
|
||||||
Log.w("Baresip",
|
Log.e("Baresip",
|
||||||
"Command 'zrtp_unverify ${calls[0].zid}' failed")
|
"Command 'zrtp_unverify ${calls[0].zid}' failed")
|
||||||
} else {
|
} else {
|
||||||
securityButton.setImageResource(R.drawable.box_yellow)
|
securityButton.setImageResource(R.drawable.box_yellow)
|
||||||
@@ -446,7 +446,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val uap = intent.getStringExtra("uap")
|
val uap = intent.getStringExtra("uap")
|
||||||
val ua = UserAgent.find(uap)
|
val ua = UserAgent.find(uap)
|
||||||
if (ua == null) {
|
if (ua == null) {
|
||||||
Log.e("Baresip", "handleIntent 'call' did not find ua $uap")
|
Log.w("Baresip", "handleIntent 'call' did not find ua $uap")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (ua != UserAgent.uas()[aorSpinner.selectedItemPosition])
|
if (ua != UserAgent.uas()[aorSpinner.selectedItemPosition])
|
||||||
@@ -458,7 +458,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val callp = intent.getStringExtra("callp")
|
val callp = intent.getStringExtra("callp")
|
||||||
val call = Call.find(callp)
|
val call = Call.find(callp)
|
||||||
if (call == null) {
|
if (call == null) {
|
||||||
Log.e("Baresip", "handleIntent '$action' did not find call $callp")
|
Log.w("Baresip", "handleIntent '$action' did not find call $callp")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val ua = call.ua
|
val ua = call.ua
|
||||||
@@ -471,7 +471,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val callp = intent.getStringExtra("callp")
|
val callp = intent.getStringExtra("callp")
|
||||||
val call = Call.find(callp)
|
val call = Call.find(callp)
|
||||||
if (call == null) {
|
if (call == null) {
|
||||||
Log.e("Baresip", "handleIntent '$action' did not find call $callp")
|
Log.w("Baresip", "handleIntent '$action' did not find call $callp")
|
||||||
moveTaskToBack(true)
|
moveTaskToBack(true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -483,7 +483,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val uap = intent.getStringExtra("uap")
|
val uap = intent.getStringExtra("uap")
|
||||||
val ua = UserAgent.find(uap)
|
val ua = UserAgent.find(uap)
|
||||||
if (ua == null) {
|
if (ua == null) {
|
||||||
Log.e("Baresip", "onNewIntent did not find ua $uap")
|
Log.w("Baresip", "onNewIntent did not find ua $uap")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (ua != UserAgent.uas()[aorSpinner.selectedItemPosition])
|
if (ua != UserAgent.uas()[aorSpinner.selectedItemPosition])
|
||||||
@@ -516,8 +516,9 @@ class MainActivity : AppCompatActivity() {
|
|||||||
"message show", "message reply" ->
|
"message show", "message reply" ->
|
||||||
handleServiceEvent(resumeAction, arrayListOf(resumeUap, resumeTime))
|
handleServiceEvent(resumeAction, arrayListOf(resumeUap, resumeTime))
|
||||||
else -> {
|
else -> {
|
||||||
uaAdapter.notifyDataSetChanged()
|
if ((aorSpinner.selectedItemPosition == -1) && (UserAgent.uas().size > 0))
|
||||||
if (aorSpinner.selectedItemPosition != -1)
|
aorSpinner.setSelection(0)
|
||||||
|
if (aorSpinner.selectedItemPosition >= 0)
|
||||||
showCall(UserAgent.uas()[aorSpinner.selectedItemPosition])
|
showCall(UserAgent.uas()[aorSpinner.selectedItemPosition])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -589,7 +590,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
val call = Call.find(callp)
|
val call = Call.find(callp)
|
||||||
if (call == null) {
|
if (call == null) {
|
||||||
Log.e("Baresip", "Incoming call $callp not found")
|
Log.w("Baresip", "Incoming call $callp not found")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setVolumeControlStream(AudioManager.STREAM_RING)
|
setVolumeControlStream(AudioManager.STREAM_RING)
|
||||||
@@ -622,7 +623,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val callp = params[1]
|
val callp = params[1]
|
||||||
val call = Call.find(callp)
|
val call = Call.find(callp)
|
||||||
if (call == null) {
|
if (call == null) {
|
||||||
Log.e("Baresip", "Established call $callp not found")
|
Log.w("Baresip", "Established call $callp not found")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setVolumeControlStream(AudioManager.STREAM_VOICE_CALL)
|
setVolumeControlStream(AudioManager.STREAM_VOICE_CALL)
|
||||||
@@ -658,7 +659,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val callp = params[1]
|
val callp = params[1]
|
||||||
val call = Call.find(callp)
|
val call = Call.find(callp)
|
||||||
if (call == null) {
|
if (call == null) {
|
||||||
Log.e("Baresip", "Call $callp to be verified is not found")
|
Log.w("Baresip", "Call $callp to be verified is not found")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val verifyDialog = AlertDialog.Builder(this@MainActivity)
|
val verifyDialog = AlertDialog.Builder(this@MainActivity)
|
||||||
@@ -667,7 +668,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
verifyDialog.setPositiveButton("Yes") { dialog, _ ->
|
verifyDialog.setPositiveButton("Yes") { dialog, _ ->
|
||||||
val security: Int
|
val security: Int
|
||||||
if (Api.cmd_exec("zrtp_verify ${ev[3]}") != 0) {
|
if (Api.cmd_exec("zrtp_verify ${ev[3]}") != 0) {
|
||||||
Log.w("Baresip", "Command 'zrtp_verify ${ev[3]}' failed")
|
Log.e("Baresip", "Command 'zrtp_verify ${ev[3]}' failed")
|
||||||
security = R.drawable.box_yellow
|
security = R.drawable.box_yellow
|
||||||
} else {
|
} else {
|
||||||
security = R.drawable.box_green
|
security = R.drawable.box_green
|
||||||
@@ -697,7 +698,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val callp = params[1]
|
val callp = params[1]
|
||||||
val call = Call.find(callp)
|
val call = Call.find(callp)
|
||||||
if (call == null) {
|
if (call == null) {
|
||||||
Log.e("Baresip", "Call $callp that is verified is not found")
|
Log.w("Baresip", "Call $callp that is verified is not found")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val tag: String
|
val tag: String
|
||||||
@@ -714,7 +715,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val callp = params[1]
|
val callp = params[1]
|
||||||
val call = Call.find(callp)
|
val call = Call.find(callp)
|
||||||
if (call == null) {
|
if (call == null) {
|
||||||
Log.e("Baresip", "Call $callp to be transferred is not found")
|
Log.w("Baresip", "Call $callp to be transferred is not found")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val transferDialog = AlertDialog.Builder(this)
|
val transferDialog = AlertDialog.Builder(this)
|
||||||
@@ -739,7 +740,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val callp = params[1]
|
val callp = params[1]
|
||||||
val call = Call.find(callp)
|
val call = Call.find(callp)
|
||||||
if (call == null) {
|
if (call == null) {
|
||||||
Log.e("Baresip", "Call $callp to be transferred is not found")
|
Log.w("Baresip", "Call $callp to be transferred is not found")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (call in Call.calls())
|
if (call in Call.calls())
|
||||||
@@ -773,7 +774,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val timeStamp = params[1].toLong()
|
val timeStamp = params[1].toLong()
|
||||||
val msg = ChatsActivity.findUaMessage(ua.account.aor, timeStamp)
|
val msg = ChatsActivity.findUaMessage(ua.account.aor, timeStamp)
|
||||||
if (msg == null) {
|
if (msg == null) {
|
||||||
Log.e("Baresip", "Message $aor/$timeStamp is not found")
|
Log.w("Baresip", "Message ${ua.uap}/$timeStamp is not found")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Log.d("Baresip", "Message for $aor from ${msg.peerUri}")
|
Log.d("Baresip", "Message for $aor from ${msg.peerUri}")
|
||||||
@@ -807,7 +808,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
voicemailButton.setImageResource(R.drawable.voicemail)
|
voicemailButton.setImageResource(R.drawable.voicemail)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> Log.w("Baresip", "Unknown event '${ev[0]}'")
|
else -> Log.e("Baresip", "Unknown event '${ev[0]}'")
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -995,7 +996,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
infoButton.visibility = View.INVISIBLE
|
infoButton.visibility = View.INVISIBLE
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log.w("Baresip", "ua_connect ${ua.uap}/$uri failed")
|
Log.e("Baresip", "ua_connect ${ua.uap}/$uri failed")
|
||||||
callButton.visibility = View.VISIBLE
|
callButton.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1018,11 +1019,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
showCall(ua)
|
showCall(ua)
|
||||||
} else {
|
} else {
|
||||||
Api.call_start_audio(call.callp)
|
Api.call_start_audio(call.callp)
|
||||||
Log.w("Baresip", "call_connect $newCallp failed with error $err")
|
Log.e("Baresip", "call_connect $newCallp failed with error $err")
|
||||||
Api.call_notify_sipfrag(call.callp, 500, "Call Error")
|
Api.call_notify_sipfrag(call.callp, 500, "Call Error")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.w("Baresip", "ua_call_alloc ${ua.uap}/${call.callp} failed")
|
Log.e("Baresip", "ua_call_alloc ${ua.uap}/${call.callp} failed")
|
||||||
Api.call_notify_sipfrag(call.callp, 500, "Call Error")
|
Api.call_notify_sipfrag(call.callp, 500, "Call Error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class UserAgent (val uap: String) {
|
|||||||
for (ua in BaresipService.uas) {
|
for (ua in BaresipService.uas) {
|
||||||
if (ua.account.regint > 0)
|
if (ua.account.regint > 0)
|
||||||
if (Api.ua_register(ua.uap) != 0)
|
if (Api.ua_register(ua.uap) != 0)
|
||||||
Log.e("Baresip", "Failed to register ${ua.account.aor}")
|
Log.d("Baresip", "Failed to register ${ua.account.aor}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user