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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user