Skip to content

Commit

Permalink
Improve System::long_os_version() on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 13, 2024
1 parent ddd4dc0 commit 8c8874b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/common/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ impl System {
/// | example platform | value of `System::long_os_version()` |
/// |---|---|
/// | linux laptop | "Linux 24.04 Ubuntu" |
/// | android phone | "Android 15 Pixel 9 Pro" |
/// | android phone | "Android 15 on Pixel 9 Pro" |
/// | apple laptop | "macOS 15.1.1 Sequoia" |
/// | windows server | "Windows Server 2022 Datacenter" |
///
Expand Down
9 changes: 6 additions & 3 deletions src/unix/linux/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,12 @@ impl SystemInner {
long_name.push_str(&os_version);
}

if let Some(short_name) = Self::name() {
long_name.push(' ');
long_name.push_str(&short_name);
// Android's name() is extracted from the system property "ro.product.model"
// which is documented as "The end-user-visible name for the end product."
// So this produces a long_os_version like "Android 15 on Pixel 9 Pro".
if let Some(product_name) = Self::name() {
long_name.push_str(" on ");
long_name.push_str(&product_name);
}

Some(long_name)
Expand Down

0 comments on commit 8c8874b

Please sign in to comment.