[Systeminfo] Fix implementation for 'CAMERA_FLASH' property
authorPiotr Czaja <p.czaja@samsung.com>
Mon, 20 Jul 2015 09:57:43 +0000 (11:57 +0200)
committerHyunJin Park <hj.na.park@samsung.com>
Mon, 10 Aug 2015 13:22:24 +0000 (22:22 +0900)
Change-Id: I55abdca650f6c6ebc59f84780dbbeaae9ca03c79
Signed-off-by: Piotr Czaja <p.czaja@samsung.com>
src/systeminfo/systeminfo-utils.cpp

index e8d52d80504ebf72faa930777cbd5038f15daa97..94be7b1106e02937874bafd435ad2364c1e1c233 100644 (file)
@@ -953,6 +953,21 @@ common::PlatformResult CheckTelephonySupport() {
   return PlatformResult(ErrorCode::NO_ERROR);
 }
 
+common::PlatformResult CheckCameraFlashSupport() {
+  bool supported = false;
+  PlatformResult ret = SystemInfoDeviceCapability::GetValueBool(
+    "tizen.org/feature/camera.back.flash", &supported);
+  if (ret.IsError()) {
+    return ret;
+  }
+  if (!supported) {
+    LoggerD("Back-facing camera with a flash is not supported on this device");
+    return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR,
+        "Back-facing camera with a flash is not supported on this device");
+  }
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
 PlatformResult SystemInfoListeners::RegisterEthernetNetworkListener(const SysteminfoUtilsCallback& callback,
                                                                     SysteminfoInstance& instance)
 {
@@ -1671,7 +1686,9 @@ PlatformResult SysteminfoUtils::GetCount(const std::string& property, unsigned l
     }
   } else if ("CAMERA_FLASH" == property) {
     const int numberOfCameraFlashProperties = 3;
-    count = numberOfCameraFlashProperties;
+    PlatformResult ret = CheckCameraFlashSupport();
+    if (ret.IsError()) count = 0;
+    else count = numberOfCameraFlashProperties;
   } else if ("ETHERNET_NETWORK" == property) {
     PlatformResult ret = CheckIfEthernetNetworkSupported();
     if (ret.IsError()) count = 0;
@@ -2736,7 +2753,11 @@ PlatformResult SysteminfoUtils::ReportStorage(picojson::object& out) {
   return PlatformResult(ErrorCode::NO_ERROR);
 }
 PlatformResult SysteminfoUtils::ReportCameraFlash(picojson::object& out) {
-  return PlatformResult(ErrorCode::NO_ERROR);
+    PlatformResult ret = CheckCameraFlashSupport();
+    if (ret.IsError()) {
+      return ret;
+    }
+    return PlatformResult(ErrorCode::NO_ERROR);
 }
 
 PlatformResult SysteminfoUtils::RegisterBatteryListener(const SysteminfoUtilsCallback& callback,