Skip to content

Commit 18957ab

Browse files
QusicBang Lee
andauthored
Add device class field support for iOS (#945)
Co-authored-by: Bang Lee <[email protected]>
1 parent 166e897 commit 18957ab

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed

lib/pal/posix/SystemInformationImpl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace PAL_NS_BEGIN {
1919
m_os_name = sysInfo.get("osName");
2020
m_os_major_version = sysInfo.get("osVer");
2121
m_os_full_version = sysInfo.get("osRel");
22+
m_device_class = sysInfo.get("devClass");
2223
}
2324

2425
SystemInformationImpl::~SystemInformationImpl()

lib/pal/posix/sysinfo_sources.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ sysinfo_sources_impl::sysinfo_sources_impl() : sysinfo_sources()
279279
cache["osVer"] = GetDeviceOsVersion();
280280
cache["osRel"] = GetDeviceOsRelease();
281281
cache["osBuild"] = GetDeviceOsBuild();
282+
cache["devClass"] = GetDeviceClass();
282283

283284
// Populate user timezone as hh:mm offset from UTC timezone. Example for PST: "-08:00"
284285
CFTimeZoneRef tz = CFTimeZoneCopySystem();

lib/pal/posix/sysinfo_utils_apple.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ std::string GetDeviceModel();
2121

2222
std::string GetDeviceId();
2323

24+
std::string GetDeviceClass();
2425
#endif /* LIB_PAL_POSIX_SYSINFO_UTILS_IOS_HPP_ */
2526

lib/pal/posix/sysinfo_utils_ios.mm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,19 @@
6868
return std::string { [[[UIDevice currentDevice] systemVersion] UTF8String] };
6969
}
7070

71+
std::string GetDeviceClass() {
72+
#if TARGET_IPHONE_SIMULATOR
73+
return "iOS.Emulator";
74+
#else
75+
switch (UIDevice.currentDevice.userInterfaceIdiom) {
76+
case UIUserInterfaceIdiomPhone:
77+
return "iOS.Phone";
78+
case UIUserInterfaceIdiomPad:
79+
return "iOS.Tablet";
80+
case UIUserInterfaceIdiomTV:
81+
return "iOS.AppleTV";
82+
default:
83+
return {};
84+
}
85+
#endif
86+
}

lib/pal/posix/sysinfo_utils_mac.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,6 @@
8383
return GetDeviceOsVersion();
8484
}
8585

86+
std::string GetDeviceClass() {
87+
return {};
88+
}

0 commit comments

Comments
 (0)