Split Modem into ModemClassic and Modem1
Along the way:
Restructure ModemManagerXxx to use the split modem classes.
Add new mocks to limit scope of modem tests
Change modem state enum to a neutral format and convert from MM1 and
MMClassic to this format.
Fix a bug where we weren't properly releasing a callback in
DBusObjectManagerProxy.
Add new DBus property matchers
BUG=chromium-os:27935,chromium-os:27936
TEST=unit tests
Change-Id: Ib78c7dfd9e30fe556f09a4427fd71c9d785210c9
Reviewed-on: https://gerrit.chromium.org/gerrit/19228
Commit-Ready: David Rochberg <rochberg@chromium.org>
Reviewed-by: David Rochberg <rochberg@chromium.org>
Tested-by: David Rochberg <rochberg@chromium.org>
diff --git a/modem_1.cc b/modem_1.cc
new file mode 100644
index 0000000..5b7a7a5
--- /dev/null
+++ b/modem_1.cc
@@ -0,0 +1,72 @@
+// Copyright (c) 2012 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/modem.h"
+
+#include <mm/ModemManager-enums.h>
+#include <mm/ModemManager-names.h>
+
+#include "shill/cellular.h"
+
+using std::string;
+
+namespace shill {
+
+Modem1::Modem1(const string &owner,
+ 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) {
+}
+
+Modem1::~Modem1() {}
+
+Cellular::ModemState Modem1::ConvertMmToCellularModemState(uint32 input) const {
+ switch (input) {
+ case MM_MODEM_STATE_UNKNOWN: return Cellular::kModemStateUnknown;
+ case MM_MODEM_STATE_INITIALIZING: return Cellular::kModemStateInitializing;
+ case MM_MODEM_STATE_LOCKED: return Cellular::kModemStateLocked;
+ case MM_MODEM_STATE_DISABLED: return Cellular::kModemStateDisabled;
+ case MM_MODEM_STATE_DISABLING: return Cellular::kModemStateDisabling;
+ case MM_MODEM_STATE_ENABLING: return Cellular::kModemStateEnabling;
+ case MM_MODEM_STATE_ENABLED: return Cellular::kModemStateEnabled;
+ case MM_MODEM_STATE_SEARCHING: return Cellular::kModemStateSearching;
+ case MM_MODEM_STATE_REGISTERED: return Cellular::kModemStateRegistered;
+ case MM_MODEM_STATE_DISCONNECTING:
+ return Cellular::kModemStateDisconnecting;
+ case MM_MODEM_STATE_CONNECTING: return Cellular::kModemStateConnecting;
+ case MM_MODEM_STATE_CONNECTED: return Cellular::kModemStateConnected;
+ default:
+ DCHECK(false) << "Unknown cellular state: " << input;
+ return Cellular::kModemStateUnknown;
+ }
+}
+
+bool Modem1::GetLinkName(const DBusPropertiesMap & /* modem_props */,
+ string *name) const {
+ // TODO(rochberg): use the device path to find the link name in
+ // sysfs. crosbug.com/28498
+ *name = "usb0";
+ return true;
+}
+
+void Modem1::CreateDeviceMM1(const DBusInterfaceToProperties &i_to_p) {
+ DBusInterfaceToProperties::const_iterator modem_properties =
+ i_to_p.find(MM_DBUS_INTERFACE_MODEM);
+ if (modem_properties == i_to_p.end()) {
+ LOG(ERROR) << "Cellular device with no modem properties";
+ return;
+ }
+ set_type(Cellular::kTypeUniversal);
+
+ // We cannot check the IP method to make sure it's not PPP. The IP
+ // method will be checked later when the bearer object is fetched.
+ CreateDeviceFromModemProperties(modem_properties->second);
+}
+
+} // namespace shill