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