summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-03-05 15:30:13 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-04-03 16:46:18 +0000
commit25fe46d117b9d2d1a6457352961f62aa01d82a13 (patch)
treeae097ea23391356e88304067aebfdbe38b480729
parent9b726d845ce3a7a3d18b250d3193ce436be6d92d (diff)
downloadmullvadvpn-25fe46d117b9d2d1a6457352961f62aa01d82a13.tar.xz
mullvadvpn-25fe46d117b9d2d1a6457352961f62aa01d82a13.zip
Implement OS version retrieval for Android
-rw-r--r--mullvad-problem-report/src/metadata.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/mullvad-problem-report/src/metadata.rs b/mullvad-problem-report/src/metadata.rs
index d45c344c83..8153e7671f 100644
--- a/mullvad-problem-report/src/metadata.rs
+++ b/mullvad-problem-report/src/metadata.rs
@@ -109,6 +109,27 @@ mod os {
}
}
+#[cfg(target_os = "android")]
+mod os {
+ pub fn version() -> String {
+ let manufacturer = get_prop("ro.product.manufacturer").unwrap_or_else(String::new);
+ let product = get_prop("ro.product.model").unwrap_or_else(String::new);
+ let build = get_prop("ro.build.display.id").unwrap_or_else(String::new);
+ let api_level = get_prop("ro.build.version.sdk")
+ .map(|api| format!("(API level: {})", api))
+ .unwrap_or_else(String::new);
+
+ format!(
+ "Android {} {} {} {}",
+ manufacturer, product, build, api_level
+ )
+ }
+
+ fn get_prop(property: &str) -> Option<String> {
+ super::command_stdout_lossy("getprop", &[property])
+ }
+}
+
/// Helper for getting stdout of some command as a String. Ignores the exit code of the command.
fn command_stdout_lossy(cmd: &str, args: &[&str]) -> Option<String> {
Command::new(cmd)