[Systeminfo] Fixed behaviour of Network property 73/235873/1 submit/tizen_3.0/20200610.123619
authorPiotr Kosko <p.kosko@samsung.com>
Wed, 10 Jun 2020 11:19:07 +0000 (13:19 +0200)
committerPiotr Kosko <p.kosko@samsung.com>
Wed, 10 Jun 2020 12:22:20 +0000 (12:22 +0000)
[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 8882280..4854376 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 2541e08..2832c62 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 f7afef0..2dc2be7 100644 (file)
@@ -1346,6 +1346,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();
     }