[Systeminfo][Update] getCapability - add support for custom device capability key
authorPawel Kaczmarek <p.kaczmarek3@samsung.com>
Tue, 2 Jun 2015 08:07:08 +0000 (10:07 +0200)
committerPawel Kaczmarek <p.kaczmarek3@samsung.com>
Wed, 3 Jun 2015 13:07:44 +0000 (22:07 +0900)
[Verification] TCT without changes:
97.15% 281/273/8

Change-Id: I72641ab1689f5843db5ca6bc23272b02a2d461cd
Signed-off-by: Pawel Kaczmarek <p.kaczmarek3@samsung.com>
src/systeminfo/systeminfo-utils.cpp

index cf20b232caeaa01b83d09da04622467a8f5a65e2..c13e41ab9ef922a8fafdf5e39a780e0ed04c74fb 100644 (file)
@@ -1436,10 +1436,13 @@ PlatformResult SystemInfoDeviceCapability::GetValueBool(const char *key, bool* v
   bool platform_result = false;
   int ret = system_info_get_platform_bool(key, &platform_result);
   if (SYSTEM_INFO_ERROR_NONE != ret) {
-    std::string log_msg = "Platform error while getting bool value: ";
-    log_msg += std::string(key) + " " + std::to_string(ret);
-    LoggerE("%s", log_msg.c_str());
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+    ret = system_info_get_custom_bool(key, &platform_result);
+    if (SYSTEM_INFO_ERROR_NONE != ret) {
+      std::string log_msg = "Platform error while getting bool value: ";
+      log_msg += std::string(key) + " " + std::to_string(ret);
+      LoggerE("%s", log_msg.c_str());
+      return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+    }
   }
 
   *value = platform_result;
@@ -1451,10 +1454,13 @@ PlatformResult SystemInfoDeviceCapability::GetValueInt(const char *key, int* val
   int platform_result = 0;
   int ret = system_info_get_platform_int(key, &platform_result);
   if (SYSTEM_INFO_ERROR_NONE != ret) {
-    std::string log_msg = "Platform error while getting int value: ";
-    log_msg += std::string(key) + " " + std::to_string(ret);
-    LoggerE("%s", log_msg.c_str());
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+    ret = system_info_get_custom_int(key, &platform_result);
+    if (SYSTEM_INFO_ERROR_NONE != ret) {
+      std::string log_msg = "Platform error while getting int value: ";
+      log_msg += std::string(key) + " " + std::to_string(ret);
+      LoggerE("%s", log_msg.c_str());
+      return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+    }
   }
 
   *value = platform_result;
@@ -1466,17 +1472,20 @@ PlatformResult SystemInfoDeviceCapability::GetValueString(const char *key, std::
   char* value = nullptr;
 
   int ret = system_info_get_platform_string(key, &value);
-  if (SYSTEM_INFO_ERROR_NONE == ret) {
-    if (value != nullptr) {
-      *str_value = value;
-      free(value);
-      value = nullptr;
+  if (SYSTEM_INFO_ERROR_NONE != ret) {
+    ret = system_info_get_custom_string(key, &value);
+    if (SYSTEM_INFO_ERROR_NONE != ret) {
+      std::string log_msg = "Platform error while getting string value: ";
+      log_msg += std::string(key) + " " + std::to_string(ret);
+      LoggerE("%s", log_msg.c_str());
+      return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
     }
-  } else {
-    std::string log_msg = "Platform error while getting string value: ";
-    log_msg += std::string(key) + " " + std::to_string(ret);
-    LoggerE("%s", log_msg.c_str());
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+  }
+
+  if (value != nullptr) {
+    *str_value = value;
+    free(value);
+    value = nullptr;
   }
 
   LoggerD("value[%s]: %s", key, str_value->c_str());