From: Piotr Kosko Date: Thu, 10 Sep 2015 11:12:22 +0000 (+0200) Subject: [Systeminfo] vconf calls related to SIM replaced with tapi calls X-Git-Tag: submit/tizen/20151026.073646^2^2~113^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ce625ac633dc0bba76823d47631d8617ba091f16;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Systeminfo] vconf calls related to SIM replaced with tapi calls [Feature] fetching sim-related fields with vconf was replaced with proper calls of TAPI (in case of getters and change listeners) [Verification] Code compiles without errors. TCT passrate is 100% on web-tct_2.4_r40. Change-Id: I7f6ee8b23c301bb15b1d473b44b26bdc46267d0d Signed-off-by: Piotr Kosko --- diff --git a/src/systeminfo/systeminfo-utils.cpp b/src/systeminfo/systeminfo-utils.cpp index cf948d56..ab4c7c22 100644 --- a/src/systeminfo/systeminfo-utils.cpp +++ b/src/systeminfo/systeminfo-utils.cpp @@ -165,6 +165,25 @@ PlatformResult SysteminfoUtils::UnregisterVconfCallback(const char *in_key, vcon return PlatformResult(ErrorCode::NO_ERROR); } +PlatformResult SysteminfoUtils::RegisterTapiChangeCallback(TapiHandle *handle, + const char *noti_id, + tapi_notification_cb callback, + void *user_data) { + if (TAPI_API_SUCCESS != tel_register_noti_event(handle, noti_id, callback, user_data)) { + LoggerE("Failed to register tapi callback with key: %s", noti_id); + return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to register tapi callback"); + } + return PlatformResult(ErrorCode::NO_ERROR); +} + +PlatformResult SysteminfoUtils::UnregisterTapiChangeCallback(TapiHandle *handle, + const char *noti_id) { + if (TAPI_API_SUCCESS != tel_deregister_noti_event(handle, noti_id)) { + LoggerE("Failed to unregister tapi callback with key: %s", noti_id); + return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to unregister tapi callback"); + } + return PlatformResult(ErrorCode::NO_ERROR); +} } // namespace systeminfo } // namespace webapi diff --git a/src/systeminfo/systeminfo-utils.h b/src/systeminfo/systeminfo-utils.h index 4ccdd36a..818933da 100644 --- a/src/systeminfo/systeminfo-utils.h +++ b/src/systeminfo/systeminfo-utils.h @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include "common/picojson.h" #include "common/platform_result.h" #include "systeminfo/systeminfo_device_capability.h" @@ -49,6 +51,11 @@ class SysteminfoUtils { static common::PlatformResult RegisterVconfCallback(const char *in_key, vconf_callback_fn cb, void* event_ptr); static common::PlatformResult UnregisterVconfCallback(const char *in_key, vconf_callback_fn cb); + static common::PlatformResult RegisterTapiChangeCallback(TapiHandle *handle, const char *noti_id, + tapi_notification_cb callback, + void *user_data); + static common::PlatformResult UnregisterTapiChangeCallback(TapiHandle *handle, + const char *noti_id); }; typedef unsigned char byte; diff --git a/src/systeminfo/systeminfo_manager.cc b/src/systeminfo/systeminfo_manager.cc index 11487f00..6da6e5ad 100644 --- a/src/systeminfo/systeminfo_manager.cc +++ b/src/systeminfo/systeminfo_manager.cc @@ -187,6 +187,14 @@ static void OnCellularNetworkValueChangedCb(keynode_t *node, void *event_ptr) { manager->CallListenerCallback(kPropertyIdCellularNetwork); } +static void OnTapiValueChangedCb(TapiHandle *handle, const char *noti_id, + void *data, void *user_data) { + LoggerD("Enter"); + LoggerD("Changed key: %s", noti_id); + SysteminfoManager* manager = static_cast(user_data); + manager->CallListenerCallback(kPropertyIdCellularNetwork); +} + static void OnPeripheralChangedCb(keynode_t* node, void* event_ptr) { LoggerD("Enter"); SysteminfoManager* manager = static_cast(event_ptr); @@ -926,14 +934,18 @@ PlatformResult SysteminfoManager::RegisterCellularNetworkListener() { } if (!IsListenerRegistered(kPropertyIdCellularNetwork)) { - CHECK_LISTENER_ERROR(SysteminfoUtils::RegisterVconfCallback(VCONFKEY_TELEPHONY_FLIGHT_MODE, - OnCellularNetworkValueChangedCb, this)) - CHECK_LISTENER_ERROR(SysteminfoUtils::RegisterVconfCallback(VCONFKEY_TELEPHONY_CELLID, - OnCellularNetworkValueChangedCb, this)) - CHECK_LISTENER_ERROR(SysteminfoUtils::RegisterVconfCallback(VCONFKEY_TELEPHONY_LAC, - OnCellularNetworkValueChangedCb, this)) - CHECK_LISTENER_ERROR(SysteminfoUtils::RegisterVconfCallback(VCONFKEY_TELEPHONY_SVC_ROAM, - OnCellularNetworkValueChangedCb, this)) + CHECK_LISTENER_ERROR(SysteminfoUtils::RegisterVconfCallback( + VCONFKEY_TELEPHONY_FLIGHT_MODE, OnCellularNetworkValueChangedCb, this)) + int sim_count = GetSimCount(); + TapiHandle **tapis = GetTapiHandles(); + for (int i = 0; i < sim_count; ++i) { + CHECK_LISTENER_ERROR(SysteminfoUtils::RegisterTapiChangeCallback( + tapis[i], TAPI_PROP_NETWORK_CELLID, OnTapiValueChangedCb, this)) + CHECK_LISTENER_ERROR(SysteminfoUtils::RegisterTapiChangeCallback( + tapis[i], TAPI_PROP_NETWORK_LAC, OnTapiValueChangedCb, this)) + CHECK_LISTENER_ERROR(SysteminfoUtils::RegisterTapiChangeCallback( + tapis[i], TAPI_PROP_NETWORK_ROAMING_STATUS, OnTapiValueChangedCb, this)) + } LoggerD("Added callback for CELLULAR_NETWORK"); } return PlatformResult(ErrorCode::NO_ERROR); @@ -945,14 +957,18 @@ PlatformResult SysteminfoManager::UnregisterCellularNetworkListener() { // if there is no other ip-relateded listeners left, unregister if (!IsListenerRegistered(kPropertyIdCellularNetwork)) { PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR); - CHECK_LISTENER_ERROR(SysteminfoUtils::UnregisterVconfCallback(VCONFKEY_TELEPHONY_FLIGHT_MODE, - OnCellularNetworkValueChangedCb)) - CHECK_LISTENER_ERROR(SysteminfoUtils::UnregisterVconfCallback(VCONFKEY_TELEPHONY_CELLID, - OnCellularNetworkValueChangedCb)) - CHECK_LISTENER_ERROR(SysteminfoUtils::UnregisterVconfCallback(VCONFKEY_TELEPHONY_LAC, - OnCellularNetworkValueChangedCb)) - CHECK_LISTENER_ERROR(SysteminfoUtils::UnregisterVconfCallback(VCONFKEY_TELEPHONY_SVC_ROAM, - OnCellularNetworkValueChangedCb)) + CHECK_LISTENER_ERROR(SysteminfoUtils::UnregisterVconfCallback( + VCONFKEY_TELEPHONY_FLIGHT_MODE, OnCellularNetworkValueChangedCb)) + int sim_count = GetSimCount(); + TapiHandle **tapis = GetTapiHandles(); + for (int i = 0; i < sim_count; ++i) { + CHECK_LISTENER_ERROR(SysteminfoUtils::UnregisterTapiChangeCallback( + tapis[i], TAPI_PROP_NETWORK_CELLID)) + CHECK_LISTENER_ERROR(SysteminfoUtils::UnregisterTapiChangeCallback( + tapis[i], TAPI_PROP_NETWORK_LAC)) + CHECK_LISTENER_ERROR(SysteminfoUtils::UnregisterTapiChangeCallback( + tapis[i], TAPI_PROP_NETWORK_ROAMING_STATUS)) + } } if (IsIpChangeCallbackNotRegistered()) { @@ -1091,18 +1107,10 @@ PlatformResult SysteminfoManager::GetPropertyCount(const std::string& property, if ("BATTERY" == property || "CPU" == property || "STORAGE" == property || "DISPLAY" == property || "DEVICE_ORIENTATION" == property || - "BUILD" == property || "LOCALE" == property || "NETWORK" == property || - "WIFI_NETWORK" == property || "PERIPHERAL" == property || - "MEMORY" == property) { + "BUILD" == property || "LOCALE" == property || "WIFI_NETWORK" == property || + "PERIPHERAL" == property || "MEMORY" == property) { *count = kDefaultPropertyCount; - } else if ("CELLULAR_NETWORK" == property) { - PlatformResult ret = SysteminfoUtils::CheckTelephonySupport(); - if (ret.IsError()) { - *count = 0; - } else { - *count = GetSimCount(); - } - } else if ("SIM" == property) { + } else if ("CELLULAR_NETWORK" == property || "SIM" == property || "NETWORK" == property) { PlatformResult ret = SysteminfoUtils::CheckTelephonySupport(); if (ret.IsError()) { *count = 0; diff --git a/src/systeminfo/systeminfo_properties_manager.cc b/src/systeminfo/systeminfo_properties_manager.cc index d520b8b9..1d217298 100644 --- a/src/systeminfo/systeminfo_properties_manager.cc +++ b/src/systeminfo/systeminfo_properties_manager.cc @@ -159,7 +159,7 @@ PlatformResult SysteminfoPropertiesManager::ReportProperty(const std::string& pr } else if ("LOCALE" == property) { return ReportLocale(res_obj); } else if ("NETWORK" == property) { - return ReportNetwork(res_obj); + return ReportNetwork(res_obj, index); } else if ("WIFI_NETWORK" == property) { return ReportWifiNetwork(res_obj); } else if ("ETHERNET_NETWORK" == property) { @@ -486,7 +486,7 @@ static PlatformResult GetNetworkTypeString(NetworkType type, std::string& type_s return PlatformResult(ErrorCode::NO_ERROR); } -PlatformResult SysteminfoPropertiesManager::ReportNetwork(picojson::object* out) { +PlatformResult SysteminfoPropertiesManager::ReportNetwork(picojson::object* out, unsigned long count) { connection_h connection_handle = nullptr; connection_type_e connection_type = CONNECTION_TYPE_DISCONNECTED; int networkType = 0; @@ -518,18 +518,19 @@ PlatformResult SysteminfoPropertiesManager::ReportNetwork(picojson::object* out) type = kWifi; break; case CONNECTION_TYPE_CELLULAR : - if (vconf_get_int(VCONFKEY_TELEPHONY_SVCTYPE, &networkType) == 0) { - if (networkType < VCONFKEY_TELEPHONY_SVCTYPE_2G) { + if (TAPI_API_SUCCESS == tel_get_property_int(manager_.GetTapiHandles()[count], + TAPI_PROP_NETWORK_SERVICE_TYPE, &networkType)) { + if (networkType < TAPI_NETWORK_SERVICE_TYPE_2G) { type = kNone; - } else if (networkType == VCONFKEY_TELEPHONY_SVCTYPE_2G) { + } else if (networkType == TAPI_NETWORK_SERVICE_TYPE_2G) { type = kType2G; - } else if (networkType == VCONFKEY_TELEPHONY_SVCTYPE_2G - || networkType == VCONFKEY_TELEPHONY_SVCTYPE_2_5G_EDGE) { + } else if (networkType == TAPI_NETWORK_SERVICE_TYPE_2_5G + || networkType == TAPI_NETWORK_SERVICE_TYPE_2_5G_EDGE) { type = kType2_5G; - } else if (networkType == VCONFKEY_TELEPHONY_SVCTYPE_3G - || networkType == VCONFKEY_TELEPHONY_SVCTYPE_HSDPA) { + } else if (networkType == TAPI_NETWORK_SERVICE_TYPE_3G + || networkType == TAPI_NETWORK_SERVICE_TYPE_HSDPA) { type = kType3G; - } else if (networkType == VCONFKEY_TELEPHONY_SVCTYPE_LTE) { + } else if (networkType == TAPI_NETWORK_SERVICE_TYPE_LTE) { type = kType4G; } else { type = kNone; diff --git a/src/systeminfo/systeminfo_properties_manager.h b/src/systeminfo/systeminfo_properties_manager.h index cb966d88..7b7a030a 100644 --- a/src/systeminfo/systeminfo_properties_manager.h +++ b/src/systeminfo/systeminfo_properties_manager.h @@ -44,7 +44,7 @@ class SysteminfoPropertiesManager { common::PlatformResult ReportDeviceOrientation(picojson::object* out); common::PlatformResult ReportBuild(picojson::object* out); common::PlatformResult ReportLocale(picojson::object* out); - common::PlatformResult ReportNetwork(picojson::object* out); + common::PlatformResult ReportNetwork(picojson::object* out, unsigned long count); common::PlatformResult ReportWifiNetwork(picojson::object* out); common::PlatformResult ReportEthernetNetwork(picojson::object* out); common::PlatformResult ReportCellularNetwork(picojson::object* out, unsigned long count);