- 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()
|
||||
if (!aor.startsWith("sip:")) aor = "sip:$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",
|
||||
"Invalid SIP Address of Record: $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 {
|
||||
val ua = UserAgent.uaAlloc("<$aor>;stunserver=\"stun:stun.l.google.com:19302\";regq=0.5;pubint=0;regint=0")
|
||||
if (ua == null) {
|
||||
|
||||
@ -180,7 +180,7 @@ class BaresipService: Service() {
|
||||
} else {
|
||||
val peerUri = call.peerURI
|
||||
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")
|
||||
CallHistory.add(CallHistory(aor, peerUri, "in", false))
|
||||
CallHistory.save(filesPath)
|
||||
@ -280,11 +280,13 @@ class BaresipService: Service() {
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
Log.d(LOG_TAG, "In onDestroy restart baresip killed by Android")
|
||||
Log.d(LOG_TAG, "At Baresip Service onDestroy")
|
||||
super.onDestroy()
|
||||
cleanService()
|
||||
val broadcastIntent = Intent("com.tutpro.baresip.Restart")
|
||||
sendBroadcast(broadcastIntent)
|
||||
if (isServiceRunning) {
|
||||
val broadcastIntent = Intent("com.tutpro.baresip.Restart")
|
||||
sendBroadcast(broadcastIntent)
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
@ -346,7 +348,7 @@ class BaresipService: Service() {
|
||||
"call incoming" -> {
|
||||
val peerUri = Api.call_peeruri(callp)
|
||||
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")
|
||||
CallHistory.add(CallHistory(aor, peerUri, "in", false))
|
||||
CallHistory.save(filesPath)
|
||||
@ -401,7 +403,7 @@ class BaresipService: Service() {
|
||||
nm.cancel(CALL_NOTIFICATION_ID)
|
||||
val call = Call.find(callp)
|
||||
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
|
||||
}
|
||||
Log.d(LOG_TAG, "AoR $aor call $callp established")
|
||||
@ -420,7 +422,7 @@ class BaresipService: Service() {
|
||||
"call verified", "call secure" -> {
|
||||
val call = Call.find(callp)
|
||||
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
|
||||
}
|
||||
if (ev[0] == "call secure") {
|
||||
@ -525,7 +527,7 @@ class BaresipService: Service() {
|
||||
try {
|
||||
text = String(msg, StandardCharsets.UTF_8)
|
||||
} 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")
|
||||
val ua = UserAgent.find(uap)
|
||||
|
||||
@ -58,7 +58,7 @@ class CallHistory(val aor: String, val peerURI: String, val direction: String,
|
||||
oos.close()
|
||||
fos.close()
|
||||
} catch (e: IOException) {
|
||||
Log.w("Baresip", "OutputStream exception: " + e.toString())
|
||||
Log.e("Baresip", "OutputStream exception: " + e.toString())
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
@ -73,7 +73,7 @@ class CallHistory(val aor: String, val peerURI: String, val direction: String,
|
||||
ois.close()
|
||||
fis.close()
|
||||
} 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)
|
||||
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()
|
||||
setResult(Activity.RESULT_CANCELED, i)
|
||||
finish()
|
||||
|
||||
@ -244,7 +244,7 @@ class ChatsActivity: AppCompatActivity() {
|
||||
oos.close()
|
||||
fos.close()
|
||||
} catch (e: IOException) {
|
||||
Log.w("Baresip", "OutputStream exception: " + e.toString())
|
||||
Log.e("Baresip", "OutputStream exception: " + e.toString())
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
@ -259,7 +259,7 @@ class ChatsActivity: AppCompatActivity() {
|
||||
ois.close()
|
||||
fis.close()
|
||||
} 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")
|
||||
val ua = Account.findUa(aor)
|
||||
if (ua == null) {
|
||||
Log.e("Baresip", "onClickListener did not find AoR $aor")
|
||||
Log.w("Baresip", "onClickListener did not find AoR $aor")
|
||||
} else {
|
||||
i.putExtra("uap", ua.uap)
|
||||
i.putExtra("peer", Contact.contacts()[pos].uri)
|
||||
|
||||
@ -216,7 +216,7 @@ class MainActivity : AppCompatActivity() {
|
||||
"")
|
||||
if (calls.size > 0) {
|
||||
if (Api.cmd_exec("zrtp_unverify " + calls[0].zid) != 0) {
|
||||
Log.w("Baresip",
|
||||
Log.e("Baresip",
|
||||
"Command 'zrtp_unverify ${calls[0].zid}' failed")
|
||||
} else {
|
||||
securityButton.setImageResource(R.drawable.box_yellow)
|
||||
@ -446,7 +446,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val uap = intent.getStringExtra("uap")
|
||||
val ua = UserAgent.find(uap)
|
||||
if (ua == null) {
|
||||
Log.e("Baresip", "handleIntent 'call' did not find ua $uap")
|
||||
Log.w("Baresip", "handleIntent 'call' did not find ua $uap")
|
||||
return
|
||||
}
|
||||
if (ua != UserAgent.uas()[aorSpinner.selectedItemPosition])
|
||||
@ -458,7 +458,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val callp = intent.getStringExtra("callp")
|
||||
val call = Call.find(callp)
|
||||
if (call == null) {
|
||||
Log.e("Baresip", "handleIntent '$action' did not find call $callp")
|
||||
Log.w("Baresip", "handleIntent '$action' did not find call $callp")
|
||||
return
|
||||
}
|
||||
val ua = call.ua
|
||||
@ -471,7 +471,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val callp = intent.getStringExtra("callp")
|
||||
val call = Call.find(callp)
|
||||
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)
|
||||
return
|
||||
}
|
||||
@ -483,7 +483,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val uap = intent.getStringExtra("uap")
|
||||
val ua = UserAgent.find(uap)
|
||||
if (ua == null) {
|
||||
Log.e("Baresip", "onNewIntent did not find ua $uap")
|
||||
Log.w("Baresip", "onNewIntent did not find ua $uap")
|
||||
return
|
||||
}
|
||||
if (ua != UserAgent.uas()[aorSpinner.selectedItemPosition])
|
||||
@ -516,8 +516,9 @@ class MainActivity : AppCompatActivity() {
|
||||
"message show", "message reply" ->
|
||||
handleServiceEvent(resumeAction, arrayListOf(resumeUap, resumeTime))
|
||||
else -> {
|
||||
uaAdapter.notifyDataSetChanged()
|
||||
if (aorSpinner.selectedItemPosition != -1)
|
||||
if ((aorSpinner.selectedItemPosition == -1) && (UserAgent.uas().size > 0))
|
||||
aorSpinner.setSelection(0)
|
||||
if (aorSpinner.selectedItemPosition >= 0)
|
||||
showCall(UserAgent.uas()[aorSpinner.selectedItemPosition])
|
||||
}
|
||||
}
|
||||
@ -589,7 +590,7 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
val call = Call.find(callp)
|
||||
if (call == null) {
|
||||
Log.e("Baresip", "Incoming call $callp not found")
|
||||
Log.w("Baresip", "Incoming call $callp not found")
|
||||
return
|
||||
}
|
||||
setVolumeControlStream(AudioManager.STREAM_RING)
|
||||
@ -622,7 +623,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val callp = params[1]
|
||||
val call = Call.find(callp)
|
||||
if (call == null) {
|
||||
Log.e("Baresip", "Established call $callp not found")
|
||||
Log.w("Baresip", "Established call $callp not found")
|
||||
return
|
||||
}
|
||||
setVolumeControlStream(AudioManager.STREAM_VOICE_CALL)
|
||||
@ -658,7 +659,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val callp = params[1]
|
||||
val call = Call.find(callp)
|
||||
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
|
||||
}
|
||||
val verifyDialog = AlertDialog.Builder(this@MainActivity)
|
||||
@ -667,7 +668,7 @@ class MainActivity : AppCompatActivity() {
|
||||
verifyDialog.setPositiveButton("Yes") { dialog, _ ->
|
||||
val security: Int
|
||||
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
|
||||
} else {
|
||||
security = R.drawable.box_green
|
||||
@ -697,7 +698,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val callp = params[1]
|
||||
val call = Call.find(callp)
|
||||
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
|
||||
}
|
||||
val tag: String
|
||||
@ -714,7 +715,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val callp = params[1]
|
||||
val call = Call.find(callp)
|
||||
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
|
||||
}
|
||||
val transferDialog = AlertDialog.Builder(this)
|
||||
@ -739,7 +740,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val callp = params[1]
|
||||
val call = Call.find(callp)
|
||||
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
|
||||
}
|
||||
if (call in Call.calls())
|
||||
@ -773,7 +774,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val timeStamp = params[1].toLong()
|
||||
val msg = ChatsActivity.findUaMessage(ua.account.aor, timeStamp)
|
||||
if (msg == null) {
|
||||
Log.e("Baresip", "Message $aor/$timeStamp is not found")
|
||||
Log.w("Baresip", "Message ${ua.uap}/$timeStamp is not found")
|
||||
return
|
||||
}
|
||||
Log.d("Baresip", "Message for $aor from ${msg.peerUri}")
|
||||
@ -807,7 +808,7 @@ class MainActivity : AppCompatActivity() {
|
||||
voicemailButton.setImageResource(R.drawable.voicemail)
|
||||
}
|
||||
}
|
||||
else -> Log.w("Baresip", "Unknown event '${ev[0]}'")
|
||||
else -> Log.e("Baresip", "Unknown event '${ev[0]}'")
|
||||
}
|
||||
break
|
||||
}
|
||||
@ -995,7 +996,7 @@ class MainActivity : AppCompatActivity() {
|
||||
infoButton.visibility = View.INVISIBLE
|
||||
|
||||
} else {
|
||||
Log.w("Baresip", "ua_connect ${ua.uap}/$uri failed")
|
||||
Log.e("Baresip", "ua_connect ${ua.uap}/$uri failed")
|
||||
callButton.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
@ -1018,11 +1019,11 @@ class MainActivity : AppCompatActivity() {
|
||||
showCall(ua)
|
||||
} else {
|
||||
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")
|
||||
}
|
||||
} 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")
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class UserAgent (val uap: String) {
|
||||
for (ua in BaresipService.uas) {
|
||||
if (ua.account.regint > 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