message related enhancements

This commit is contained in:
Juha Heinanen
2018-07-25 14:00:17 +03:00
parent 80edbbc1d7
commit b016811a16
8 changed files with 96 additions and 28 deletions
@@ -319,14 +319,13 @@ class BaresipService: Service() {
@Keep
fun messageEvent(uap: String, peer: String, msg: ByteArray) {
Log.d(LOG_TAG, "message event $uap/$peer")
var s = "Decoding of message failed!"
try {
s = String(msg, StandardCharsets.UTF_8)
Log.d(LOG_TAG, "UTF-8 $s")
} catch (e: Exception) {
Log.e(LOG_TAG, "UTF-8 decode failed")
}
Log.d(LOG_TAG, "Message event $uap/$peer/$s")
val timeStamp = System.currentTimeMillis().toString()
if (!Utils.isVisible()) {
val cnb = NotificationCompat.Builder(this, HIGH_CHANNEL_ID)
@@ -383,6 +382,15 @@ class BaresipService: Service() {
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
}
@Keep
fun messageResponse(responseCode: Int, time: String) {
Log.d(LOG_TAG, "Message response $responseCode at $time")
val intent = Intent("message response")
intent.putExtra("response code", responseCode)
intent.putExtra("time", time)
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
}
private fun updateStatusNotification() {
val contentView = RemoteViews(getPackageName(), R.layout.status_notification)
for (i: Int in 0 .. 5) {