From e97081c23b69a819e5355296f85d5b0632134f5c Mon Sep 17 00:00:00 2001
From: Piotr Kosko
Date: Wed, 10 Jun 2020 13:19:07 +0200
Subject: [PATCH] [Systeminfo] Fixed behaviour of Network property
[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 | 15 +++++++++++++++
src/systeminfo/systeminfo-utils.h | 1 +
src/systeminfo/systeminfo_manager.cc | 5 +++++
3 files changed, 21 insertions(+)
diff --git a/src/systeminfo/systeminfo-utils.cpp b/src/systeminfo/systeminfo-utils.cpp
index 3487de8..4c56af8 100644
--- a/src/systeminfo/systeminfo-utils.cpp
+++ b/src/systeminfo/systeminfo-utils.cpp
@@ -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;
diff --git a/src/systeminfo/systeminfo-utils.h b/src/systeminfo/systeminfo-utils.h
index 7f56f26..004d4b1 100644
--- a/src/systeminfo/systeminfo-utils.h
+++ b/src/systeminfo/systeminfo-utils.h
@@ -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);
diff --git a/src/systeminfo/systeminfo_manager.cc b/src/systeminfo/systeminfo_manager.cc
index f883257..edd0020 100644
--- a/src/systeminfo/systeminfo_manager.cc
+++ b/src/systeminfo/systeminfo_manager.cc
@@ -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();
}
--
2.7.4