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}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,8 +21,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@android:color/black"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:onClick="onClick"
|
||||
android:text="Display Name" >
|
||||
</TextView>
|
||||
|
||||
@ -41,6 +40,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@android:color/black"
|
||||
android:onClick="onClick"
|
||||
android:text="Authentication Username" >
|
||||
</TextView>
|
||||
|
||||
@ -58,6 +58,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@android:color/black"
|
||||
android:onClick="onClick"
|
||||
android:text="Authentication Password" >
|
||||
</TextView>
|
||||
|
||||
@ -76,6 +77,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@android:color/black"
|
||||
android:onClick="onClick"
|
||||
android:text="Outbound Proxies" >
|
||||
</TextView>
|
||||
|
||||
@ -97,22 +99,27 @@
|
||||
android:layout_width="fill_parent">
|
||||
</EditText>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/RegIntTitle"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@android:color/black"
|
||||
android:text="Registration Interval (sec)" >
|
||||
</TextView>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/RegInt"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:inputType="number"
|
||||
android:layout_width="fill_parent">
|
||||
</EditText>
|
||||
android:orientation="horizontal" >
|
||||
<TextView
|
||||
android:id="@+id/RegTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@android:color/black"
|
||||
android:onClick="onClick"
|
||||
android:text="Register" >
|
||||
</TextView>
|
||||
<CheckBox
|
||||
android:id="@+id/Register"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
android:checked="false" >
|
||||
</CheckBox>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/AudioCodecsTitle"
|
||||
@ -120,6 +127,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@android:color/black"
|
||||
android:onClick="onClick"
|
||||
android:text="Audio Codecs" >
|
||||
</TextView>
|
||||
|
||||
@ -137,6 +145,7 @@
|
||||
android:paddingTop="10dp"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@android:color/black"
|
||||
android:onClick="onClick"
|
||||
android:text="Media Encryption" >
|
||||
</TextView>
|
||||
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
one that responds. If no outbound proxy is given, requests are sent based on
|
||||
DNS NAPTR/SRV/A record lookup of callee URI hostpart.\nExample:\nsip:foo.com:5060;transport=tls
|
||||
</string>
|
||||
<string name="regInt">Tells how often (in seconds) REGISTER requests are sent. Value 0
|
||||
disables registration.
|
||||
<string name="register">If checked, registration is enabled and REGISTER requests are sent at
|
||||
10 minute intervals.
|
||||
</string>
|
||||
<string name="auCodecs">List of supported audio codecs in priority order.</string>
|
||||
<string name="mediaEnc">Selects media transport encryption protocol.\n
|
||||
|
||||
Reference in New Issue
Block a user