diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-04-17 20:49:23 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-04-22 13:46:49 +0000 |
| commit | 8a0b8a8ba868fa2aeebf4cd183f76ec86f9df642 (patch) | |
| tree | 17764e033390662985c04cf1f691a248a35b4681 /android/src/main | |
| parent | 25207a598a6c088dcb71a5e06efb1eaee3274b3d (diff) | |
| download | mullvadvpn-8a0b8a8ba868fa2aeebf4cd183f76ec86f9df642.tar.xz mullvadvpn-8a0b8a8ba868fa2aeebf4cd183f76ec86f9df642.zip | |
Store problem report file in app's files directory
Diffstat (limited to 'android/src/main')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt | 16 | ||||
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt | 6 |
2 files changed, 16 insertions, 6 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 40e93ff882..2e8b89642f 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt @@ -7,9 +7,11 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.async -const val PROBLEM_REPORT_PATH = "/data/data/net.mullvad.mullvadvpn/problem_report.txt" +const val PROBLEM_REPORT_FILE = "problem_report.txt" + +class MullvadProblemReport(val logDirectory: File) { + private val problemReportPath = File(logDirectory, PROBLEM_REPORT_FILE) -class MullvadProblemReport { private var collectJob: Deferred<Boolean>? = null private var sendJob: Deferred<Boolean>? = null @@ -38,7 +40,7 @@ class MullvadProblemReport { if (!isActive) { collectJob = GlobalScope.async(Dispatchers.Default) { deleteReportFile() - collectReport(PROBLEM_REPORT_PATH) + collectReport(problemReportPath.absolutePath) } } } @@ -51,7 +53,11 @@ class MullvadProblemReport { if (currentJob == null || currentJob.isCompleted) { currentJob = GlobalScope.async(Dispatchers.Default) { val result = (collectJob?.await() ?: false) && - sendProblemReport(userEmail, userMessage, PROBLEM_REPORT_PATH) + sendProblemReport( + userEmail, + userMessage, + problemReportPath.absolutePath + ) if (result) { deleteReportFile() @@ -68,7 +74,7 @@ class MullvadProblemReport { } fun deleteReportFile() { - File(PROBLEM_REPORT_PATH).delete() + problemReportPath.delete() } private external fun collectReport(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 93b85c001b..524d4ab00d 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt @@ -19,9 +19,10 @@ 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 serviceConnectionSubscription: Int? = null @@ -64,6 +65,9 @@ class MainActivity : FragmentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + + problemReport = MullvadProblemReport(filesDir) + setContentView(R.layout.main) if (savedInstanceState == null) { |
