diff --git a/app/src/main/kotlin/com/tutpro/baresip/CallHistory.kt b/app/src/main/kotlin/com/tutpro/baresip/CallHistory.kt index cc8eacd9..6be81d16 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/CallHistory.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/CallHistory.kt @@ -84,7 +84,9 @@ class CallHistoryNew(val aor: String, val peerUri: String, val direction: String val fis = FileInputStream(file) val ois = ObjectInputStream(fis) @Suppress("UNCHECKED_CAST") - BaresipService.callHistory = ois.readObject() as ArrayList + val restoredHistory = ois.readObject() as? List + if (restoredHistory != null) + BaresipService.callHistory = ArrayList(restoredHistory) ois.close() fis.close() Log.d(TAG, "Restored history of ${BaresipService.callHistory.size} calls") @@ -132,7 +134,9 @@ class CallHistory(val aor: String, val peerUri: String, val direction: String) : val fis = FileInputStream(file) val ois = ObjectInputStream(fis) @Suppress("UNCHECKED_CAST") - result = ois.readObject() as ArrayList + val restoredHistory = ois.readObject() as? List + if (restoredHistory != null) + result = ArrayList(restoredHistory) ois.close() fis.close() Log.d(TAG, "Got history of ${result.size} calls") diff --git a/app/src/main/kotlin/com/tutpro/baresip/Message.kt b/app/src/main/kotlin/com/tutpro/baresip/Message.kt index d175951c..bf27a753 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/Message.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/Message.kt @@ -123,7 +123,9 @@ class Message(val aor: String, val peerUri: String, val message: String, val tim val fis = FileInputStream(file) val ois = ObjectInputStream(fis) @Suppress("UNCHECKED_CAST") - BaresipService.messages = ois.readObject() as ArrayList + val restoredMessages = ois.readObject() as? List + if (restoredMessages != null) + BaresipService.messages = restoredMessages ois.close() fis.close() Log.d(TAG, "Restored ${BaresipService.messages.size} messages")