diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-06-01 16:35:18 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-06-01 16:35:18 -0300 |
| commit | 3b59a0ae1ca0cd725b166a843364712956bf3335 (patch) | |
| tree | 142836d711dd37e6bced113359a07a588bc82a18 | |
| parent | 28033c96a8e1a3718b5e3161506b6abc387d0ca5 (diff) | |
| parent | fef23fc3d9b3580d731e7d4241926aebaf942801 (diff) | |
| download | mullvadvpn-3b59a0ae1ca0cd725b166a843364712956bf3335.tar.xz mullvadvpn-3b59a0ae1ca0cd725b166a843364712956bf3335.zip | |
Merge branch 'fix-problem-report-uninitialized-crash'
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt | 35 | ||||
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt | 5 |
3 files changed, 31 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f88dfad12..ff057c6346 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ Line wrap the file at 100 chars. Th - Fix time left in account not showing in settings screen. - Fix attempt to connect when the app doesn't have the VPN permission. - Fix crash that happened sometimes when the WireGuard key was loaded too quickly. +- Fix crash when entering split-screen mode whilst on the Report a Problem screen. #### Windows - Fix race in network adapter monitor that could result in data corruption and crashes. 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 66a55503d6..97e6559bd4 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt @@ -5,15 +5,22 @@ import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.Deferred import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.Job import kotlinx.coroutines.async +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 + private var deleteJob: Job? = null var confirmNoEmail: CompletableDeferred<Boolean>? = null @@ -39,8 +46,11 @@ class MullvadProblemReport(val logDirectory: File) { synchronized(this) { if (!isActive) { collectJob = GlobalScope.async(Dispatchers.Default) { - deleteReportFile() - collectReport(logDirectory.absolutePath, problemReportPath.absolutePath) + val logDirectoryPath = logDirectory.await().absolutePath + val reportPath = problemReportPath.await().absolutePath + + deleteReportFile().join() + collectReport(logDirectoryPath, reportPath) } } } @@ -56,7 +66,7 @@ class MullvadProblemReport(val logDirectory: File) { sendProblemReport( userEmail, userMessage, - problemReportPath.absolutePath + problemReportPath.await().absolutePath ) if (result) { @@ -73,8 +83,19 @@ class MullvadProblemReport(val logDirectory: File) { } } - fun deleteReportFile() { - problemReportPath.delete() + fun deleteReportFile(): Job { + synchronized(this) { + val oldDeleteJob = deleteJob + + val job = GlobalScope.launch(Dispatchers.Default) { + oldDeleteJob?.join() + problemReportPath.await().delete() + } + + deleteJob = job + + return job + } } private external fun collectReport(logDirectory: String, reportPath: String): Boolean 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) |
