Skip to content

Add device-info crate#982

Open
theomonnom wants to merge 10 commits intomainfrom
theo/device-info
Open

Add device-info crate#982
theomonnom wants to merge 10 commits intomainfrom
theo/device-info

Conversation

@theomonnom
Copy link
Copy Markdown
Member

@theomonnom theomonnom commented Mar 31, 2026

Device Model

  • macOS: sysctlbyname("hw.model") → "Mac16,5", "MacBookPro18,1"
  • Windows: Registry SystemProductName → "Surface Pro 9", "HoloLens 2", "ROG STRIX Z790-E" (custom PCs return motherboard name)
  • Linux x86: /sys/class/dmi/id/product_name → "ThinkPad X1 Carbon"
  • Linux ARM: /proc/device-tree/model → "Raspberry Pi 4 Model B Rev 1.4", "NVIDIA Jetson Nano Developer Kit"
  • iOS: uname().machine → "iPhone15,2", "iPad14,1"
  • tvOS: uname().machine → "AppleTV11,1"
  • visionOS: uname().machine → "RealityDevice14,1"
  • watchOS: uname().machine → "Watch6,1"
  • Android/Quest: Build.MODEL → "Pixel 8", "SM-S921B", "Quest 3"
  • WASM: navigator.platform → "MacIntel", "Win32", "Linux x86_64"

Device Name

  • macOS: SCDynamicStoreCopyComputerName → "Theo's MacBook Pro"
  • Windows: GetComputerNameExW → "DESKTOP-ABC123"
  • Linux: gethostname() → "raspberrypi", "theo-desktop"
  • iOS/tvOS/visionOS/watchOS: UIDevice.name → "iPhone" (iOS 16+ returns generic name for privacy)
  • Android: Settings.Global.device_name with bluetooth_name fallback, falls back to model
  • WASM: Parsed from User-Agent → "Chrome", "Firefox", "Safari", "Edge"

Device Type

  • macOS: Battery presence via IOKit → Laptop/Desktop
  • Windows: Battery via GetSystemPowerStatus, model string for HoloLens → Headset
  • Linux: DMI chassis type → /etc/machine-info CHASSIS → battery in /sys/class/power_supply/ → Unknown
  • iOS: Model prefix → iPhone/iPod = Phone, iPad = Tablet
  • tvOS: AppleTV prefix → Television
  • visionOS: RealityDevice prefix → Headset
  • watchOS: Watch prefix → Watch
  • Android: Build.MANUFACTURER contains "Meta"/"Oculus" → Headset, else Phone
  • WASM: User-Agent parsing → Quest/HoloLens = Headset, iPad = Tablet, Mobile = Phone, else Desktop

@MaxHeimbrock
Copy link
Copy Markdown
Contributor

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.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

Changeset

The following package versions will be affected by this PR:

Package Bump
livekit patch
livekit-api patch
livekit-ffi patch

@lukasIO
Copy link
Copy Markdown
Contributor

lukasIO commented Mar 31, 2026

@MaxHeimbrock would be great if you could add the crate it to knope.toml as well. And depending on whether it should be published as its own crate also add it to the changeset. I think the check action might have missed the new crate because it wasn't configured in the knope config

@MaxHeimbrock MaxHeimbrock self-requested a review March 31, 2026 17:22
@MaxHeimbrock MaxHeimbrock self-assigned this Mar 31, 2026
@MaxHeimbrock MaxHeimbrock removed their request for review March 31, 2026 17:22
@MaxHeimbrock
Copy link
Copy Markdown
Contributor

@MaxHeimbrock would be great if you could add the crate it to knope.toml as well. And depending on whether it should be published as its own crate also add it to the changeset. I think the check action might have missed the new crate because it wasn't configured in the knope config

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.

Comment on lines +37 to +48
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())
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thread safety may requires attention here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants