Don't try to create cellular device if modem interface is blacklisted.

Shill does honor the presence of usb0 on the blacklist at the time the
RTNL message is received indicating the presence of the interface.
However, there is another path that can lead to creation of a Cellular
device: when ModemManager is detected, shill calls EnumerateDevices to
get a list of modems known to ModemManager. In response, shill goes
ahead and creates a Cellular device for each modem, without checking
the blacklist.

BUG=chromium-os:28215
TEST=manual testing, with and without usb0 on the blacklist

Change-Id: I7ef4348610027d6c815b3c4d382f646666725930
Reviewed-on: https://gerrit.chromium.org/gerrit/18771
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Ready: Eric Shienbrood <ers@chromium.org>
Tested-by: Eric Shienbrood <ers@chromium.org>
diff --git a/device_info.cc b/device_info.cc
index ab93828..3800319 100644
--- a/device_info.cc
+++ b/device_info.cc
@@ -90,6 +90,10 @@
   black_list_.insert(device_name);
 }
 
+bool DeviceInfo::IsDeviceBlackListed(const string &device_name) {
+  return ContainsKey(black_list_, device_name);
+}
+
 void DeviceInfo::Start() {
   link_listener_.reset(
       new RTNLListener(RTNLHandler::kRequestLink, link_callback_));
diff --git a/device_info.h b/device_info.h
index 6822e1a..cf00499 100644
--- a/device_info.h
+++ b/device_info.h
@@ -49,6 +49,7 @@
   ~DeviceInfo();
 
   void AddDeviceToBlackList(const std::string &device_name);
+  bool IsDeviceBlackListed(const std::string &device_name);
   void Start();
   void Stop();
 
diff --git a/modem.cc b/modem.cc
index 7b938ed..fead592 100644
--- a/modem.cc
+++ b/modem.cc
@@ -91,6 +91,12 @@
     LOG(ERROR) << "Unable to create cellular device without a link name.";
     return;
   }
+  if (manager_->device_info()->IsDeviceBlackListed(link_name_)) {
+    LOG(INFO) << "Do not create cellular device for blacklisted interface "
+              << link_name_;
+    return;
+  }
+
   // TODO(petkov): Get the interface index from DeviceInfo, similar to the MAC
   // address below.
   int interface_index =
diff --git a/modem.h b/modem.h
index e92ba88..f5ec360 100644
--- a/modem.h
+++ b/modem.h
@@ -10,7 +10,6 @@
 
 #include <base/basictypes.h>
 #include <base/memory/scoped_ptr.h>
-#include <base/memory/weak_ptr.h>
 #include <gtest/gtest_prod.h>  // for FRIEND_TEST
 
 #include "shill/dbus_properties_proxy_interface.h"