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