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