summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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
}