added account_[set_]sipnat API functions

added ua_update_account API function
go directly to settings of new account
fixed some main activity layout bugs
keep main activity interactive when screen is locked
removed aor from UserAgent class
added register method to UserAgent class
added foregrounded and isDeviceLocked util functions
updated libbaresip distribution
This commit is contained in:
Juha Heinanen
2018-06-03 18:08:31 +03:00
parent d7e624bc40
commit d3c7ce29ca
10 changed files with 204 additions and 102 deletions
@@ -1,11 +1,17 @@
package com.tutpro.baresip
import android.app.ActivityManager
import android.content.Context
import android.support.v7.app.AlertDialog
import android.util.Log
import android.net.ConnectivityManager
import java.io.*
import android.os.Build
import android.os.PowerManager
import android.app.KeyguardManager
object Utils {
@@ -127,6 +133,30 @@ object Utils {
}
}
fun foregrounded(): Boolean {
val appProcessInfo = ActivityManager.RunningAppProcessInfo()
ActivityManager.getMyMemoryState(appProcessInfo);
return ((appProcessInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) or
(appProcessInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE))
}
fun isDeviceLocked(context: Context): Boolean {
val isLocked: Boolean
val keyguardManager = context.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
val inKeyguardRestrictedInputMode = keyguardManager.inKeyguardRestrictedInputMode()
if (inKeyguardRestrictedInputMode) {
isLocked = true
} else {
val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager
isLocked = !powerManager.isInteractive
}
Log.d("Baresip", "Now device is ${if (isLocked) "locked" else "unlocked"}")
return isLocked
}
external fun cmd_exec(cmd: String): Int
external fun uri_decode(uri: String): Boolean
external fun audio_codecs(): String