iOS: extract device/platform info into DeviceInfoHelper, keep Settings platform string as iOS X.Y.Z

This commit is contained in:
DoncicX
2026-02-24 13:40:35 +08:00
committed by Peter Steinberger
parent e3ac491da3
commit 32d7756d8c
5 changed files with 87 additions and 82 deletions

View File

@@ -26,12 +26,12 @@ final class DeviceStatusService: DeviceStatusServicing {
func info() -> OpenClawDeviceInfoPayload {
let device = UIDevice.current
let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "dev"
let appBuild = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "0"
let appVersion = DeviceInfoHelper.appVersion()
let appBuild = DeviceStatusService.fallbackAppBuild(DeviceInfoHelper.appBuild())
let locale = Locale.preferredLanguages.first ?? Locale.current.identifier
return OpenClawDeviceInfoPayload(
deviceName: device.name,
modelIdentifier: Self.modelIdentifier(),
modelIdentifier: DeviceInfoHelper.modelIdentifier(),
systemName: device.systemName,
systemVersion: device.systemVersion,
appVersion: appVersion,
@@ -75,13 +75,8 @@ final class DeviceStatusService: DeviceStatusServicing {
return OpenClawStorageStatusPayload(totalBytes: total, freeBytes: free, usedBytes: used)
}
private static func modelIdentifier() -> String {
var systemInfo = utsname()
uname(&systemInfo)
let machine = withUnsafeBytes(of: &systemInfo.machine) { ptr in
String(bytes: ptr.prefix { $0 != 0 }, encoding: .utf8)
}
let trimmed = machine?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
return trimmed.isEmpty ? "unknown" : trimmed
/// Fallback for payloads that require a non-empty build (e.g. "0").
private static func fallbackAppBuild(_ build: String) -> String {
build.isEmpty ? "0" : build
}
}