Darin Petkov | c64fe5e | 2012-01-11 12:46:13 +0100 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Darin Petkov | a4ca3c3 | 2012-08-17 16:05:24 +0200 | [diff] [blame] | 5 | #ifndef SHILL_CELLULAR_H_ |
| 6 | #define SHILL_CELLULAR_H_ |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 7 | |
| 8 | #include <string> |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 9 | #include <vector> |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 10 | |
| 11 | #include <base/basictypes.h> |
Thieu Le | 64b0fe5 | 2012-08-08 14:57:36 -0700 | [diff] [blame] | 12 | #include <base/memory/weak_ptr.h> |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 13 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 14 | |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -0700 | [diff] [blame] | 15 | #include "shill/dbus_properties.h" |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 16 | #include "shill/device.h" |
Paul Stewart | 26b327e | 2011-10-19 11:38:09 -0700 | [diff] [blame] | 17 | #include "shill/event_dispatcher.h" |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -0700 | [diff] [blame] | 18 | #include "shill/modem_proxy_interface.h" |
Chris Masone | 2b10554 | 2011-06-22 10:58:09 -0700 | [diff] [blame] | 19 | #include "shill/refptr_types.h" |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 20 | |
Darin Petkov | 137884a | 2011-10-26 18:52:47 +0200 | [diff] [blame] | 21 | struct mobile_provider_db; |
| 22 | |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 23 | namespace shill { |
| 24 | |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 25 | class CellularCapability; |
Ben Chan | 62028b2 | 2012-11-05 11:20:02 -0800 | [diff] [blame] | 26 | class CellularOperatorInfo; |
Darin Petkov | 4d6d941 | 2011-08-24 13:19:54 -0700 | [diff] [blame] | 27 | class Error; |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 28 | class ProxyFactory; |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 29 | |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 30 | class Cellular : public Device { |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 31 | public: |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 32 | enum Type { |
| 33 | kTypeGSM, |
David Rochberg | fa1d31d | 2012-03-20 10:38:07 -0400 | [diff] [blame] | 34 | kTypeCDMA, |
| 35 | kTypeUniversal, // ModemManager1 |
| 36 | kTypeInvalid, |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 37 | }; |
| 38 | |
Darin Petkov | 0828f5f | 2011-08-11 10:18:52 -0700 | [diff] [blame] | 39 | // The device states progress linearly from Disabled to Linked. |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 40 | enum State { |
Darin Petkov | 0828f5f | 2011-08-11 10:18:52 -0700 | [diff] [blame] | 41 | // This is the initial state of the modem and indicates that the modem radio |
| 42 | // is not turned on. |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 43 | kStateDisabled, |
Darin Petkov | 0828f5f | 2011-08-11 10:18:52 -0700 | [diff] [blame] | 44 | // This state indicates that the modem radio is turned on, and it should be |
| 45 | // possible to measure signal strength. |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 46 | kStateEnabled, |
Darin Petkov | 0828f5f | 2011-08-11 10:18:52 -0700 | [diff] [blame] | 47 | // The modem has registered with a network and has signal quality |
Darin Petkov | 5148900 | 2011-08-18 13:13:20 -0700 | [diff] [blame] | 48 | // measurements. A cellular service object is created. |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 49 | kStateRegistered, |
Darin Petkov | 0828f5f | 2011-08-11 10:18:52 -0700 | [diff] [blame] | 50 | // The modem has connected to a network. |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 51 | kStateConnected, |
Darin Petkov | 0828f5f | 2011-08-11 10:18:52 -0700 | [diff] [blame] | 52 | // The network interface is UP. |
| 53 | kStateLinked, |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 54 | }; |
| 55 | |
Darin Petkov | bac9600 | 2011-08-09 13:22:00 -0700 | [diff] [blame] | 56 | enum ModemState { |
| 57 | kModemStateUnknown = 0, |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 58 | kModemStateInitializing = 1, |
| 59 | kModemStateLocked = 2, |
| 60 | kModemStateDisabled = 3, |
David Rochberg | fa1d31d | 2012-03-20 10:38:07 -0400 | [diff] [blame] | 61 | kModemStateDisabling = 4, |
| 62 | kModemStateEnabling = 5, |
| 63 | kModemStateEnabled = 6, |
| 64 | kModemStateSearching = 7, |
| 65 | kModemStateRegistered = 8, |
| 66 | kModemStateDisconnecting = 9, |
| 67 | kModemStateConnecting = 10, |
| 68 | kModemStateConnected = 11, |
Darin Petkov | bac9600 | 2011-08-09 13:22:00 -0700 | [diff] [blame] | 69 | }; |
| 70 | |
Darin Petkov | 3335b37 | 2011-08-22 11:05:32 -0700 | [diff] [blame] | 71 | class Operator { |
| 72 | public: |
| 73 | Operator(); |
| 74 | ~Operator(); |
| 75 | |
| 76 | void CopyFrom(const Operator &oper); |
Darin Petkov | 9cb0268 | 2012-01-28 00:17:38 +0100 | [diff] [blame] | 77 | bool Equals(const Operator &oper) const { return dict_ == oper.dict_; } |
Darin Petkov | 3335b37 | 2011-08-22 11:05:32 -0700 | [diff] [blame] | 78 | |
| 79 | const std::string &GetName() const; |
| 80 | void SetName(const std::string &name); |
| 81 | |
| 82 | const std::string &GetCode() const; |
| 83 | void SetCode(const std::string &code); |
| 84 | |
| 85 | const std::string &GetCountry() const; |
| 86 | void SetCountry(const std::string &country); |
| 87 | |
| 88 | const Stringmap &ToDict() const; |
| 89 | |
| 90 | private: |
| 91 | Stringmap dict_; |
| 92 | |
| 93 | DISALLOW_COPY_AND_ASSIGN(Operator); |
| 94 | }; |
| 95 | |
Jason Glasgow | a585fc3 | 2012-06-06 11:04:09 -0400 | [diff] [blame] | 96 | // |owner| is the ModemManager DBus service owner (e.g., ":1.17"). |
| 97 | // |path| is the ModemManager.Modem DBus object path (e.g., |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 98 | // "/org/chromium/ModemManager/Gobi/0"). |
Jason Glasgow | a585fc3 | 2012-06-06 11:04:09 -0400 | [diff] [blame] | 99 | // |service| is the modem mananager service name (e.g., |
| 100 | // /org/freeDesktop/ModemManager, /org/freedesktop/ModemManager1 |
| 101 | // or /org/chromium/ModemManager). |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 102 | Cellular(ControlInterface *control_interface, |
| 103 | EventDispatcher *dispatcher, |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 104 | Metrics *metrics, |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 105 | Manager *manager, |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 106 | const std::string &link_name, |
Chris Masone | 626719f | 2011-08-18 16:58:48 -0700 | [diff] [blame] | 107 | const std::string &address, |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 108 | int interface_index, |
| 109 | Type type, |
| 110 | const std::string &owner, |
Jason Glasgow | a585fc3 | 2012-06-06 11:04:09 -0400 | [diff] [blame] | 111 | const std::string &service, |
Darin Petkov | 137884a | 2011-10-26 18:52:47 +0200 | [diff] [blame] | 112 | const std::string &path, |
Ben Chan | 62028b2 | 2012-11-05 11:20:02 -0800 | [diff] [blame] | 113 | CellularOperatorInfo *cellular_operator_info, |
Ben Chan | 3ecdf82 | 2012-08-06 12:29:23 -0700 | [diff] [blame] | 114 | mobile_provider_db *provider_db, |
| 115 | ProxyFactory *proxy_factory); |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 116 | virtual ~Cellular(); |
| 117 | |
Jason Glasgow | 7b461df | 2012-05-01 16:38:45 -0400 | [diff] [blame] | 118 | // Load configuration for the device from |storage|. |
| 119 | virtual bool Load(StoreInterface *storage); |
| 120 | |
| 121 | // Save configuration for the device to |storage|. |
| 122 | virtual bool Save(StoreInterface *storage); |
| 123 | |
Darin Petkov | 4d6d941 | 2011-08-24 13:19:54 -0700 | [diff] [blame] | 124 | // Asynchronously connects the modem to the network. Populates |error| on |
| 125 | // failure, leaves it unchanged otherwise. |
| 126 | void Connect(Error *error); |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -0700 | [diff] [blame] | 127 | |
Christopher Wiley | 8a46890 | 2012-11-30 11:52:38 -0800 | [diff] [blame] | 128 | // Asynchronously disconnects the modem from the network and populates |
| 129 | // |error| on failure, leaves it unchanged otherwise. |
Christopher Wiley | 7d0953e | 2012-11-16 00:37:10 -0800 | [diff] [blame] | 130 | virtual void Disconnect(Error *error); |
Darin Petkov | fb0625e | 2012-01-16 13:05:56 +0100 | [diff] [blame] | 131 | |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 132 | // Asynchronously activates the modem. Returns an error on failure. |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 133 | void Activate(const std::string &carrier, Error *error, |
| 134 | const ResultCallback &callback); |
Darin Petkov | c408e69 | 2011-08-17 13:47:15 -0700 | [diff] [blame] | 135 | |
Darin Petkov | 3e50924 | 2011-11-10 14:46:44 +0100 | [diff] [blame] | 136 | const CellularServiceRefPtr &service() const { return service_; } |
| 137 | |
Darin Petkov | a0a0efe | 2012-06-27 12:50:01 +0200 | [diff] [blame] | 138 | // Deregisters and destructs the current service and destroys the connection, |
| 139 | // if any. This also eliminates the circular references between this device |
| 140 | // and the associated service, allowing eventual device destruction. |
| 141 | virtual void DestroyService(); |
| 142 | |
Darin Petkov | a3d3be5 | 2011-11-14 21:34:16 +0100 | [diff] [blame] | 143 | static std::string GetStateString(State state); |
| 144 | |
Darin Petkov | ac635a8 | 2012-01-10 16:51:58 +0100 | [diff] [blame] | 145 | std::string CreateFriendlyServiceName(); |
| 146 | |
Darin Petkov | a3d3be5 | 2011-11-14 21:34:16 +0100 | [diff] [blame] | 147 | State state() const { return state_; } |
| 148 | |
Darin Petkov | bac9600 | 2011-08-09 13:22:00 -0700 | [diff] [blame] | 149 | void set_modem_state(ModemState state) { modem_state_ = state; } |
| 150 | ModemState modem_state() const { return modem_state_; } |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 151 | bool IsUnderlyingDeviceEnabled() const; |
Thieu Le | d001205 | 2012-07-25 16:09:09 -0700 | [diff] [blame] | 152 | bool IsModemRegistered() const; |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 153 | static bool IsEnabledModemState(ModemState state); |
Darin Petkov | bac9600 | 2011-08-09 13:22:00 -0700 | [diff] [blame] | 154 | |
Ben Chan | 62028b2 | 2012-11-05 11:20:02 -0800 | [diff] [blame] | 155 | CellularOperatorInfo *cellular_operator_info() const { |
| 156 | return cellular_operator_info_; |
| 157 | } |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 158 | mobile_provider_db *provider_db() const { return provider_db_; } |
| 159 | |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 160 | const std::string &dbus_owner() const { return dbus_owner_; } |
| 161 | const std::string &dbus_path() const { return dbus_path_; } |
| 162 | |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 163 | const Operator &home_provider() const { return home_provider_; } |
| 164 | void set_home_provider(const Operator &oper); |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 165 | |
Darin Petkov | 3e50924 | 2011-11-10 14:46:44 +0100 | [diff] [blame] | 166 | void HandleNewSignalQuality(uint32 strength); |
| 167 | |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 168 | // Processes a change in the modem registration state, possibly creating, |
| 169 | // destroying or updating the CellularService. |
| 170 | void HandleNewRegistrationState(); |
| 171 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 172 | virtual void OnDBusPropertiesChanged( |
| 173 | const std::string &interface, |
| 174 | const DBusPropertiesMap &changed_properties, |
| 175 | const std::vector<std::string> &invalidated_properties); |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 176 | |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 177 | // Inherited from Device. |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 178 | virtual void Start(Error *error, const EnabledStateChangedCallback &callback); |
| 179 | virtual void Stop(Error *error, const EnabledStateChangedCallback &callback); |
Darin Petkov | 0828f5f | 2011-08-11 10:18:52 -0700 | [diff] [blame] | 180 | virtual void LinkEvent(unsigned int flags, unsigned int change); |
Darin Petkov | c086531 | 2011-09-16 15:31:20 -0700 | [diff] [blame] | 181 | virtual void Scan(Error *error); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 182 | virtual void RegisterOnNetwork(const std::string &network_id, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 183 | Error *error, |
| 184 | const ResultCallback &callback); |
| 185 | virtual void RequirePIN(const std::string &pin, bool require, |
| 186 | Error *error, const ResultCallback &callback); |
| 187 | virtual void EnterPIN(const std::string &pin, |
| 188 | Error *error, const ResultCallback &callback); |
Darin Petkov | e42e101 | 2011-08-31 12:35:04 -0700 | [diff] [blame] | 189 | virtual void UnblockPIN(const std::string &unblock_code, |
| 190 | const std::string &pin, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 191 | Error *error, const ResultCallback &callback); |
Darin Petkov | e42e101 | 2011-08-31 12:35:04 -0700 | [diff] [blame] | 192 | virtual void ChangePIN(const std::string &old_pin, |
| 193 | const std::string &new_pin, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 194 | Error *error, const ResultCallback &callback); |
Ben Chan | 5d0d32c | 2013-01-08 02:05:29 -0800 | [diff] [blame] | 195 | virtual void Reset(Error *error, const ResultCallback &callback); |
Darin Petkov | c37a9c4 | 2012-09-06 15:28:22 +0200 | [diff] [blame] | 196 | virtual void SetCarrier(const std::string &carrier, |
| 197 | Error *error, const ResultCallback &callback); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 198 | |
Thieu Le | 37b9003 | 2012-05-15 15:18:41 -0700 | [diff] [blame] | 199 | void StartModemCallback(const EnabledStateChangedCallback &callback, |
| 200 | const Error &error); |
| 201 | void StopModemCallback(const EnabledStateChangedCallback &callback, |
| 202 | const Error &error); |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 203 | void OnConnecting(); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 204 | void OnConnected(); |
Eric Shienbrood | 30bc0ec | 2012-03-21 18:19:46 -0400 | [diff] [blame] | 205 | void OnConnectFailed(const Error &error); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 206 | void OnDisconnected(); |
| 207 | void OnDisconnectFailed(); |
Eric Shienbrood | 0db6a9b | 2012-03-30 16:11:39 -0400 | [diff] [blame] | 208 | std::string GetTechnologyFamily(Error *error); |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 209 | void OnModemStateChanged(ModemState old_state, |
| 210 | ModemState new_state, |
| 211 | uint32 reason); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 212 | |
Jason Glasgow | 7b461df | 2012-05-01 16:38:45 -0400 | [diff] [blame] | 213 | // accessor to read the allow roaming property |
| 214 | bool allow_roaming_property() const { return allow_roaming_; } |
Christopher Wiley | 1582bdd | 2012-11-15 11:31:14 -0800 | [diff] [blame] | 215 | // Is the underlying device in the process of activating? |
| 216 | bool IsActivating() const; |
Jason Glasgow | 7b461df | 2012-05-01 16:38:45 -0400 | [diff] [blame] | 217 | |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 218 | private: |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 219 | friend class CellularTest; |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 220 | friend class CellularCapabilityTest; |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 221 | friend class CellularCapabilityCDMATest; |
| 222 | friend class CellularCapabilityGSMTest; |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 223 | friend class CellularCapabilityUniversalTest; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 224 | friend class CellularServiceTest; |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 225 | friend class ModemTest; |
Darin Petkov | ac635a8 | 2012-01-10 16:51:58 +0100 | [diff] [blame] | 226 | FRIEND_TEST(CellularCapabilityCDMATest, CreateFriendlyServiceName); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 227 | FRIEND_TEST(CellularCapabilityCDMATest, GetRegistrationState); |
Darin Petkov | f508c82 | 2012-09-21 13:43:17 +0200 | [diff] [blame] | 228 | FRIEND_TEST(CellularCapabilityGSMTest, AllowRoaming); |
Darin Petkov | ac635a8 | 2012-01-10 16:51:58 +0100 | [diff] [blame] | 229 | FRIEND_TEST(CellularCapabilityGSMTest, CreateFriendlyServiceName); |
Darin Petkov | a4ca3c3 | 2012-08-17 16:05:24 +0200 | [diff] [blame] | 230 | FRIEND_TEST(CellularCapabilityTest, AllowRoaming); |
| 231 | FRIEND_TEST(CellularCapabilityTest, EnableModemFail); |
| 232 | FRIEND_TEST(CellularCapabilityTest, EnableModemSucceed); |
| 233 | FRIEND_TEST(CellularCapabilityTest, FinishEnable); |
| 234 | FRIEND_TEST(CellularCapabilityTest, GetModemInfo); |
| 235 | FRIEND_TEST(CellularCapabilityTest, GetModemStatus); |
Darin Petkov | f508c82 | 2012-09-21 13:43:17 +0200 | [diff] [blame] | 236 | FRIEND_TEST(CellularCapabilityUniversalTest, AllowRoaming); |
Darin Petkov | a4ca3c3 | 2012-08-17 16:05:24 +0200 | [diff] [blame] | 237 | FRIEND_TEST(CellularCapabilityUniversalTest, CreateFriendlyServiceName); |
| 238 | FRIEND_TEST(CellularCapabilityUniversalTest, Connect); |
Ben Chan | 1578603 | 2012-11-04 21:28:02 -0800 | [diff] [blame] | 239 | FRIEND_TEST(CellularCapabilityUniversalTest, IsServiceActivationRequired); |
Darin Petkov | a4ca3c3 | 2012-08-17 16:05:24 +0200 | [diff] [blame] | 240 | FRIEND_TEST(CellularCapabilityUniversalTest, StopModemConnected); |
Ben Chan | 6d0d1e7 | 2012-11-06 21:19:28 -0800 | [diff] [blame] | 241 | FRIEND_TEST(CellularCapabilityUniversalTest, UpdateOLP); |
Ben Chan | 092b12b | 2012-11-07 22:04:05 -0800 | [diff] [blame] | 242 | FRIEND_TEST(CellularCapabilityUniversalTest, UpdateOperatorInfoViaOperatorId); |
Darin Petkov | ac635a8 | 2012-01-10 16:51:58 +0100 | [diff] [blame] | 243 | FRIEND_TEST(CellularServiceTest, FriendlyName); |
Darin Petkov | 3335b37 | 2011-08-22 11:05:32 -0700 | [diff] [blame] | 244 | FRIEND_TEST(CellularTest, CreateService); |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -0700 | [diff] [blame] | 245 | FRIEND_TEST(CellularTest, Connect); |
Gary Morain | a9fb325 | 2012-05-31 12:05:31 -0700 | [diff] [blame] | 246 | FRIEND_TEST(CellularTest, ConnectAddsTerminationAction); |
Eric Shienbrood | cc95c5d | 2012-03-30 15:25:49 -0400 | [diff] [blame] | 247 | FRIEND_TEST(CellularTest, ConnectFailure); |
Thieu Le | b5954a2 | 2012-05-18 10:37:34 -0700 | [diff] [blame] | 248 | FRIEND_TEST(CellularTest, ConnectFailureNoService); |
Darin Petkov | fb0625e | 2012-01-16 13:05:56 +0100 | [diff] [blame] | 249 | FRIEND_TEST(CellularTest, DisableModem); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 250 | FRIEND_TEST(CellularTest, Disconnect); |
Arman Uguray | 539c423 | 2012-09-11 10:00:22 -0700 | [diff] [blame] | 251 | FRIEND_TEST(CellularTest, DisconnectFailure); |
Christopher Wiley | 7d0953e | 2012-11-16 00:37:10 -0800 | [diff] [blame] | 252 | FRIEND_TEST(CellularTest, DisconnectWithCallback); |
Ben Chan | 09fa2a0 | 2012-11-07 22:09:09 -0800 | [diff] [blame] | 253 | FRIEND_TEST(CellularTest, |
| 254 | HandleNewRegistrationStateForServiceRequiringActivation); |
Arman Uguray | 32c7640 | 2012-11-27 14:01:13 -0800 | [diff] [blame] | 255 | FRIEND_TEST(CellularTest, LinkEventWontDestroyService); |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 256 | FRIEND_TEST(CellularTest, ModemStateChangeDisable); |
| 257 | FRIEND_TEST(CellularTest, ModemStateChangeEnable); |
Thieu Le | d001205 | 2012-07-25 16:09:09 -0700 | [diff] [blame] | 258 | FRIEND_TEST(CellularTest, ModemStateChangeStaleConnected); |
| 259 | FRIEND_TEST(CellularTest, ModemStateChangeValidConnected); |
Darin Petkov | e7c6ad3 | 2012-06-29 10:22:09 +0200 | [diff] [blame] | 260 | FRIEND_TEST(CellularTest, SetAllowRoaming); |
Thieu Le | 37b9003 | 2012-05-15 15:18:41 -0700 | [diff] [blame] | 261 | FRIEND_TEST(CellularTest, StartModemCallback); |
| 262 | FRIEND_TEST(CellularTest, StartModemCallbackFail); |
| 263 | FRIEND_TEST(CellularTest, StopModemCallback); |
| 264 | FRIEND_TEST(CellularTest, StopModemCallbackFail); |
Darin Petkov | bac9600 | 2011-08-09 13:22:00 -0700 | [diff] [blame] | 265 | FRIEND_TEST(CellularTest, StartConnected); |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 266 | FRIEND_TEST(CellularTest, StartCDMARegister); |
Darin Petkov | 9bac6fe | 2011-08-26 12:49:05 -0700 | [diff] [blame] | 267 | FRIEND_TEST(CellularTest, StartGSMRegister); |
Darin Petkov | 0828f5f | 2011-08-11 10:18:52 -0700 | [diff] [blame] | 268 | FRIEND_TEST(CellularTest, StartLinked); |
Ben Chan | 876efd3 | 2012-09-28 15:25:13 -0700 | [diff] [blame] | 269 | FRIEND_TEST(Modem1Test, CreateDeviceMM1); |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 270 | |
Jason Glasgow | 7b461df | 2012-05-01 16:38:45 -0400 | [diff] [blame] | 271 | // Names of properties in storage |
| 272 | static const char kAllowRoaming[]; |
| 273 | |
Darin Petkov | 0828f5f | 2011-08-11 10:18:52 -0700 | [diff] [blame] | 274 | void SetState(State state); |
| 275 | |
Darin Petkov | bac9600 | 2011-08-09 13:22:00 -0700 | [diff] [blame] | 276 | // Invoked when the modem is connected to the cellular network to transition |
| 277 | // to the network-connected state and bring the network interface up. |
| 278 | void EstablishLink(); |
| 279 | |
Ben Chan | 3ecdf82 | 2012-08-06 12:29:23 -0700 | [diff] [blame] | 280 | void InitCapability(Type type); |
Darin Petkov | f5f61e0 | 2011-07-29 11:35:40 -0700 | [diff] [blame] | 281 | |
Darin Petkov | d966195 | 2011-08-03 16:25:42 -0700 | [diff] [blame] | 282 | void CreateService(); |
| 283 | |
Eric Shienbrood | 0db6a9b | 2012-03-30 16:11:39 -0400 | [diff] [blame] | 284 | // HelpRegisterDerived*: Expose a property over RPC, with the name |name|. |
| 285 | // |
| 286 | // Reads of the property will be handled by invoking |get|. |
| 287 | // Writes to the property will be handled by invoking |set|. |
| 288 | // Clearing the property will be handled by PropertyStore. |
Jason Glasgow | 7b461df | 2012-05-01 16:38:45 -0400 | [diff] [blame] | 289 | void HelpRegisterDerivedBool( |
| 290 | const std::string &name, |
| 291 | bool(Cellular::*get)(Error *error), |
| 292 | void(Cellular::*set)(const bool &value, Error *error)); |
Eric Shienbrood | 0db6a9b | 2012-03-30 16:11:39 -0400 | [diff] [blame] | 293 | void HelpRegisterDerivedString( |
| 294 | const std::string &name, |
| 295 | std::string(Cellular::*get)(Error *error), |
| 296 | void(Cellular::*set)(const std::string &value, Error *error)); |
| 297 | |
Nathan Williams | b54974f | 2012-04-19 11:16:30 -0400 | [diff] [blame] | 298 | void OnConnectReply(const Error &error); |
Christopher Wiley | 8a46890 | 2012-11-30 11:52:38 -0800 | [diff] [blame] | 299 | void OnDisconnectReply(const Error &error); |
Nathan Williams | b54974f | 2012-04-19 11:16:30 -0400 | [diff] [blame] | 300 | |
Jason Glasgow | 7b461df | 2012-05-01 16:38:45 -0400 | [diff] [blame] | 301 | // DBUS accessors to read/modify the allow roaming property |
| 302 | bool GetAllowRoaming(Error */*error*/) { return allow_roaming_; } |
| 303 | void SetAllowRoaming(const bool &value, Error *error); |
| 304 | |
Gary Morain | a9fb325 | 2012-05-31 12:05:31 -0700 | [diff] [blame] | 305 | // When shill terminates or ChromeOS suspends, this function is called to |
| 306 | // disconnect from the cellular network. |
| 307 | void StartTermination(); |
| 308 | |
Arman Uguray | 539c423 | 2012-09-11 10:00:22 -0700 | [diff] [blame] | 309 | // This function does the final cleanup once a disconnect request terminates. |
| 310 | // Returns true, if the device state is successfully changed. |
| 311 | bool DisconnectCleanup(); |
| 312 | |
Thieu Le | 64b0fe5 | 2012-08-08 14:57:36 -0700 | [diff] [blame] | 313 | base::WeakPtrFactory<Cellular> weak_ptr_factory_; |
| 314 | |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 315 | State state_; |
Darin Petkov | bac9600 | 2011-08-09 13:22:00 -0700 | [diff] [blame] | 316 | ModemState modem_state_; |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 317 | |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 318 | scoped_ptr<CellularCapability> capability_; |
| 319 | |
Jason Glasgow | a585fc3 | 2012-06-06 11:04:09 -0400 | [diff] [blame] | 320 | const std::string dbus_owner_; // :x.y |
| 321 | const std::string dbus_service_; // org.*.ModemManager* |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 322 | const std::string dbus_path_; // ModemManager.Modem |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 323 | |
Ben Chan | 62028b2 | 2012-11-05 11:20:02 -0800 | [diff] [blame] | 324 | CellularOperatorInfo *cellular_operator_info_; |
Darin Petkov | 137884a | 2011-10-26 18:52:47 +0200 | [diff] [blame] | 325 | mobile_provider_db *provider_db_; |
Ben Chan | 3ecdf82 | 2012-08-06 12:29:23 -0700 | [diff] [blame] | 326 | ProxyFactory *proxy_factory_; |
Darin Petkov | 137884a | 2011-10-26 18:52:47 +0200 | [diff] [blame] | 327 | |
Darin Petkov | d966195 | 2011-08-03 16:25:42 -0700 | [diff] [blame] | 328 | CellularServiceRefPtr service_; |
Chris Masone | 853b81b | 2011-06-24 14:11:41 -0700 | [diff] [blame] | 329 | |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 330 | // Properties |
Darin Petkov | 3335b37 | 2011-08-22 11:05:32 -0700 | [diff] [blame] | 331 | Operator home_provider_; |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 332 | |
Jason Glasgow | 7b461df | 2012-05-01 16:38:45 -0400 | [diff] [blame] | 333 | // User preference to allow or disallow roaming |
| 334 | bool allow_roaming_; |
| 335 | |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 336 | DISALLOW_COPY_AND_ASSIGN(Cellular); |
| 337 | }; |
| 338 | |
| 339 | } // namespace shill |
| 340 | |
Darin Petkov | a4ca3c3 | 2012-08-17 16:05:24 +0200 | [diff] [blame] | 341 | #endif // SHILL_CELLULAR_H_ |