- Ranamed Main Activity Export/Import to Backup/Restore.

- Removed export/import of accounts and contacts.
This commit is contained in:
Juha Heinanen
2019-10-09 21:21:04 +03:00
parent e9f37b5c26
commit 4d48ac82f9
11 changed files with 96 additions and 223 deletions
@@ -280,7 +280,10 @@ object Utils {
fun deleteFile(filePath: String) {
val file = File(filePath)
if (file.exists()) file.delete()
if (file.exists()) {
Log.d("Baresip", "Deleting file '$filePath'")
file.delete()
}
}
fun getFileContents(filePath: String): ByteArray? {
@@ -411,9 +414,13 @@ object Utils {
}
fun unZip(zipFilePath: String): Boolean {
val allFiles = listOf("accounts", "config", "contacts", "history", "messages", "uuid",
"zrtp_cache.dat", "zrtp_zid", "cert.pem", "ca_cert", "ca_certs.crt")
val zipFiles = mutableListOf<String>()
try {
ZipFile(zipFilePath).use { zip ->
zip.entries().asSequence().forEach { entry ->
zipFiles.add(entry.name.substringAfterLast("/"))
zip.getInputStream(entry).use { input ->
File(entry.name).outputStream().use { output ->
input.copyTo(output)
@@ -425,6 +432,9 @@ object Utils {
Log.e("Baresip", "Failed to unzip file '$zipFilePath': $e")
return false
}
(allFiles - zipFiles).iterator().forEach {
deleteFile(BaresipService.filesPath + "/$it")
}
return true
}