try to avoid loosing registrations by using ;expires=3600 and by registering
UAs every 10 minutes fixed account help clicks
This commit is contained in:
@@ -19,7 +19,7 @@ class AccountActivity : AppCompatActivity() {
|
||||
internal lateinit var authPass: EditText
|
||||
internal lateinit var outbound1: EditText
|
||||
internal lateinit var outbound2: EditText
|
||||
internal lateinit var regint: EditText
|
||||
internal lateinit var regCheck: CheckBox
|
||||
internal lateinit var mediaEnc: String
|
||||
|
||||
private var newCodecs = ArrayList<String>()
|
||||
@@ -50,8 +50,8 @@ class AccountActivity : AppCompatActivity() {
|
||||
outbound2.setText(acc.outbound[1])
|
||||
}
|
||||
|
||||
regint = findViewById(R.id.RegInt) as EditText
|
||||
regint.setText(acc.regint.toString())
|
||||
regCheck = findViewById(R.id.Register) as CheckBox
|
||||
regCheck.isChecked = acc.regint > 0
|
||||
|
||||
val audioCodecs = ArrayList(Api.audio_codecs().split(","))
|
||||
newCodecs.addAll(audioCodecs)
|
||||
@@ -206,22 +206,19 @@ class AccountActivity : AppCompatActivity() {
|
||||
save = true
|
||||
}
|
||||
|
||||
val ri = regint.text.toString().trim()
|
||||
if (Utils.checkUint(ri)) {
|
||||
if (ri.toInt() != acc.regint) {
|
||||
if (account_set_regint(acc.accp, ri.toInt()) == 0) {
|
||||
acc.regint = account_regint(acc.accp)
|
||||
Log.d("Baresip", "New regint is ${acc.regint}")
|
||||
save = true
|
||||
} else {
|
||||
Log.e("Baresip", "Setting of regint $ri failed")
|
||||
}
|
||||
var newRegint = -1
|
||||
if (regCheck.isChecked)
|
||||
if (acc.regint != 3600) newRegint = 3600
|
||||
else
|
||||
if (acc.regint != 0) newRegint = 0
|
||||
if (newRegint != -1)
|
||||
if (account_set_regint(acc.accp, newRegint) == 0) {
|
||||
acc.regint = account_regint(acc.accp)
|
||||
Log.d("Baresip", "New regint is ${acc.regint}")
|
||||
save = true
|
||||
} else {
|
||||
Log.e("Baresip", "Setting of regint failed")
|
||||
}
|
||||
} else {
|
||||
Utils.alertView(this, "Notice",
|
||||
"Invalid Registration Interval: $ri")
|
||||
return false
|
||||
}
|
||||
|
||||
val ac = ArrayList(LinkedHashSet<String>(newCodecs.filter { it != "" } as ArrayList<String>))
|
||||
if (ac != acc.audioCodec) {
|
||||
@@ -299,8 +296,8 @@ class AccountActivity : AppCompatActivity() {
|
||||
Utils.alertView(this, "Outbound Proxies",
|
||||
getString(R.string.obProxies))
|
||||
}
|
||||
findViewById(R.id.RegIntTitle) -> {
|
||||
Utils.alertView(this, "Registration Interval", getString(R.string.regInt))
|
||||
findViewById(R.id.RegTitle) -> {
|
||||
Utils.alertView(this, "Register", getString(R.string.register))
|
||||
}
|
||||
findViewById(R.id.AudioCodecsTitle) -> {
|
||||
Utils.alertView(this, "Audio Codecs", getString(R.string.auCodecs))
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.net.NetworkInfo
|
||||
import android.os.Handler
|
||||
import android.os.IBinder
|
||||
import android.support.annotation.Keep
|
||||
import android.support.v4.app.NotificationCompat
|
||||
@@ -116,6 +117,16 @@ class BaresipService: Service() {
|
||||
BaresipService.IS_SERVICE_RUNNING = true
|
||||
registerReceiver(nr, IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"))
|
||||
showNotification()
|
||||
|
||||
val handler = Handler()
|
||||
val delay = 1000 * 600L
|
||||
handler.postDelayed(object : Runnable {
|
||||
override fun run() {
|
||||
Log.d(LOG_TAG, "Handler based registration")
|
||||
UserAgent.register(MainActivity.uas)
|
||||
handler.postDelayed(this, delay)
|
||||
}
|
||||
}, delay)
|
||||
}
|
||||
|
||||
"UpdateNotification" -> {
|
||||
|
||||
@@ -9,9 +9,6 @@ class UserAgent (val uap: String) {
|
||||
fun register() {
|
||||
if (account.regint > 0) {
|
||||
Log.d("Baresip", "Registering ${account.aor} UA ${uap}")
|
||||
val accp = ua_account(uap)
|
||||
val reg_int = account_regint(accp)
|
||||
Log.d("Baresip", "reg_int is $reg_int")
|
||||
if (ua_register(uap) != 0)
|
||||
Log.e("Baresip", "Registering failed")
|
||||
}
|
||||
@@ -52,8 +49,9 @@ class UserAgent (val uap: String) {
|
||||
|
||||
fun register(uas: ArrayList<UserAgent>) {
|
||||
for (ua in uas) {
|
||||
if (ua_register(ua.uap) != 0)
|
||||
Log.e("Baresip", "Failed to register ${ua.account.aor}")
|
||||
if (ua.account.regint > 0)
|
||||
if (ua_register(ua.uap) != 0)
|
||||
Log.e("Baresip", "Failed to register ${ua.account.aor}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user