diff options
| author | Emīls <emils@mullvad.net> | 2020-04-28 12:27:28 +0100 |
|---|---|---|
| committer | Emīls <emils@mullvad.net> | 2020-04-28 12:30:42 +0100 |
| commit | 03029aedbc33bb1ddbda6f545f771aeb092e9bd0 (patch) | |
| tree | 13668f25f374dac5574caaac9c513a70e4279c8f | |
| parent | e1a1f1206cf7f7dfc7220c2d8c4abad36b6620d0 (diff) | |
| download | mullvadvpn-03029aedbc33bb1ddbda6f545f771aeb092e9bd0.tar.xz mullvadvpn-03029aedbc33bb1ddbda6f545f771aeb092e9bd0.zip | |
Pass resource directory to problem report
4 files changed, 32 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 66a55503d6..4c291bbc10 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt @@ -9,7 +9,7 @@ import kotlinx.coroutines.async const val PROBLEM_REPORT_FILE = "problem_report.txt" -class MullvadProblemReport(val logDirectory: File) { +class MullvadProblemReport(val logDirectory: File, val resourceDirectory: File) { private val problemReportPath = File(logDirectory, PROBLEM_REPORT_FILE) private var collectJob: Deferred<Boolean>? = null @@ -56,7 +56,8 @@ class MullvadProblemReport(val logDirectory: File) { sendProblemReport( userEmail, userMessage, - problemReportPath.absolutePath + problemReportPath.absolutePath, + resourceDirectory.absolutePath ) if (result) { @@ -81,6 +82,7 @@ class MullvadProblemReport(val logDirectory: File) { private external fun sendProblemReport( userEmail: String, userMessage: String, - reportPath: String + reportPath: String, + resourceDir: 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 524d4ab00d..60356f4b20 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt @@ -66,7 +66,7 @@ class MainActivity : FragmentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - problemReport = MullvadProblemReport(filesDir) + problemReport = MullvadProblemReport(filesDir, filesDir) setContentView(R.layout.main) diff --git a/mullvad-jni/src/lib.rs b/mullvad-jni/src/lib.rs index 89a4a4e1a0..d9ea3cb5a8 100644 --- a/mullvad-jni/src/lib.rs +++ b/mullvad-jni/src/lib.rs @@ -826,14 +826,21 @@ pub extern "system" fn Java_net_mullvad_mullvadvpn_dataproxy_MullvadProblemRepor userEmail: JString<'_>, userMessage: JString<'_>, outputPath: JString<'_>, + resourceDir: JString<'_>, ) -> jboolean { let env = JnixEnv::from(env); let user_email = String::from_java(&env, userEmail); let user_message = String::from_java(&env, userMessage); let output_path_string = String::from_java(&env, outputPath); + let resource_dir = String::from_java(&env, resourceDir); let output_path = Path::new(&output_path_string); - match mullvad_problem_report::send_problem_report(&user_email, &user_message, output_path) { + match mullvad_problem_report::send_problem_report( + &user_email, + &user_message, + output_path, + &resource_dir.as_ref(), + ) { Ok(()) => JNI_TRUE, Err(error) => { log::error!( diff --git a/mullvad-problem-report/src/lib.rs b/mullvad-problem-report/src/lib.rs index cf37e6cb0f..eaeafbbf85 100644 --- a/mullvad-problem-report/src/lib.rs +++ b/mullvad-problem-report/src/lib.rs @@ -251,6 +251,22 @@ pub fn send_problem_report( user_email: &str, user_message: &str, report_path: &Path, + #[cfg(target_os = "android")] resource_dir: &Path, +) -> Result<(), Error> { + #[cfg(not(target_os = "android"))] + let ca_path = mullvad_paths::resources::get_api_ca_path(); + + #[cfg(target_os = "android")] + let ca_path = resource_dir.join(mullvad_paths::resources::API_CA_FILENAME); + + send_problem_report_inner(user_email, user_message, report_path, &ca_path) +} + +pub fn send_problem_report_inner( + user_email: &str, + user_message: &str, + report_path: &Path, + ca_path: &Path, ) -> Result<(), Error> { let report_content = normalize_newlines( read_file_lossy(report_path, REPORT_MAX_SIZE).map_err(|source| { @@ -263,10 +279,8 @@ pub fn send_problem_report( let metadata = ProblemReport::parse_metadata(&report_content).unwrap_or_else(|| metadata::collect()); - let ca_path = mullvad_paths::resources::get_api_ca_path(); - - let mut rpc_manager = mullvad_rpc::MullvadRpcRuntime::new(ca_path.as_ref()) - .map_err(Error::CreateRpcClientError)?; + let mut rpc_manager = + mullvad_rpc::MullvadRpcRuntime::new(ca_path).map_err(Error::CreateRpcClientError)?; let rpc_client = mullvad_rpc::ProblemReportProxy::new(rpc_manager.mullvad_rest_handle()); rpc_client |
