From 11b7e6949a5aff9eb258f3c0924d6eb813768c24 Mon Sep 17 00:00:00 2001
From: Piotr Kosko
Date: Fri, 10 Jul 2015 10:34:16 +0200
Subject: [PATCH] [Systeminfo] Supported second sim for CELLULAR_NETWORK
[Feature] Added support for getting CELLULAR_NETWORK properties array when
multiple SIM cards are present.
[Verification] Code compiles without errors.
TCT passrate 100%
Change-Id: I19aeb1f0e135272d1458c7cbba30affc04e1bb60
Signed-off-by: Piotr Kosko
---
src/systeminfo/systeminfo-utils.cpp | 56 +++++++++++++++++------------
1 file changed, 33 insertions(+), 23 deletions(-)
diff --git a/src/systeminfo/systeminfo-utils.cpp b/src/systeminfo/systeminfo-utils.cpp
index a665847d..f7de75a2 100644
--- a/src/systeminfo/systeminfo-utils.cpp
+++ b/src/systeminfo/systeminfo-utils.cpp
@@ -2385,7 +2385,7 @@ PlatformResult SysteminfoUtils::ReportEthernetNetwork(picojson::object& out) {
return PlatformResult(ErrorCode::NO_ERROR);
}
-static PlatformResult FetchVconfSettings(
+static PlatformResult FetchBasicSimProperties(TapiHandle *tapi_handle,
unsigned short *result_mcc,
unsigned short *result_mnc,
unsigned short *result_cell_id,
@@ -2394,37 +2394,46 @@ static PlatformResult FetchVconfSettings(
bool *result_is_flight_mode)
{
LoggerD("Entered");
- int result;
- if (0 != vconf_get_int(VCONFKEY_TELEPHONY_PLMN, &result)) {
- LoggerE("Cannot get mcc value");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get mcc value");
+ int result_value = 0;
+ int tapi_res = TAPI_API_SUCCESS;
+ tapi_res = tel_get_property_int(tapi_handle, TAPI_PROP_NETWORK_PLMN, &result_value);
+ if (TAPI_API_SUCCESS != tapi_res) {
+ std::string error_msg = "Cannot get mcc value, error: " + tapi_res;
+ LoggerE("%s", error_msg.c_str());
+ return PlatformResult(ErrorCode::UNKNOWN_ERR, error_msg);
}
- *result_mcc = static_cast(result) / kMccDivider;
- *result_mnc = static_cast(result) % kMccDivider;
+ *result_mcc = static_cast(result_value) / kMccDivider;
+ *result_mnc = static_cast(result_value) % kMccDivider;
- if (0 != vconf_get_int(VCONFKEY_TELEPHONY_CELLID, &result)) {
- LoggerE("Cannot get cell_id value");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get cell_id value");
+ tapi_res = tel_get_property_int(tapi_handle, TAPI_PROP_NETWORK_CELLID, &result_value);
+ if (TAPI_API_SUCCESS != tapi_res) {
+ std::string error_msg = "Cannot get cell_id value, error: " + tapi_res;
+ LoggerE("%s", error_msg.c_str());
+ return PlatformResult(ErrorCode::UNKNOWN_ERR, error_msg);
}
- *result_cell_id = static_cast(result);
+ *result_cell_id = static_cast(result_value);
- if (0 != vconf_get_int(VCONFKEY_TELEPHONY_LAC, &result)) {
- LoggerE("Cannot get lac value");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get lac value");
+ tapi_res = tel_get_property_int(tapi_handle, TAPI_PROP_NETWORK_LAC, &result_value);
+ if (TAPI_API_SUCCESS != tapi_res) {
+ std::string error_msg = "Cannot get lac value, error: " + tapi_res;
+ LoggerE("%s", error_msg.c_str());
+ return PlatformResult(ErrorCode::UNKNOWN_ERR, error_msg);
}
- *result_lac = static_cast(result);
+ *result_lac = static_cast(result_value);
- if (0 != vconf_get_int(VCONFKEY_TELEPHONY_SVC_ROAM, &result)) {
- LoggerE("Cannot get is_roaming value");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get is_roaming value");
+ tapi_res = tel_get_property_int(tapi_handle, TAPI_PROP_NETWORK_ROAMING_STATUS, &result_value);
+ if (TAPI_API_SUCCESS != tapi_res) {
+ std::string error_msg = "Cannot get is_roaming value, error: " + tapi_res;
+ LoggerE("%s", error_msg.c_str());
+ return PlatformResult(ErrorCode::UNKNOWN_ERR, error_msg);
}
- *result_is_roaming = (0 != result) ? true : false;
+ *result_is_roaming = (0 != result_value) ? true : false;
- if (0 != vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &result)) {
+ if (0 != vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &result_value)) {
LoggerE("Cannot get is_flight_mode value");
return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get is_flight_mode value");
}
- *result_is_flight_mode = (0 != result) ? true : false;
+ *result_is_flight_mode = (0 != result_value) ? true : false;
return PlatformResult(ErrorCode::NO_ERROR);
}
@@ -2539,8 +2548,9 @@ PlatformResult SysteminfoUtils::ReportCellularNetwork(picojson::object& out, uns
std::string result_imei;
//gathering vconf-based values
- ret = FetchVconfSettings(&result_mcc, &result_mnc, &result_cell_id, &result_lac,
- &result_is_roaming, &result_is_flight_mode);
+ ret = FetchBasicSimProperties(system_info_listeners.GetTapiHandles()[count], &result_mcc,
+ &result_mnc, &result_cell_id, &result_lac,
+ &result_is_roaming, &result_is_flight_mode);
if (ret.IsError()) {
return ret;
}
--
2.34.1