namespace
{
+const std::string UNDEFINED_VAL{"undefined"};
+
/**
* @brief getStringSystemProperty returns system property as std::string
* @param prop the requested system property key
* @return requested system property on success and "undefined" otherwise
*/
-std::string getStringSystemProperty(system_info_key_e prop)
+bool getStringSystemProperty(system_info_key_e prop, std::string& property)
{
- std::string property{"undefined"};
char* val;
if (0 == system_info_get_value_string(prop, &val)) {
property.assign(val);
free(val);
+ return true;
}
- return property;
+ return false;
}
/**
* @param prop the requested platform property key
* @return requested platform property on success and "undefined" otherwise
*/
-std::string getStringPlatformProperty(const char* prop)
+bool getStringPlatformProperty(const char* prop, std::string& property)
{
- std::string property{"undefined"};
char* val;
if (0 == system_info_get_platform_string(prop, &val)) {
property.assign(val);
free(val);
+ return true;
}
- return property;
+ return false;
}
}
std::string SysInfo::model()
{
- return getStringSystemProperty(SYSTEM_INFO_KEY_MODEL);
+ std::string prop;
+ if (!getStringSystemProperty(SYSTEM_INFO_KEY_MODEL, prop)
+ && !getStringPlatformProperty("tizen.org/system/model_name", prop)) {
+ prop = UNDEFINED_VAL;
+ }
+ return prop;
}
std::string SysInfo::type()
{
- return getStringPlatformProperty("com.samsung/build_config/product_type");
+ std::string prop;
+ if (!getStringPlatformProperty("com.samsung/build_config/product_type", prop)
+ && !getStringPlatformProperty("tizen.org/feature/profile", prop)) {
+ prop = UNDEFINED_VAL;
+ }
+ return prop;
}
std::string SysInfo::osVersion()
{
- return getStringPlatformProperty("tizen.org/feature/platform.version");
+ std::string prop;
+ if (!getStringPlatformProperty("tizen.org/feature/platform.version", prop)) {
+ prop = UNDEFINED_VAL;
+ }
+ return prop;
}
std::string SysInfo::osName()
{
- return getStringSystemProperty(SYSTEM_INFO_KEY_PLATFORM_NAME);
+ std::string prop;
+ if (!getStringSystemProperty(SYSTEM_INFO_KEY_PLATFORM_NAME, prop)
+ && !getStringPlatformProperty("tizen.org/system/platform.name", prop)) {
+ prop = UNDEFINED_VAL;
+ }
+ return prop;
}
std::string SysInfo::swVersion()
{
- return getStringSystemProperty(SYSTEM_INFO_KEY_TIZEN_VERSION);
+ std::string prop;
+ if (!getStringSystemProperty(SYSTEM_INFO_KEY_TIZEN_VERSION, prop)
+ && !getStringPlatformProperty("tizen.org/system/build.string", prop)) {
+ prop = UNDEFINED_VAL;
+ }
+ return prop;
}
}