From 6fd2d877d48daa5dfc37e0ed28f4fb2edd44aa1d Mon Sep 17 00:00:00 2001 From: Jiajia Qin Date: Fri, 13 Sep 2013 18:18:15 +0800 Subject: [PATCH] [SystemInfo] Fixed type mismatch error in cellular --- system_info/system_info_cellular_network.h | 5 ++--- system_info/system_info_cellular_network_mobile.cc | 24 ++++++---------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/system_info/system_info_cellular_network.h b/system_info/system_info_cellular_network.h index 801f8fb..4d29311 100644 --- a/system_info/system_info_cellular_network.h +++ b/system_info/system_info_cellular_network.h @@ -10,7 +10,6 @@ #include #endif -#include #include #include "common/extension_adapter.h" @@ -67,8 +66,8 @@ class SysInfoCellularNetwork { std::string apn_; std::string ipAddress_; std::string ipv6Address_; - std::string mcc_; - std::string mnc_; + int mcc_; + int mnc_; int cellId_; int lac_; bool isRoaming_; diff --git a/system_info/system_info_cellular_network_mobile.cc b/system_info/system_info_cellular_network_mobile.cc index 8dfe5f5..79e462a 100644 --- a/system_info/system_info_cellular_network_mobile.cc +++ b/system_info/system_info_cellular_network_mobile.cc @@ -65,33 +65,21 @@ void SysInfoCellularNetwork::SetMcc() { int plmn_int = 0; if (vconf_get_int(VCONFKEY_TELEPHONY_PLMN, &plmn_int) != 0) { - mcc_ = ""; + mcc_ = 0; return; } - std::stringstream ss; - ss << plmn_int; - std::string s = ss.str(); - if (s.size() < 3) - mcc_ = s; - else - mcc_.assign(s, 0, 3); + mcc_ = plmn_int / 100; } void SysInfoCellularNetwork::SetMnc() { int plmn_int = 0; if (vconf_get_int(VCONFKEY_TELEPHONY_PLMN, &plmn_int) != 0) { - mnc_ = ""; + mnc_ = 0; return; } - std::stringstream ss; - ss << plmn_int; - std::string s = ss.str(); - if (s.size() < 4) - mnc_ = "0"; - else - mnc_.assign(s, 3, 3); + mnc_ = plmn_int % 100; } void SysInfoCellularNetwork::SetCellId() { @@ -163,9 +151,9 @@ void SysInfoCellularNetwork::SetData(picojson::value& data) { system_info::SetPicoJsonObjectValue(data, "ipv6Address", picojson::value("NOT SUPPORTTED")); system_info::SetPicoJsonObjectValue(data, "mcc", - picojson::value(mcc_)); + picojson::value(static_cast(mcc_))); system_info::SetPicoJsonObjectValue(data, "mnc", - picojson::value(mnc_)); + picojson::value(static_cast(mnc_))); system_info::SetPicoJsonObjectValue(data, "cellId", picojson::value(static_cast(cellId_))); system_info::SetPicoJsonObjectValue(data, "lac", -- 2.7.4