Clear recordings from call history after restore

Improved handling of call recording merge
This commit is contained in:
Juha Heinanen
2025-12-06 08:22:18 +02:00
parent f551048a6e
commit 1bd304fee9
@@ -463,6 +463,13 @@ class BaresipService: Service() {
} }
} }
val restored = File(filesPath, "restored")
if (restored.exists()) {
CallHistoryNew.clearRecordings()
CallHistoryNew.save()
restored.delete()
}
Message.restore() Message.restore()
hotSpotAddresses = Utils.hotSpotAddresses() hotSpotAddresses = Utils.hotSpotAddresses()
@@ -1099,17 +1106,20 @@ class BaresipService: Service() {
history.stopTime = GregorianCalendar() history.stopTime = GregorianCalendar()
history.startTime = if (completedElsewhere) history.stopTime else call.startTime history.startTime = if (completedElsewhere) history.stopTime else call.startTime
history.rejected = call.rejected history.rejected = call.rejected
if (call.dumpfiles[0] != "") {
history.recording = call.dumpfiles
}
history.add()
CoroutineScope(Dispatchers.IO).launch { CoroutineScope(Dispatchers.IO).launch {
if (call.startTime != null && call.dumpfiles[0] != "") { if (call.startTime != null && call.dumpfiles[0] != "") {
delay(500) delay(500)
val rxFile = File(call.dumpfiles[0]) val rxFile = File(call.dumpfiles[0])
val txFile = File(call.dumpfiles[1]) val txFile = File(call.dumpfiles[1])
val mergedFile = File(filesPath, "${rxFile.nameWithoutExtension}_stereo.wav") val mergedFile = File(filesPath, "${rxFile.nameWithoutExtension}_stereo.wav")
if (Utils.mergeWavFiles(rxFile, txFile, mergedFile)) { if (Utils.mergeWavFiles(rxFile, txFile, mergedFile)) {
Log.d(TAG, "Automatic merge succeeded.") Log.d(TAG, "Automatic merge succeeded.")
history.recording = arrayOf(mergedFile.absolutePath, "") history.recording = arrayOf(mergedFile.absolutePath, "")
CallHistoryNew.save()
try { try {
rxFile.delete() rxFile.delete()
txFile.delete() txFile.delete()
@@ -1121,9 +1131,7 @@ class BaresipService: Service() {
history.recording = call.dumpfiles history.recording = call.dumpfiles
} }
} }
history.add()
} }
ua.account.missedCalls = ua.account.missedCalls || missed ua.account.missedCalls = ua.account.missedCalls || missed
} }
if (!Utils.isVisible()) { if (!Utils.isVisible()) {