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