diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-06-01 15:15:33 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-06-01 19:03:03 +0000 |
| commit | 6819c1b21e0982765cbcd81fafb7a1f770452974 (patch) | |
| tree | 32c7763b56fe1171e60a7fd3bad65cd943c04bc9 /android/src | |
| parent | 4361bd5a454a9cff85d5e0d85300d04242028e50 (diff) | |
| download | mullvadvpn-6819c1b21e0982765cbcd81fafb7a1f770452974.tar.xz mullvadvpn-6819c1b21e0982765cbcd81fafb7a1f770452974.zip | |
Fix access to uninitialized problem report object
Diffstat (limited to 'android/src')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt | 17 | ||||
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt | 5 |
2 files changed, 14 insertions, 8 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 82d213bb65..97e6559bd4 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt @@ -11,8 +11,12 @@ import kotlinx.coroutines.launch const val PROBLEM_REPORT_FILE = "problem_report.txt" -class MullvadProblemReport(val logDirectory: File) { - private val problemReportPath = File(logDirectory, PROBLEM_REPORT_FILE) +class MullvadProblemReport { + val logDirectory = CompletableDeferred<File>() + + private val problemReportPath = GlobalScope.async(Dispatchers.Default) { + File(logDirectory.await(), PROBLEM_REPORT_FILE) + } private var collectJob: Deferred<Boolean>? = null private var sendJob: Deferred<Boolean>? = null @@ -42,8 +46,11 @@ class MullvadProblemReport(val logDirectory: File) { synchronized(this) { if (!isActive) { collectJob = GlobalScope.async(Dispatchers.Default) { + val logDirectoryPath = logDirectory.await().absolutePath + val reportPath = problemReportPath.await().absolutePath + deleteReportFile().join() - collectReport(logDirectory.absolutePath, problemReportPath.absolutePath) + collectReport(logDirectoryPath, reportPath) } } } @@ -59,7 +66,7 @@ class MullvadProblemReport(val logDirectory: File) { sendProblemReport( userEmail, userMessage, - problemReportPath.absolutePath + problemReportPath.await().absolutePath ) if (result) { @@ -82,7 +89,7 @@ class MullvadProblemReport(val logDirectory: File) { val job = GlobalScope.launch(Dispatchers.Default) { oldDeleteJob?.join() - problemReportPath.delete() + problemReportPath.await().delete() } deleteJob = job diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt index d3fca15be7..a4595a9a92 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt @@ -20,10 +20,9 @@ class MainActivity : FragmentActivity() { val KEY_SHOULD_CONNECT = "should_connect" } + val problemReport = MullvadProblemReport() val serviceNotifier = EventNotifier<ServiceConnection?>(null) - lateinit var problemReport: MullvadProblemReport - private var service: MullvadVpnService.LocalBinder? = null private var serviceConnection: ServiceConnection? = null private var shouldConnect = false @@ -60,7 +59,7 @@ class MainActivity : FragmentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - problemReport = MullvadProblemReport(filesDir) + problemReport.logDirectory.complete(filesDir) setContentView(R.layout.main) |
