Use TAG const in log messages

This commit is contained in:
Juha Heinanen
2021-01-22 09:46:18 +02:00
parent 9b6ca80715
commit 1ff7c7ee0d

View File

@ -82,7 +82,7 @@ class MainActivity : AppCompatActivity() {
val intentAction = intent.getStringExtra("action")
Log.d("Baresip", "MainActivity onCreate ${intent.action}/${intent.data}/$intentAction")
Log.d(TAG, "MainActivity onCreate ${intent.action}/${intent.data}/$intentAction")
if (intent?.action == ACTION_CALL && !BaresipService.isServiceRunning)
BaresipService.callActionUri = URLDecoder.decode(intent.data.toString(), "UTF-8")
@ -131,7 +131,7 @@ class MainActivity : AppCompatActivity() {
stopState = "initial"
quitTimer = object : CountDownTimer(5000, 1000) {
override fun onTick(millisUntilFinished: Long) {
Log.d("Baresip", "Seconds remaining: ${millisUntilFinished / 1000}")
Log.d(TAG, "Seconds remaining: ${millisUntilFinished / 1000}")
}
override fun onFinish() {
when (stopState) {
@ -159,7 +159,7 @@ class MainActivity : AppCompatActivity() {
// Have to allow NULL view, since sometimes when onItemSelected is called, view is NULL.
// Haven't found any explanation why this can happen.
override fun onItemSelected(parent: AdapterView<*>, view: View?, position: Int, id: Long) {
Log.d("Baresip", "aorSpinner selecting $position")
Log.d(TAG, "aorSpinner selecting $position")
val acc = UserAgent.uas()[position].account
aorSpinner.tag = acc.aor
val ua = UserAgent.uas()[position]
@ -167,7 +167,7 @@ class MainActivity : AppCompatActivity() {
updateIcons(acc)
}
override fun onNothingSelected(parent: AdapterView<*>) {
Log.d("Baresip", "Nothing selected")
Log.d(TAG, "Nothing selected")
}
}
aorSpinner.setOnTouchListener { view, event ->
@ -237,8 +237,7 @@ class MainActivity : AppCompatActivity() {
val calls = Call.uaCalls(UserAgent.uas()[aorSpinner.selectedItemPosition], "")
if (calls.size > 0) {
if (Api.cmd_exec("zrtp_unverify " + calls[0].zid) != 0) {
Log.e("Baresip",
"Command 'zrtp_unverify ${calls[0].zid}' failed")
Log.e(TAG, "Command 'zrtp_unverify ${calls[0].zid}' failed")
} else {
securityButton.setImageResource(R.drawable.box_yellow)
securityButton.tag = "yellow"
@ -307,7 +306,7 @@ class MainActivity : AppCompatActivity() {
val uaCalls = Call.uaCalls(ua, "")
if (uaCalls.size > 0) {
val callp = uaCalls[uaCalls.size - 1].callp
Log.d("Baresip", "AoR $aor hanging up call $callp with ${callUri.text}")
Log.d(TAG, "AoR $aor hanging up call $callp with ${callUri.text}")
hangupButton.isEnabled = false
Api.ua_hangup(ua.uap, callp, 0, "")
}
@ -317,7 +316,7 @@ class MainActivity : AppCompatActivity() {
val ua = UserAgent.uas()[aorSpinner.selectedItemPosition]
val aor = ua.account.aor
val callp = Call.uaCalls(ua, "in")[0].callp
Log.d("Baresip", "AoR $aor answering call $callp from ${callUri.text}")
Log.d(TAG, "AoR $aor answering call $callp from ${callUri.text}")
answerButton.isEnabled = false
rejectButton.isEnabled = false
Api.ua_answer(ua.uap, callp, Api.VIDMODE_OFF)
@ -327,7 +326,7 @@ class MainActivity : AppCompatActivity() {
val ua = UserAgent.uas()[aorSpinner.selectedItemPosition]
val aor = ua.account.aor
val callp = Call.uaCalls(ua, "in")[0].callp
Log.d("Baresip", "AoR $aor rejecting call $callp from ${callUri.text}")
Log.d(TAG, "AoR $aor rejecting call $callp from ${callUri.text}")
answerButton.isEnabled = false
rejectButton.isEnabled = false
Api.ua_hangup(ua.uap, callp, 486, "Rejected")
@ -338,12 +337,12 @@ class MainActivity : AppCompatActivity() {
val aor = ua.account.aor
val call = Call.uaCalls(ua, "")[0]
if (call.onhold) {
Log.d("Baresip", "AoR $aor resuming call ${call.callp} with ${callUri.text}")
Log.d(TAG, "AoR $aor resuming call ${call.callp} with ${callUri.text}")
call.unhold()
call.onhold = false
holdButton.setImageResource(R.drawable.pause)
} else {
Log.d("Baresip", "AoR $aor holding call ${call.callp} with ${callUri.text}")
Log.d(TAG, "AoR $aor holding call ${call.callp} with ${callUri.text}")
call.hold()
call.onhold = true
holdButton.setImageResource(R.drawable.play)
@ -505,7 +504,7 @@ class MainActivity : AppCompatActivity() {
super.onNewIntent(intent)
resumeAction = ""
resumeUri = ""
Log.i("Baresip", "onNewIntent ${intent.action} ${intent.data}")
Log.d(TAG, "onNewIntent ${intent.action} ${intent.data}")
if (intent.action == ACTION_CALL) {
if (Call.calls().isNotEmpty() || UserAgent.uas().isEmpty()) {
return
@ -515,7 +514,6 @@ class MainActivity : AppCompatActivity() {
val uriStr = URLDecoder.decode(uri.toString(), "UTF-8")
when (uri.scheme) {
"sip" -> {
Log.d("Baresip", "Got sip URI $uriStr")
var ua = UserAgent.ofDomain(Utils.uriHostPart(uriStr))
if (ua == null)
ua = BaresipService.uas[0]
@ -524,14 +522,13 @@ class MainActivity : AppCompatActivity() {
ua.account.resumeUri = uriStr
}
"tel" -> {
Log.d("Baresip", "Got tel URI $uriStr")
val acc = BaresipService.uas[0].account
spinToAor(acc.aor)
resumeAction = "call"
acc.resumeUri = uriStr.replace("tel", "sip") + "@" + acc.aor
}
else -> {
Log.w("Baresip", "Unsupported URI scheme ${uri.scheme}")
Log.w(TAG, "Unsupported URI scheme ${uri.scheme}")
return
}
}
@ -544,7 +541,7 @@ class MainActivity : AppCompatActivity() {
private fun handleIntent(intent: Intent) {
val action = intent.getStringExtra("action")
Log.d("Baresip", "Handling intent '$action'")
Log.d(TAG, "Handling intent '$action'")
when (action) {
"accounts" -> {
resumeAction = "accounts"
@ -558,7 +555,7 @@ class MainActivity : AppCompatActivity() {
val uap = intent.getStringExtra("uap")!!
val ua = UserAgent.ofUap(uap)
if (ua == null) {
Log.w("Baresip", "handleIntent 'call' did not find ua $uap")
Log.w(TAG, "handleIntent 'call' did not find ua $uap")
return
}
if (ua.account.aor != aorSpinner.tag)
@ -570,7 +567,7 @@ class MainActivity : AppCompatActivity() {
val callp = intent.getStringExtra("callp")!!
val call = Call.ofCallp(callp)
if (call == null) {
Log.w("Baresip", "handleIntent '$action' did not find call $callp")
Log.w(TAG, "handleIntent '$action' did not find call $callp")
return
}
val ua = call.ua
@ -583,7 +580,7 @@ class MainActivity : AppCompatActivity() {
val uap = intent.getStringExtra("uap")!!
val ua = UserAgent.ofUap(uap)
if (ua == null) {
Log.w("Baresip", "onNewIntent did not find ua $uap")
Log.w(TAG, "onNewIntent did not find ua $uap")
return
}
if (ua.account.aor != aorSpinner.tag)
@ -594,7 +591,7 @@ class MainActivity : AppCompatActivity() {
val callp = intent.getStringExtra("callp")!!
val call = Call.ofCallp(callp)
if (call == null) {
Log.w("Baresip", "handleIntent '$action' did not find call $callp")
Log.w(TAG, "handleIntent '$action' did not find call $callp")
moveTaskToBack(true)
return
}
@ -606,7 +603,7 @@ class MainActivity : AppCompatActivity() {
val uap = intent.getStringExtra("uap")!!
val ua = UserAgent.ofUap(uap)
if (ua == null) {
Log.w("Baresip", "onNewIntent did not find ua $uap")
Log.w(TAG, "onNewIntent did not find ua $uap")
return
}
if (ua.account.aor != aorSpinner.tag)
@ -619,13 +616,13 @@ class MainActivity : AppCompatActivity() {
}
override fun onStart() {
Log.d("Baresip", "Main onStart")
Log.d(TAG, "Main onStart")
super.onStart()
}
override fun onResume() {
super.onResume()
Log.d("Baresip", "Main onResume with action '$resumeAction'")
Log.d(TAG, "Main onResume with action '$resumeAction'")
visible = true
when (resumeAction) {
"call show" ->
@ -678,7 +675,7 @@ class MainActivity : AppCompatActivity() {
}
override fun onPause() {
Log.d("Baresip", "Main onPause")
Log.d(TAG, "Main onPause")
Utils.addActivity("main")
visible = false
saveCallUri()
@ -686,19 +683,19 @@ class MainActivity : AppCompatActivity() {
}
override fun onStop() {
Log.d("Baresip", "Main onStop")
Log.d(TAG, "Main onStop")
super.onStop()
}
override fun recreate() {
Log.d("Baresip", "Main onCreate")
Log.d(TAG, "Main onCreate")
super.recreate()
}
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
when (keyCode) {
KeyEvent.KEYCODE_VOLUME_DOWN, KeyEvent.KEYCODE_VOLUME_UP -> {
Log.d("Baresip", "Adjusting volume $keyCode of stream ${volumeControlStream}")
Log.d(TAG, "Adjusting volume $keyCode of stream ${volumeControlStream}")
am.adjustStreamVolume(volumeControlStream,
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
AudioManager.ADJUST_LOWER else
@ -712,12 +709,12 @@ class MainActivity : AppCompatActivity() {
private fun handleServiceEvent(event: String, params: ArrayList<String>) {
if (taskId == -1) {
Log.d("Baresip", "Omit service event '$event' for task -1")
Log.d(TAG, "Omit service event '$event' for task -1")
return
}
if (event == "started") {
val callActionUri = params[0]
Log.d("Baresip", "Handling service event 'started' with '$callActionUri'")
Log.d(TAG, "Handling service event 'started' with '$callActionUri'")
uaAdapter.notifyDataSetChanged()
if (callActionUri != "") {
var ua = UserAgent.ofDomain(Utils.uriHostPart(callActionUri))
@ -725,7 +722,7 @@ class MainActivity : AppCompatActivity() {
if (BaresipService.uas.size > 0) {
ua = BaresipService.uas[0]
} else {
Log.w("Baresip", "No UAs to make the call to '$callActionUri'")
Log.w(TAG, "No UAs to make the call to '$callActionUri'")
return
}
spinToAor(ua.account.aor)
@ -741,7 +738,7 @@ class MainActivity : AppCompatActivity() {
return
}
if (event == "stopped") {
Log.d("Baresip", "Handling service event 'stopped' with param '${params[0]}'")
Log.d(TAG, "Handling service event 'stopped' with param '${params[0]}'")
if (params[0] != "") {
val titleView = View.inflate(this, R.layout.alert_title, null) as TextView
titleView.text = getString(R.string.notice)
@ -767,11 +764,11 @@ class MainActivity : AppCompatActivity() {
val uap = params[0]
val ua = UserAgent.ofUap(uap)
if (ua == null) {
Log.w("Baresip", "handleServiceEvent '$event' did not find ua $uap")
Log.w(TAG, "handleServiceEvent '$event' did not find ua $uap")
return
}
val ev = event.split(",")
Log.d("Baresip", "Handling service event '${ev[0]}' for $uap")
Log.d(TAG, "Handling service event '${ev[0]}' for $uap")
val acc = ua.account
val aor = ua.account.aor
for (account_index in UserAgent.uas().indices) {
@ -806,7 +803,7 @@ class MainActivity : AppCompatActivity() {
spinToAor(aor)
showCall(ua)
} else {
Log.d("Baresip", "Reordering to front")
Log.d(TAG, "Reordering to front")
val i = Intent(applicationContext, MainActivity::class.java)
i.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
i.putExtra("action", "call show")
@ -826,7 +823,7 @@ class MainActivity : AppCompatActivity() {
val callp = params[1]
val call = Call.ofCallp(callp)
if (call == null) {
Log.w("Baresip", "Call $callp to be verified is not found")
Log.w(TAG, "Call $callp to be verified is not found")
return
}
val titleView = View.inflate(this, R.layout.alert_title, null) as TextView
@ -838,7 +835,7 @@ class MainActivity : AppCompatActivity() {
setPositiveButton(getString(R.string.yes)) { dialog, _ ->
val security: Int
if (Api.cmd_exec("zrtp_verify ${ev[3]}") != 0) {
Log.e("Baresip", "Command 'zrtp_verify ${ev[3]}' failed")
Log.e(TAG, "Command 'zrtp_verify ${ev[3]}' failed")
security = R.drawable.box_yellow
} else {
security = R.drawable.box_green
@ -869,7 +866,7 @@ class MainActivity : AppCompatActivity() {
val callp = params[1]
val call = Call.ofCallp(callp)
if (call == null) {
Log.w("Baresip", "Call $callp that is verified is not found")
Log.w(TAG, "Call $callp that is verified is not found")
return
}
val tag: String
@ -886,7 +883,7 @@ class MainActivity : AppCompatActivity() {
val callp = params[1]
val call = Call.ofCallp(callp)
if (call == null) {
Log.w("Baresip", "Call $callp to be transferred is not found")
Log.w(TAG, "Call $callp to be transferred is not found")
return
}
val titleView = View.inflate(this, R.layout.alert_title, null) as TextView
@ -916,7 +913,7 @@ class MainActivity : AppCompatActivity() {
val callp = params[1]
val call = Call.ofCallp(callp)
if (call == null) {
Log.w("Baresip", "Call $callp to be transferred is not found")
Log.w(TAG, "Call $callp to be transferred is not found")
return
}
if (call in Call.calls())
@ -957,8 +954,6 @@ class MainActivity : AppCompatActivity() {
}
"message", "message show", "message reply" -> {
val peer = params[1]
Log.d("Baresip", "Message for $aor from $peer")
Log.d("Baresip", "Activity stack ${BaresipService.activities.toString()}")
val i = Intent(applicationContext, ChatActivity::class.java)
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
val b = Bundle()
@ -985,7 +980,7 @@ class MainActivity : AppCompatActivity() {
voicemailButton.setImageResource(R.drawable.voicemail)
}
}
else -> Log.e("Baresip", "Unknown event '${ev[0]}'")
else -> Log.e(TAG, "Unknown event '${ev[0]}'")
}
break
}
@ -993,7 +988,7 @@ class MainActivity : AppCompatActivity() {
}
private fun reStart() {
Log.d("Baresip", "Trigger restart")
Log.d(TAG, "Trigger restart")
val pm = applicationContext.packageManager
val intent = pm.getLaunchIntentForPackage(this.getPackageName())
this.finishAffinity()
@ -1006,7 +1001,7 @@ class MainActivity : AppCompatActivity() {
}
override fun onDestroy() {
Log.d("Baresip", "Main onDestroy")
Log.d(TAG, "Main onDestroy")
LocalBroadcastManager.getInstance(this).unregisterReceiver(serviceEventReceiver)
BaresipService.activities.clear()
super.onDestroy()
@ -1077,7 +1072,7 @@ class MainActivity : AppCompatActivity() {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
Log.d("Baresip", "onActivity result $requestCode $resultCode")
Log.d(TAG, "onActivity result $requestCode $resultCode")
when (requestCode) {
@ -1173,7 +1168,7 @@ class MainActivity : AppCompatActivity() {
private fun quitRestart(reStart: Boolean) {
if (stopState == "initial") {
Log.d("Baresip", "quitRestart Restart = $reStart")
Log.d(TAG, "quitRestart Restart = $reStart")
if (BaresipService.isServiceRunning) {
restart = reStart
baresipService.setAction("Stop");
@ -1367,14 +1362,14 @@ class MainActivity : AppCompatActivity() {
val zipFile = getString(R.string.app_name) + ".zip"
val zipFilePath = BaresipService.filesPath + "/$zipFile"
if (!Utils.zip(files, zipFile)) {
Log.w("Baresip", "Failed to write zip file '$zipFile'")
Log.w(TAG, "Failed to write zip file '$zipFile'")
Utils.alertView(this, getString(R.string.error),
String.format(getString(R.string.backup_failed), bsFile))
return
}
val content = Utils.getFileContents(zipFilePath)
if (content == null) {
Log.w("Baresip", "Failed to read zip file '$zipFile'")
Log.w(TAG, "Failed to read zip file '$zipFile'")
Utils.alertView(this, getString(R.string.error),
String.format(getString(R.string.backup_failed), bsFile))
return
@ -1401,13 +1396,13 @@ class MainActivity : AppCompatActivity() {
return
}
if (!Utils.putFileContents(zipFilePath, zipData)) {
Log.w("Baresip", "Failed to write zip file '$zipFile'")
Log.w(TAG, "Failed to write zip file '$zipFile'")
Utils.alertView(this, getString(R.string.error),
String.format(getString(R.string.restore_failed), bsFile))
return
}
if (!Utils.unZip(zipFilePath)) {
Log.w("Baresip", "Failed to unzip file '$zipFile'")
Log.w(TAG, "Failed to unzip file '$zipFile'")
Utils.alertView(this, getString(R.string.error),
String.format(getString(R.string.restore_failed), bsFile))
return
@ -1456,12 +1451,12 @@ class MainActivity : AppCompatActivity() {
spinToAor(ua.account.aor)
val callp = Api.ua_connect(ua.uap, uri, Api.VIDMODE_OFF)
if (callp != "") {
Log.d("Baresip", "Adding outgoing call ${ua.uap}/$callp/$uri")
Log.d(TAG, "Adding outgoing call ${ua.uap}/$callp/$uri")
Call(callp, ua, uri, "out", status, Utils.dtmfWatcher(callp)).add()
showCall(ua)
return true
} else {
Log.e("Baresip", "ua_connect ${ua.uap}/$uri failed")
Log.w(TAG, "ua_connect ${ua.uap}/$uri failed")
return false
}
}
@ -1470,7 +1465,7 @@ class MainActivity : AppCompatActivity() {
private fun transfer(ua: UserAgent, call: Call, uri: String) {
val newCallp = Api.ua_call_alloc(ua.uap, call.callp, Api.VIDMODE_OFF)
if (newCallp != "") {
Log.d("Baresip", "Adding outgoing call ${ua.uap}/$newCallp/$uri")
Log.d(TAG, "Adding outgoing call ${ua.uap}/$newCallp/$uri")
val newCall = Call(newCallp, ua, uri, "out", "transferring",
Utils.dtmfWatcher(newCallp))
newCall.add()
@ -1484,11 +1479,11 @@ class MainActivity : AppCompatActivity() {
showCall(ua)
} else {
call.startAudio()
Log.e("Baresip", "call_connect $newCallp failed with error $err")
Log.w(TAG, "call_connect $newCallp failed with error $err")
call.notifySipfrag(500, "Call Error")
}
} else {
Log.e("Baresip", "ua_call_alloc ${ua.uap}/${call.callp} failed")
Log.w(TAG, "ua_call_alloc ${ua.uap}/${call.callp} failed")
call.notifySipfrag(500, "Call Error")
}
}
@ -1649,7 +1644,7 @@ class MainActivity : AppCompatActivity() {
private fun restoreActivities() {
if (BaresipService.activities.isEmpty()) return
Log.d("Baresip", "Activity stack ${BaresipService.activities}")
Log.d(TAG, "Activity stack ${BaresipService.activities}")
val activity = BaresipService.activities[0].split(",")
BaresipService.activities.removeAt(0)
when (activity[0]) {
@ -1770,6 +1765,8 @@ class MainActivity : AppCompatActivity() {
// <aor, password> of those accounts that have auth username without auth password
val aorPasswords = mutableMapOf<String, String>()
private const val TAG = "Baresip"
const val ACCOUNTS_CODE = 1
const val CONTACTS_CODE = 2
const val CONFIG_CODE = 3
@ -1788,7 +1785,7 @@ class MainActivity : AppCompatActivity() {
init {
if (!BaresipService.libraryLoaded) {
Log.d("Baresip", "Loading baresip library")
Log.d(TAG, "Loading baresip library")
System.loadLibrary("baresip")
BaresipService.libraryLoaded = true
}