diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-04-17 20:58:15 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-04-22 13:46:49 +0000 |
| commit | 36e1fafdba17d81fd939e5a70d4610a54a9bb79b (patch) | |
| tree | 824d04e722f31d79acd9bcf6698a7d586a095fdc | |
| parent | 8a0b8a8ba868fa2aeebf4cd183f76ec86f9df642 (diff) | |
| download | mullvadvpn-36e1fafdba17d81fd939e5a70d4610a54a9bb79b.tar.xz mullvadvpn-36e1fafdba17d81fd939e5a70d4610a54a9bb79b.zip | |
Remove hard-coded log directory for problem report
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt | 4 | ||||
| -rw-r--r-- | mullvad-jni/src/lib.rs | 5 | ||||
| -rw-r--r-- | mullvad-problem-report/src/lib.rs | 22 |
3 files changed, 22 insertions, 9 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 2e8b89642f..66a55503d6 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt @@ -40,7 +40,7 @@ class MullvadProblemReport(val logDirectory: File) { if (!isActive) { collectJob = GlobalScope.async(Dispatchers.Default) { deleteReportFile() - collectReport(problemReportPath.absolutePath) + collectReport(logDirectory.absolutePath, problemReportPath.absolutePath) } } } @@ -77,7 +77,7 @@ class MullvadProblemReport(val logDirectory: File) { problemReportPath.delete() } - private external fun collectReport(reportPath: String): Boolean + private external fun collectReport(logDirectory: String, reportPath: String): Boolean private external fun sendProblemReport( userEmail: String, userMessage: String, diff --git a/mullvad-jni/src/lib.rs b/mullvad-jni/src/lib.rs index 3ead52febe..90fcc1a482 100644 --- a/mullvad-jni/src/lib.rs +++ b/mullvad-jni/src/lib.rs @@ -797,13 +797,16 @@ pub extern "system" fn Java_net_mullvad_mullvadvpn_service_MullvadDaemon_updateR pub extern "system" fn Java_net_mullvad_mullvadvpn_dataproxy_MullvadProblemReport_collectReport( env: JNIEnv<'_>, _: JObject<'_>, + logDirectory: JString<'_>, outputPath: JString<'_>, ) -> jboolean { let env = JnixEnv::from(env); + let log_dir_string = String::from_java(&env, logDirectory); + let log_dir = Path::new(&log_dir_string); let output_path_string = String::from_java(&env, outputPath); let output_path = Path::new(&output_path_string); - match mullvad_problem_report::collect_report(&[], output_path, Vec::new()) { + match mullvad_problem_report::collect_report(&[], output_path, Vec::new(), log_dir) { Ok(()) => JNI_TRUE, Err(error) => { log::error!( diff --git a/mullvad-problem-report/src/lib.rs b/mullvad-problem-report/src/lib.rs index 96d181bc11..bac11df5dc 100644 --- a/mullvad-problem-report/src/lib.rs +++ b/mullvad-problem-report/src/lib.rs @@ -100,12 +100,22 @@ pub fn collect_report( extra_logs: &[&Path], output_path: &Path, redact_custom_strings: Vec<String>, + #[cfg(target_os = "android")] android_log_dir: &Path, ) -> Result<(), Error> { let mut problem_report = ProblemReport::new(redact_custom_strings); - let daemon_logs = mullvad_paths::get_log_dir() - .map_err(LogError::GetLogDir) - .and_then(list_logs); + let daemon_logs_dir = { + #[cfg(target_os = "android")] + { + Ok(android_log_dir.to_owned()) + } + #[cfg(not(target_os = "android"))] + { + mullvad_paths::get_log_dir().map_err(LogError::GetLogDir) + } + }; + + let daemon_logs = daemon_logs_dir.and_then(list_logs); match daemon_logs { Ok(daemon_logs) => { let mut other_logs = Vec::new(); @@ -144,7 +154,7 @@ pub fn collect_report( None => {} } #[cfg(target_os = "android")] - match write_logcat_to_file() { + match write_logcat_to_file(android_log_dir) { Ok(logcat_path) => problem_report.add_log(&logcat_path), Err(error) => problem_report.add_error("Failed to collect logcat", &error), } @@ -227,8 +237,8 @@ fn is_tunnel_log(path: &Path) -> bool { } #[cfg(target_os = "android")] -fn write_logcat_to_file() -> Result<PathBuf, io::Error> { - let logcat_path = PathBuf::from("/data/data/net.mullvad.mullvadvpn/logcat.txt"); +fn write_logcat_to_file(log_dir: &Path) -> Result<PathBuf, io::Error> { + let logcat_path = log_dir.join("logcat.txt"); duct::cmd!("logcat", "-d") .stderr_to_stdout() |
