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
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<SysteminfoManager*>(user_data);
+ manager->CallListenerCallback(kPropertyIdCellularNetwork);
+}
+
static void OnPeripheralChangedCb(keynode_t* node, void* event_ptr) {
LoggerD("Enter");
SysteminfoManager* manager = static_cast<SysteminfoManager*>(event_ptr);
}
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);
// 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()) {
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;
} 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) {
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;
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;