Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 1 | // Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [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 | |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 5 | #ifndef SHILL_CELLULAR_CAPABILITY_UNIVERSAL_H_ |
| 6 | #define SHILL_CELLULAR_CAPABILITY_UNIVERSAL_H_ |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 7 | |
| 8 | #include <deque> |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 9 | #include <map> |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 10 | #include <string> |
| 11 | #include <vector> |
| 12 | |
| 13 | #include <base/memory/scoped_ptr.h> |
| 14 | #include <base/memory/weak_ptr.h> |
| 15 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Ben Chan | 5c853ef | 2012-10-05 00:05:37 -0700 | [diff] [blame] | 16 | #include <ModemManager/ModemManager.h> |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 17 | |
| 18 | #include "shill/accessor_interface.h" |
| 19 | #include "shill/cellular.h" |
| 20 | #include "shill/cellular_capability.h" |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 21 | #include "shill/mm1_bearer_proxy_interface.h" |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 22 | #include "shill/mm1_modem_modem3gpp_proxy_interface.h" |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 23 | #include "shill/mm1_modem_proxy_interface.h" |
| 24 | #include "shill/mm1_modem_simple_proxy_interface.h" |
| 25 | #include "shill/mm1_sim_proxy_interface.h" |
| 26 | |
| 27 | |
| 28 | struct mobile_provider; |
| 29 | |
| 30 | namespace shill { |
| 31 | |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 32 | class ModemInfo; |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 33 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 34 | // CellularCapabilityUniversal handles modems using the |
| 35 | // org.chromium.ModemManager1 DBUS interface. This class is used for |
| 36 | // all types of modems, i.e. CDMA, GSM, and LTE modems. |
| 37 | class CellularCapabilityUniversal : public CellularCapability { |
| 38 | public: |
| 39 | typedef std::vector<DBusPropertiesMap> ScanResults; |
| 40 | typedef DBusPropertiesMap ScanResult; |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 41 | typedef std::map< uint32_t, uint32_t > LockRetryData; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 42 | |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 43 | // Constants used in connect method call. Make available to test matchers. |
| 44 | // TODO(jglasgow): Generate from modem manager into |
| 45 | // ModemManager-names.h. |
| 46 | // See http://crosbug.com/30551. |
| 47 | static const char kConnectPin[]; |
| 48 | static const char kConnectOperatorId[]; |
| 49 | static const char kConnectBands[]; |
| 50 | static const char kConnectAllowedModes[]; |
| 51 | static const char kConnectPreferredMode[]; |
| 52 | static const char kConnectApn[]; |
| 53 | static const char kConnectIPType[]; |
| 54 | static const char kConnectUser[]; |
| 55 | static const char kConnectPassword[]; |
| 56 | static const char kConnectNumber[]; |
| 57 | static const char kConnectAllowRoaming[]; |
| 58 | static const char kConnectRMProtocol[]; |
| 59 | |
Thieu Le | ce4483e | 2013-01-23 15:12:03 -0800 | [diff] [blame] | 60 | CellularCapabilityUniversal(Cellular *cellular, |
| 61 | ProxyFactory *proxy_factory, |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 62 | ModemInfo *modem_info); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 63 | |
| 64 | // Inherited from CellularCapability. |
Gary Morain | e285a84 | 2012-08-15 08:23:57 -0700 | [diff] [blame] | 65 | // Checks the modem state. If the state is kModemStateDisabled, then the |
| 66 | // modem is enabled. Otherwise, the enable command is buffered until the |
| 67 | // modem becomes disabled. ModemManager rejects the enable command if the |
| 68 | // modem is not disabled, for exmaple, if it is initializing insted. |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 69 | virtual void StartModem(Error *error, const ResultCallback &callback); |
| 70 | virtual void StopModem(Error *error, const ResultCallback &callback); |
| 71 | virtual void Connect(const DBusPropertiesMap &properties, Error *error, |
| 72 | const ResultCallback &callback); |
| 73 | virtual void Disconnect(Error *error, const ResultCallback &callback); |
Christopher Wiley | 8a46890 | 2012-11-30 11:52:38 -0800 | [diff] [blame] | 74 | virtual void DisconnectCleanup(); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 75 | virtual void Activate(const std::string &carrier, |
| 76 | Error *error, const ResultCallback &callback); |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 77 | virtual void CompleteActivation(Error *error); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 78 | |
| 79 | virtual void OnServiceCreated(); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 80 | virtual void SetupConnectProperties(DBusPropertiesMap *properties); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 81 | virtual void GetProperties(); |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 82 | virtual bool IsRegistered(); |
Ben Chan | 1578603 | 2012-11-04 21:28:02 -0800 | [diff] [blame] | 83 | virtual bool IsServiceActivationRequired() const; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 84 | virtual void Register(const ResultCallback &callback); |
| 85 | |
| 86 | virtual void RegisterOnNetwork(const std::string &network_id, |
| 87 | Error *error, |
| 88 | const ResultCallback &callback); |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 89 | virtual void SetUnregistered(bool searching); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 90 | virtual std::string CreateFriendlyServiceName(); |
| 91 | virtual void RequirePIN(const std::string &pin, bool require, |
| 92 | Error *error, const ResultCallback &callback); |
| 93 | virtual void EnterPIN(const std::string &pin, |
| 94 | Error *error, const ResultCallback &callback); |
| 95 | virtual void UnblockPIN(const std::string &unblock_code, |
| 96 | const std::string &pin, |
| 97 | Error *error, const ResultCallback &callback); |
| 98 | virtual void ChangePIN(const std::string &old_pin, |
| 99 | const std::string &new_pin, |
| 100 | Error *error, const ResultCallback &callback); |
Ben Chan | 5d0d32c | 2013-01-08 02:05:29 -0800 | [diff] [blame] | 101 | virtual void Reset(Error *error, const ResultCallback &callback); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 102 | |
| 103 | virtual void Scan(Error *error, const ResultCallback &callback); |
| 104 | virtual std::string GetNetworkTechnologyString() const; |
| 105 | virtual std::string GetRoamingStateString() const; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 106 | virtual void GetSignalQuality(); |
Jason Glasgow | 9f09aef | 2012-05-08 16:26:55 -0400 | [diff] [blame] | 107 | virtual std::string GetTypeString() const; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 108 | virtual void OnDBusPropertiesChanged( |
| 109 | const std::string &interface, |
| 110 | const DBusPropertiesMap &changed_properties, |
| 111 | const std::vector<std::string> &invalidated_properties); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 112 | virtual bool AllowRoaming(); |
Arman Uguray | f84a424 | 2013-04-09 20:01:07 -0700 | [diff] [blame] | 113 | virtual bool ShouldDetectOutOfCredit() const; |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 114 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 115 | protected: |
| 116 | virtual void InitProxies(); |
| 117 | virtual void ReleaseProxies(); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 118 | |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 119 | // Updates the |sim_path_| variable and creates a new proxy to the |
| 120 | // DBUS ModemManager1.Sim interface. |
| 121 | // TODO(armansito): Put this method in a 3GPP-only subclass. |
| 122 | virtual void OnSimPathChanged(const std::string &sim_path); |
| 123 | |
| 124 | // Updates the online payment portal information, if any, for the cellular |
| 125 | // provider. |
| 126 | virtual void UpdateOLP(); |
| 127 | |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 128 | // Post-payment activation handlers. |
| 129 | virtual void UpdatePendingActivationState(); |
| 130 | |
| 131 | const std::string &mdn() const { return mdn_; } |
| 132 | void set_mdn(const std::string &mdn) { mdn_ = mdn; } |
| 133 | |
| 134 | const std::string &min() const { return min_; } |
| 135 | void set_min(const std::string &min) { min_ = min; } |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 136 | |
| 137 | const std::string &meid() const { return meid_; } |
| 138 | void set_meid(const std::string &meid) { meid_ = meid; } |
| 139 | |
| 140 | const std::string &esn() const { return esn_; } |
| 141 | void set_esn(const std::string &esn) { esn_ = esn; } |
| 142 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 143 | private: |
Jason Glasgow | cd0349c | 2012-05-03 23:32:15 -0400 | [diff] [blame] | 144 | // Constants used in scan results. Make available to unit tests. |
| 145 | // TODO(jglasgow): Generate from modem manager into ModemManager-names.h. |
| 146 | // See http://crosbug.com/30551. |
| 147 | static const char kStatusProperty[]; |
| 148 | static const char kOperatorLongProperty[]; |
| 149 | static const char kOperatorShortProperty[]; |
| 150 | static const char kOperatorCodeProperty[]; |
| 151 | static const char kOperatorAccessTechnologyProperty[]; |
| 152 | |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 153 | // Modem Model ID strings. From modem firmware via modemmanager. |
| 154 | static const char kE362ModelId[]; |
| 155 | |
Arman Uguray | 2717a10 | 2013-01-29 23:36:06 -0800 | [diff] [blame] | 156 | // Generic service name prefix, shown when the correct carrier name is |
| 157 | // unknown. |
| 158 | static const char kGenericServiceNamePrefix[]; |
| 159 | |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 160 | static const int64 kActivationRegistrationTimeoutMilliseconds; |
| 161 | static const int64 kDefaultScanningOrSearchingTimeoutMilliseconds; |
Thieu Le | 2cac294 | 2013-03-05 18:41:08 -0800 | [diff] [blame] | 162 | static const int kSetPowerStateTimeoutMilliseconds; |
Arman Uguray | ee464d3 | 2013-02-13 17:14:36 -0800 | [diff] [blame] | 163 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 164 | |
Arman Uguray | 6552f8c | 2013-02-12 15:33:18 -0800 | [diff] [blame] | 165 | // Root path. The SIM path is reported by ModemManager to be the root path |
| 166 | // when no SIM is present. |
| 167 | static const char kRootPath[]; |
| 168 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 169 | friend class CellularTest; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 170 | friend class CellularCapabilityTest; |
Thieu Le | 3d27539 | 2012-07-20 15:32:58 -0700 | [diff] [blame] | 171 | friend class CellularCapabilityUniversalTest; |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 172 | friend class CellularCapabilityUniversalCDMATest; |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 173 | FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, PropertiesChanged); |
| 174 | FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, UpdateOLP); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 175 | FRIEND_TEST(CellularCapabilityUniversalMainTest, AllowRoaming); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 176 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
| 177 | ActivationWaitForRegisterTimeout); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 178 | FRIEND_TEST(CellularCapabilityUniversalMainTest, Connect); |
| 179 | FRIEND_TEST(CellularCapabilityUniversalMainTest, ConnectApns); |
| 180 | FRIEND_TEST(CellularCapabilityUniversalMainTest, CreateFriendlyServiceName); |
| 181 | FRIEND_TEST(CellularCapabilityUniversalMainTest, DisconnectNoProxy); |
Arman Uguray | 7af0fac | 2013-03-18 17:35:35 -0700 | [diff] [blame] | 182 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
| 183 | GetNetworkTechnologyStringOnE362); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 184 | FRIEND_TEST(CellularCapabilityUniversalMainTest, GetTypeString); |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 185 | FRIEND_TEST(CellularCapabilityUniversalMainTest, IsMdnValid); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 186 | FRIEND_TEST(CellularCapabilityUniversalMainTest, IsServiceActivationRequired); |
Arman Uguray | 6552f8c | 2013-02-12 15:33:18 -0800 | [diff] [blame] | 187 | FRIEND_TEST(CellularCapabilityUniversalMainTest, IsValidSimPath); |
Ben Chan | d759252 | 2013-02-13 16:02:01 -0800 | [diff] [blame] | 188 | FRIEND_TEST(CellularCapabilityUniversalMainTest, NormalizeMdn); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 189 | FRIEND_TEST(CellularCapabilityUniversalMainTest, OnListBearersReply); |
| 190 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
Ben Chan | fcca27b | 2013-01-22 15:03:44 -0800 | [diff] [blame] | 191 | OnModemCurrentCapabilitiesChanged); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 192 | FRIEND_TEST(CellularCapabilityUniversalMainTest, PropertiesChanged); |
| 193 | FRIEND_TEST(CellularCapabilityUniversalMainTest, Reset); |
| 194 | FRIEND_TEST(CellularCapabilityUniversalMainTest, Scan); |
| 195 | FRIEND_TEST(CellularCapabilityUniversalMainTest, ScanFailure); |
| 196 | FRIEND_TEST(CellularCapabilityUniversalMainTest, SetHomeProvider); |
Arman Uguray | d42d8ec | 2013-04-08 19:28:21 -0700 | [diff] [blame] | 197 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
Arman Uguray | f84a424 | 2013-04-09 20:01:07 -0700 | [diff] [blame] | 198 | ShouldDetectOutOfCredit); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 199 | FRIEND_TEST(CellularCapabilityUniversalMainTest, SimLockStatusChanged); |
| 200 | FRIEND_TEST(CellularCapabilityUniversalMainTest, SimPathChanged); |
| 201 | FRIEND_TEST(CellularCapabilityUniversalMainTest, SimPropertiesChanged); |
| 202 | FRIEND_TEST(CellularCapabilityUniversalMainTest, StartModem); |
| 203 | FRIEND_TEST(CellularCapabilityUniversalMainTest, StopModem); |
| 204 | FRIEND_TEST(CellularCapabilityUniversalMainTest, StopModemConnected); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 205 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
| 206 | UpdatePendingActivationState); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 207 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
| 208 | UpdateServiceActivationState); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 209 | FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateServiceName); |
| 210 | FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateStorageIdentifier); |
| 211 | FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateOLP); |
| 212 | FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateOperatorInfo); |
| 213 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
| 214 | UpdateOperatorInfoViaOperatorId); |
| 215 | FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateScanningProperty); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 216 | FRIEND_TEST(CellularCapabilityUniversalTimerTest, CompleteActivation); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 217 | FRIEND_TEST(CellularCapabilityUniversalTimerTest, |
| 218 | UpdateScanningPropertyTimeout); |
Arman Uguray | d42d8ec | 2013-04-08 19:28:21 -0700 | [diff] [blame] | 219 | FRIEND_TEST(CellularTest, EnableTrafficMonitor); |
Ben Chan | 09fa2a0 | 2012-11-07 22:09:09 -0800 | [diff] [blame] | 220 | FRIEND_TEST(CellularTest, |
| 221 | HandleNewRegistrationStateForServiceRequiringActivation); |
Thieu Le | 5218cf2 | 2012-11-26 11:52:57 -0800 | [diff] [blame] | 222 | FRIEND_TEST(CellularTest, ModemStateChangeLostRegistration); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 223 | |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 224 | // Methods used in starting a modem |
Gary Morain | e285a84 | 2012-08-15 08:23:57 -0700 | [diff] [blame] | 225 | void EnableModem(Error *error, const ResultCallback &callback); |
Thieu Le | b9c05e0 | 2013-03-04 14:09:32 -0800 | [diff] [blame] | 226 | void Start_ModemAlreadyEnabled(const ResultCallback &callback); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 227 | void Start_EnableModemCompleted(const ResultCallback &callback, |
| 228 | const Error &error); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 229 | |
| 230 | // Methods used in stopping a modem |
| 231 | void Stop_DisconnectCompleted(const ResultCallback &callback, |
| 232 | const Error &error); |
| 233 | void Stop_Disable(const ResultCallback &callback); |
| 234 | void Stop_DisableCompleted(const ResultCallback &callback, |
| 235 | const Error &error); |
Arman Uguray | ee464d3 | 2013-02-13 17:14:36 -0800 | [diff] [blame] | 236 | void Stop_PowerDown(const ResultCallback &callback); |
| 237 | void Stop_PowerDownCompleted(const ResultCallback &callback, |
| 238 | const Error &error); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 239 | |
Arman Uguray | 2717a10 | 2013-01-29 23:36:06 -0800 | [diff] [blame] | 240 | // Updates the name property that is exposed by the service to Chrome. |
| 241 | void UpdateServiceName(); |
| 242 | |
Ben Chan | 8a2c01e | 2013-01-23 10:09:14 -0800 | [diff] [blame] | 243 | void UpdateScanningProperty(); |
| 244 | |
Arman Uguray | d73783f | 2013-01-31 16:11:21 -0800 | [diff] [blame] | 245 | // Methods used in acquiring information related to the carrier; |
| 246 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 247 | // Updates the Universal operator name and country based on a newly |
| 248 | // obtained network id. |
| 249 | void UpdateOperatorInfo(); |
| 250 | |
Arman Uguray | d73783f | 2013-01-31 16:11:21 -0800 | [diff] [blame] | 251 | // Sets the upper level information about the home cellular provider from the |
| 252 | // modem's IMSI and SPN. |
| 253 | void SetHomeProvider(); |
| 254 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 255 | // Updates the serving operator on the active service. |
| 256 | void UpdateServingOperator(); |
| 257 | |
Arman Uguray | d73783f | 2013-01-31 16:11:21 -0800 | [diff] [blame] | 258 | // Initializes the |apn_list_| property based on the current |home_provider_|. |
| 259 | void InitAPNList(); |
| 260 | |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 261 | // Updates |bearer_path_| to match the currently active bearer. |
| 262 | void UpdateBearerPath(); |
| 263 | |
Arman Uguray | c953357 | 2013-01-22 17:34:20 -0800 | [diff] [blame] | 264 | // Updates the storage identifier used for the current cellular service. |
| 265 | void UpdateStorageIdentifier(); |
| 266 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 267 | |
| 268 | Stringmap ParseScanResult(const ScanResult &result); |
| 269 | |
| 270 | KeyValueStore SimLockStatusToProperty(Error *error); |
| 271 | |
| 272 | void SetupApnTryList(); |
| 273 | void FillConnectPropertyMap(DBusPropertiesMap *properties); |
| 274 | |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 275 | void HelpRegisterConstDerivedKeyValueStore( |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 276 | const std::string &name, |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 277 | KeyValueStore(CellularCapabilityUniversal::*get)(Error *error)); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 278 | |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 279 | // Returns true if a connect error should be retried. This function |
| 280 | // abstracts modem specific behavior for modems which do a lousy job |
| 281 | // of returning specific errors on connect failures. |
| 282 | bool RetriableConnectError(const Error &error) const; |
| 283 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 284 | // Signal callbacks |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 285 | void OnNetworkModeSignal(uint32 mode); |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 286 | void OnModemStateChangedSignal(int32 old_state, |
| 287 | int32 new_state, |
| 288 | uint32 reason); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 289 | |
| 290 | // Property Change notification handlers |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 291 | void OnModemPropertiesChanged( |
Jason Glasgow | 4c0724a | 2012-04-17 15:47:40 -0400 | [diff] [blame] | 292 | const DBusPropertiesMap &properties, |
| 293 | const std::vector<std::string> &invalidated_properties); |
| 294 | |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 295 | void OnSignalQualityChanged(uint32 quality); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 296 | |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 297 | void OnModemCapabilitesChanged(uint32 capabilities); |
| 298 | void OnModemCurrentCapabilitiesChanged(uint32 current_capabilities); |
| 299 | void OnMdnChanged(const std::string &mdn); |
| 300 | void OnModemManufacturerChanged(const std::string &manufacturer); |
| 301 | void OnModemModelChanged(const std::string &model); |
| 302 | void OnModemRevisionChanged(const std::string &revision); |
| 303 | void OnModemStateChanged(Cellular::ModemState state); |
| 304 | void OnAccessTechnologiesChanged(uint32 access_technologies); |
| 305 | void OnSupportedModesChanged(uint32 supported_modes); |
| 306 | void OnAllowedModesChanged(uint32 allowed_modes); |
| 307 | void OnPreferredModeChanged(MMModemMode preferred_mode); |
| 308 | void OnLockRetriesChanged(MMModemLock unlock_required, |
| 309 | const LockRetryData &lock_retries); |
| 310 | void OnSimLockStatusChanged(); |
| 311 | |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 312 | // Returns false if the MDN is empty or if the MDN consists of all 0s. |
| 313 | bool IsMdnValid() const; |
| 314 | |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 315 | // 3GPP property change handlers |
| 316 | virtual void OnModem3GPPPropertiesChanged( |
| 317 | const DBusPropertiesMap &properties, |
| 318 | const std::vector<std::string> &invalidated_properties); |
| 319 | void OnImeiChanged(const std::string &imei); |
| 320 | void On3GPPRegistrationChanged(MMModem3gppRegistrationState state, |
| 321 | const std::string &operator_code, |
| 322 | const std::string &operator_name); |
| 323 | void OnFacilityLocksChanged(uint32 locks); |
| 324 | |
| 325 | // SIM property change handlers |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 326 | // TODO(armansito): Put these methods in a 3GPP-only subclass. |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 327 | void OnSimPropertiesChanged( |
| 328 | const DBusPropertiesMap &props, |
| 329 | const std::vector<std::string> &invalidated_properties); |
| 330 | void OnImsiChanged(const std::string &imsi); |
Arman Uguray | d73783f | 2013-01-31 16:11:21 -0800 | [diff] [blame] | 331 | void OnSpnChanged(const std::string &spn); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 332 | void OnSimIdentifierChanged(const std::string &id); |
| 333 | void OnOperatorIdChanged(const std::string &operator_id); |
| 334 | void OnOperatorNameChanged(const std::string &operator_name); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 335 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 336 | // Method callbacks |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 337 | void OnRegisterReply(const ResultCallback &callback, |
| 338 | const Error &error); |
Ben Chan | 5d0d32c | 2013-01-08 02:05:29 -0800 | [diff] [blame] | 339 | void OnResetReply(const ResultCallback &callback, const Error &error); |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 340 | void OnScanReply(const ResultCallback &callback, |
| 341 | const ScanResults &results, |
| 342 | const Error &error); |
Nathan Williams | b54974f | 2012-04-19 11:16:30 -0400 | [diff] [blame] | 343 | void OnConnectReply(const ResultCallback &callback, |
| 344 | const DBus::Path &bearer, |
| 345 | const Error &error); |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 346 | void OnListBearersReply(const std::vector<DBus::Path> &paths, |
| 347 | const Error &error); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 348 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 349 | // Timeout callback for the network scan initiated when Cellular connectivity |
| 350 | // gets enabled. |
| 351 | void OnScanningOrSearchingTimeout(); |
| 352 | |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 353 | // Timeout callback that is called if the modem takes too long to register to |
| 354 | // a network after online payment is complete. Resets the modem. |
| 355 | void OnActivationWaitForRegisterTimeout(); |
| 356 | |
Arman Uguray | 6552f8c | 2013-02-12 15:33:18 -0800 | [diff] [blame] | 357 | // Returns true, if |sim_path| constitutes a valid SIM path. Currently, a |
| 358 | // path is accepted to be valid, as long as it is not equal to one of "" |
| 359 | // and "/". |
| 360 | bool IsValidSimPath(const std::string &sim_path) const; |
| 361 | |
Ben Chan | d759252 | 2013-02-13 16:02:01 -0800 | [diff] [blame] | 362 | // Returns the normalized version of |mdn| by keeping only digits in |mdn| |
| 363 | // and removing other non-digit characters. |
| 364 | std::string NormalizeMdn(const std::string &mdn) const; |
| 365 | |
Arman Uguray | 2717a10 | 2013-01-29 23:36:06 -0800 | [diff] [blame] | 366 | static std::string GenerateNewGenericServiceName(); |
| 367 | |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 368 | // Post-payment activation handlers. |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 369 | void ResetAfterActivation(); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 370 | void UpdateServiceActivationState(); |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 371 | void OnResetAfterActivationReply(const Error &error); |
| 372 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 373 | scoped_ptr<mm1::ModemModem3gppProxyInterface> modem_3gpp_proxy_; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 374 | scoped_ptr<mm1::ModemProxyInterface> modem_proxy_; |
| 375 | scoped_ptr<mm1::ModemSimpleProxyInterface> modem_simple_proxy_; |
| 376 | scoped_ptr<mm1::SimProxyInterface> sim_proxy_; |
| 377 | |
| 378 | base::WeakPtrFactory<CellularCapabilityUniversal> weak_ptr_factory_; |
| 379 | |
| 380 | MMModem3gppRegistrationState registration_state_; |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 381 | |
| 382 | // Bits based on MMModemCapabilities |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 383 | uint32 capabilities_; // technologies supported, may require reload |
| 384 | uint32 current_capabilities_; // technologies supportsed without a reload |
| 385 | uint32 access_technologies_; // Bits based on MMModemAccessTechnology |
| 386 | uint32 supported_modes_; // Bits based on MMModemMode |
| 387 | uint32 allowed_modes_; // Bits based on MMModemMode |
| 388 | MMModemMode preferred_mode_; // A single MMModemMode bit |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 389 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 390 | Cellular::Operator serving_operator_; |
| 391 | std::string spn_; |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 392 | std::string sim_identifier_; |
| 393 | std::string operator_id_; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 394 | mobile_provider *home_provider_; |
Darin Petkov | f508c82 | 2012-09-21 13:43:17 +0200 | [diff] [blame] | 395 | bool provider_requires_roaming_; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 396 | std::string desired_network_; |
| 397 | |
| 398 | // Properties. |
| 399 | std::string carrier_; |
| 400 | std::string esn_; |
| 401 | std::string firmware_revision_; |
| 402 | std::string hardware_revision_; |
| 403 | std::string imei_; |
| 404 | std::string imsi_; |
| 405 | std::string manufacturer_; |
| 406 | std::string mdn_; |
| 407 | std::string meid_; |
| 408 | std::string min_; |
| 409 | std::string model_id_; |
| 410 | std::string selected_network_; |
| 411 | Stringmaps found_networks_; |
| 412 | std::deque<Stringmap> apn_try_list_; |
Ben Chan | 5d0d32c | 2013-01-08 02:05:29 -0800 | [diff] [blame] | 413 | bool resetting_; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 414 | bool scanning_supported_; |
| 415 | bool scanning_; |
Ben Chan | 8a2c01e | 2013-01-23 10:09:14 -0800 | [diff] [blame] | 416 | bool scanning_or_searching_; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 417 | uint16 scan_interval_; |
| 418 | SimLockStatus sim_lock_status_; |
| 419 | Stringmaps apn_list_; |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 420 | std::string sim_path_; |
Ben Chan | bd3aee8 | 2012-10-16 23:52:04 -0700 | [diff] [blame] | 421 | bool sim_present_; |
Nathan Williams | b54974f | 2012-04-19 11:16:30 -0400 | [diff] [blame] | 422 | DBus::Path bearer_path_; |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 423 | bool reset_done_; |
| 424 | |
Gary Morain | e285a84 | 2012-08-15 08:23:57 -0700 | [diff] [blame] | 425 | // If the modem is not in a state to be enabled when StartModem is called, |
| 426 | // enabling is deferred using this callback. |
| 427 | base::Closure deferred_enable_modem_callback_; |
| 428 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 429 | // Sometimes modems may be stuck in the SEARCHING state during the lack of |
| 430 | // presence of a network. During this indefinite duration of time, keeping |
| 431 | // the Device.Scanning property as |true| causes a bad user experience. |
| 432 | // This callback sets it to |false| after a timeout period has passed. |
| 433 | base::CancelableClosure scanning_or_searching_timeout_callback_; |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 434 | int64 scanning_or_searching_timeout_milliseconds_; |
| 435 | |
| 436 | base::CancelableClosure activation_wait_for_registration_callback_; |
| 437 | int64 activation_registration_timeout_milliseconds_; |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 438 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 439 | static unsigned int friendly_service_name_id_; |
| 440 | |
| 441 | DISALLOW_COPY_AND_ASSIGN(CellularCapabilityUniversal); |
| 442 | }; |
| 443 | |
| 444 | } // namespace shill |
| 445 | |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 446 | #endif // SHILL_CELLULAR_CAPABILITY_UNIVERSAL_H_ |