shill: Lookup the mobile provider database to obtain GSM network info.

Load the provider database in ModemInfo. Use the database to lookup operator
name and country when the GSM registration state changes.

This also adds a small mobile provider database used for unit test purposes.

BUG=chromium-os:19699
TEST=unit tests

Change-Id: I5cf0b6d0682d1e0f47fe4b92a45ec6c48837b650
Reviewed-on: https://gerrit.chromium.org/gerrit/10718
Commit-Ready: Darin Petkov <petkov@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Darin Petkov <petkov@chromium.org>
diff --git a/cellular.h b/cellular.h
index 66eb306..a2ab074 100644
--- a/cellular.h
+++ b/cellular.h
@@ -20,6 +20,8 @@
 #include "shill/modem_proxy_interface.h"
 #include "shill/refptr_types.h"
 
+struct mobile_provider_db;
+
 namespace shill {
 
 class CellularCapability;
@@ -117,7 +119,8 @@
            int interface_index,
            Type type,
            const std::string &owner,
-           const std::string &path);
+           const std::string &path,
+           mobile_provider_db *provider_db);
   virtual ~Cellular();
 
   // Asynchronously connects the modem to the network. Populates |error| on
@@ -195,6 +198,7 @@
   FRIEND_TEST(CellularTest, InitProxiesCDMA);
   FRIEND_TEST(CellularTest, InitProxiesGSM);
   FRIEND_TEST(CellularTest, ParseScanResult);
+  FRIEND_TEST(CellularTest, ParseScanResultProviderLookup);
   FRIEND_TEST(CellularTest, RegisterOnNetwork);
   FRIEND_TEST(CellularTest, RegisterOnNetworkError);
   FRIEND_TEST(CellularTest, RequirePIN);
@@ -207,6 +211,7 @@
   FRIEND_TEST(CellularTest, StartLinked);
   FRIEND_TEST(CellularTest, UnblockPIN);
   FRIEND_TEST(CellularTest, UnblockPINError);
+  FRIEND_TEST(CellularTest, UpdateGSMOperatorInfo);
 
   struct CDMA {
     CDMA();
@@ -227,6 +232,7 @@
     uint32 access_technology;
     std::string network_id;
     std::string operator_name;
+    std::string operator_country;
     std::string spn;
   };
 
@@ -307,6 +313,13 @@
 
   void HandleNewCDMAActivationState(uint32 error);
 
+  // Updates the GSM operator name and country based on a newly obtained network
+  // id.
+  void UpdateGSMOperatorInfo();
+
+  // Updates the serving operator on the active service.
+  void UpdateServingOperator();
+
   Stringmap ParseScanResult(
       const ModemGSMNetworkProxyInterface::ScanResult &result);
 
@@ -348,6 +361,8 @@
   scoped_ptr<ModemGSMCardProxyInterface> gsm_card_proxy_;
   scoped_ptr<ModemGSMNetworkProxyInterface> gsm_network_proxy_;
 
+  mobile_provider_db *provider_db_;
+
   CDMA cdma_;
   GSM gsm_;