diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt
index 296e6f95..ca1885cb 100644
--- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt
+++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt
@@ -642,7 +642,11 @@ class BaresipService: Service() {
fun stopped(error: String) {
Log.d(LOG_TAG, "'stopped' from baresip with error $error")
isServiceRunning = false
- if (error == "ua_init") Config.remove("sip_listen")
+ if (error == "ua_init") {
+ Config.remove("sip_listen")
+ Config.remove("sip_certificate")
+ Config.remove("sip_cafile")
+ }
val intent = Intent("service event")
intent.putExtra("event", "stopped")
intent.putExtra("params", arrayListOf(error))
diff --git a/app/src/main/kotlin/com/tutpro/baresip/ConfigActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/ConfigActivity.kt
index bfe38483..2849725e 100644
--- a/app/src/main/kotlin/com/tutpro/baresip/ConfigActivity.kt
+++ b/app/src/main/kotlin/com/tutpro/baresip/ConfigActivity.kt
@@ -6,18 +6,23 @@ import android.content.Intent
import android.net.ConnectivityManager
import android.os.Build
import android.os.Bundle
+import android.os.Environment
import android.support.v7.app.AppCompatActivity
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.*
+import java.io.File
+
class ConfigActivity : AppCompatActivity() {
internal lateinit var autoStart: CheckBox
internal lateinit var listenAddr: EditText
internal lateinit var preferIPv6: CheckBox
internal lateinit var dnsServers: EditText
+ internal lateinit var certificateFile: CheckBox
+ internal lateinit var caFile: CheckBox
internal lateinit var aec: CheckBox
internal lateinit var opusBitRate: EditText
internal lateinit var iceLite: CheckBox
@@ -28,6 +33,8 @@ class ConfigActivity : AppCompatActivity() {
private var oldListenAddr = ""
private var oldPreferIPv6 = ""
private var oldDnsServers = ""
+ private var oldCertificateFile = false
+ private var oldCAFile = false
private var oldAec = false
private var oldOpusBitrate = ""
private var oldIceMode = ""
@@ -35,6 +42,8 @@ class ConfigActivity : AppCompatActivity() {
private var callVolume = BaresipService.callVolume
private var save = false
private var restart = false
+ private var downloadsDir =
+ Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
override fun onCreate(savedInstanceState: Bundle?) {
@@ -68,6 +77,14 @@ class ConfigActivity : AppCompatActivity() {
}
dnsServers.setText(oldDnsServers)
+ certificateFile = findViewById(R.id.CertificateFile) as CheckBox
+ oldCertificateFile = Config.variable("sip_certificate").isNotEmpty()
+ certificateFile.isChecked = oldCertificateFile
+
+ caFile = findViewById(R.id.CAFile) as CheckBox
+ oldCAFile = Config.variable("sip_cafile").isNotEmpty()
+ caFile.isChecked = oldCAFile
+
aec = findViewById(R.id.Aec) as CheckBox
val aecCv = Config.variable("module")
oldAec = aecCv.contains("webrtc_aec.so")
@@ -190,6 +207,56 @@ class ConfigActivity : AppCompatActivity() {
save = true
}
+ if (certificateFile.isChecked != oldCertificateFile) {
+ if (certificateFile.isChecked) {
+ if (!Utils.checkPermission(applicationContext,
+ android.Manifest.permission.READ_EXTERNAL_STORAGE)) {
+ Utils.alertView(this, getString(R.string.error),
+ getString(R.string.no_storage_space_permission))
+ return false
+ }
+ val content = Utils.getFileContents(File(downloadsDir, "cert.pem"))
+ if (content == "Failed") {
+ Utils.alertView(this, getString(R.string.error),
+ getString(R.string.read_cert_error))
+ return false
+ }
+ Utils.putFileContents(File(BaresipService.filesPath + "/cert.pem"),
+ content)
+ Config.remove("sip_certificate")
+ Config.add("sip_certificate", BaresipService.filesPath + "/cert.pem")
+ } else {
+ Config.remove("sip_certificate")
+ }
+ save = true
+ restart = true
+ }
+
+ if (caFile.isChecked != oldCAFile) {
+ if (caFile.isChecked) {
+ if (!Utils.checkPermission(applicationContext,
+ android.Manifest.permission.READ_EXTERNAL_STORAGE)) {
+ Utils.alertView(this, getString(R.string.error),
+ getString(R.string.no_storage_space_permission))
+ return false
+ }
+ val content = Utils.getFileContents(File(downloadsDir, "ca_certs.crt"))
+ if (content == "Failed") {
+ Utils.alertView(this, getString(R.string.error),
+ getString(R.string.read_ca_certs_error))
+ return false
+ }
+ Utils.putFileContents(File(BaresipService.filesPath + "/ca_certs.crt"),
+ content)
+ Config.remove("sip_cafile")
+ Config.add("sip_cafile", BaresipService.filesPath + "/ca_certs.crt")
+ } else {
+ Config.remove("sip_cafile")
+ }
+ save = true
+ restart = true
+ }
+
if (aec.isChecked != oldAec) {
Config.remove("module webrtc_aec.so")
if (aec.isChecked) {
@@ -280,6 +347,14 @@ class ConfigActivity : AppCompatActivity() {
Utils.alertView(this, getString(R.string.dns_servers),
getString(R.string.dns_servers_help))
}
+ findViewById(R.id.CertificateFileTitle) as TextView -> {
+ Utils.alertView(this, getString(R.string.tls_certificate_file),
+ getString(R.string.tls_certificate_file_help))
+ }
+ findViewById(R.id.CAFileTitle) as TextView -> {
+ Utils.alertView(this, getString(R.string.tls_ca_file),
+ getString(R.string.tls_ca_file_help))
+ }
findViewById(R.id.AecTitle) as TextView-> {
Utils.alertView(this, getString(R.string.aec),
getString(R.string.aec_help))
diff --git a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt
index c22819a0..9ee11661 100644
--- a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt
+++ b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt
@@ -50,7 +50,6 @@ object Utils {
e.toString())
return "Failed"
}
-
}
}
@@ -321,6 +320,10 @@ object Utils {
}
}
+ fun checkPermission(ctx: Context, permission: String) : Boolean {
+ return ContextCompat.checkSelfPermission(ctx, permission) == PackageManager.PERMISSION_GRANTED
+ }
+
fun requestPermission(ctx: Context, permission: String) : Boolean {
if (ContextCompat.checkSelfPermission(ctx, permission) != PackageManager.PERMISSION_GRANTED) {
Log.w("Baresip", "Baresip does not have $permission permission")
diff --git a/app/src/main/res/layout/activity_config.xml b/app/src/main/res/layout/activity_config.xml
index 09724103..4688330a 100644
--- a/app/src/main/res/layout/activity_config.xml
+++ b/app/src/main/res/layout/activity_config.xml
@@ -112,6 +112,62 @@
android:importantForAutofill="no" >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Jos merkitty, oletuskonfiguraatio palautetaan, kun
baresip seuraavan kerran käynnistetään.
+ Tiedoston \'cert.pem\' luku Download-kansiosta epäonnistui.
+ Tiedoston \'ca_certs.crt\' luku Download-kansiosta epäonnistui.
Kontakti
Uusi kontakti
@@ -286,7 +288,8 @@
Numeronäppäimistö
Sinulla on jo puhelu käynnissä.
Sovelluksen käynnistäminen
- epäonnistui. Kuunteluosoiteen oletusarvo palautettu. Käynnistä
+ epäonnistui. Tämä voi johtua virheellisestä kuunteluosoitteesta tai
+ TLS sertifikaattitiedostosta. Niiden oletusarvot on palautettu. Käynnistä
baresip uudelleen.
Tilin \'%1$s\' rekisteröinti
@@ -312,4 +315,9 @@
Tämä pulelu on turvallinen ja kohde on
todennettu! Haluatko poistaa todennuksen?
Poista todennus
+ Et ole antanut käyttölupaa tallennustilaan. Tarkista Sovellukset → baresip → Käyttöluvat → Tallennustila.
+ TLS CA-tiedosto
+ Jos merkitty, tiedosto \'ca_certs.crt\', joka sisältää todennusauktoriteettien TLS-sertifikaatit, on ladattu tai ladataan Download-kansiosta.
+ TLS sertifikaattitiedosto
+ "Jos merkitty, tiedosto \'cert.pem\', joka sisältää tämän baresip-sovelluksen TLS-sertifikaatin ja yksityisen avaimen, on ladattu tai ladataan Download-kansiosta."
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 981d2763..cb19d93a 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -144,6 +144,10 @@ Check Apps → baresip → Permissions → Storage and that file \'accounts.bs\'
add peer to contacts?
Do you want to delete chat with \'%1$s\'?
+
+ You have not granted storage space permission.
+ Check Apps → baresip → Permissions → Storage.
+
Configuration
Start Automatically
@@ -165,6 +169,13 @@ Check Apps → baresip → Permissions → Storage and that file \'accounts.bs\'
also port is given, ip must
be written inside brackets []. As an example, list \'8.8.8.8:53,[2001:4860:4860::8888]:53\'
points to IPv4 and IPv6 addresses of public Google DNS servers.
+ TLS Certificate File
+ If checked, file \'cert.pem\' containing
+ TLS certificate and private key of this baresip instance has been or will be loaded from
+ Download directory. For security reasons, delete the file after loading.
+ TLS CA File
+ If checked, file \'ca_certs.crt\' containing TLS certificates
+ of Certificate Authorities has been or will be loaded from Download directory.
Acoustic Echo Cancellation
If checked, echo cancellation is attempted on call audio.
Opus Bit Rate
@@ -179,7 +190,9 @@ Check Apps → baresip → Permissions → Storage and that file \'accounts.bs\'
Provides debug and info level log message availability in Logcat.
Reset to Factory Defaults
If checked, configuration is reset
- to factory default values.
+ to factory default values.
+ Failed to read file \'cert.pem\' from Download directory.
+ Failed to read file \'ca_certs.crt\' from Download directory.
Contact
@@ -255,8 +268,8 @@ Check Apps → baresip → Permissions → Storage and that file \'contacts.bs\'
Messages
Dialpad
You already have an active call.
- Baresip failed to start. Listen Address was reset.
- Restart baresip.
+ Baresip failed to start. This may be due to invalid Listen Address
+ or TLS file. They have been reset. Restart baresip.
Registering of \`%1$s\` failed.
You have not granted microphone permission.
Verify