From 415c69298472c85cf88248ba86a19e2ac853aa20 Mon Sep 17 00:00:00 2001 From: dionysuz <13951458+dionysuzx@users.noreply.github.com> Date: Wed, 18 Dec 2024 05:27:35 -0500 Subject: [PATCH] Add iPhone 15 (#1429) Fix CPU names for iPhone and iPad --- src/unix/apple/cpu.rs | 60 ++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/src/unix/apple/cpu.rs b/src/unix/apple/cpu.rs index 8df3798f5..6f587a45f 100644 --- a/src/unix/apple/cpu.rs +++ b/src/unix/apple/cpu.rs @@ -413,24 +413,48 @@ pub(crate) fn get_vendor_id_and_brand() -> (String, String) { } let full_brand = get_sysctl_str(b"hw.machine\0"); // This is a fallback when the `sysctl` to get the CPU brand returns an empty string. - // FIXME: This list is incomplete! - let brand = match full_brand.split(',').next().unwrap() { - "iPhone16" => "A18 Bionic", - "iPhone14" => "A16 Bionic", - "iPhone13" => "A15 Bionic", - "iPhone12" | "iPad10" => "A14 Bionic", - "iPhone11" | "iPad9" => "A13 Bionic", - "iPad8" => "A12 Bionic", - "iPhone8" => "A11 Bionic", - "iPhone7" => "A10 Fusion", - "iPad13" => "M1", - "iPad5" => "A9", - "iPhone6" => "A8", - "iPad4" => "A6X", - "iPhone5" => "A6", - "iPad3" => "A5X", - "iPad2" => "A5", - "iPad1" | "iPhone4" => "A4", + let mut iter = full_brand.split(','); + let brand = match (iter.next().unwrap_or(""), iter.next()) { + ("iPhone1", Some("1" | "2")) => "S5L8900", + ("iPhone2", Some("1")) => "S5L8920", + ("iPhone3", Some("1" | "2" | "3")) => "A4", + ("iPhone4", Some("1" | "2")) => "A5", + ("iPhone5", Some("1" | "2")) => "A6", + ("iPhone5", Some("3" | "4")) => "A6", + ("iPhone6", Some("1" | "2")) => "A7", + ("iPhone7", Some("1" | "2")) => "A8", + ("iPhone8", Some("1" | "2" | "4")) => "A9", + ("iPhone9", Some("1" | "2" | "3" | "4")) => "A10 Fusion", + ("iPhone10", Some("1" | "2" | "3" | "4" | "5" | "6")) => "A11 Bionic", + ("iPhone11", Some("1" | "2" | "4" | "6" | "8")) => "A12 Bionic", + ("iPhone12", Some("1" | "3" | "5" | "8")) => "A13 Bionic", + ("iPhone13", Some("1" | "2" | "3" | "4")) => "A14 Bionic", + ("iPhone14", Some("1" | "2" | "3" | "4" | "5" | "6" | "7" | "8")) => "A15 Bionic", + ("iPhone15", Some("2" | "3" | "4" | "5")) => "A16 Bionic", + ("iPhone16", Some("1" | "2")) => "A17 Pro", + ("iPhone17", Some("1" | "2")) => "A18 Pro", + ("iPhone17", Some("3" | "4")) => "A18", + ("iPad1", Some("1" | "2")) => "A4", + ("iPad2", Some("1" | "2" | "3" | "4" | "5" | "6" | "7")) => "A5", + ("iPad3", Some("1" | "2" | "3")) => "A5X", + ("iPad3", Some("4" | "5" | "6")) => "A6X", + ("iPad4", Some("1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9")) => "A7", + ("iPad5", Some("1" | "2")) => "A8", + ("iPad5", Some("3" | "4")) => "A8X", + ("iPad6", Some("3" | "4" | "7" | "8")) => "A9X", + ("iPad6", Some("11" | "12")) => "A9", + ("iPad7", Some("1" | "2" | "3" | "4")) => "A10X Fusion", + ("iPad7", Some("5" | "6" | "11" | "12")) => "A10 Fusion", + ("iPad8", Some("1" | "2" | "3" | "4" | "5" | "6" | "7" | "8")) => "A12X Bionic", + ("iPad8", Some("9" | "10" | "11" | "12")) => "A12Z Bionic", + ("iPad11", Some("1" | "2" | "3" | "4" | "6" | "7")) => "A12 Bionic", + ("iPad12", Some("1" | "2")) => "A13 Bionic", + ("iPad13", Some("1" | "2" | "18" | "19")) => "A14 Bionic", + ("iPad13", Some("4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "16" | "17")) => "M1", + ("iPad14", Some("1" | "2")) => "A15 Bionic", + ("iPad14", Some("3" | "4" | "5" | "6" | "10" | "11")) => "M2", + ("iPad14", Some("8" | "9")) => "M1", + ("iPad16", Some("3" | "4" | "5" | "6")) => "M3", _ => "unknown", }; (vendor, brand.to_string())