shill: cellular: Delete CellularOperatorInfo.
|CellularOperatorInfo| has been replaced by |MobileOperatorInfo|. Unwire the few
remaining places, and delete the old object.
BUG=chromium:371639
TEST=(1) Run shill_unittest
(2) Run network_3GSmokeTest on a few modems.
Change-Id: Ib840f10c034f9777a504c0fb04eb442cdcb0ffb0
Reviewed-on: https://chromium-review.googlesource.com/201101
Reviewed-by: Thieu Le <thieule@chromium.org>
Commit-Queue: Prathmesh Prabhu <pprabhu@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
diff --git a/cellular_capability_universal.cc b/cellular_capability_universal.cc
index 61484d3..7b80646 100644
--- a/cellular_capability_universal.cc
+++ b/cellular_capability_universal.cc
@@ -74,7 +74,7 @@
const char kPhoneNumber[] = "*99#";
-// This identifier is specified in the cellular_operator_info file.
+// This identifier is specified in the additional_providers.prototxt file.
const char kVzwIdentifier[] = "c83d6597-dc91-4d48-a3a7-d86b80123751";
const size_t kVzwMdnLength = 10;
diff --git a/cellular_capability_universal.h b/cellular_capability_universal.h
index 1a2efff..928c9e4 100644
--- a/cellular_capability_universal.h
+++ b/cellular_capability_universal.h
@@ -19,7 +19,6 @@
#include "shill/cellular.h"
#include "shill/cellular_bearer.h"
#include "shill/cellular_capability.h"
-#include "shill/cellular_operator_info.h"
#include "shill/mm1_modem_modem3gpp_proxy_interface.h"
#include "shill/mm1_modem_proxy_interface.h"
#include "shill/mm1_modem_simple_proxy_interface.h"
diff --git a/cellular_capability_universal_cdma.cc b/cellular_capability_universal_cdma.cc
index 3a3546f..3d6f65d 100644
--- a/cellular_capability_universal_cdma.cc
+++ b/cellular_capability_universal_cdma.cc
@@ -10,7 +10,7 @@
#include <base/strings/string_util.h>
#include "shill/cellular_bearer.h"
-#include "shill/cellular_operator_info.h"
+#include "shill/cellular_service.h"
#include "shill/dbus_properties_proxy_interface.h"
#include "shill/error.h"
#include "shill/logging.h"
diff --git a/cellular_capability_universal_cdma_unittest.cc b/cellular_capability_universal_cdma_unittest.cc
index fb86542..a65148b 100644
--- a/cellular_capability_universal_cdma_unittest.cc
+++ b/cellular_capability_universal_cdma_unittest.cc
@@ -18,7 +18,6 @@
#include "shill/cellular_service.h"
#include "shill/event_dispatcher.h"
#include "shill/mock_adaptors.h"
-#include "shill/mock_cellular_operator_info.h"
#include "shill/mock_cellular_service.h"
#include "shill/mock_dbus_properties_proxy.h"
#include "shill/mock_glib.h"
@@ -451,7 +450,6 @@
.Times(1);
capability_->UpdateServiceActivationStateProperty();
Mock::VerifyAndClearExpectations(service_);
- Mock::VerifyAndClearExpectations(modem_info_.mock_cellular_operator_info());
Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store());
}
diff --git a/cellular_capability_universal_unittest.cc b/cellular_capability_universal_unittest.cc
index fc05fad..e94d3df 100644
--- a/cellular_capability_universal_unittest.cc
+++ b/cellular_capability_universal_unittest.cc
@@ -22,7 +22,6 @@
#include "shill/event_dispatcher.h"
#include "shill/mock_adaptors.h"
#include "shill/mock_cellular.h"
-#include "shill/mock_cellular_operator_info.h"
#include "shill/mock_cellular_service.h"
#include "shill/mock_dbus_properties_proxy.h"
#include "shill/mock_event_dispatcher.h"
diff --git a/cellular_operator_info.cc b/cellular_operator_info.cc
deleted file mode 100644
index caca4bc..0000000
--- a/cellular_operator_info.cc
+++ /dev/null
@@ -1,701 +0,0 @@
-// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Implements shill::CellularOperatorInfo. See cellular_operator_info.h for
-// details.
-
-#include "shill/cellular_operator_info.h"
-
-#include <base/stl_util.h>
-#include <base/strings/string_number_conversions.h>
-#include <base/strings/string_split.h>
-#include <base/strings/string_util.h>
-#include <chromeos/dbus/service_constants.h>
-
-#include "shill/logging.h"
-
-using base::FilePath;
-using std::map;
-using std::string;
-using std::vector;
-
-namespace shill {
-
-CellularOperatorInfo::OLP::OLP() {
- SetURL("");
- SetMethod("");
- SetPostData("");
-}
-
-CellularOperatorInfo::OLP::~OLP() {}
-
-void CellularOperatorInfo::OLP::CopyFrom(const OLP &olp) {
- dict_ = olp.dict_;
-}
-
-bool CellularOperatorInfo::OLP::Equals(const OLP &olp) const {
- return dict_ == olp.dict_;
-}
-
-const string &CellularOperatorInfo::OLP::GetURL() const {
- return dict_.find(kPaymentPortalURL)->second;
-}
-
-void CellularOperatorInfo::OLP::SetURL(const string &url) {
- dict_[kPaymentPortalURL] = url;
-}
-
-const string &CellularOperatorInfo::OLP::GetMethod() const {
- return dict_.find(kPaymentPortalMethod)->second;
-}
-
-void CellularOperatorInfo::OLP::SetMethod(const string &method) {
- dict_[kPaymentPortalMethod] = method;
-}
-
-const string &CellularOperatorInfo::OLP::GetPostData() const {
- return dict_.find(kPaymentPortalPostData)->second;
-}
-
-void CellularOperatorInfo::OLP::SetPostData(const string &post_data) {
- dict_[kPaymentPortalPostData] = post_data;
-}
-
-const Stringmap &CellularOperatorInfo::OLP::ToDict() const {
- return dict_;
-}
-
-namespace {
-
-typedef vector<const CellularOperatorInfo::CellularOperator *>
- ConstOperatorVector;
-
-string FormattedMCCMNC(const string &mccmnc) {
- return "[MCCMNC=" + mccmnc + "]";
-}
-
-string FormattedSID(const string &sid) {
- return "[SID=" + sid + "]";
-}
-
-template <class Collection>
-const typename Collection::value_type::second_type *FindOrNull(
- const Collection &collection,
- const typename Collection::value_type::first_type &key) {
- typename Collection::const_iterator it = collection.find(key);
- if (it == collection.end())
- return NULL;
- return &it->second;
-}
-
-typedef CellularOperatorInfo COI;
-bool ParseNameLine(const string &value, COI::LocalizedName *name) {
- vector<string> fields;
- base::SplitString(value, ',', &fields);
- if (fields.size() != 2) {
- LOG(ERROR) << "Badly formed \"name\" entry.";
- return false;
- }
- name->language = fields[0];
- name->name = fields[1];
- return true;
-}
-
-// Advances the file reader to the next line that is neither a line comment
-// nor empty and returns it in |line|. If the end of file is reached, returns
-// false.
-bool AdvanceToNextValidLine(FileReader &file_reader, string *line) {
- while (file_reader.ReadLine(line)) {
- TrimWhitespaceASCII(*line, TRIM_ALL, line);
- // Skip line comments.
- if ((*line)[0] == '#' || line->empty())
- continue;
- // If line consists of a single null character, skip
- if (line->length() == 1 && (*line)[0] == '\0')
- continue;
- return true;
- }
- return false;
-}
-
-// Splits |line| into two strings, separated with the |key_value_delimiter|.
-// Returns |false| if line does not contain |key_value_delimiter|, otherwise
-// returns the first substring in |key| and the second substring in |value|,
-// and returns true.
-bool ParseKeyValue(const string &line,
- char key_value_delimiter,
- std::string *key,
- std::string *value) {
- const size_t length = line.length();
- for (size_t i = 0; i < length; ++i) {
- if (line[i] == key_value_delimiter) {
- key->assign(line, 0, i);
- value->assign(line, i + 1, length-i);
- return true;
- }
- }
- LOG(ERROR) << "Badly formed line: " << line;
- return false;
-}
-
-} // namespace
-
-class CellularOperatorInfoImpl {
- public:
- CellularOperatorInfoImpl() {
- key_to_handler_["provider"] = new ProviderHandler(this);
- key_to_handler_["mccmnc"] = new MccmncHandler(this);
- key_to_handler_["name"] = new NameHandler(this);
- key_to_handler_["apn"] = new ApnHandler(this);
- key_to_handler_["sid"] = new SidHandler(this);
- key_to_handler_["olp"] = new OlpHandler(this);
- key_to_handler_["identifier"] = new IdentifierHandler(this);
- key_to_handler_["activation-code"] = new ActivationCodeHandler(this);
- key_to_handler_["country"] = new CountryHandler(this);
- }
-
- ~CellularOperatorInfoImpl() {
- STLDeleteContainerPairSecondPointers(key_to_handler_.begin(),
- key_to_handler_.end());
- }
-
- private:
- struct ParserState {
- ParserState() : provider(NULL), apn(NULL), parsing_apn(false) {}
-
- void Clear() {
- country.clear();
- provider = NULL;
- apn = NULL;
- parsing_apn = false;
- }
-
- std::string country;
- COI::CellularOperator *provider;
- COI::MobileAPN *apn;
-
- bool parsing_apn;
- };
-
- class KeyHandler {
- public:
- KeyHandler(CellularOperatorInfoImpl *info_impl) : info_impl_(info_impl) {}
- virtual ~KeyHandler() {}
-
- virtual bool HandleKey(const string &value) = 0;
-
- protected:
- CellularOperatorInfoImpl *info_impl() const { return info_impl_; }
-
- private:
- CellularOperatorInfoImpl *info_impl_;
-
- DISALLOW_COPY_AND_ASSIGN(KeyHandler);
- };
-
- class CountryHandler : public KeyHandler {
- public:
- CountryHandler(CellularOperatorInfoImpl *info_impl)
- : KeyHandler(info_impl) {}
-
- bool HandleKey(const string &value) {
- return info_impl()->HandleCountry(value);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CountryHandler);
- };
-
- class NameHandler : public KeyHandler {
- public:
- NameHandler(CellularOperatorInfoImpl *info_impl)
- : KeyHandler(info_impl) {}
-
- bool HandleKey(const string &value) {
- return info_impl()->HandleNameKey(value);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(NameHandler);
- };
-
- class ProviderHandler : public KeyHandler {
- public:
- ProviderHandler(CellularOperatorInfoImpl *info_impl)
- : KeyHandler(info_impl) {}
-
- bool HandleKey(const string &value) {
- return info_impl()->HandleProvider(value);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ProviderHandler);
- };
-
- class MccmncHandler : public KeyHandler {
- public:
- MccmncHandler(CellularOperatorInfoImpl *info_impl)
- : KeyHandler(info_impl) {}
-
- bool HandleKey(const string &value) {
- return info_impl()->HandleMCCMNC(value);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MccmncHandler);
- };
-
- class IdentifierHandler : public KeyHandler {
- public:
- IdentifierHandler(CellularOperatorInfoImpl *info_impl)
- : KeyHandler(info_impl) {}
-
- bool HandleKey(const string &value) {
- return info_impl()->HandleIdentifier(value);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(IdentifierHandler);
- };
-
- class ActivationCodeHandler : public KeyHandler {
- public:
- ActivationCodeHandler(CellularOperatorInfoImpl *info_impl)
- : KeyHandler(info_impl) {}
-
- bool HandleKey(const string &value) {
- return info_impl()->HandleActivationCode(value);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ActivationCodeHandler);
- };
-
- class ApnHandler : public KeyHandler {
- public:
- ApnHandler(CellularOperatorInfoImpl *info_impl)
- : KeyHandler(info_impl) {}
-
- bool HandleKey(const string &value) {
- return info_impl()->HandleAPN(value);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ApnHandler);
- };
-
- class SidHandler : public KeyHandler {
- public:
- SidHandler(CellularOperatorInfoImpl *info_impl)
- : KeyHandler(info_impl) {}
-
- bool HandleKey(const string &value) {
- return info_impl()->HandleSID(value);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(SidHandler);
- };
-
- class OlpHandler : public KeyHandler {
- public:
- OlpHandler(CellularOperatorInfoImpl *info_impl)
- : KeyHandler(info_impl) {}
-
- bool HandleKey(const string &value) {
- return info_impl()->HandleOLP(value);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(OlpHandler);
- };
-
- bool HandleFirstLine(FileReader &reader) {
- // Read until the first line that is not a line comment.
- string line;
- if (!AdvanceToNextValidLine(reader, &line))
- return false;
-
- string key, value;
- if (!ParseKeyValue(line, ':', &key, &value))
- return false;
-
- if (key != "serviceproviders") {
- LOG(ERROR) << "File does not begin with \"serviceproviders\" "
- << "entry.";
- return false;
- }
- if (value != "3.0") {
- LOG(ERROR) << "Unrecognized serviceproviders format.";
- return false;
- }
- return true;
- }
-
- bool HandleCountry(const string &value) {
- state_.country = value;
- return true;
- }
-
- bool HandleNameKey(const string &value) {
- if (state_.parsing_apn)
- return HandleAPNName(value);
- return HandleName(value);
- }
-
- bool HandleProvider(const string &value) {
- state_.parsing_apn = false;
-
- vector<string> fields;
- base::SplitString(value, ',', &fields);
- if (fields.size() != 4) {
- LOG(ERROR) << "Badly formed \"provider\" entry.";
- return false;
- }
-
- int is_primary = 0;
- if (!base::StringToInt(fields[2], &is_primary)) {
- LOG(ERROR) << "Badly formed value for \"is_primary\": " << fields[2];
- return false;
- }
- int requires_roaming = 0;
- if (!base::StringToInt(fields[3], &requires_roaming)) {
- LOG(ERROR) << "Badly formed value for \"requires_roaming\": "
- << fields[3];
- return false;
- }
- state_.provider = new COI::CellularOperator();
- state_.provider->is_primary_ = is_primary != 0;
- state_.provider->requires_roaming_ = requires_roaming != 0;
- state_.provider->country_ = state_.country;
-
- operators_.push_back(state_.provider);
- return true;
- }
-
- bool HandleMCCMNC(const string &value) {
- if (value.empty()) {
- LOG(ERROR) << "Empty \"mccmnc\" value.";
- return false;
- }
- if (!state_.provider) {
- LOG(ERROR) << "Found \"mccmnc\" entry without \"provider\".";
- return false;
- }
-
- vector<string> mccmnc_list;
- base::SplitString(value, ',', &mccmnc_list);
- if ((mccmnc_list.size() % 2) != 0) {
- LOG(ERROR) << "Badly formatted \"mccmnc\" entry. "
- << "Expected even number of elements.";
- return false;
- }
-
- for (size_t i = 0; i < mccmnc_list.size(); i += 2) {
- const string &mccmnc = mccmnc_list[i];
- if (!mccmnc.empty()) {
- state_.provider->mccmnc_list_.push_back(mccmnc);
- mccmnc_to_operator_[mccmnc] = state_.provider;
- int index = -1;
- if (base::StringToInt(mccmnc_list[i + 1], &index))
- state_.provider->mccmnc_to_olp_idx_[mccmnc] = index;
- }
- }
- return true;
- }
-
- bool HandleIdentifier(const string &value) {
- if (!state_.provider) {
- LOG(ERROR) << "Found \"identifier\" entry without \"provider\".";
- return false;
- }
- state_.provider->identifier_ = value;
- return true;
- }
-
- bool HandleActivationCode(const string &value) {
- if (!state_.provider) {
- LOG(ERROR) << "Found \"activation-code\" entry without \"provider\".";
- return false;
- }
- state_.provider->activation_code_ = value;
- return true;
- }
-
- bool HandleAPN(const string &value) {
- if (!state_.provider) {
- LOG(ERROR) << "Found \"apn\" entry without \"provider\".";
- return false;
- }
- vector<string> fields;
- base::SplitString(value, ',', &fields);
- if (fields.size() != 4) {
- LOG(ERROR) << "Badly formed \"apn\" entry.";
- return false;
- }
- state_.apn = new COI::MobileAPN();
- state_.apn->apn = fields[1];
- state_.apn->username = fields[2];
- state_.apn->password = fields[3];
- state_.provider->apn_list_.push_back(state_.apn);
- state_.parsing_apn = true;
- return true;
- }
-
- bool HandleAPNName(const string &value) {
- if (!(state_.parsing_apn && state_.apn)) {
- LOG(ERROR) << "APN not being parsed.";
- return false;
- }
- COI::LocalizedName name;
- if (!ParseNameLine(value, &name))
- return false;
- state_.apn->name_list.push_back(name);
- return true;
- }
-
- bool HandleName(const string &value) {
- if (!state_.provider) {
- LOG(ERROR) << "Found \"name\" entry without \"provider\".";
- return false;
- }
-
- COI::LocalizedName name;
- if (!ParseNameLine(value, &name))
- return false;
-
- if (state_.provider->name_list_.size() == 0) {
- ConstOperatorVector &matching_operators =
- name_to_operators_[name.name];
- matching_operators.push_back(state_.provider);
- }
- state_.provider->name_list_.push_back(name);
- return true;
- }
-
- bool HandleSID(const string &value) {
- if (value.empty()) {
- LOG(ERROR) << "Empty \"sid\" value.";
- return false;
- }
- if (!state_.provider) {
- LOG(ERROR) << "Found \"sid\" entry without \"provider\".";
- return false;
- }
- vector<string> sid_list;
- base::SplitString(value, ',', &sid_list);
- if ((sid_list.size() % 2) != 0) {
- LOG(ERROR) << "Badly formatted \"sid\" entry. "
- << "Expected even number of elements. ";
- return false;
- }
-
- for (size_t i = 0; i < sid_list.size(); i += 2) {
- const string &sid = sid_list[i];
- if (!sid.empty()) {
- state_.provider->sid_list_.push_back(sid);
- sid_to_operator_[sid] = state_.provider;
- int index = -1;
- if (base::StringToInt(sid_list[i + 1], &index))
- state_.provider->sid_to_olp_idx_[sid] = index;
- }
- }
- return true;
- }
-
- bool HandleOLP(const string &value) {
- if (!state_.provider) {
- LOG(ERROR) << "Found \"olp\" entry without \"provider\"";
- return false;
- }
- vector<string> fields;
- base::SplitString(value, ',', &fields);
- if (fields.size() != 3) {
- LOG(ERROR) << "Badly formed \"apn\" entry.";
- return false;
- }
- CellularOperatorInfo::OLP *olp = new CellularOperatorInfo::OLP();
- olp->SetMethod(fields[0]);
- olp->SetURL(fields[1]);
- olp->SetPostData(fields[2]);
-
- state_.provider->olp_list_.push_back(olp);
- return true;
- }
-
- void ClearOperators() {
- operators_.clear();
- mccmnc_to_operator_.clear();
- sid_to_operator_.clear();
- name_to_operators_.clear();
- }
-
- bool HandleKeyValue(const string &key, const string &value) {
- KeyHandler * const *handler = FindOrNull(key_to_handler_, key);
- if (!handler) {
- LOG(ERROR) << "Invalid key \"" << key << "\".";
- return false;
- }
- return (*handler)->HandleKey(value);
- }
-
- bool Load(const FilePath &info_file_path) {
- // Clear any previus operators.
- ClearOperators();
-
- FileReader file_reader;
- if (!file_reader.Open(info_file_path)) {
- LOG(ERROR) << "Could not open operator info file.";
- return false;
- }
-
- // See data/cellular_operator_info for the format of file contents.
-
- state_.Clear();
-
- if (!HandleFirstLine(file_reader))
- return false;
-
- string line;
- while (true) {
- if (!AdvanceToNextValidLine(file_reader, &line))
- break;
-
- string key, value;
- if (!ParseKeyValue(line, ':', &key, &value)) {
- ClearOperators();
- return false;
- }
-
- if (!HandleKeyValue(key, value)) {
- LOG(ERROR) << "Failed to parse \"" << key << "\" entry.";
- ClearOperators();
- return false;
- }
- }
- return true;
- }
-
- private:
- friend class CellularOperatorInfo;
-
- ParserState state_;
-
- ScopedVector<COI::CellularOperator> operators_;
- map<string, COI::CellularOperator *> mccmnc_to_operator_;
- map<string, COI::CellularOperator *> sid_to_operator_;
- map<string, ConstOperatorVector> name_to_operators_;
-
- map<string, KeyHandler *> key_to_handler_;
-
- DISALLOW_COPY_AND_ASSIGN(CellularOperatorInfoImpl);
-};
-
-COI::LocalizedName::LocalizedName() {}
-COI::LocalizedName::LocalizedName(string name,
- string language)
- : name(name),
- language(language) {}
-
-CellularOperatorInfo::CellularOperator::CellularOperator()
- : is_primary_(false),
- requires_roaming_(false) {}
-
-CellularOperatorInfo::CellularOperatorInfo()
- : impl_(new CellularOperatorInfoImpl()) {}
-CellularOperatorInfo::~CellularOperatorInfo() {}
-
-const ScopedVector<CellularOperatorInfo::CellularOperator> &
-CellularOperatorInfo::operators() const {
- return impl_->operators_;
-}
-
-const CellularOperatorInfo::CellularOperator *
-CellularOperatorInfo::GetCellularOperatorByMCCMNC(const string &mccmnc) const {
- SLOG(Cellular, 2) << __func__ << "(" << FormattedMCCMNC(mccmnc) << ")";
-
- CellularOperator * const *provider =
- FindOrNull(impl_->mccmnc_to_operator_, mccmnc);
- if (!provider) {
- LOG(ERROR) << "Operator with " << FormattedMCCMNC(mccmnc)
- << " not found.";
- return NULL;
- }
- return *provider;
-}
-
-const CellularOperatorInfo::CellularOperator *
-CellularOperatorInfo::GetCellularOperatorBySID(const string &sid) const {
- SLOG(Cellular, 2) << __func__ << "(" << FormattedSID(sid) << ")";
-
- CellularOperator * const *provider = FindOrNull(impl_->sid_to_operator_, sid);
- if (!provider) {
- LOG(ERROR) << "Operator with " << FormattedSID(sid) << " not found.";
- return NULL;
- }
- return *provider;
-}
-
-const ConstOperatorVector *CellularOperatorInfo::GetCellularOperators(
- const string &name) const {
- SLOG(Cellular, 2) << __func__ << "(" << name << ")";
-
- const ConstOperatorVector *providers =
- FindOrNull(impl_->name_to_operators_, name);
- if (!providers) {
- LOG(ERROR) << "Given name \"" << name << "\" did not match any operators.";
- return NULL;
- }
- return providers;
-}
-
-const CellularOperatorInfo::OLP *
-CellularOperatorInfo::GetOLPByMCCMNC(const string &mccmnc) const {
- SLOG(Cellular, 2) << __func__ << "(" << FormattedMCCMNC(mccmnc) << ")";
-
- const CellularOperator *provider = GetCellularOperatorByMCCMNC(mccmnc);
- if (!provider)
- return NULL;
-
- const uint32 *indexptr = FindOrNull(provider->mccmnc_to_olp_idx_, mccmnc);
- if (!indexptr)
- return NULL;
-
- uint32 index = *indexptr;
- if (index >= provider->olp_list_.size()) {
- LOG(ERROR) << "Invalid OLP index found for "
- << FormattedMCCMNC(mccmnc) << ".";
- return NULL;
- }
-
- return provider->olp_list_[index];
-}
-
-const CellularOperatorInfo::OLP *
-CellularOperatorInfo::GetOLPBySID(const string &sid) const {
- SLOG(Cellular, 2) << __func__ << "(" << FormattedSID(sid) << ")";
-
- const CellularOperator *provider = GetCellularOperatorBySID(sid);
- if (!provider)
- return NULL;
-
- const uint32 *indexptr = FindOrNull(provider->sid_to_olp_idx_, sid);
- if (!indexptr)
- return NULL;
-
- uint32 index = *indexptr;
- if (index >= provider->olp_list_.size()) {
- LOG(ERROR) << "Invalid OLP index found for " << FormattedSID(sid) << ".";
- return NULL;
- }
-
- return provider->olp_list_[index];
-}
-
-bool CellularOperatorInfo::Load(const FilePath &info_file_path) {
- SLOG(Cellular, 2) << __func__ << "(" << info_file_path.value() << ")";
- return impl_->Load(info_file_path);
-}
-
-} // namespace shill
diff --git a/cellular_operator_info.h b/cellular_operator_info.h
deleted file mode 100644
index ef7b44c..0000000
--- a/cellular_operator_info.h
+++ /dev/null
@@ -1,237 +0,0 @@
-// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Defines shill::CellularOperatorInfo, which is meant to replace the
-// mobile-broadband-provider-info library by providing the same mechanisms in
-// C++. It also extends the information provided by
-// mobile-broadband-provider-info.
-
-#ifndef SHILL_CELLULAR_OPERATOR_INFO_H_
-#define SHILL_CELLULAR_OPERATOR_INFO_H_
-
-#include <map>
-#include <string>
-#include <vector>
-
-#include <base/basictypes.h>
-#include <base/files/file_path.h>
-#include <base/memory/scoped_ptr.h>
-#include <base/memory/scoped_vector.h>
-#include <gtest/gtest_prod.h> // for FRIEND_TEST
-
-#include "shill/cellular_service.h"
-#include "shill/file_reader.h"
-
-namespace shill {
-
-class CellularOperatorInfoImpl;
-
-// CellularOperatorInfo, which is a utility class for parsing
-// cellular carrier specific infomation from a specially formatted file that
-// encodes carrier related data in a key-value format.
-class CellularOperatorInfo {
- public:
- // Encapsulates a name and the language that name has been localized to.
- // The name can be a carrier name, or the name that a cellular carrier
- // prefers to show for a certain access point.
- struct LocalizedName {
- LocalizedName();
- LocalizedName(std::string name, std::string language);
-
- // The name as it appears in the corresponding language.
- std::string name;
-
- // The language of this localized name. The format of a language is a two
- // letter language code, e.g. 'en' for English.
- // It is legal for an instance of LocalizedName to have an empty |language|
- // field, as sometimes the underlying database does not contain that
- // information.
- std::string language;
- };
-
- // Encapsulates information on a mobile access point name. This information
- // is usually necessary for 3GPP networks to be able to connect to a mobile
- // network. So far, CDMA networks don't use this information.
- struct MobileAPN {
- // The access point url, which is fed to the modemmanager while connecting.
- std::string apn;
-
- // A list of localized names for this access point. Usually there is only
- // one for each country that the associated cellular carrier operates in.
- std::vector<LocalizedName> name_list;
-
- // The username and password fields that are required by the modemmanager.
- // Either of these values can be empty if none is present. If a MobileAPN
- // instance that is obtained from this parser contains a non-empty value
- // for username/password, this usually means that the carrier requires
- // a certain default pair.
- std::string username;
- std::string password;
- };
-
- // TODO(pprabhu) This is a temporary addition to CellularOperatorInfo, to make
- // it easy to transition the rest of the code away from using ::OLP.
- // CellularOperatorInfo is soon going away anyway.
- class OLP {
- public:
- OLP();
- ~OLP();
-
- void CopyFrom(const OLP &olp);
- bool Equals(const OLP &olp) const;
-
- const std::string &GetURL() const;
- void SetURL(const std::string &url);
-
- const std::string &GetMethod() const;
- void SetMethod(const std::string &method);
-
- const std::string &GetPostData() const;
- void SetPostData(const std::string &post_data);
-
- const Stringmap &ToDict() const;
-
- private:
- Stringmap dict_;
-
- DISALLOW_COPY_AND_ASSIGN(OLP);
- };
-
- // This class contains all the necessary information for shill to register
- // with and establish a connection to a mobile network.
- class CellularOperator {
- public:
- CellularOperator();
-
- // For this instance, returns the primary country code that this operator
- // serves. The underlying database sometimes contains multiple entries for
- // the same carrier for different countries.
- const std::string &country() const { return country_; }
-
- // The unique identifier of this carrier. This is primarily used to
- // identify the user profile in store for each carrier. This identifier is
- // access technology agnostic and should be the same across 3GPP and CDMA.
- const std::string &identifier() const { return identifier_; }
-
- // The number to dial for automatic activation.
- const std::string &activation_code() const { return activation_code_; }
-
- // MCCMNC or (MCC/MNC tuple) is the combination of a "Mobile Country Code"
- // and "Mobile Network Code" and is used to uniquely identify a carrier.
- // ModemManager currently return MCCMNC as the primary operator code for
- // 3GPP networks. A carrier can be associated with multiple MCCMNC values
- // based on location and technology (e.g. 3G, LTE).
- const std::vector<std::string> &mccmnc_list() const {
- return mccmnc_list_;
- }
-
- // The SID is the primary operator code currently used by ModemManager to
- // identify CDMA networks. There are likely many SID values associated with
- // a CDMA carrier as they vary across regions and are more fine grained
- // than countries. An important thing to keep in mind is that, since an SID
- // contains fine grained information on where a modem is physically
- // located, it should be regarded as user-sensitive information.
- const std::vector<std::string> &sid_list() const { return sid_list_; }
-
- // All localized names associated with this carrier entry.
- const std::vector<LocalizedName> &name_list() const { return name_list_; }
-
- // All access point names associated with this carrier entry.
- const ScopedVector<MobileAPN> &apn_list() const { return apn_list_; }
-
- // All Online Payment Portal URLs associated with this carrier entry. There
- // are usually multiple OLPs based on access technology and it is up to the
- // application to use the appropriate one.
- const ScopedVector<CellularOperatorInfo::OLP> &olp_list() const {
- return olp_list_;
- }
-
- // This flag is declared for certain carriers in the underlying database.
- // Shill currently does not use it.
- bool is_primary() const { return is_primary_; }
-
- // Some carriers are only available while roaming. This is mainly used by
- // Chrome.
- bool requires_roaming() const { return requires_roaming_; }
-
- private:
- friend class CellularOperatorInfo;
- friend class CellularOperatorInfoImpl;
- friend class CellularCapabilityUniversalCDMATest;
- friend class MobileOperatorTest;
- FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest,
- OnCDMARegistrationChanged);
- FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, UpdateOLP);
- FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, UpdateOperatorInfo);
- FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest,
- UpdateStorageIdentifier);
- FRIEND_TEST(CellularCapabilityUniversalMainTest, GetMdnForOLP);
- FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateOLP);
- FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateStorageIdentifier);
-
- std::string country_;
- std::string identifier_;
- std::string activation_code_;
- std::vector<std::string> mccmnc_list_;
- std::vector<std::string> sid_list_;
- std::vector<LocalizedName> name_list_;
- ScopedVector<MobileAPN> apn_list_;
- ScopedVector<CellularOperatorInfo::OLP> olp_list_;
- std::map<std::string, uint32> mccmnc_to_olp_idx_;
- std::map<std::string, uint32> sid_to_olp_idx_;
- bool is_primary_;
- bool requires_roaming_;
-
- DISALLOW_COPY_AND_ASSIGN(CellularOperator);
- };
-
- // The class Constructor and Destructor don't perform any special
- // initialization or cleanup. The primary initializer is the Load()
- // method.
- CellularOperatorInfo();
- virtual ~CellularOperatorInfo();
-
- // Loads the operator info from |info_file_path|. Returns true on success.
- bool Load(const base::FilePath &info_file_path);
-
- // Gets the cellular operator info of the operator with MCCMNC |mccmnc|.
- // If found, returns a pointer to the matching operator.
- virtual const CellularOperator *GetCellularOperatorByMCCMNC(
- const std::string &mccmnc) const;
-
- // Gets the cellular operator info of the operator with SID |sid|.
- // If found, returns a pointer to the matching operator.
- virtual const CellularOperator *GetCellularOperatorBySID(
- const std::string &sid) const;
-
- // Gets the cellular operator info of the operators that match the name
- // |name|, such that each element contains information about the operator
- // in different countries. The given name must be the first enumerated name
- // for the operator in the operator database.
- // If found, returns a pointer to a vector containing the matching operators.
- virtual const std::vector<const CellularOperator *> *GetCellularOperators(
- const std::string &name) const;
-
- // Gets the online payment portal info of the operator with MCCMNC |mccmnc|.
- // If found, returns a pointer to the matching OLP.
- virtual const CellularOperatorInfo::OLP *GetOLPByMCCMNC(
- const std::string &mccmnc) const;
-
- // Gets the online payment portal info of the operator with SID |sid|.
- // If found, returns a pointer to the matching OLP.
- virtual const CellularOperatorInfo::OLP *GetOLPBySID(
- const std::string &sid) const;
-
- // Returns a list of all operators.
- const ScopedVector<CellularOperator> &operators() const;
-
- private:
- scoped_ptr<CellularOperatorInfoImpl> impl_;
-
- DISALLOW_COPY_AND_ASSIGN(CellularOperatorInfo);
-};
-
-} // namespace shill
-
-#endif // SHILL_CELLULAR_OPERATOR_INFO_H_
diff --git a/cellular_operator_info_unittest.cc b/cellular_operator_info_unittest.cc
deleted file mode 100644
index 4714fb8..0000000
--- a/cellular_operator_info_unittest.cc
+++ /dev/null
@@ -1,597 +0,0 @@
-// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "shill/cellular_operator_info.h"
-
-#include <base/file_util.h>
-#include <gtest/gtest.h>
-
-#include "shill/glib.h"
-
-using base::FilePath;
-using std::map;
-using std::string;
-using std::vector;
-
-namespace shill {
-
-namespace {
-
-const char kTestInfoFileContent[] =
- "#\n"
- "# Comments\n"
- "#\n"
- "serviceproviders:3.0\n"
- "country:us\n"
- "\n"
- "# TestProvider1\n"
- "provider:1,1,0,1\n"
- "identifier:provider1identifier\n"
- "name:,TestProvider1\n"
- "mccmnc:000001,0,000002,0\n"
- "sid:1,0,2,0,3,0\n"
- "olp:POST,https://testurl,imei=${imei}&iccid=${iccid}\n"
- "apn:2,testprovider1apn,,\n"
- "name:en,Test Provider 1\n"
- "name:de,Testmobilfunkanbieter 1\n"
- "\n"
- "# TestProvider2\n"
- "provider:1,2,1,0\n"
- "identifier:provider2identifier\n"
- "name:,TestProviderTwo\n"
- "name:,TestProvider2\n"
- "mccmnc:100001,1,100002,0\n"
- "sid:4,0,5,1\n"
- "olp:,https://testurl2,\n"
- "olp:,https://testurl3,\n"
- "apn:1,testprovider2apn,,\n"
- "name:,Test Provider 2\n"
- "apn:1,testprovider2apn2,testusername,testpassword\n"
- "name:tr,Test Operatoru 2\n";
-
-} // namespace
-
-class CellularOperatorInfoTest : public testing::Test {
- public:
- CellularOperatorInfoTest() {}
-
- protected:
- void SetUp() {
- ASSERT_TRUE(base::CreateTemporaryFile(&info_file_path_));
- ASSERT_EQ(arraysize(kTestInfoFileContent),
- file_util::WriteFile(info_file_path_, kTestInfoFileContent,
- arraysize(kTestInfoFileContent)));
- }
-
- void TruncateFile() {
- FILE *file = base::OpenFile(info_file_path_, "rw");
- base::TruncateFile(file);
- base::CloseFile(file);
- }
-
- void WriteToFile(const char *content) {
- ASSERT_EQ(strlen(content),
- file_util::WriteFile(info_file_path_, content, strlen(content)));
- }
-
- void TruncateAndWriteToFile(const char *content) {
- TruncateFile();
- WriteToFile(content);
- }
-
- void TearDown() {
- ASSERT_TRUE(base::DeleteFile(info_file_path_, false));
- }
-
- GLib glib_;
- FilePath info_file_path_;
- CellularOperatorInfo info_;
-};
-
-TEST_F(CellularOperatorInfoTest, ParseSuccess) {
- EXPECT_TRUE(info_.Load(info_file_path_));
- EXPECT_EQ(2, info_.operators().size());
-
- const CellularOperatorInfo::CellularOperator *provider = info_.operators()[0];
- EXPECT_FALSE(provider->is_primary());
- EXPECT_TRUE(provider->requires_roaming());
- EXPECT_EQ("us", provider->country());
- EXPECT_EQ("provider1identifier", provider->identifier());
- EXPECT_EQ(1, provider->name_list().size());
- EXPECT_TRUE(provider->name_list()[0].language.empty());
- EXPECT_EQ("TestProvider1", provider->name_list()[0].name);
- EXPECT_EQ(2, provider->mccmnc_list().size());
- EXPECT_EQ("000001", provider->mccmnc_list()[0]);
- EXPECT_EQ("000002", provider->mccmnc_list()[1]);
- EXPECT_EQ(3, provider->sid_list().size());
- EXPECT_EQ("1", provider->sid_list()[0]);
- EXPECT_EQ("2", provider->sid_list()[1]);
- EXPECT_EQ("3", provider->sid_list()[2]);
- EXPECT_EQ(1, provider->olp_list().size());
- EXPECT_EQ("https://testurl", provider->olp_list()[0]->GetURL());
- EXPECT_EQ("POST", provider->olp_list()[0]->GetMethod());
- EXPECT_EQ("imei=${imei}&iccid=${iccid}",
- provider->olp_list()[0]->GetPostData());
- EXPECT_EQ(1, provider->apn_list().size());
- EXPECT_EQ("testprovider1apn", provider->apn_list()[0]->apn);
- EXPECT_TRUE(provider->apn_list()[0]->username.empty());
- EXPECT_TRUE(provider->apn_list()[0]->password.empty());
- EXPECT_EQ(2, provider->apn_list()[0]->name_list.size());
- EXPECT_EQ("en", provider->apn_list()[0]->name_list[0].language);
- EXPECT_EQ("Test Provider 1", provider->apn_list()[0]->name_list[0].name);
- EXPECT_EQ("de", provider->apn_list()[0]->name_list[1].language);
- EXPECT_EQ("Testmobilfunkanbieter 1",
- provider->apn_list()[0]->name_list[1].name);
-
- const CellularOperatorInfo::CellularOperator *provider2 =
- info_.operators()[1];
- EXPECT_TRUE(provider2->is_primary());
- EXPECT_FALSE(provider2->requires_roaming());
- EXPECT_EQ("us", provider2->country());
- EXPECT_EQ("provider2identifier", provider2->identifier());
- EXPECT_EQ(2, provider2->name_list().size());
- EXPECT_TRUE(provider2->name_list()[0].language.empty());
- EXPECT_EQ("TestProviderTwo", provider2->name_list()[0].name);
- EXPECT_TRUE(provider2->name_list()[1].language.empty());
- EXPECT_EQ("TestProvider2", provider2->name_list()[1].name);
- EXPECT_EQ(2, provider2->mccmnc_list().size());
- EXPECT_EQ("100001", provider2->mccmnc_list()[0]);
- EXPECT_EQ("100002", provider2->mccmnc_list()[1]);
- EXPECT_EQ(2, provider2->sid_list().size());
- EXPECT_EQ("4", provider2->sid_list()[0]);
- EXPECT_EQ("5", provider2->sid_list()[1]);
- EXPECT_EQ(2, provider2->olp_list().size());
- EXPECT_EQ("https://testurl2", provider2->olp_list()[0]->GetURL());
- EXPECT_TRUE(provider2->olp_list()[0]->GetMethod().empty());
- EXPECT_TRUE(provider2->olp_list()[0]->GetPostData().empty());
- EXPECT_EQ("https://testurl3", provider2->olp_list()[1]->GetURL());
- EXPECT_TRUE(provider2->olp_list()[1]->GetMethod().empty());
- EXPECT_TRUE(provider2->olp_list()[1]->GetPostData().empty());
- EXPECT_EQ(2, provider2->apn_list().size());
- EXPECT_EQ("testprovider2apn", provider2->apn_list()[0]->apn);
- EXPECT_TRUE(provider2->apn_list()[0]->username.empty());
- EXPECT_TRUE(provider2->apn_list()[0]->password.empty());
- EXPECT_EQ(1, provider2->apn_list()[0]->name_list.size());
- EXPECT_TRUE(provider2->apn_list()[0]->name_list[0].language.empty());
- EXPECT_EQ("Test Provider 2",
- provider2->apn_list()[0]->name_list[0].name);
- EXPECT_EQ("testprovider2apn2", provider2->apn_list()[1]->apn);
- EXPECT_EQ("testusername", provider2->apn_list()[1]->username);
- EXPECT_EQ("testpassword", provider2->apn_list()[1]->password);
- EXPECT_EQ(1, provider2->apn_list()[1]->name_list.size());
- EXPECT_EQ("tr", provider2->apn_list()[1]->name_list[0].language);
- EXPECT_EQ("Test Operatoru 2",
- provider2->apn_list()[1]->name_list[0].name);
-}
-
-TEST_F(CellularOperatorInfoTest, GetCellularOperatorByMCCMNC) {
- EXPECT_TRUE(info_.Load(info_file_path_));
-
- EXPECT_FALSE(info_.GetCellularOperatorByMCCMNC("1"));
- EXPECT_FALSE(info_.GetCellularOperatorByMCCMNC("000003"));
- EXPECT_FALSE(info_.GetCellularOperatorByMCCMNC("bananas"));
- EXPECT_FALSE(info_.GetCellularOperatorByMCCMNC("abcd"));
-
- const CellularOperatorInfo::CellularOperator *provider = NULL;
- EXPECT_TRUE((provider = info_.GetCellularOperatorByMCCMNC("000001")));
- EXPECT_EQ(info_.operators()[0], provider);
- EXPECT_TRUE((provider = info_.GetCellularOperatorByMCCMNC("100001")));
- EXPECT_EQ(info_.operators()[1], provider);
- EXPECT_TRUE((provider = info_.GetCellularOperatorByMCCMNC("000002")));
- EXPECT_EQ(info_.operators()[0], provider);
- EXPECT_TRUE((provider = info_.GetCellularOperatorByMCCMNC("100002")));
- EXPECT_EQ(info_.operators()[1], provider);
-}
-
-TEST_F(CellularOperatorInfoTest, GetCellularOperatorBySID) {
- EXPECT_TRUE(info_.Load(info_file_path_));
-
- EXPECT_FALSE(info_.GetCellularOperatorBySID("000001"));
- EXPECT_FALSE(info_.GetCellularOperatorBySID("000002"));
- EXPECT_FALSE(info_.GetCellularOperatorBySID("100001"));
- EXPECT_FALSE(info_.GetCellularOperatorBySID("100002"));
- EXPECT_FALSE(info_.GetCellularOperatorBySID("banana"));
-
- const CellularOperatorInfo::CellularOperator *provider = NULL;
- EXPECT_TRUE((provider = info_.GetCellularOperatorBySID("1")));
- EXPECT_EQ(info_.operators()[0], provider);
- EXPECT_TRUE((provider = info_.GetCellularOperatorBySID("4")));
- EXPECT_EQ(info_.operators()[1], provider);
- EXPECT_TRUE((provider = info_.GetCellularOperatorBySID("2")));
- EXPECT_EQ(info_.operators()[0], provider);
- EXPECT_TRUE((provider = info_.GetCellularOperatorBySID("5")));
- EXPECT_EQ(info_.operators()[1], provider);
- EXPECT_TRUE((provider = info_.GetCellularOperatorBySID("3")));
- EXPECT_EQ(info_.operators()[0], provider);
-}
-
-TEST_F(CellularOperatorInfoTest, GetCellularOperators) {
- EXPECT_TRUE(info_.Load(info_file_path_));
-
- const vector<const CellularOperatorInfo::CellularOperator *> *list = NULL;
- EXPECT_FALSE(info_.GetCellularOperators("banana"));
- EXPECT_FALSE(info_.GetCellularOperators("TestProvider2"));
-
- EXPECT_TRUE((list = info_.GetCellularOperators("TestProvider1")));
- EXPECT_EQ(1, list->size());
- EXPECT_EQ("testprovider1apn", (*list)[0]->apn_list()[0]->apn);
-
- EXPECT_FALSE(info_.GetCellularOperators("TestProvider2"));
-
- EXPECT_TRUE((list = info_.GetCellularOperators("TestProviderTwo")));
- EXPECT_EQ(1, list->size());
- EXPECT_EQ("testprovider2apn", (*list)[0]->apn_list()[0]->apn);
-}
-
-TEST_F(CellularOperatorInfoTest, GetOLPByMCCMNC) {
- EXPECT_TRUE(info_.Load(info_file_path_));
-
- const CellularOperatorInfo::OLP *olp = NULL;
- EXPECT_TRUE((olp = info_.GetOLPByMCCMNC("000001")));
- EXPECT_EQ("https://testurl", olp->GetURL());
- EXPECT_EQ("POST", olp->GetMethod());
- EXPECT_EQ("imei=${imei}&iccid=${iccid}", olp->GetPostData());
-
- EXPECT_TRUE((olp = info_.GetOLPByMCCMNC("000002")));
- EXPECT_EQ("https://testurl", olp->GetURL());
- EXPECT_EQ("POST", olp->GetMethod());
- EXPECT_EQ("imei=${imei}&iccid=${iccid}", olp->GetPostData());
-
- EXPECT_TRUE((olp = info_.GetOLPByMCCMNC("100001")));
- EXPECT_EQ("https://testurl3", olp->GetURL());
- EXPECT_TRUE(olp->GetMethod().empty());
- EXPECT_TRUE(olp->GetPostData().empty());
-
- EXPECT_TRUE((olp = info_.GetOLPByMCCMNC("100002")));
- EXPECT_EQ("https://testurl2", olp->GetURL());
- EXPECT_TRUE(olp->GetMethod().empty());
- EXPECT_TRUE(olp->GetPostData().empty());
-
- EXPECT_FALSE(info_.GetOLPByMCCMNC("000003"));
- EXPECT_FALSE(info_.GetOLPByMCCMNC("000004"));
-}
-
-TEST_F(CellularOperatorInfoTest, GetOLPBySID) {
- EXPECT_TRUE(info_.Load(info_file_path_));
-
- const CellularOperatorInfo::OLP *olp = NULL;
- EXPECT_TRUE((olp = info_.GetOLPBySID("1")));
- EXPECT_EQ("https://testurl", olp->GetURL());
- EXPECT_EQ("POST", olp->GetMethod());
- EXPECT_EQ("imei=${imei}&iccid=${iccid}", olp->GetPostData());
-
- EXPECT_TRUE((olp = info_.GetOLPBySID("2")));
- EXPECT_EQ("https://testurl", olp->GetURL());
- EXPECT_EQ("POST", olp->GetMethod());
- EXPECT_EQ("imei=${imei}&iccid=${iccid}", olp->GetPostData());
-
- EXPECT_TRUE((olp = info_.GetOLPBySID("3")));
- EXPECT_EQ("https://testurl", olp->GetURL());
- EXPECT_EQ("POST", olp->GetMethod());
- EXPECT_EQ("imei=${imei}&iccid=${iccid}", olp->GetPostData());
-
- EXPECT_TRUE((olp = info_.GetOLPBySID("4")));
- EXPECT_EQ("https://testurl2", olp->GetURL());
- EXPECT_TRUE(olp->GetMethod().empty());
- EXPECT_TRUE(olp->GetPostData().empty());
-
- EXPECT_TRUE((olp = info_.GetOLPBySID("5")));
- EXPECT_EQ("https://testurl3", olp->GetURL());
- EXPECT_TRUE(olp->GetMethod().empty());
- EXPECT_TRUE(olp->GetPostData().empty());
-
- EXPECT_FALSE(info_.GetOLPBySID("6"));
- EXPECT_FALSE(info_.GetOLPBySID("7"));
-}
-
-TEST_F(CellularOperatorInfoTest, BadServiceProvidersLine) {
- TruncateFile();
-
- // Invalid first line.
- TruncateAndWriteToFile(
- "# Bla bla bla\n"
- "# Blabbidy boo\n"
- "serviceproviders:2.3\n");
- EXPECT_FALSE(info_.Load(info_file_path_));
-
- // Valid first line
- TruncateAndWriteToFile(
- "# Bla bla bla\n"
- "# Blabbidy boo\n"
- "serviceproviders:3.0\n");
- EXPECT_TRUE(info_.Load(info_file_path_));
-}
-
-TEST_F(CellularOperatorInfoTest, HandleProvider) {
- // Invalid provider entry
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "# Invalid provider entry\n"
- "provider:0,0,0\n");
- EXPECT_FALSE(info_.Load(info_file_path_));
- EXPECT_TRUE(info_.operators().empty());
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "# Invalid provider entry\n"
- "provider:1,1,0,1\n");
- EXPECT_TRUE(info_.Load(info_file_path_));
- EXPECT_EQ(1, info_.operators().size());
- EXPECT_FALSE(info_.operators()[0]->is_primary());
- EXPECT_TRUE(info_.operators()[0]->requires_roaming());
- EXPECT_TRUE(info_.operators()[0]->country().empty());
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "# Invalid provider entry\n"
- "country:us\n"
- "provider:1,1,1,0\n");
- EXPECT_TRUE(info_.Load(info_file_path_));
- EXPECT_EQ(1, info_.operators().size());
- EXPECT_TRUE(info_.operators()[0]->is_primary());
- EXPECT_FALSE(info_.operators()[0]->requires_roaming());
- EXPECT_EQ("us", info_.operators()[0]->country());
-}
-
-TEST_F(CellularOperatorInfoTest, HandleMCCMNC) {
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "# MCCMNC entry without a provider.\n"
- "mccmnc:1,1\n");
- EXPECT_FALSE(info_.Load(info_file_path_));
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "# Empty MCCMNC entry.\n"
- "provider:1,1,0,1\n"
- "mccmnc:\n");
- EXPECT_FALSE(info_.Load(info_file_path_));
- EXPECT_TRUE(info_.operators().empty());
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "# MCCMNC entry has odd number of values.\n"
- "provider:1,1,0,1\n"
- "mccmnc:000001,0,000002\n");
-
- EXPECT_FALSE(info_.Load(info_file_path_));
- EXPECT_TRUE(info_.operators().empty());
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "# MCCMNC entry in this one is good.\n"
- "provider:1,1,0,1\n"
- "mccmnc:000001,0,000002,3\n");
-
- EXPECT_TRUE(info_.Load(info_file_path_));
- EXPECT_EQ(1, info_.operators().size());
- EXPECT_EQ(2, info_.operators()[0]->mccmnc_list().size());
- EXPECT_EQ("000001", info_.operators()[0]->mccmnc_list()[0]);
- EXPECT_EQ("000002", info_.operators()[0]->mccmnc_list()[1]);
- EXPECT_EQ(info_.operators()[0], info_.GetCellularOperatorByMCCMNC("000001"));
- EXPECT_EQ(info_.operators()[0], info_.GetCellularOperatorByMCCMNC("000002"));
- EXPECT_EQ(NULL, info_.GetCellularOperatorByMCCMNC("000003"));
-}
-
-TEST_F(CellularOperatorInfoTest, HandleName) {
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "# No provider entry\n"
- "name:,\n");
- EXPECT_FALSE(info_.Load(info_file_path_));
- EXPECT_TRUE(info_.operators().empty());
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "provider:1,1,0,0\n"
- "# Name has incorrect number of fields.\n"
- "name:,,\n");
- EXPECT_FALSE(info_.Load(info_file_path_));
- EXPECT_TRUE(info_.operators().empty());
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "provider:1,1,0,0\n"
- "# Name is valid.\n"
- "name:en,Test Name\n");
- EXPECT_TRUE(info_.Load(info_file_path_));
- EXPECT_EQ(1, info_.operators().size());
- EXPECT_EQ(1, info_.operators()[0]->name_list().size());
- EXPECT_EQ("en", info_.operators()[0]->name_list()[0].language);
- EXPECT_EQ("Test Name", info_.operators()[0]->name_list()[0].name);
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "provider:1,1,0,0\n"
- "# More than one valid names.\n"
- "name:en,Test Name\n"
- "name:,Other Name\n"
- "name:de,\n");
- EXPECT_TRUE(info_.Load(info_file_path_));
- EXPECT_EQ(1, info_.operators().size());
- EXPECT_EQ(3, info_.operators()[0]->name_list().size());
- EXPECT_EQ("en", info_.operators()[0]->name_list()[0].language);
- EXPECT_EQ("Test Name", info_.operators()[0]->name_list()[0].name);
- EXPECT_TRUE(info_.operators()[0]->name_list()[1].language.empty());
- EXPECT_EQ("Other Name", info_.operators()[0]->name_list()[1].name);
- EXPECT_EQ("de", info_.operators()[0]->name_list()[2].language);
- EXPECT_TRUE(info_.operators()[0]->name_list()[2].name.empty());
-}
-
-TEST_F(CellularOperatorInfoTest, HandleAPN) {
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "# No provider\n"
- "apn:,,,\n");
- EXPECT_FALSE(info_.Load(info_file_path_));
- EXPECT_TRUE(info_.operators().empty());
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "provider:1,0,0,0\n"
- "# Badly formed apn line.\n"
- "apn:,\n");
- EXPECT_FALSE(info_.Load(info_file_path_));
- EXPECT_TRUE(info_.operators().empty());
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "provider:1,0,0,0\n"
- "apn:0,testapn,testusername,testpassword\n");
- EXPECT_TRUE(info_.Load(info_file_path_));
- EXPECT_EQ(1, info_.operators().size());
- EXPECT_EQ(1, info_.operators()[0]->apn_list().size());
- EXPECT_EQ("testapn", info_.operators()[0]->apn_list()[0]->apn);
- EXPECT_EQ("testusername", info_.operators()[0]->apn_list()[0]->username);
- EXPECT_EQ("testpassword", info_.operators()[0]->apn_list()[0]->password);
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "provider:1,0,0,0\n"
- "apn:0,apn1,user1,password1\n"
- "apn:2,apn2,user2,password2\n"
- "name:en,Apn Name\n"
- "name:de,Apn Name2\n");
- EXPECT_TRUE(info_.Load(info_file_path_));
- EXPECT_EQ(1, info_.operators().size());
- EXPECT_EQ(2, info_.operators()[0]->apn_list().size());
- EXPECT_EQ("apn1", info_.operators()[0]->apn_list()[0]->apn);
- EXPECT_EQ("user1", info_.operators()[0]->apn_list()[0]->username);
- EXPECT_EQ("password1", info_.operators()[0]->apn_list()[0]->password);
- EXPECT_EQ("apn2", info_.operators()[0]->apn_list()[1]->apn);
- EXPECT_EQ("user2", info_.operators()[0]->apn_list()[1]->username);
- EXPECT_EQ("password2", info_.operators()[0]->apn_list()[1]->password);
-
- EXPECT_TRUE(info_.operators()[0]->apn_list()[0]->name_list.empty());
- EXPECT_EQ(2, info_.operators()[0]->apn_list()[1]->name_list.size());
- EXPECT_EQ("en",
- info_.operators()[0]->apn_list()[1]->name_list[0].language);
- EXPECT_EQ("Apn Name",
- info_.operators()[0]->apn_list()[1]->name_list[0].name);
- EXPECT_EQ("de",
- info_.operators()[0]->apn_list()[1]->name_list[1].language);
- EXPECT_EQ("Apn Name2",
- info_.operators()[0]->apn_list()[1]->name_list[1].name);
-}
-
-TEST_F(CellularOperatorInfoTest, HandleSID) {
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "# SID entry without a provider.\n"
- "sid:1,1\n");
- EXPECT_FALSE(info_.Load(info_file_path_));
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "# Empty SID entry.\n"
- "provider:1,1,0,1\n"
- "sid:\n");
- EXPECT_FALSE(info_.Load(info_file_path_));
- EXPECT_TRUE(info_.operators().empty());
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "# SID entry has odd number of values.\n"
- "provider:1,1,0,1\n"
- "sid:1,0,2\n");
-
- EXPECT_FALSE(info_.Load(info_file_path_));
- EXPECT_TRUE(info_.operators().empty());
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "# SID entry in this one is good.\n"
- "provider:1,1,0,1\n"
- "sid:1,0,2,3\n");
-
- EXPECT_TRUE(info_.Load(info_file_path_));
- EXPECT_EQ(1, info_.operators().size());
- EXPECT_EQ(2, info_.operators()[0]->sid_list().size());
- EXPECT_EQ("1", info_.operators()[0]->sid_list()[0]);
- EXPECT_EQ("2", info_.operators()[0]->sid_list()[1]);
- EXPECT_EQ(info_.operators()[0], info_.GetCellularOperatorBySID("1"));
- EXPECT_EQ(info_.operators()[0], info_.GetCellularOperatorBySID("2"));
- EXPECT_EQ(NULL, info_.GetCellularOperatorBySID("3"));
-}
-
-TEST_F(CellularOperatorInfoTest, HandleIdentifier) {
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "# No provider entry.\n"
- "identifier:test-id\n");
- EXPECT_FALSE(info_.Load(info_file_path_));
- EXPECT_TRUE(info_.operators().empty());
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "provider:1,1,0,0\n"
- "identifier:test-id\n");
- EXPECT_TRUE(info_.Load(info_file_path_));
- EXPECT_EQ(1, info_.operators().size());
- EXPECT_EQ("test-id", info_.operators()[0]->identifier());
-}
-
-TEST_F(CellularOperatorInfoTest, HandleActivationCode) {
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "# No provider entry.\n"
- "activation-code:test-code\n");
- EXPECT_FALSE(info_.Load(info_file_path_));
- EXPECT_TRUE(info_.operators().empty());
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "provider:1,1,0,0\n"
- "activation-code:test-code\n");
- EXPECT_TRUE(info_.Load(info_file_path_));
- EXPECT_EQ(1, info_.operators().size());
- EXPECT_EQ("test-code", info_.operators()[0]->activation_code());
-}
-
-TEST_F(CellularOperatorInfoTest, HandleOLP) {
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "# No provider entry.\n"
- "olp:,,\n");
- EXPECT_FALSE(info_.Load(info_file_path_));
- EXPECT_TRUE(info_.operators().empty());
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "provider:1,1,0,0\n"
- "# Badly formed APN\n"
- "olp:,\n");
- EXPECT_FALSE(info_.Load(info_file_path_));
- EXPECT_TRUE(info_.operators().empty());
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "provider:1,1,0,0\n"
- "# Badly formed APN\n"
- "olp:,,\n");
- EXPECT_TRUE(info_.Load(info_file_path_));
- EXPECT_EQ(1, info_.operators().size());
- EXPECT_EQ(1, info_.operators()[0]->olp_list().size());
- EXPECT_TRUE(info_.operators()[0]->olp_list()[0]->GetURL().empty());
- EXPECT_TRUE(info_.operators()[0]->olp_list()[0]->GetMethod().empty());
- EXPECT_TRUE(info_.operators()[0]->olp_list()[0]->GetPostData().empty());
-
- TruncateAndWriteToFile(
- "serviceproviders:3.0\n"
- "provider:1,1,0,0\n"
- "# Badly formed APN\n"
- "olp:a,b,c\n"
- "olp:d,e,f\n");
- EXPECT_TRUE(info_.Load(info_file_path_));
- EXPECT_EQ(1, info_.operators().size());
- EXPECT_EQ(2, info_.operators()[0]->olp_list().size());
- EXPECT_EQ("a", info_.operators()[0]->olp_list()[0]->GetMethod());
- EXPECT_EQ("b", info_.operators()[0]->olp_list()[0]->GetURL());
- EXPECT_EQ("c", info_.operators()[0]->olp_list()[0]->GetPostData());
- EXPECT_EQ("d", info_.operators()[0]->olp_list()[1]->GetMethod());
- EXPECT_EQ("e", info_.operators()[0]->olp_list()[1]->GetURL());
- EXPECT_EQ("f", info_.operators()[0]->olp_list()[1]->GetPostData());
-}
-
-} // namespace shill
diff --git a/cellular_unittest.cc b/cellular_unittest.cc
index f1e4a60..0f6a4c6 100644
--- a/cellular_unittest.cc
+++ b/cellular_unittest.cc
@@ -410,8 +410,6 @@
EXPECT_CALL(*mm1_proxy_, set_state_changed_callback(_)).Times(AnyNumber());
EXPECT_CALL(*modem_info_.mock_metrics(), NotifyDeviceScanStarted(_))
.Times(AnyNumber());
- EXPECT_CALL(*modem_info_.mock_cellular_operator_info(),
- GetOLPByMCCMNC(_)).Times(AnyNumber());
EXPECT_CALL(*modem_info_.mock_manager(), UpdateEnabledTechnologies())
.Times(AnyNumber());
EXPECT_CALL(*dynamic_cast<DeviceMockAdaptor *>(device_->adaptor()),
diff --git a/mock_cellular_operator_info.cc b/mock_cellular_operator_info.cc
deleted file mode 100644
index 8a9f336..0000000
--- a/mock_cellular_operator_info.cc
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "shill/mock_cellular_operator_info.h"
-
-namespace shill {
-
-MockCellularOperatorInfo::MockCellularOperatorInfo()
- : CellularOperatorInfo() {}
-
-MockCellularOperatorInfo::~MockCellularOperatorInfo() {}
-
-} // namespace shill
diff --git a/mock_cellular_operator_info.h b/mock_cellular_operator_info.h
deleted file mode 100644
index b65488c..0000000
--- a/mock_cellular_operator_info.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef SHILL_MOCK_CELLULAR_OPERATOR_INFO_H_
-#define SHILL_MOCK_CELLULAR_OPERATOR_INFO_H_
-
-#include <string>
-
-#include <gmock/gmock.h>
-
-#include "shill/cellular_operator_info.h"
-
-namespace shill {
-
-class MockCellularOperatorInfo : public CellularOperatorInfo {
- public:
- MockCellularOperatorInfo();
- virtual ~MockCellularOperatorInfo();
-
- MOCK_METHOD1(Load, bool(const base::FilePath &info_file_path));
- MOCK_CONST_METHOD1(
- GetOLPByMCCMNC,
- const CellularOperatorInfo::OLP *(const std::string &mccmnc));
- MOCK_CONST_METHOD1(GetCellularOperatorByMCCMNC,
- const CellularOperator *(const std::string &mccmnc));
- MOCK_CONST_METHOD1(GetOLPBySID,
- const CellularOperatorInfo::OLP *(const std::string &sid));
- MOCK_CONST_METHOD1(GetCellularOperatorBySID,
- const CellularOperator *(const std::string &sid));
-};
-
-} // namespace shill
-
-#endif // SHILL_MOCK_CELLULAR_OPERATOR_INFO_H_
diff --git a/mock_modem_info.cc b/mock_modem_info.cc
index beb6eb8..c93d034 100644
--- a/mock_modem_info.cc
+++ b/mock_modem_info.cc
@@ -10,8 +10,7 @@
MockModemInfo::MockModemInfo() :
ModemInfo(NULL, NULL, NULL, NULL, NULL),
- mock_pending_activation_store_(NULL),
- mock_cellular_operator_info_(NULL) {}
+ mock_pending_activation_store_(NULL) {}
MockModemInfo::MockModemInfo(ControlInterface *control,
EventDispatcher *dispatcher,
@@ -19,8 +18,7 @@
Manager *manager,
GLib *glib) :
ModemInfo(control, dispatcher, metrics, manager, glib),
- mock_pending_activation_store_(NULL),
- mock_cellular_operator_info_(NULL) {
+ mock_pending_activation_store_(NULL) {
SetMockMembers();
}
@@ -32,11 +30,6 @@
set_pending_activation_store(new MockPendingActivationStore());
mock_pending_activation_store_ =
static_cast<MockPendingActivationStore*>(pending_activation_store());
- // Assumes ownership.
- set_cellular_operator_info(new MockCellularOperatorInfo());
- mock_cellular_operator_info_ =
- static_cast<MockCellularOperatorInfo*>(cellular_operator_info());
-
// These are replaced by mocks only if current unset in ModemInfo.
if(control_interface() == NULL) {
mock_control_.reset(new MockControl());
diff --git a/mock_modem_info.h b/mock_modem_info.h
index 6149630..a96a1bb 100644
--- a/mock_modem_info.h
+++ b/mock_modem_info.h
@@ -8,7 +8,6 @@
#include <base/basictypes.h>
#include <gmock/gmock.h>
-#include "shill/mock_cellular_operator_info.h"
#include "shill/mock_control.h"
#include "shill/mock_event_dispatcher.h"
#include "shill/mock_glib.h"
@@ -35,8 +34,7 @@
// Replaces data members in ModemInfo by mock objects.
// The following are relaced by mocks if they are NULL: control_interface,
// dispatcher, metrics, manager, glib.
- // The following are always replaced by mocks: pending_activation_store,
- // cellular_operator_info.
+ // The following are always replaced by mocks: pending_activation_store.
void SetMockMembers();
// Create a new provider_db and set it in ModemInfo.
@@ -47,9 +45,6 @@
MockPendingActivationStore* mock_pending_activation_store() const {
return mock_pending_activation_store_;
}
- MockCellularOperatorInfo* mock_cellular_operator_info() const {
- return mock_cellular_operator_info_;
- }
MockControl* mock_control_interface() const {
return mock_control_.get();
}
@@ -79,7 +74,6 @@
// owned by ModemInfo
MockPendingActivationStore *mock_pending_activation_store_;
- MockCellularOperatorInfo *mock_cellular_operator_info_;
DISALLOW_COPY_AND_ASSIGN(MockModemInfo);
};
diff --git a/modem_info.cc b/modem_info.cc
index 9c3769e..eee6266 100644
--- a/modem_info.cc
+++ b/modem_info.cc
@@ -8,7 +8,6 @@
#include <chromeos/dbus/service_constants.h>
#include <mobile_provider.h>
-#include "shill/cellular_operator_info.h"
#include "shill/logging.h"
#include "shill/manager.h"
#include "shill/modem_manager.h"
@@ -21,8 +20,6 @@
namespace {
-const char kCellularOperatorInfoPath[] =
- "/usr/share/shill/cellular_operator_info";
const char kMobileProviderDBPath[] =
"/usr/share/mobile-broadband-provider-info/serviceproviders.bfd";
@@ -49,8 +46,6 @@
pending_activation_store_.reset(new PendingActivationStore());
pending_activation_store_->InitStorage(manager_->glib(),
manager_->storage_path());
- cellular_operator_info_.reset(new CellularOperatorInfo());
- cellular_operator_info_->Load(FilePath(kCellularOperatorInfoPath));
// TODO(petkov): Consider initializing the mobile provider database lazily
// only if a GSM modem needs to be registered.
@@ -69,7 +64,6 @@
void ModemInfo::Stop() {
pending_activation_store_.reset();
- cellular_operator_info_.reset();
if(provider_db_)
mobile_provider_close_db(provider_db_);
provider_db_ = NULL;
@@ -87,11 +81,6 @@
pending_activation_store_.reset(pending_activation_store);
}
-void ModemInfo::set_cellular_operator_info(
- CellularOperatorInfo *cellular_operator_info) {
- cellular_operator_info_.reset(cellular_operator_info);
-}
-
void ModemInfo::RegisterModemManager(ModemManager *manager) {
modem_managers_.push_back(manager); // Passes ownership.
manager->Start();
diff --git a/modem_info.h b/modem_info.h
index d6ad4a0..c25a94a 100644
--- a/modem_info.h
+++ b/modem_info.h
@@ -15,7 +15,6 @@
namespace shill {
-class CellularOperatorInfo;
class ControlInterface;
class EventDispatcher;
class GLib;
@@ -47,9 +46,6 @@
PendingActivationStore *pending_activation_store() const {
return pending_activation_store_.get();
}
- CellularOperatorInfo *cellular_operator_info() const {
- return cellular_operator_info_.get();
- }
mobile_provider_db *provider_db() const { return provider_db_; }
protected:
@@ -71,8 +67,6 @@
}
void set_pending_activation_store(
PendingActivationStore *pending_activation_store);
- void set_cellular_operator_info(
- CellularOperatorInfo *cellular_operator_info);
void set_mobile_provider_db(mobile_provider_db *provider_db) {
provider_db_ = provider_db;
}
@@ -96,7 +90,6 @@
// Post-payment activation state of the modem.
scoped_ptr<PendingActivationStore> pending_activation_store_;
- scoped_ptr<CellularOperatorInfo> cellular_operator_info_;
std::string provider_db_path_; // For testing.
mobile_provider_db *provider_db_; // Database instance owned by |this|.
diff --git a/modem_manager.cc b/modem_manager.cc
index 8db37be..2540eae 100644
--- a/modem_manager.cc
+++ b/modem_manager.cc
@@ -7,7 +7,6 @@
#include <base/stl_util.h>
#include <mm/mm-modem.h>
-#include "shill/cellular_operator_info.h"
#include "shill/dbus_manager.h"
#include "shill/error.h"
#include "shill/logging.h"
diff --git a/shill.gyp b/shill.gyp
index 458c2de..c8201c6 100644
--- a/shill.gyp
+++ b/shill.gyp
@@ -230,7 +230,6 @@
'cellular_capability_universal_cdma.cc',
'cellular_error.cc',
'cellular_error_mm1.cc',
- 'cellular_operator_info.cc',
'cellular_service.cc',
'dbus_objectmanager_proxy.cc',
'mm1_bearer_proxy.cc',
@@ -709,12 +708,10 @@
'cellular_capability_universal_cdma_unittest.cc',
'cellular_capability_universal_unittest.cc',
'cellular_error_unittest.cc',
- 'cellular_operator_info_unittest.cc',
'cellular_service_unittest.cc',
'cellular_unittest.cc',
'mobile_operator_info_unittest.cc',
'mock_cellular.cc',
- 'mock_cellular_operator_info.cc',
'mock_cellular_service.cc',
'mock_mm1_bearer_proxy.cc',
'mock_mm1_modem_location_proxy.cc',