cellular: export the DBus.ServiceProperty

Export the DBus.ServiceProperty for cellular devices, which is the
service name of the modem manager that is handling the modem.  This
allows Chrome to monitor for signals on a service name instead of a
connection name, and is consistent with the rest of Chrome's
monitoring infrastructure.

BUG=chromium-os:31757
TEST=run /usr/local/lib/flimflam/test/fake-gsm-modem --shill & list-devices
CQ-DEPEND=I0c42d65a7033beb8932303c62eb5dbfde411ea55

Change-Id: I872d9a5647fd9990f2b979e42837c46951dbd452
Reviewed-on: https://gerrit.chromium.org/gerrit/24613
Tested-by: Jason Glasgow <jglasgow@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Jason Glasgow <jglasgow@chromium.org>
diff --git a/cellular.cc b/cellular.cc
index 2cba0db..8ccd949 100644
--- a/cellular.cc
+++ b/cellular.cc
@@ -96,6 +96,7 @@
                    int interface_index,
                    Type type,
                    const string &owner,
+                   const string &service,
                    const string &path,
                    mobile_provider_db *provider_db)
     : Device(control_interface,
@@ -109,11 +110,14 @@
       state_(kStateDisabled),
       modem_state_(kModemStateUnknown),
       dbus_owner_(owner),
+      dbus_service_(service),
       dbus_path_(path),
       provider_db_(provider_db),
       allow_roaming_(false) {
   PropertyStore *store = this->mutable_store();
+  // TODO(jglasgow): kDBusConnectionProperty is deprecated.
   store->RegisterConstString(flimflam::kDBusConnectionProperty, &dbus_owner_);
+  store->RegisterConstString(flimflam::kDBusServiceProperty, &dbus_service_);
   store->RegisterConstString(flimflam::kDBusObjectProperty, &dbus_path_);
   HelpRegisterDerivedString(flimflam::kTechnologyFamilyProperty,
                             &Cellular::GetTechnologyFamily,
diff --git a/cellular.h b/cellular.h
index 9e89ef8..8997e34 100644
--- a/cellular.h
+++ b/cellular.h
@@ -91,9 +91,12 @@
     DISALLOW_COPY_AND_ASSIGN(Operator);
   };
 
-  // |owner| is the ModemManager DBus service owner (e.g., ":1.17"). |path| is
-  // the ModemManager.Modem DBus object path (e.g.,
+  // |owner| is the ModemManager DBus service owner (e.g., ":1.17").
+  // |path| is the ModemManager.Modem DBus object path (e.g.,
   // "/org/chromium/ModemManager/Gobi/0").
+  // |service| is the modem mananager service name (e.g.,
+  // /org/freeDesktop/ModemManager, /org/freedesktop/ModemManager1
+  // or /org/chromium/ModemManager).
   Cellular(ControlInterface *control_interface,
            EventDispatcher *dispatcher,
            Metrics *metrics,
@@ -103,6 +106,7 @@
            int interface_index,
            Type type,
            const std::string &owner,
+           const std::string &service,
            const std::string &path,
            mobile_provider_db *provider_db);
   virtual ~Cellular();
@@ -275,7 +279,8 @@
 
   scoped_ptr<CellularCapability> capability_;
 
-  const std::string dbus_owner_;  // ModemManager.Modem
+  const std::string dbus_owner_;  // :x.y
+  const std::string dbus_service_;  // org.*.ModemManager*
   const std::string dbus_path_;  // ModemManager.Modem
 
   mobile_provider_db *provider_db_;
diff --git a/cellular_capability_cdma_unittest.cc b/cellular_capability_cdma_unittest.cc
index 1cf13dd..5b2b28e 100644
--- a/cellular_capability_cdma_unittest.cc
+++ b/cellular_capability_cdma_unittest.cc
@@ -43,6 +43,7 @@
                                Cellular::kTypeCDMA,
                                "",
                                "",
+                               "",
                                NULL)),
         proxy_(new MockModemCDMAProxy()),
         capability_(NULL) {}
diff --git a/cellular_capability_classic_unittest.cc b/cellular_capability_classic_unittest.cc
index a7bde94..1b87375 100644
--- a/cellular_capability_classic_unittest.cc
+++ b/cellular_capability_classic_unittest.cc
@@ -58,6 +58,7 @@
                                Cellular::kTypeGSM,
                                "",
                                "",
+                               "",
                                NULL)),
         proxy_(new MockModemProxy()),
         simple_proxy_(new MockModemSimpleProxy()),
diff --git a/cellular_capability_gsm_unittest.cc b/cellular_capability_gsm_unittest.cc
index 75912ae..f87517f 100644
--- a/cellular_capability_gsm_unittest.cc
+++ b/cellular_capability_gsm_unittest.cc
@@ -61,6 +61,7 @@
                                Cellular::kTypeGSM,
                                "",
                                "",
+                               "",
                                NULL)),
         proxy_(new MockModemProxy()),
         simple_proxy_(new MockModemSimpleProxy()),
diff --git a/cellular_capability_universal_unittest.cc b/cellular_capability_universal_unittest.cc
index c3b1330..7c9b3b8 100644
--- a/cellular_capability_universal_unittest.cc
+++ b/cellular_capability_universal_unittest.cc
@@ -74,6 +74,7 @@
                                Cellular::kTypeUniversal,
                                "",
                                "",
+                               "",
                                NULL)),
         service_(new MockCellularService(&control_,
                                          &dispatcher_,
diff --git a/cellular_service_unittest.cc b/cellular_service_unittest.cc
index 0545162..3834ff3 100644
--- a/cellular_service_unittest.cc
+++ b/cellular_service_unittest.cc
@@ -34,6 +34,7 @@
                              Cellular::kTypeGSM,
                              "",
                              "",
+                             "",
                              NULL)),
         service_(new CellularService(&control_, NULL, &metrics_, NULL,
                                      device_)),
diff --git a/cellular_unittest.cc b/cellular_unittest.cc
index 5afa651..156873c 100644
--- a/cellular_unittest.cc
+++ b/cellular_unittest.cc
@@ -71,6 +71,7 @@
                              Cellular::kTypeGSM,
                              "",
                              "",
+                             "",
                              NULL)) {}
   virtual ~CellularPropertyTest() {}
 
@@ -127,6 +128,7 @@
                              3,
                              Cellular::kTypeGSM,
                              kDBusOwner,
+                             kDBusService,
                              kDBusPath,
                              NULL)),
         proxy_(new MockModemProxy()),
@@ -288,6 +290,7 @@
   static const char kTestDeviceName[];
   static const char kTestDeviceAddress[];
   static const char kDBusOwner[];
+  static const char kDBusService[];
   static const char kDBusPath[];
   static const char kTestCarrier[];
   static const char kMEID[];
@@ -378,6 +381,7 @@
 const char CellularTest::kTestDeviceName[] = "usb0";
 const char CellularTest::kTestDeviceAddress[] = "00:01:02:03:04:05";
 const char CellularTest::kDBusOwner[] = ":1.19";
+const char CellularTest::kDBusService[] = "org.chromium.ModemManager";
 const char CellularTest::kDBusPath[] = "/org/chromium/ModemManager/Gobi/0";
 const char CellularTest::kTestCarrier[] = "The Cellular Carrier";
 const char CellularTest::kMEID[] = "01234567EF8901";
diff --git a/mock_cellular.cc b/mock_cellular.cc
index d19aab0..6b376b9 100644
--- a/mock_cellular.cc
+++ b/mock_cellular.cc
@@ -18,10 +18,12 @@
                            int interface_index,
                            Type type,
                            const std::string &owner,
+                           const std::string &service,
                            const std::string &path,
                            mobile_provider_db *provider_db)
     : Cellular(control_interface, dispatcher, metrics, manager, link_name,
-               address, interface_index, type, owner, path, provider_db) {}
+               address, interface_index, type, owner, service, path,
+               provider_db) {}
 
 MockCellular::~MockCellular() {}
 
diff --git a/mock_cellular.h b/mock_cellular.h
index 43a6753..827ce7b 100644
--- a/mock_cellular.h
+++ b/mock_cellular.h
@@ -25,6 +25,7 @@
                int interface_index,
                Type type,
                const std::string &owner,
+               const std::string &service,
                const std::string &path,
                mobile_provider_db *provider_db);
   virtual ~MockCellular();
diff --git a/mock_modem.cc b/mock_modem.cc
index dbf4ffe..ed9958d 100644
--- a/mock_modem.cc
+++ b/mock_modem.cc
@@ -7,14 +7,15 @@
 namespace shill {
 
 MockModem::MockModem(const std::string &owner,
+                     const std::string &service,
                      const std::string &path,
                      ControlInterface *control_interface,
                      EventDispatcher *dispatcher,
                      Metrics *metrics,
                      Manager *manager,
                      mobile_provider_db *provider_db)
-    : Modem(owner, path, control_interface, dispatcher, metrics, manager,
-            provider_db) {}
+    : Modem(owner, service, path, control_interface, dispatcher, metrics,
+            manager, provider_db) {}
 
 MockModem::~MockModem() {}
 
diff --git a/mock_modem.h b/mock_modem.h
index 133a511..3f850f9 100644
--- a/mock_modem.h
+++ b/mock_modem.h
@@ -16,6 +16,7 @@
 class MockModem : public Modem {
  public:
   MockModem(const std::string &owner,
+            const std::string &service,
             const std::string &path,
             ControlInterface *control_interface,
             EventDispatcher *dispatcher,
diff --git a/modem.cc b/modem.cc
index b30f315..c54e76c 100644
--- a/modem.cc
+++ b/modem.cc
@@ -26,6 +26,7 @@
 const char Modem::kPropertyType[] = "Type";
 
 Modem::Modem(const string &owner,
+             const string &service,
              const string &path,
              ControlInterface *control_interface,
              EventDispatcher *dispatcher,
@@ -33,6 +34,7 @@
              Manager *manager,
              mobile_provider_db *provider_db)
     : owner_(owner),
+      service_(service),
       path_(path),
       control_interface_(control_interface),
       dispatcher_(dispatcher),
@@ -86,6 +88,7 @@
                       interface_index,
                       type_,
                       owner_,
+                      service_,
                       path_,
                       provider_db_);
 }
diff --git a/modem.h b/modem.h
index 337c81e..a2f5af3 100644
--- a/modem.h
+++ b/modem.h
@@ -36,6 +36,7 @@
   // the ModemManager.Modem DBus object path (e.g.,
   // "/org/chromium/ModemManager/Gobi/0").
   Modem(const std::string &owner,
+        const std::string &service,
         const std::string &path,
         ControlInterface *control_interface,
         EventDispatcher *dispatcher,
@@ -54,6 +55,7 @@
   void OnDeviceInfoAvailable(const std::string &link_name);
 
   const std::string &owner() const { return owner_; }
+  const std::string &service() const { return service_; }
   const std::string &path() const { return path_; }
 
   void set_type(Cellular::Type type) { type_ = type; }
@@ -109,6 +111,7 @@
   DBusPropertiesMap initial_modem_properties_;
 
   const std::string owner_;
+  const std::string service_;
   const std::string path_;
 
   CellularRefPtr device_;
@@ -132,6 +135,7 @@
 class ModemClassic : public Modem {
  public:
   ModemClassic(const std::string &owner,
+               const std::string &service,
                const std::string &path,
                ControlInterface *control_interface,
                EventDispatcher *dispatcher,
@@ -155,6 +159,7 @@
 class Modem1 : public Modem {
  public:
   Modem1(const std::string &owner,
+         const std::string &service,
          const std::string &path,
          ControlInterface *control_interface,
          EventDispatcher *dispatcher,
diff --git a/modem_1.cc b/modem_1.cc
index 889c906..c9fd08d 100644
--- a/modem_1.cc
+++ b/modem_1.cc
@@ -21,14 +21,15 @@
 } // namespace {}
 
 Modem1::Modem1(const string &owner,
+               const string &service,
                const string &path,
                ControlInterface *control_interface,
                EventDispatcher *dispatcher,
                Metrics *metrics,
                Manager *manager,
                mobile_provider_db *provider_db)
-    : Modem(owner, path, control_interface, dispatcher, metrics, manager,
-            provider_db),
+    : Modem(owner, service, path, control_interface, dispatcher, metrics,
+            manager, provider_db),
       netfiles_path_(kDefaultNetfilesPath) {
 }
 
diff --git a/modem_1_unittest.cc b/modem_1_unittest.cc
index f6a4298..d49e526 100644
--- a/modem_1_unittest.cc
+++ b/modem_1_unittest.cc
@@ -38,6 +38,7 @@
 const int kTestInterfaceIndex = 5;
 const char kLinkName[] = "usb0";
 const char kOwner[] = ":1.18";
+const char kService[] = "org.chromium.ModemManager";
 const char kPath[] = "/org/chromium/ModemManager/Gobi/0";
 const unsigned char kAddress[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
 const char kAddressAsString[] = "000102030405";
@@ -54,6 +55,7 @@
         modem_(
             new Modem1(
                 kOwner,
+                kService,
                 kPath,
                 &control_interface_,
                 &dispatcher_,
@@ -108,6 +110,7 @@
   ASSERT_TRUE(file_util::CreateSymbolicLink(device_dir, symlink));
 
   EXPECT_EQ(kOwner, modem_->owner_);
+  EXPECT_EQ(kService, modem_->service_);
   EXPECT_EQ(kPath, modem_->path_);
   ReplaceSingletons();
   expected_address_ = ByteString(kAddress, arraysize(kAddress));
diff --git a/modem_classic.cc b/modem_classic.cc
index 01e9f4e..95778c8 100644
--- a/modem_classic.cc
+++ b/modem_classic.cc
@@ -13,15 +13,16 @@
 
 namespace shill {
 
-ModemClassic::ModemClassic(const std::string &owner,
-                           const std::string &path,
+ModemClassic::ModemClassic(const string &owner,
+                           const string &service,
+                           const string &path,
                            ControlInterface *control_interface,
                            EventDispatcher *dispatcher,
                            Metrics *metrics,
                            Manager *manager,
                            mobile_provider_db *provider_db)
-    : Modem(owner, path, control_interface, dispatcher, metrics, manager,
-            provider_db) {
+    : Modem(owner, service, path, control_interface, dispatcher, metrics,
+            manager, provider_db) {
 }
 
 ModemClassic::~ModemClassic() {}
diff --git a/modem_manager.cc b/modem_manager.cc
index 69ed70c..155099f 100644
--- a/modem_manager.cc
+++ b/modem_manager.cc
@@ -159,6 +159,7 @@
     return;
   }
   shared_ptr<ModemClassic> modem(new ModemClassic(owner(),
+                                                  service(),
                                                   path,
                                                   control_interface(),
                                                   dispatcher(),
@@ -247,6 +248,7 @@
     return;
   }
   shared_ptr<Modem1> modem1(new Modem1(owner(),
+                                       service(),
                                        path,
                                        control_interface(),
                                        dispatcher(),
diff --git a/modem_manager.h b/modem_manager.h
index 3c14ab8..3a93688 100644
--- a/modem_manager.h
+++ b/modem_manager.h
@@ -66,6 +66,7 @@
   Manager *manager() const { return manager_; }
   Metrics *metrics() const { return metrics_; }
   const std::string &owner() const { return owner_; }
+  const std::string &service() const { return service_; }
   const std::string &path() const { return path_; }
   ProxyFactory *proxy_factory() const { return proxy_factory_; }
   mobile_provider_db *provider_db() const { return provider_db_; }
diff --git a/modem_manager_unittest.cc b/modem_manager_unittest.cc
index 9ed54f7..2878ccc 100644
--- a/modem_manager_unittest.cc
+++ b/modem_manager_unittest.cc
@@ -64,8 +64,8 @@
 
   virtual void SetUp() {
     modem_.reset(new StrictModem(
-        kOwner, kModemPath, &control_interface_, &dispatcher_, &metrics_,
-        &manager_, static_cast<mobile_provider_db *>(NULL)));
+        kOwner, kService, kModemPath, &control_interface_, &dispatcher_,
+        &metrics_, &manager_, static_cast<mobile_provider_db *>(NULL)));
   }
  protected:
   static const char kService[];
diff --git a/modem_unittest.cc b/modem_unittest.cc
index c9cf13c..d9db8bf 100644
--- a/modem_unittest.cc
+++ b/modem_unittest.cc
@@ -46,6 +46,7 @@
 const int kTestInterfaceIndex = 5;
 const char kLinkName[] = "usb0";
 const char kOwner[] = ":1.18";
+const char kService[] = "org.chromium.ModemManager";
 const char kPath[] = "/org/chromium/ModemManager/Gobi/0";
 const unsigned char kAddress[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
 const char kAddressAsString[] = "000102030405";
@@ -68,6 +69,7 @@
         modem_(
             new StrictModem(
                 kOwner,
+                kService,
                 kPath,
                 &control_interface_,
                 &dispatcher_,
@@ -116,6 +118,7 @@
 
 void ModemTest::SetUp() {
   EXPECT_EQ(kOwner, modem_->owner_);
+  EXPECT_EQ(kService, modem_->service_);
   EXPECT_EQ(kPath, modem_->path_);
   ReplaceSingletons();
   expected_address_ = ByteString(kAddress, arraysize(kAddress));
@@ -169,6 +172,7 @@
       kTestInterfaceIndex,
       Cellular::kTypeGSM,
       kOwner,
+      kService,
       kPath,
       static_cast<mobile_provider_db *>(NULL));