- Added recordings to backup/restore
- Some code cleanup
This commit is contained in:
@ -92,6 +92,7 @@ class BaresipService: Service() {
|
||||
intent.setPackage("com.tutpro.baresip")
|
||||
|
||||
filesPath = filesDir.absolutePath
|
||||
pName = packageName
|
||||
|
||||
am = getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
|
||||
@ -576,7 +577,7 @@ class BaresipService: Service() {
|
||||
|
||||
if (ev[0] == "sndfile dump") {
|
||||
Log.d(TAG, "Got sndfile dump ${ev[1]}")
|
||||
if (Call.calls().size > 0)
|
||||
if (Call.inCall())
|
||||
Call.calls()[0].dumpfile = ev[1]
|
||||
return
|
||||
}
|
||||
@ -871,7 +872,7 @@ class BaresipService: Service() {
|
||||
call.onHoldCall = null
|
||||
}
|
||||
call.remove()
|
||||
if (Call.calls().size == 0) {
|
||||
if (!Call.inCall()) {
|
||||
resetCallVolume()
|
||||
abandonAudioFocus(am)
|
||||
Utils.clearCommunicationDevice(am)
|
||||
@ -1074,7 +1075,7 @@ class BaresipService: Service() {
|
||||
callActionUri = ""
|
||||
if (VERSION.SDK_INT >= 23)
|
||||
Log.d(TAG, "Battery optimizations are ignored: " +
|
||||
"${pm.isIgnoringBatteryOptimizations(applicationContext.packageName)}")
|
||||
"${pm.isIgnoringBatteryOptimizations(packageName)}")
|
||||
Log.d(TAG, "Partial wake lock/wifi lock is held: " +
|
||||
"${partialWakeLock.isHeld}/${wifiLock.isHeld}")
|
||||
updateStatusNotification()
|
||||
@ -1501,6 +1502,7 @@ class BaresipService: Service() {
|
||||
var callVolume = 0
|
||||
var dynDns = false
|
||||
var filesPath = ""
|
||||
var pName = ""
|
||||
var logLevel = 2
|
||||
var sipTrace = false
|
||||
var callActionUri = ""
|
||||
|
||||
@ -113,5 +113,9 @@ class Call(val callp: Long, val ua: UserAgent, val peerUri: String, val dir: Str
|
||||
return null
|
||||
}
|
||||
|
||||
fun inCall(): Boolean {
|
||||
return BaresipService.calls.isNotEmpty()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ class MainActivity : AppCompatActivity() {
|
||||
override fun onReceive(contxt: Context, intent: Intent) {
|
||||
if (kgm.isKeyguardLocked) {
|
||||
Log.d(TAG, "Screen on when locked")
|
||||
Utils.setShowWhenLocked(this@MainActivity, Call.calls().size > 0)
|
||||
Utils.setShowWhenLocked(this@MainActivity, Call.inCall())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -770,7 +770,7 @@ class MainActivity : AppCompatActivity() {
|
||||
restoreActivities()
|
||||
if (BaresipService.uas.size > 0) {
|
||||
if (aorSpinner.selectedItemPosition == -1) {
|
||||
if (Call.calls().size > 0)
|
||||
if (Call.inCall())
|
||||
spinToAor(Call.calls()[0].ua.account.aor)
|
||||
else {
|
||||
aorSpinner.setSelection(0)
|
||||
@ -839,7 +839,7 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun callAction(intent: Intent) {
|
||||
if (Call.calls().isNotEmpty() || BaresipService.uas.size == 0)
|
||||
if (Call.inCall() || BaresipService.uas.size == 0)
|
||||
return
|
||||
val uri: Uri? = intent.data
|
||||
if (uri != null) {
|
||||
@ -895,7 +895,7 @@ class MainActivity : AppCompatActivity() {
|
||||
return
|
||||
}
|
||||
"call" -> {
|
||||
if (Call.calls().isNotEmpty()) {
|
||||
if (Call.inCall()) {
|
||||
Toast.makeText(applicationContext, getString(R.string.call_already_active),
|
||||
Toast.LENGTH_SHORT).show()
|
||||
return
|
||||
@ -1293,7 +1293,7 @@ class MainActivity : AppCompatActivity() {
|
||||
when (item.itemId) {
|
||||
|
||||
R.id.recIcon -> {
|
||||
if (Call.call("connected") == null) {
|
||||
if (!Call.inCall()) {
|
||||
BaresipService.isRecOn = !BaresipService.isRecOn
|
||||
if (BaresipService.isRecOn) {
|
||||
item.setIcon(R.drawable.rec_on)
|
||||
@ -1302,6 +1302,12 @@ class MainActivity : AppCompatActivity() {
|
||||
item.setIcon(R.drawable.rec_off)
|
||||
Api.module_unload("sndfile")
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
R.string.rec_in_call,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1664,7 +1670,12 @@ class MainActivity : AppCompatActivity() {
|
||||
val files = arrayListOf("accounts", "history", "config", "contacts", "messages", "uuid",
|
||||
"gzrtp.zid", "cert.pem", "ca_cert", "ca_certs.crt")
|
||||
File(BaresipService.filesPath).walk().forEach {
|
||||
if (it.name.endsWith(".png")) files.add(it.name)
|
||||
if (it.name.endsWith(".png"))
|
||||
files.add(it.name)
|
||||
}
|
||||
File("${BaresipService.filesPath}/recordings").walk().forEach {
|
||||
if (it.name.startsWith("dump"))
|
||||
files.add("recordings/${it.name}")
|
||||
}
|
||||
val zipFile = getString(R.string.app_name) + ".zip"
|
||||
val zipFilePath = BaresipService.filesPath + "/$zipFile"
|
||||
@ -1805,7 +1816,7 @@ class MainActivity : AppCompatActivity() {
|
||||
callUri.setAdapter(null)
|
||||
val ua = BaresipService.uas[aorSpinner.selectedItemPosition]
|
||||
val aor = ua.account.aor
|
||||
if (Call.calls().isEmpty()) {
|
||||
if (!Call.inCall()) {
|
||||
var uriText = callUri.text.toString().trim()
|
||||
if (uriText.isNotEmpty()) {
|
||||
if (lookForContact) {
|
||||
@ -2075,7 +2086,7 @@ class MainActivity : AppCompatActivity() {
|
||||
BaresipService.activities.removeAt(0)
|
||||
when (activity[0]) {
|
||||
"main" -> {
|
||||
if ((Call.calls().size == 0) && (BaresipService.activities.size > 1))
|
||||
if (!Call.inCall() && (BaresipService.activities.size > 1))
|
||||
restoreActivities()
|
||||
}
|
||||
"config" -> {
|
||||
|
||||
@ -789,11 +789,11 @@ object Utils {
|
||||
try {
|
||||
ZipFile(zipFilePath).use { zip ->
|
||||
zip.entries().asSequence().forEach { entry ->
|
||||
if (!entry.name.contains("/com.tutpro.baresip/")) {
|
||||
Log.e(TAG, "Backup file is not from baresip application")
|
||||
if (!entry.name.contains("/${BaresipService.pName}/")) {
|
||||
Log.e(TAG, "Backup file is not from this application")
|
||||
return false
|
||||
}
|
||||
zipFiles.add(entry.name.substringAfterLast("/"))
|
||||
zipFiles.add(entry.name.substringAfter("/files/"))
|
||||
zip.getInputStream(entry).use { input ->
|
||||
File(entry.name).outputStream().use { output ->
|
||||
input.copyTo(output)
|
||||
|
||||
@ -475,6 +475,8 @@
|
||||
<string name="hold">Puhelu pitoon/pidosta</string>
|
||||
<string name="call_is_on_hold">Puhelu on pidossa</string>
|
||||
<string name="mic">Mikrofoni päälle/pois</string>
|
||||
<string name="rec_in_call">Tallennus voidaan asettaa päälle tai pois vain silloin, kun puhelu
|
||||
ei ole aktiivinen</string>
|
||||
<string name="call_transfer">Puhelun siirto</string>
|
||||
<string name="blind">Sokeasti</string>
|
||||
<string name="attended">Osallistu</string>
|
||||
|
||||
@ -448,6 +448,7 @@
|
||||
<string name="hold">Call Hold/Unhold</string>
|
||||
<string name="call_is_on_hold">Call is on hold</string>
|
||||
<string name="mic">Microphone On/Off</string>
|
||||
<string name="rec_in_call">Recording can be turned on or off only when not in call</string>
|
||||
<string name="call_transfer">Call Transfer</string>
|
||||
<string name="blind">Blind</string>
|
||||
<string name="attended">Attended</string>
|
||||
|
||||
Reference in New Issue
Block a user