Conversation
90f977c to
4b3e9e2
Compare
|
Thanks for the work, I rebased on main to get Shijings Android build fix in and then branched off to implement it instead of the ffi version, my PR points to this one: #984 |
Ditching the ffi version of device model info in favor of Theo's proposed Rust implementation. Minor fix to Android.
ChangesetThe following package versions will be affected by this PR:
|
|
@MaxHeimbrock would be great if you could add the crate it to |
Good point, as I am not familiar with Rust that much I can need a thorough review here. Will see if I get that done tomorrow. |
| fn ui_device_name() -> Result<String, DeviceInfoError> { | ||
| use objc2::MainThreadMarker; | ||
| use objc2_ui_kit::UIDevice; | ||
|
|
||
| // UIDevice can be accessed from any thread, but currentDevice() requires | ||
| // a MainThreadMarker in objc2. We assume the caller is on the main thread | ||
| // or that UIDevice is safe to query (which it is in practice). | ||
| let mtm = unsafe { MainThreadMarker::new_unchecked() }; | ||
| let device = UIDevice::currentDevice(mtm); | ||
| let name = device.name(); | ||
| Ok(name.to_string()) | ||
| } |
There was a problem hiding this comment.
Thread safety may requires attention here
Device Model
sysctlbyname("hw.model")→ "Mac16,5", "MacBookPro18,1"SystemProductName→ "Surface Pro 9", "HoloLens 2", "ROG STRIX Z790-E" (custom PCs return motherboard name)/sys/class/dmi/id/product_name→ "ThinkPad X1 Carbon"/proc/device-tree/model→ "Raspberry Pi 4 Model B Rev 1.4", "NVIDIA Jetson Nano Developer Kit"uname().machine→ "iPhone15,2", "iPad14,1"uname().machine→ "AppleTV11,1"uname().machine→ "RealityDevice14,1"uname().machine→ "Watch6,1"Build.MODEL→ "Pixel 8", "SM-S921B", "Quest 3"navigator.platform→ "MacIntel", "Win32", "Linux x86_64"Device Name
SCDynamicStoreCopyComputerName→ "Theo's MacBook Pro"GetComputerNameExW→ "DESKTOP-ABC123"gethostname()→ "raspberrypi", "theo-desktop"UIDevice.name→ "iPhone" (iOS 16+ returns generic name for privacy)Settings.Global.device_namewithbluetooth_namefallback, falls back to modelDevice Type
GetSystemPowerStatus, model string for HoloLens → Headset/etc/machine-infoCHASSIS → battery in/sys/class/power_supply/→ UnknownBuild.MANUFACTURERcontains "Meta"/"Oculus" → Headset, else Phone