summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-06-20 15:38:43 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-06-24 11:35:21 +0000
commitc4ecd93d4fd3dea702e8876f25fea0babddba380 (patch)
tree386e6aa531f2b14bb4d361efc276492585fc9328 /android
parent9d05edfe05d330e4fc8d2967fe3e31a0d3307991 (diff)
downloadmullvadvpn-c4ecd93d4fd3dea702e8876f25fea0babddba380.tar.xz
mullvadvpn-c4ecd93d4fd3dea702e8876f25fea0babddba380.zip
Add `MullvadProblemReport::collect` async method
Diffstat (limited to 'android')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt26
1 files changed, 26 insertions, 0 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt
index 502a57c93c..deb0af497e 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt
@@ -1,8 +1,17 @@
package net.mullvad.mullvadvpn.dataproxy
+import java.io.File
+
+import kotlinx.coroutines.async
+import kotlinx.coroutines.Deferred
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.GlobalScope
+
const val PROBLEM_REPORT_PATH = "/data/data/net.mullvad.mullvadvpn/problem_report.txt"
class MullvadProblemReport {
+ private var collectJob: Deferred<Boolean>? = null
+
var userEmail = ""
var userMessage = ""
@@ -10,5 +19,22 @@ class MullvadProblemReport {
System.loadLibrary("mullvad_jni")
}
+ fun collect() {
+ synchronized(this) {
+ val currentJob = collectJob
+
+ if (currentJob == null || currentJob.isCompleted) {
+ collectJob = GlobalScope.async(Dispatchers.Default) {
+ deleteReportFile()
+ collectReport(PROBLEM_REPORT_PATH)
+ }
+ }
+ }
+ }
+
+ private fun deleteReportFile() {
+ File(PROBLEM_REPORT_PATH).delete()
+ }
+
private external fun collectReport(reportPath: String): Boolean
}