[Systeminfo] Fixed behaviour of Network property 69/235869/2 accepted/tizen/unified/20200615.135439 submit/tizen/20200610.123237
authorPiotr Kosko <p.kosko@samsung.com>
Wed, 10 Jun 2020 11:19:07 +0000 (13:19 +0200)
committerPiotr Kosko/Native/Web API (PLT) /SRPOL/Engineer/Samsung Electronics <p.kosko@samsung.com>
Wed, 10 Jun 2020 11:59:10 +0000 (13:59 +0200)
[Bug] When using device with not supported feature
http://tizen.org/feature/network.telephony
e.g. R800 device, below code returns no error:
  tizen.systeminfo.getPropertyValueArray("NETWORK", (s) => {console.log(s)}, (s) => {console.log(s)})
listener for "NETWORK" property is never triggered also:
  tizen.systeminfo.addPropertyValueChangeListener("NETWORK", (s) => console.log(s));

[verification]
Systeminfo TCT 100% passrate.
After fix, listener and getter works properly on TW3.

Change-Id: I9f0d533055926d186305fb7c39418de1fed76f5b

src/systeminfo/systeminfo-utils.cpp
src/systeminfo/systeminfo-utils.h
src/systeminfo/systeminfo_manager.cc

index 3487de8..4c56af8 100644 (file)
@@ -78,6 +78,21 @@ PlatformResult SysteminfoUtils::CheckTelephonySupport() {
   return PlatformResult(ErrorCode::NO_ERROR);
 }
 
+PlatformResult SysteminfoUtils::CheckWifiSupport() {
+  ScopeLogger();
+  bool supported = false;
+  PlatformResult ret =
+      SystemInfoDeviceCapability::GetValueBool("tizen.org/feature/network.wifi", &supported);
+  if (ret.IsError()) {
+    return ret;
+  }
+  if (!supported) {
+    return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR,
+                              "Wifi is not supported on this device");
+  }
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
 PlatformResult SysteminfoUtils::CheckCameraFlashSupport() {
   ScopeLogger();
   bool supported = false;
index 7f56f26..004d4b1 100644 (file)
@@ -44,6 +44,7 @@ class SysteminfoUtils {
   static common::PlatformResult GetRuntimeInfoString(system_settings_key_e key,
                                                      std::string *platform_string);
   static common::PlatformResult CheckTelephonySupport();
+  static common::PlatformResult CheckWifiSupport();
   static common::PlatformResult CheckCameraFlashSupport();
   static common::PlatformResult CheckIfEthernetNetworkSupported();
   static common::PlatformResult GetTotalMemory(long long *result);
index f883257..edd0020 100644 (file)
@@ -1407,6 +1407,11 @@ PlatformResult SysteminfoManager::GetPropertyCount(const std::string& property,
     PlatformResult ret = SysteminfoUtils::CheckTelephonySupport();
     if (ret.IsError()) {
       *count = 0;
+      if ("NETWORK" == property && SysteminfoUtils::CheckWifiSupport()) {
+      // Telephony is not supported in this case, but WiFi is still supported, thus setting
+      // counter to 1.
+        *count = 1;
+      }
     } else {
       *count = tapi_manager_->GetSimCount();
     }