Use constant TAG as log tag everywhere

This commit is contained in:
Juha Heinanen
2021-05-14 13:47:26 +03:00
parent dd15f017b3
commit 355a030aa3
13 changed files with 69 additions and 69 deletions
@@ -40,13 +40,13 @@ class AccountsActivity : AppCompatActivity() {
addAccountButton.setOnClickListener { addAccountButton.setOnClickListener {
val aor = newAorView.text.toString().trim() val aor = newAorView.text.toString().trim()
if (!Utils.checkAor("sip:$aor")) { if (!Utils.checkAor("sip:$aor")) {
Log.d("Baresip", "Invalid Address of Record $aor") Log.d(TAG, "Invalid Address of Record $aor")
Utils.alertView(this, getString(R.string.notice), Utils.alertView(this, getString(R.string.notice),
String.format(getString(R.string.invalid_aor), aor)) String.format(getString(R.string.invalid_aor), aor))
return@setOnClickListener return@setOnClickListener
} }
if (Account.ofAor("sip:$aor") != null) { if (Account.ofAor("sip:$aor") != null) {
Log.d("Baresip", "Account $aor already exists") Log.d(TAG, "Account $aor already exists")
Utils.alertView(this, getString(R.string.notice), Utils.alertView(this, getString(R.string.notice),
String.format(getString(R.string.account_exists), aor.split(":")[0])) String.format(getString(R.string.account_exists), aor.split(":")[0]))
return@setOnClickListener return@setOnClickListener
@@ -54,13 +54,13 @@ class AccountsActivity : AppCompatActivity() {
val laddr = "sip:$aor" val laddr = "sip:$aor"
val ua = UserAgent.uaAlloc("<$laddr>;stunserver=\"stun:stun.l.google.com:19302\";regq=0.5;pubint=0;regint=0;mwi=no") val ua = UserAgent.uaAlloc("<$laddr>;stunserver=\"stun:stun.l.google.com:19302\";regq=0.5;pubint=0;regint=0;mwi=no")
if (ua == null) { if (ua == null) {
Log.e("Baresip", "Failed to allocate UA for $aor") Log.e(TAG, "Failed to allocate UA for $aor")
Utils.alertView(this, getString(R.string.notice), Utils.alertView(this, getString(R.string.notice),
getString(R.string.account_allocation_failure)) getString(R.string.account_allocation_failure))
return@setOnClickListener return@setOnClickListener
} }
// Api.account_debug(ua.account.accp) // Api.account_debug(ua.account.accp)
Log.d("Baresip", "Allocated UA ${ua.uap} for ${Api.account_luri(ua.account.accp)}") Log.d(TAG, "Allocated UA ${ua.uap} for ${Api.account_luri(ua.account.accp)}")
newAorView.setText("") newAorView.setText("")
newAorView.hint = getString(R.string.user_domain) newAorView.hint = getString(R.string.user_domain)
newAorView.clearFocus() newAorView.clearFocus()
@@ -191,7 +191,7 @@ class AccountsActivity : AppCompatActivity() {
count++ count++
} }
Utils.putFileContents(BaresipService.filesPath + "/accounts", accounts.toByteArray()) Utils.putFileContents(BaresipService.filesPath + "/accounts", accounts.toByteArray())
// Log.d("Baresip", "Saved accounts '${accounts}' to '${BaresipService.filesPath}/accounts'") // Log.d(TAG, "Saved accounts '${accounts}' to '${BaresipService.filesPath}/accounts'")
} }
fun noAccounts(): Boolean { fun noAccounts(): Boolean {
@@ -207,7 +207,7 @@ class AccountsActivity : AppCompatActivity() {
if ((ap != "") && (acc.regint > 0)) if ((ap != "") && (acc.regint > 0))
Api.ua_register(ua.uap) Api.ua_register(ua.uap)
} else { } else {
Log.e("Baresip", "Setting of auth pass failed") Log.e(TAG, "Setting of auth pass failed")
} }
} }
} }
@@ -19,7 +19,7 @@ class BootCompletedReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) { override fun onReceive(context: Context, intent: Intent) {
Log.i("Baresip", "BootCompletedReceiver received intent ${intent.action}") Log.i(TAG, "BootCompletedReceiver received intent ${intent.action}")
val configPath = context.filesDir.absolutePath + "/config" val configPath = context.filesDir.absolutePath + "/config"
val config = String(Utils.getFileContents(configPath)!!, StandardCharsets.ISO_8859_1) val config = String(Utils.getFileContents(configPath)!!, StandardCharsets.ISO_8859_1)
@@ -27,7 +27,7 @@ class BootCompletedReceiver : BroadcastReceiver() {
if ((asCv.size > 0) && (asCv[0] == "yes")) { if ((asCv.size > 0) && (asCv[0] == "yes")) {
Log.i("Baresip", "Start baresip upon boot completed") Log.i(TAG, "Start baresip upon boot completed")
val i = Intent(context, MainActivity::class.java).apply { val i = Intent(context, MainActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
@@ -42,7 +42,7 @@ class CallHistory(val aor: String, val peerUri: String, val direction: String,
} }
fun save() { fun save() {
Log.d("Baresip", "Saving history of ${BaresipService.callHistory.size} calls") Log.d(TAG, "Saving history of ${BaresipService.callHistory.size} calls")
val file = File(BaresipService.filesPath, "calls") val file = File(BaresipService.filesPath, "calls")
try { try {
val fos = FileOutputStream(file) val fos = FileOutputStream(file)
@@ -51,7 +51,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.e("Baresip", "OutputStream exception: " + e.toString()) Log.e(TAG, "OutputStream exception: " + e.toString())
e.printStackTrace() e.printStackTrace()
} }
} }
@@ -66,15 +66,15 @@ class CallHistory(val aor: String, val peerUri: String, val direction: String,
BaresipService.callHistory = ois.readObject() as ArrayList<CallHistory> BaresipService.callHistory = ois.readObject() as ArrayList<CallHistory>
ois.close() ois.close()
fis.close() fis.close()
Log.d("Baresip", "Restored history of ${BaresipService.callHistory.size} calls") Log.d(TAG, "Restored history of ${BaresipService.callHistory.size} calls")
} catch (e: Exception) { } catch (e: Exception) {
Log.e("Baresip", "InputStream exception: - " + e.toString()) Log.e(TAG, "InputStream exception: - " + e.toString())
} }
} }
fun print() { fun print() {
for (h in BaresipService.callHistory) for (h in BaresipService.callHistory)
Log.d("Baresip", "[${h.aor}, ${h.peerUri}, ${h.direction}, ${h.connected}]") Log.d(TAG, "[${h.aor}, ${h.peerUri}, ${h.direction}, ${h.connected}]")
} }
} }
@@ -53,7 +53,7 @@ class ChatActivity : AppCompatActivity() {
val userAgent = UserAgent.ofAor(aor) val userAgent = UserAgent.ofAor(aor)
if (userAgent == null) { if (userAgent == null) {
Log.w("Baresip", "MessageActivity did not find ua of $aor") Log.w(TAG, "MessageActivity did not find ua of $aor")
MainActivity.activityAor = aor MainActivity.activityAor = aor
returnResult(Activity.RESULT_CANCELED) returnResult(Activity.RESULT_CANCELED)
return return
@@ -181,7 +181,7 @@ class ChatActivity : AppCompatActivity() {
override fun onPause() { override fun onPause() {
if (newMessage.text.toString() != "") { if (newMessage.text.toString() != "") {
Log.d("Baresip", "Saving newMessage ${newMessage.text} for $aor::$peerUri") Log.d(TAG, "Saving newMessage ${newMessage.text} for $aor::$peerUri")
BaresipService.chatTexts.put("$aor::$peerUri", newMessage.text.toString()) BaresipService.chatTexts.put("$aor::$peerUri", newMessage.text.toString())
} }
MainActivity.activityAor = aor MainActivity.activityAor = aor
@@ -193,7 +193,7 @@ class ChatActivity : AppCompatActivity() {
super.onResume() super.onResume()
val chatText = BaresipService.chatTexts["$aor::$peerUri"] val chatText = BaresipService.chatTexts["$aor::$peerUri"]
if (chatText != null) { if (chatText != null) {
Log.d("Baresip", "Restoring newMessage ${newMessage.text} for $aor::$peerUri") Log.d(TAG, "Restoring newMessage ${newMessage.text} for $aor::$peerUri")
newMessage.setText(chatText) newMessage.setText(chatText)
newMessage.requestFocus() newMessage.requestFocus()
BaresipService.chatTexts.remove("$aor::$peerUri") BaresipService.chatTexts.remove("$aor::$peerUri")
@@ -113,29 +113,29 @@ class CodecsActivity : AppCompatActivity() {
if (media == "audio") if (media == "audio")
if (mc != acc.audioCodec) { if (mc != acc.audioCodec) {
if (Api.account_set_audio_codecs(acc.accp, mcList) == 0) { if (Api.account_set_audio_codecs(acc.accp, mcList) == 0) {
Log.d("Baresip", "New audio codecs '$mcList'") Log.d(TAG, "New audio codecs '$mcList'")
acc.audioCodec = mc acc.audioCodec = mc
save = true save = true
} else { } else {
Log.e("Baresip", "Setting of audio codecs '$mcList' failed") Log.e(TAG, "Setting of audio codecs '$mcList' failed")
} }
} }
if (media == "video") if (media == "video")
if (mc != acc.videoCodec) { if (mc != acc.videoCodec) {
if (Api.account_set_video_codecs(acc.accp, mcList) == 0) { if (Api.account_set_video_codecs(acc.accp, mcList) == 0) {
Log.d("Baresip", "New video codecs '$mcList'") Log.d(TAG, "New video codecs '$mcList'")
acc.videoCodec = mc acc.videoCodec = mc
save = true save = true
} else { } else {
Log.e("Baresip", "Setting of video codecs '$mcList' failed") Log.e(TAG, "Setting of video codecs '$mcList' failed")
} }
} }
if (save) { if (save) {
AccountsActivity.saveAccounts() AccountsActivity.saveAccounts()
if (Api.ua_update_account(ua.uap) != 0) if (Api.ua_update_account(ua.uap) != 0)
Log.e("Baresip", "Failed to update UA ${ua.uap} with AoR $aor") Log.e(TAG, "Failed to update UA ${ua.uap} with AoR $aor")
} }
if ((acc.regint > 0) && !((acc.authUser != "") && (acc.authPass == ""))) if ((acc.regint > 0) && !((acc.authUser != "") && (acc.authPass == "")))
@@ -12,7 +12,7 @@ object Config {
fun initialize() { fun initialize() {
Log.d("Baresip", "Config is '$config'") Log.d(TAG, "Config is '$config'")
if (!config.contains(Regex("ausrc_format s16"))) { if (!config.contains(Regex("ausrc_format s16"))) {
config = "${config}ausrc_format s16\nauplay_format s16\nauenc_format s16\naudec_format s16\nmodule webrtc_aec.so\n" config = "${config}ausrc_format s16\nauplay_format s16\nauenc_format s16\naudec_format s16\nmodule webrtc_aec.so\n"
@@ -89,7 +89,7 @@ object Config {
Utils.putFileContents(configPath, config.toByteArray()) Utils.putFileContents(configPath, config.toByteArray())
BaresipService.isConfigInitialized = true BaresipService.isConfigInitialized = true
Log.i("Baresip", "Initialized config to '$config'") Log.i(TAG, "Initialized config to '$config'")
} }
@@ -136,12 +136,12 @@ object Config {
result = result + line + '\n' result = result + line + '\n'
config = result config = result
Utils.putFileContents(configPath, config.toByteArray()) Utils.putFileContents(configPath, config.toByteArray())
Log.d("Baresip", "New config '$result'") Log.d(TAG, "Saved new config '$result'")
// Api.reload_config() // Api.reload_config()
} }
fun updateDnsServers(dnsServers: List<InetAddress>): Int { fun updateDnsServers(dnsServers: List<InetAddress>): Int {
Log.i("Baresip", "Updating dnsServers with $dnsServers") Log.i(TAG, "Updating dnsServers with $dnsServers")
var servers = "" var servers = ""
for (dnsServer in dnsServers) { for (dnsServer in dnsServers) {
var address = dnsServer.hostAddress.removePrefix("/") var address = dnsServer.hostAddress.removePrefix("/")
@@ -55,18 +55,18 @@ class Contact(var name: String, var uri: String, var color: Int, val id: Long) {
id = idValue.toLong() id = idValue.toLong()
else else
id = baseId + contactNo id = baseId + contactNo
Log.d("Baresip", "Restoring contact $name, $uri, $color, $id, $androidContact") Log.d(TAG, "Restoring contact $name, $uri, $color, $id, $androidContact")
val contact = Contact(name, uri, color, id) val contact = Contact(name, uri, color, id)
contact.androidContact = androidContact contact.androidContact = androidContact
val avatarFilePath = BaresipService.filesPath + "/$id.png" val avatarFilePath = BaresipService.filesPath + "/$id.png"
if (File(avatarFilePath).exists()) { if (File(avatarFilePath).exists()) {
try { try {
contact.avatarImage = BitmapFactory.decodeFile(avatarFilePath) contact.avatarImage = BitmapFactory.decodeFile(avatarFilePath)
Log.d("Baresip", "Set avatarImage") Log.d(TAG, "Set avatarImage")
if (contact.avatarImage == null) if (contact.avatarImage == null)
Log.d("Baresip", "Contact $id avatarImage is null") Log.d(TAG, "Contact $id avatarImage is null")
} catch (e: Exception) { } catch (e: Exception) {
Log.e("Baresip", "Could not read avatar image from '$id.img") Log.e(TAG, "Could not read avatar image from '$id.img")
} }
} }
BaresipService.contacts.add(contact) BaresipService.contacts.add(contact)
@@ -162,7 +162,7 @@ class ContactActivity : AppCompatActivity() {
if (Utils.saveBitmap(rotatedBitmap, File(BaresipService.filesPath, "tmp.png"))) if (Utils.saveBitmap(rotatedBitmap, File(BaresipService.filesPath, "tmp.png")))
newAvatar = "image" newAvatar = "image"
} catch (e: Exception) { } catch (e: Exception) {
Log.e("Baresip", "Could not read avatar image: $e") Log.e(TAG, "Could not read avatar image: $e")
} }
} }
} }
@@ -421,7 +421,7 @@ class ContactActivity : AppCompatActivity() {
try { try {
ctx.contentResolver.applyBatch(ContactsContract.AUTHORITY, ops) ctx.contentResolver.applyBatch(ContactsContract.AUTHORITY, ops)
} catch (e: Exception) { } catch (e: Exception) {
Log.e("Baresip", "Adding of contact ${contact.name} failed") Log.e(TAG, "Adding of contact ${contact.name} failed")
return false return false
} }
return true return true
@@ -446,7 +446,7 @@ class ContactActivity : AppCompatActivity() {
try { try {
contentResolver.applyBatch(ContactsContract.AUTHORITY, ops) contentResolver.applyBatch(ContactsContract.AUTHORITY, ops)
} catch (e: Exception) { } catch (e: Exception) {
Log.e("Baresip", "Adding of SIP URI $sipUri failed") Log.e(TAG, "Adding of SIP URI $sipUri failed")
} }
} }
@@ -458,7 +458,7 @@ class ContactActivity : AppCompatActivity() {
return try { return try {
contentResolver.update(ContactsContract.Data.CONTENT_URI, contentValues, where, null) contentResolver.update(ContactsContract.Data.CONTENT_URI, contentValues, where, null)
} catch (e: Exception) { } catch (e: Exception) {
Log.e("Baresip", "Adding of SIP URI $sipUri failed") Log.e(TAG, "Adding of SIP URI $sipUri failed")
0 0
} }
} }
@@ -476,7 +476,7 @@ class ContactActivity : AppCompatActivity() {
try { try {
contentResolver.applyBatch(ContactsContract.AUTHORITY, ops) contentResolver.applyBatch(ContactsContract.AUTHORITY, ops)
} catch (e: Exception) { } catch (e: Exception) {
Log.e("Baresip", "Adding of Android photo failed") Log.e(TAG, "Adding of Android photo failed")
} }
} }
} }
@@ -493,7 +493,7 @@ class ContactActivity : AppCompatActivity() {
return try { return try {
contentResolver.update(ContactsContract.Data.CONTENT_URI, contentValues, where, null) contentResolver.update(ContactsContract.Data.CONTENT_URI, contentValues, where, null)
} catch (e: Exception) { } catch (e: Exception) {
Log.e("Baresip", "updateAndroidPhoto failed") Log.e(TAG, "updateAndroidPhoto failed")
0 0
} }
} }
@@ -507,7 +507,7 @@ class ContactActivity : AppCompatActivity() {
out.close() out.close()
out.toByteArray() out.toByteArray()
} catch (e: Exception) { } catch (e: Exception) {
Log.w("Baresip", "Unable to serialize photo: $e") Log.w(TAG, "Unable to serialize photo: $e")
null null
} }
} }
@@ -542,7 +542,7 @@ class ContactActivity : AppCompatActivity() {
CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE -> kind = "sip" CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE -> kind = "sip"
CommonDataKinds.Photo.CONTENT_ITEM_TYPE -> kind = "thumb" CommonDataKinds.Photo.CONTENT_ITEM_TYPE -> kind = "thumb"
} }
Log.d("Baresip", "got $id, $name, $kind - $data") Log.d(TAG, "got $id, $name, $kind - $data")
var info: MutableList<String> var info: MutableList<String>
if (contacts.containsKey(id)) { if (contacts.containsKey(id)) {
info = contacts[id]!! info = contacts[id]!!
@@ -87,7 +87,7 @@ class ContactListAdapter(private val ctx: Context, private val rows: ArrayList<C
i.putExtra("action", "message") i.putExtra("action", "message")
val ua = UserAgent.ofAor(aor) val ua = UserAgent.ofAor(aor)
if (ua == null) { if (ua == null) {
Log.w("Baresip", "onClickListener did not find AoR $aor") Log.w(TAG, "onClickListener did not find AoR $aor")
} else { } else {
BaresipService.activities.clear() BaresipService.activities.clear()
i.putExtra("uap", ua.uap) i.putExtra("uap", ua.uap)
@@ -123,7 +123,7 @@ class ContactListAdapter(private val ctx: Context, private val rows: ArrayList<C
try { try {
avatarFile.delete() avatarFile.delete()
} catch (e: IOException) { } catch (e: IOException) {
Log.e("Baresip", "Could not delete file '$id.img") Log.e(TAG, "Could not delete file '$id.img")
} }
} }
if (contact.androidContact && if (contact.androidContact &&
@@ -44,9 +44,9 @@ class Message(val aor: String, val peerUri: String, val message: String, val tim
oos.writeObject(BaresipService.messages) oos.writeObject(BaresipService.messages)
oos.close() oos.close()
fos.close() fos.close()
Log.d("Baresip", "Saved ${BaresipService.messages.size} messages") Log.d(TAG, "Saved ${BaresipService.messages.size} messages")
} catch (e: IOException) { } catch (e: IOException) {
Log.e("Baresip", "OutputStream exception: " + e.toString()) Log.e(TAG, "OutputStream exception: " + e.toString())
e.printStackTrace() e.printStackTrace()
} }
} }
@@ -61,9 +61,9 @@ class Message(val aor: String, val peerUri: String, val message: String, val tim
BaresipService.messages = ois.readObject() as ArrayList<Message> BaresipService.messages = ois.readObject() as ArrayList<Message>
ois.close() ois.close()
fis.close() fis.close()
Log.d("Baresip", "Restored ${BaresipService.messages.size} messages") Log.d(TAG, "Restored ${BaresipService.messages.size} messages")
} catch (e: Exception) { } catch (e: Exception) {
Log.e("Baresip", "InputStream exception: - " + e.toString()) Log.e(TAG, "InputStream exception: - " + e.toString())
} }
} }
} }
@@ -52,7 +52,7 @@ open class OnSwipeTouchListener(ctx: Context) : View.OnTouchListener {
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
Log.e("Baresip", "onFling exception $e") Log.e(TAG, "onFling exception $e")
e.printStackTrace() e.printStackTrace()
} }
@@ -51,7 +51,7 @@ class UserAgent(val uap: String) {
fun uaAlloc(uri: String): UserAgent? { fun uaAlloc(uri: String): UserAgent? {
val uap = Api.ua_alloc(uri) val uap = Api.ua_alloc(uri)
if (uap != "") return UserAgent(uap) if (uap != "") return UserAgent(uap)
Log.e("Baresip", "Failed to allocate UserAgent for $uri") Log.e(TAG, "Failed to allocate UserAgent for $uri")
return null return null
} }
@@ -66,7 +66,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.d("Baresip", "Failed to register ${ua.account.aor}") Log.d(TAG, "Failed to register ${ua.account.aor}")
} }
} }
} }
+23 -23
View File
@@ -294,10 +294,10 @@ object Utils {
var updated = false var updated = false
val ipV6Addr = findIpV6Address(linkAddresses) val ipV6Addr = findIpV6Address(linkAddresses)
if (ipV6Addr != findIpV6Address(BaresipService.linkAddresses)) { if (ipV6Addr != findIpV6Address(BaresipService.linkAddresses)) {
Log.d("Baresip", "Updating IPv6 address to '$ipV6Addr'") Log.d(TAG, "Updating IPv6 address to '$ipV6Addr'")
if (ipV6Addr != "") { if (ipV6Addr != "") {
if (Api.net_set_address(ipV6Addr) != 0) if (Api.net_set_address(ipV6Addr) != 0)
Log.w("Baresip", "Failed to update net address '$ipV6Addr") Log.w(TAG, "Failed to update net address '$ipV6Addr")
} else { } else {
Api.net_unset_address(Api.AF_INET6) Api.net_unset_address(Api.AF_INET6)
} }
@@ -305,10 +305,10 @@ object Utils {
} }
val ipV4Addr = findIpV4Address(linkAddresses) val ipV4Addr = findIpV4Address(linkAddresses)
if (ipV4Addr != findIpV4Address(BaresipService.linkAddresses)) { if (ipV4Addr != findIpV4Address(BaresipService.linkAddresses)) {
Log.d("Baresip", "Updating IPv4 address to '$ipV4Addr'") Log.d(TAG, "Updating IPv4 address to '$ipV4Addr'")
if (ipV4Addr != "") { if (ipV4Addr != "") {
if (Api.net_set_address(ipV4Addr) != 0) if (Api.net_set_address(ipV4Addr) != 0)
Log.w("Baresip", "Failed to update net address '$ipV4Addr'") Log.w(TAG, "Failed to update net address '$ipV4Addr'")
} else { } else {
Api.net_unset_address(Api.AF_INET) Api.net_unset_address(Api.AF_INET)
} }
@@ -327,7 +327,7 @@ object Utils {
if (BaresipService.dynDns && (BaresipService.dnsServers != props.dnsServers)) { if (BaresipService.dynDns && (BaresipService.dnsServers != props.dnsServers)) {
if (BaresipService.isServiceRunning) if (BaresipService.isServiceRunning)
if (Config.updateDnsServers(props.dnsServers) != 0) if (Config.updateDnsServers(props.dnsServers) != 0)
Log.w("Baresip", "Failed to update DNS servers '${props.dnsServers}'") Log.w(TAG, "Failed to update DNS servers '${props.dnsServers}'")
else else
BaresipService.dnsServers = props.dnsServers BaresipService.dnsServers = props.dnsServers
else else
@@ -362,9 +362,9 @@ object Utils {
val digit = text[0] val digit = text[0]
val call = Call.ofCallp(callp) val call = Call.ofCallp(callp)
if (call == null) { if (call == null) {
Log.w("Baresip", "dtmfWatcher did not find call $callp") Log.w(TAG, "dtmfWatcher did not find call $callp")
} else { } else {
Log.d("Baresip", "Got DTMF digit '$digit'") Log.d(TAG, "Got DTMF digit '$digit'")
if (((digit >= '0') && (digit <= '9')) || (digit == '*') || (digit == '#')) if (((digit >= '0') && (digit <= '9')) || (digit == '*') || (digit == '#'))
call.sendDigit(digit) call.sendDigit(digit)
} }
@@ -408,7 +408,7 @@ object Utils {
os.close() os.close()
`is`.close() `is`.close()
} catch (e: IOException) { } catch (e: IOException) {
Log.e("Baresip", "Failed to copy asset '$asset' to file: $e") Log.e(TAG, "Failed to copy asset '$asset' to file: $e")
} }
} }
@@ -417,7 +417,7 @@ object Utils {
try { try {
file.delete() file.delete()
} catch (e: IOException) { } catch (e: IOException) {
Log.e("Baresip", "Could not delete file ${file.absolutePath}") Log.e(TAG, "Could not delete file ${file.absolutePath}")
} }
} }
} }
@@ -426,10 +426,10 @@ object Utils {
return try { return try {
File(filePath).readBytes() File(filePath).readBytes()
} catch (e: FileNotFoundException) { } catch (e: FileNotFoundException) {
Log.e("Baresip", "File '$filePath' not found: ${e.printStackTrace()}") Log.e(TAG, "File '$filePath' not found: ${e.printStackTrace()}")
null null
} catch (e: Exception) { } catch (e: Exception) {
Log.e("Baresip", "Failed to read file '$filePath': ${e.printStackTrace()}") Log.e(TAG, "Failed to read file '$filePath': ${e.printStackTrace()}")
null null
} }
} }
@@ -439,7 +439,7 @@ object Utils {
File(filePath).writeBytes(contents) File(filePath).writeBytes(contents)
} }
catch (e: IOException) { catch (e: IOException) {
Log.e("Baresip", "Failed to write file '$filePath': $e") Log.e(TAG, "Failed to write file '$filePath': $e")
return false return false
} }
return true return true
@@ -465,9 +465,9 @@ object Utils {
scaledBitmap.compress(Bitmap.CompressFormat.PNG, 100, out) scaledBitmap.compress(Bitmap.CompressFormat.PNG, 100, out)
out.flush() out.flush()
out.close() out.close()
Log.e("Baresip", "Saved bitmap to ${file.absolutePath} of length ${file.length()}") Log.d(TAG, "Saved bitmap to ${file.absolutePath} of length ${file.length()}")
} catch (e: Exception) { } catch (e: Exception) {
Log.e("Baresip", "Failed to save bitmap to ${file.absolutePath}") Log.e(TAG, "Failed to save bitmap to ${file.absolutePath}")
return false return false
} }
return true return true
@@ -498,7 +498,7 @@ object Utils {
val cipherData = cipher.doFinal(content) val cipherData = cipher.doFinal(content)
obj = Crypto(salt, iterationCount, iv, cipherData) obj = Crypto(salt, iterationCount, iv, cipherData)
} catch (e: Exception) { } catch (e: Exception) {
Log.e("Baresip", "Encrypt failed: ${e.printStackTrace()}") Log.e(TAG, "Encrypt failed: ${e.printStackTrace()}")
} }
return obj return obj
@@ -516,7 +516,7 @@ object Utils {
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec) cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec)
plainData = cipher.doFinal(obj.data) plainData = cipher.doFinal(obj.data)
} catch (e: Exception) { } catch (e: Exception) {
Log.e("Baresip", "Decrypt failed: ${e.printStackTrace()}") Log.e(TAG, "Decrypt failed: ${e.printStackTrace()}")
} }
return plainData return plainData
} }
@@ -528,7 +528,7 @@ object Utils {
it.writeObject(obj) it.writeObject(obj)
} }
} catch (e: Exception) { } catch (e: Exception) {
Log.w("Baresip", "encryptToStream failed: $e") Log.w(TAG, "encryptToStream failed: $e")
return false return false
} }
return true return true
@@ -542,7 +542,7 @@ object Utils {
plainData = decrypt(obj, password.toCharArray()) plainData = decrypt(obj, password.toCharArray())
} }
} catch (e: Exception) { } catch (e: Exception) {
Log.w("Baresip", "decryptFromStream failed: $e") Log.w(TAG, "decryptFromStream failed: $e")
} }
return plainData return plainData
} }
@@ -570,7 +570,7 @@ object Utils {
} }
} }
} catch (e: IOException) { } catch (e: IOException) {
Log.e("Baresip", "Failed to zip file '$zipFilePath': $e") Log.e(TAG, "Failed to zip file '$zipFilePath': $e")
return false return false
} }
return true return true
@@ -592,7 +592,7 @@ object Utils {
} }
} }
} catch (e: IOException) { } catch (e: IOException) {
Log.e("Baresip", "Failed to unzip file '$zipFilePath': $e") Log.e(TAG, "Failed to unzip file '$zipFilePath': $e")
return false return false
} }
(allFiles - zipFiles).iterator().forEach { (allFiles - zipFiles).iterator().forEach {
@@ -605,12 +605,12 @@ object Utils {
val bundle: Bundle = intent.extras ?: return val bundle: Bundle = intent.extras ?: return
val keys = bundle.keySet() val keys = bundle.keySet()
val it = keys.iterator() val it = keys.iterator()
Log.d("Baresip", "Dumping intent start") Log.d(TAG, "Dumping intent start")
while (it.hasNext()) { while (it.hasNext()) {
val key = it.next() val key = it.next()
Log.d("Baresip", "[" + key + "=" + bundle.get(key) + "]") Log.d(TAG, "[" + key + "=" + bundle.get(key) + "]")
} }
Log.d("Baresip", "Dumping intent finish") Log.d(TAG, "Dumping intent finish")
} }
fun randomColor(): Int { fun randomColor(): Int {