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" |
Thieu Le | 2849214 | 2014-04-08 16:41:13 -0700 | [diff] [blame] | 20 | #include "shill/cellular_bearer.h" |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 21 | #include "shill/cellular_capability.h" |
Ben Chan | 07193fd | 2013-07-12 22:10:55 -0700 | [diff] [blame] | 22 | #include "shill/cellular_operator_info.h" |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 23 | #include "shill/mm1_modem_modem3gpp_proxy_interface.h" |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 24 | #include "shill/mm1_modem_proxy_interface.h" |
| 25 | #include "shill/mm1_modem_simple_proxy_interface.h" |
| 26 | #include "shill/mm1_sim_proxy_interface.h" |
Thieu Le | 43ce4d4 | 2013-10-04 16:08:55 -0700 | [diff] [blame] | 27 | #include "shill/out_of_credits_detector.h" |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 28 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 29 | struct mobile_provider; |
| 30 | |
| 31 | namespace shill { |
| 32 | |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 33 | class ModemInfo; |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 34 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 35 | // CellularCapabilityUniversal handles modems using the |
| 36 | // org.chromium.ModemManager1 DBUS interface. This class is used for |
| 37 | // all types of modems, i.e. CDMA, GSM, and LTE modems. |
| 38 | class CellularCapabilityUniversal : public CellularCapability { |
| 39 | public: |
| 40 | typedef std::vector<DBusPropertiesMap> ScanResults; |
| 41 | typedef DBusPropertiesMap ScanResult; |
Ben Chan | 74924d8 | 2013-06-15 17:52:55 -0700 | [diff] [blame] | 42 | typedef std::map<uint32_t, uint32_t> LockRetryData; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 43 | |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 44 | // Constants used in connect method call. Make available to test matchers. |
| 45 | // TODO(jglasgow): Generate from modem manager into |
| 46 | // ModemManager-names.h. |
Paul Stewart | ee6b3d7 | 2013-07-12 16:07:51 -0700 | [diff] [blame] | 47 | // See http://crbug.com/212909. |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 48 | static const char kConnectPin[]; |
| 49 | static const char kConnectOperatorId[]; |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 50 | static const char kConnectApn[]; |
| 51 | static const char kConnectIPType[]; |
| 52 | static const char kConnectUser[]; |
| 53 | static const char kConnectPassword[]; |
| 54 | static const char kConnectNumber[]; |
| 55 | static const char kConnectAllowRoaming[]; |
| 56 | static const char kConnectRMProtocol[]; |
| 57 | |
Thieu Le | ce4483e | 2013-01-23 15:12:03 -0800 | [diff] [blame] | 58 | CellularCapabilityUniversal(Cellular *cellular, |
| 59 | ProxyFactory *proxy_factory, |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 60 | ModemInfo *modem_info); |
Ben Chan | f98f00e | 2014-02-05 14:48:43 -0800 | [diff] [blame] | 61 | virtual ~CellularCapabilityUniversal(); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 62 | |
| 63 | // Inherited from CellularCapability. |
Ben Chan | f98f00e | 2014-02-05 14:48:43 -0800 | [diff] [blame] | 64 | virtual std::string GetTypeString() const override; |
| 65 | virtual void OnDBusPropertiesChanged( |
| 66 | const std::string &interface, |
| 67 | const DBusPropertiesMap &changed_properties, |
| 68 | const std::vector<std::string> &invalidated_properties) override; |
Gary Morain | e285a84 | 2012-08-15 08:23:57 -0700 | [diff] [blame] | 69 | // Checks the modem state. If the state is kModemStateDisabled, then the |
| 70 | // modem is enabled. Otherwise, the enable command is buffered until the |
| 71 | // modem becomes disabled. ModemManager rejects the enable command if the |
Arman Uguray | 1ee9391 | 2013-09-24 21:24:10 -0700 | [diff] [blame] | 72 | // modem is not disabled, for example, if it is initializing instead. |
Ben Chan | f98f00e | 2014-02-05 14:48:43 -0800 | [diff] [blame] | 73 | virtual void StartModem(Error *error, |
| 74 | const ResultCallback &callback) override; |
| 75 | virtual void StopModem(Error *error, const ResultCallback &callback) override; |
| 76 | virtual void Reset(Error *error, const ResultCallback &callback) override; |
| 77 | virtual bool IsServiceActivationRequired() const override; |
| 78 | virtual void CompleteActivation(Error *error) override; |
| 79 | virtual void Scan(Error *error, |
| 80 | const ResultStringmapsCallback &callback) override; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 81 | virtual void RegisterOnNetwork(const std::string &network_id, |
| 82 | Error *error, |
Ben Chan | f98f00e | 2014-02-05 14:48:43 -0800 | [diff] [blame] | 83 | const ResultCallback &callback) override; |
| 84 | virtual bool IsRegistered() const override; |
| 85 | virtual void SetUnregistered(bool searching) override; |
| 86 | virtual void OnServiceCreated() override; |
Ben Chan | f98f00e | 2014-02-05 14:48:43 -0800 | [diff] [blame] | 87 | virtual std::string GetNetworkTechnologyString() const override; |
| 88 | virtual std::string GetRoamingStateString() const override; |
| 89 | virtual bool AllowRoaming() override; |
| 90 | virtual void GetSignalQuality() override; |
| 91 | virtual void SetupConnectProperties(DBusPropertiesMap *properties) override; |
| 92 | virtual void Connect(const DBusPropertiesMap &properties, |
| 93 | Error *error, |
| 94 | const ResultCallback &callback) override; |
| 95 | virtual void Disconnect(Error *error, |
| 96 | const ResultCallback &callback) override; |
| 97 | virtual CellularBearer *GetActiveBearer() const override; |
| 98 | virtual void RequirePIN(const std::string &pin, |
| 99 | bool require, |
| 100 | Error *error, |
| 101 | const ResultCallback &callback) override; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 102 | virtual void EnterPIN(const std::string &pin, |
Ben Chan | f98f00e | 2014-02-05 14:48:43 -0800 | [diff] [blame] | 103 | Error *error, |
| 104 | const ResultCallback &callback) override; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 105 | virtual void UnblockPIN(const std::string &unblock_code, |
| 106 | const std::string &pin, |
Ben Chan | f98f00e | 2014-02-05 14:48:43 -0800 | [diff] [blame] | 107 | Error *error, |
| 108 | const ResultCallback &callback) override; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 109 | virtual void ChangePIN(const std::string &old_pin, |
| 110 | const std::string &new_pin, |
Ben Chan | f98f00e | 2014-02-05 14:48:43 -0800 | [diff] [blame] | 111 | Error *error, |
| 112 | const ResultCallback &callback) override; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 113 | |
Ben Chan | f98f00e | 2014-02-05 14:48:43 -0800 | [diff] [blame] | 114 | virtual void GetProperties(); |
| 115 | virtual void Register(const ResultCallback &callback); |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 116 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 117 | protected: |
| 118 | virtual void InitProxies(); |
| 119 | virtual void ReleaseProxies(); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 120 | |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 121 | // Updates the |sim_path_| variable and creates a new proxy to the |
| 122 | // DBUS ModemManager1.Sim interface. |
| 123 | // TODO(armansito): Put this method in a 3GPP-only subclass. |
| 124 | virtual void OnSimPathChanged(const std::string &sim_path); |
| 125 | |
| 126 | // Updates the online payment portal information, if any, for the cellular |
| 127 | // provider. |
Prathmesh Prabhu | 92df619 | 2014-04-29 18:08:08 -0700 | [diff] [blame] | 128 | virtual void UpdateServiceOLP() override; |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 129 | |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 130 | // Post-payment activation handlers. |
| 131 | virtual void UpdatePendingActivationState(); |
| 132 | |
Prathmesh Prabhu | 9f06c87 | 2013-11-21 14:08:23 -0800 | [diff] [blame] | 133 | // Returns the operator-specific form of |mdn|, which is passed to the online |
Ben Chan | 07193fd | 2013-07-12 22:10:55 -0700 | [diff] [blame] | 134 | // payment portal of a cellular operator. |
Prathmesh Prabhu | 92df619 | 2014-04-29 18:08:08 -0700 | [diff] [blame] | 135 | std::string GetMdnForOLP(const MobileOperatorInfo *operator_info) const; |
Ben Chan | 07193fd | 2013-07-12 22:10:55 -0700 | [diff] [blame] | 136 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 137 | private: |
Ben Chan | 74924d8 | 2013-06-15 17:52:55 -0700 | [diff] [blame] | 138 | struct ModemModes { |
| 139 | ModemModes() |
| 140 | : allowed_modes(MM_MODEM_MODE_NONE), |
| 141 | preferred_mode(MM_MODEM_MODE_NONE) {} |
| 142 | |
| 143 | ModemModes(uint32 allowed, MMModemMode preferred) |
| 144 | : allowed_modes(allowed), |
| 145 | preferred_mode(preferred) {} |
| 146 | |
| 147 | uint32 allowed_modes; // Bits based on MMModemMode. |
| 148 | MMModemMode preferred_mode; // A single MMModemMode bit. |
| 149 | }; |
| 150 | |
Jason Glasgow | cd0349c | 2012-05-03 23:32:15 -0400 | [diff] [blame] | 151 | // Constants used in scan results. Make available to unit tests. |
| 152 | // TODO(jglasgow): Generate from modem manager into ModemManager-names.h. |
Paul Stewart | ee6b3d7 | 2013-07-12 16:07:51 -0700 | [diff] [blame] | 153 | // See http://crbug.com/212909. |
Jason Glasgow | cd0349c | 2012-05-03 23:32:15 -0400 | [diff] [blame] | 154 | static const char kStatusProperty[]; |
| 155 | static const char kOperatorLongProperty[]; |
| 156 | static const char kOperatorShortProperty[]; |
| 157 | static const char kOperatorCodeProperty[]; |
| 158 | static const char kOperatorAccessTechnologyProperty[]; |
| 159 | |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 160 | // Modem Model ID strings. From modem firmware via modemmanager. |
Thieu Le | 43ce4d4 | 2013-10-04 16:08:55 -0700 | [diff] [blame] | 161 | static const char kALT3100ModelId[]; |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 162 | static const char kE362ModelId[]; |
| 163 | |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 164 | static const int64 kActivationRegistrationTimeoutMilliseconds; |
Arman Uguray | f6366ac | 2013-06-12 16:02:28 -0700 | [diff] [blame] | 165 | static const int64 kEnterPinTimeoutMilliseconds; |
Prathmesh Prabhu | 8f6479f | 2013-05-15 12:56:13 -0700 | [diff] [blame] | 166 | static const int64 kRegistrationDroppedUpdateTimeoutMilliseconds; |
Thieu Le | 2cac294 | 2013-03-05 18:41:08 -0800 | [diff] [blame] | 167 | static const int kSetPowerStateTimeoutMilliseconds; |
Arman Uguray | ee464d3 | 2013-02-13 17:14:36 -0800 | [diff] [blame] | 168 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 169 | |
Arman Uguray | 6552f8c | 2013-02-12 15:33:18 -0800 | [diff] [blame] | 170 | // Root path. The SIM path is reported by ModemManager to be the root path |
| 171 | // when no SIM is present. |
| 172 | static const char kRootPath[]; |
| 173 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 174 | friend class CellularTest; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 175 | friend class CellularCapabilityTest; |
Thieu Le | 3d27539 | 2012-07-20 15:32:58 -0700 | [diff] [blame] | 176 | friend class CellularCapabilityUniversalTest; |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 177 | friend class CellularCapabilityUniversalCDMATest; |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 178 | FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, PropertiesChanged); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 179 | FRIEND_TEST(CellularCapabilityUniversalMainTest, AllowRoaming); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 180 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
| 181 | ActivationWaitForRegisterTimeout); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 182 | FRIEND_TEST(CellularCapabilityUniversalMainTest, Connect); |
| 183 | FRIEND_TEST(CellularCapabilityUniversalMainTest, ConnectApns); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 184 | FRIEND_TEST(CellularCapabilityUniversalMainTest, DisconnectNoProxy); |
Arman Uguray | 7af0fac | 2013-03-18 17:35:35 -0700 | [diff] [blame] | 185 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
Prathmesh Prabhu | 8f6479f | 2013-05-15 12:56:13 -0700 | [diff] [blame] | 186 | DisconnectWithDeferredCallback); |
Thieu Le | 43ce4d4 | 2013-10-04 16:08:55 -0700 | [diff] [blame] | 187 | FRIEND_TEST(CellularCapabilityUniversalMainTest, ExtractPcoValue); |
| 188 | FRIEND_TEST(CellularCapabilityUniversalMainTest, GetMdnForOLP); |
Prathmesh Prabhu | 8f6479f | 2013-05-15 12:56:13 -0700 | [diff] [blame] | 189 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
Arman Uguray | 7af0fac | 2013-03-18 17:35:35 -0700 | [diff] [blame] | 190 | GetNetworkTechnologyStringOnE362); |
Thieu Le | 43ce4d4 | 2013-10-04 16:08:55 -0700 | [diff] [blame] | 191 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
| 192 | GetOutOfCreditsDetectionType); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 193 | FRIEND_TEST(CellularCapabilityUniversalMainTest, GetTypeString); |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 194 | FRIEND_TEST(CellularCapabilityUniversalMainTest, IsMdnValid); |
Ben Chan | 31ce564 | 2013-11-14 13:37:40 -0800 | [diff] [blame] | 195 | FRIEND_TEST(CellularCapabilityUniversalMainTest, IsRegistered); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 196 | FRIEND_TEST(CellularCapabilityUniversalMainTest, IsServiceActivationRequired); |
Arman Uguray | 6552f8c | 2013-02-12 15:33:18 -0800 | [diff] [blame] | 197 | FRIEND_TEST(CellularCapabilityUniversalMainTest, IsValidSimPath); |
Ben Chan | d759252 | 2013-02-13 16:02:01 -0800 | [diff] [blame] | 198 | FRIEND_TEST(CellularCapabilityUniversalMainTest, NormalizeMdn); |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 199 | FRIEND_TEST(CellularCapabilityUniversalMainTest, OnLockRetriesChanged); |
| 200 | FRIEND_TEST(CellularCapabilityUniversalMainTest, OnLockTypeChanged); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 201 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
Ben Chan | fcca27b | 2013-01-22 15:03:44 -0800 | [diff] [blame] | 202 | OnModemCurrentCapabilitiesChanged); |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 203 | FRIEND_TEST(CellularCapabilityUniversalMainTest, OnSimLockPropertiesChanged); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 204 | FRIEND_TEST(CellularCapabilityUniversalMainTest, PropertiesChanged); |
| 205 | FRIEND_TEST(CellularCapabilityUniversalMainTest, Reset); |
| 206 | FRIEND_TEST(CellularCapabilityUniversalMainTest, Scan); |
| 207 | FRIEND_TEST(CellularCapabilityUniversalMainTest, ScanFailure); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 208 | FRIEND_TEST(CellularCapabilityUniversalMainTest, SimLockStatusChanged); |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 209 | FRIEND_TEST(CellularCapabilityUniversalMainTest, SimLockStatusToProperty); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 210 | FRIEND_TEST(CellularCapabilityUniversalMainTest, SimPathChanged); |
| 211 | FRIEND_TEST(CellularCapabilityUniversalMainTest, SimPropertiesChanged); |
| 212 | FRIEND_TEST(CellularCapabilityUniversalMainTest, StartModem); |
Ben Chan | 151d447 | 2013-09-06 13:29:46 -0700 | [diff] [blame] | 213 | FRIEND_TEST(CellularCapabilityUniversalMainTest, StartModemFailure); |
| 214 | FRIEND_TEST(CellularCapabilityUniversalMainTest, StartModemInWrongState); |
| 215 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
| 216 | StartModemWithDeferredEnableFailure); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 217 | FRIEND_TEST(CellularCapabilityUniversalMainTest, StopModem); |
Thieu Le | 2849214 | 2014-04-08 16:41:13 -0700 | [diff] [blame] | 218 | FRIEND_TEST(CellularCapabilityUniversalMainTest, StopModemALT3100); |
Thieu Le | b0074e8 | 2014-04-15 14:28:21 -0700 | [diff] [blame] | 219 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
| 220 | StopModemALT3100DeleteBearerFailure); |
| 221 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
| 222 | StopModemALT3100NotConnected); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 223 | FRIEND_TEST(CellularCapabilityUniversalMainTest, StopModemConnected); |
Ben Chan | 9f3dcf8 | 2013-09-25 18:04:58 -0700 | [diff] [blame] | 224 | FRIEND_TEST(CellularCapabilityUniversalMainTest, TerminationAction); |
| 225 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
| 226 | TerminationActionRemovedByStopModem); |
Ben Chan | 539ab02 | 2014-02-03 16:34:57 -0800 | [diff] [blame] | 227 | FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateActiveBearer); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 228 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
| 229 | UpdatePendingActivationState); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 230 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
Prathmesh Prabhu | 8f6479f | 2013-05-15 12:56:13 -0700 | [diff] [blame] | 231 | UpdateRegistrationState); |
| 232 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
| 233 | UpdateRegistrationStateModemNotConnected); |
| 234 | FRIEND_TEST(CellularCapabilityUniversalMainTest, |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 235 | UpdateServiceActivationState); |
Prathmesh Prabhu | 92df619 | 2014-04-29 18:08:08 -0700 | [diff] [blame] | 236 | FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateServiceOLP); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 237 | FRIEND_TEST(CellularCapabilityUniversalTimerTest, CompleteActivation); |
Arman Uguray | d42d8ec | 2013-04-08 19:28:21 -0700 | [diff] [blame] | 238 | FRIEND_TEST(CellularTest, EnableTrafficMonitor); |
Ben Chan | 09fa2a0 | 2012-11-07 22:09:09 -0800 | [diff] [blame] | 239 | FRIEND_TEST(CellularTest, |
| 240 | HandleNewRegistrationStateForServiceRequiringActivation); |
Thieu Le | 5218cf2 | 2012-11-26 11:52:57 -0800 | [diff] [blame] | 241 | FRIEND_TEST(CellularTest, ModemStateChangeLostRegistration); |
mukesh agrawal | f407d59 | 2013-07-31 11:37:57 -0700 | [diff] [blame] | 242 | FRIEND_TEST(CellularTest, OnPPPDied); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 243 | |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 244 | // SimLockStatus represents the fields in the Cellular.SIMLockStatus |
| 245 | // DBUS property of the shill device. |
| 246 | struct SimLockStatus { |
| 247 | public: |
| 248 | SimLockStatus() : enabled(false), |
| 249 | lock_type(MM_MODEM_LOCK_UNKNOWN), |
| 250 | retries_left(0) {} |
| 251 | |
| 252 | bool enabled; |
| 253 | MMModemLock lock_type; |
| 254 | uint32 retries_left; |
| 255 | }; |
| 256 | |
Prathmesh Prabhu | 9a0534e | 2013-10-10 16:20:34 -0700 | [diff] [blame] | 257 | // SubscriptionState represents the provisioned state of SIM. It is used |
| 258 | // currently by activation logic for LTE to determine if activation process is |
| 259 | // complete. |
| 260 | enum SubscriptionState { |
| 261 | kSubscriptionStateUnknown = 0, |
| 262 | kSubscriptionStateUnprovisioned = 1, |
| 263 | kSubscriptionStateProvisioned = 2, |
| 264 | kSubscriptionStateOutOfData = 3 |
| 265 | }; |
| 266 | |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 267 | // Methods used in starting a modem |
Ben Chan | 151d447 | 2013-09-06 13:29:46 -0700 | [diff] [blame] | 268 | void EnableModem(bool deferralbe, |
| 269 | Error *error, |
| 270 | const ResultCallback& callback); |
| 271 | void EnableModemCompleted(bool deferrable, |
| 272 | const ResultCallback &callback, |
| 273 | const Error &error); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 274 | |
| 275 | // Methods used in stopping a modem |
Thieu Le | 2849214 | 2014-04-08 16:41:13 -0700 | [diff] [blame] | 276 | void Stop_DeleteActiveBearer(const ResultCallback &callback); |
| 277 | void Stop_DeleteActiveBearerCompleted(const ResultCallback &callback, |
| 278 | const Error &error); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 279 | void Stop_Disable(const ResultCallback &callback); |
| 280 | void Stop_DisableCompleted(const ResultCallback &callback, |
| 281 | const Error &error); |
Arman Uguray | ee464d3 | 2013-02-13 17:14:36 -0800 | [diff] [blame] | 282 | void Stop_PowerDown(const ResultCallback &callback); |
| 283 | void Stop_PowerDownCompleted(const ResultCallback &callback, |
| 284 | const Error &error); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 285 | |
Ben Chan | 539ab02 | 2014-02-03 16:34:57 -0800 | [diff] [blame] | 286 | // Updates |active_bearer_| to match the currently active bearer. |
| 287 | void UpdateActiveBearer(); |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 288 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 289 | Stringmap ParseScanResult(const ScanResult &result); |
| 290 | |
| 291 | KeyValueStore SimLockStatusToProperty(Error *error); |
| 292 | |
| 293 | void SetupApnTryList(); |
| 294 | void FillConnectPropertyMap(DBusPropertiesMap *properties); |
| 295 | |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 296 | void HelpRegisterConstDerivedKeyValueStore( |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 297 | const std::string &name, |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 298 | KeyValueStore(CellularCapabilityUniversal::*get)(Error *error)); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 299 | |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 300 | // Returns true if a connect error should be retried. This function |
| 301 | // abstracts modem specific behavior for modems which do a lousy job |
| 302 | // of returning specific errors on connect failures. |
| 303 | bool RetriableConnectError(const Error &error) const; |
| 304 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 305 | // Signal callbacks |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 306 | void OnNetworkModeSignal(uint32 mode); |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 307 | void OnModemStateChangedSignal(int32 old_state, |
| 308 | int32 new_state, |
| 309 | uint32 reason); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 310 | |
| 311 | // Property Change notification handlers |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 312 | void OnModemPropertiesChanged( |
Jason Glasgow | 4c0724a | 2012-04-17 15:47:40 -0400 | [diff] [blame] | 313 | const DBusPropertiesMap &properties, |
| 314 | const std::vector<std::string> &invalidated_properties); |
| 315 | |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 316 | void OnSignalQualityChanged(uint32 quality); |
Ben Chan | 74924d8 | 2013-06-15 17:52:55 -0700 | [diff] [blame] | 317 | |
| 318 | void OnSupportedCapabilitesChanged( |
| 319 | const std::vector<uint32> &supported_capabilities); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 320 | void OnModemCurrentCapabilitiesChanged(uint32 current_capabilities); |
| 321 | void OnMdnChanged(const std::string &mdn); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 322 | void OnModemRevisionChanged(const std::string &revision); |
| 323 | void OnModemStateChanged(Cellular::ModemState state); |
| 324 | void OnAccessTechnologiesChanged(uint32 access_technologies); |
Ben Chan | 74924d8 | 2013-06-15 17:52:55 -0700 | [diff] [blame] | 325 | void OnSupportedModesChanged(const std::vector<ModemModes> &supported_modes); |
| 326 | void OnCurrentModesChanged(const ModemModes ¤t_modes); |
Ben Chan | cbef812 | 2014-01-06 17:31:30 -0800 | [diff] [blame] | 327 | void OnBearersChanged(const RpcIdentifiers &bearers); |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 328 | void OnLockRetriesChanged(const LockRetryData &lock_retries); |
| 329 | void OnLockTypeChanged(MMModemLock unlock_required); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 330 | void OnSimLockStatusChanged(); |
| 331 | |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 332 | // Returns false if the MDN is empty or if the MDN consists of all 0s. |
| 333 | bool IsMdnValid() const; |
| 334 | |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 335 | // 3GPP property change handlers |
| 336 | virtual void OnModem3GPPPropertiesChanged( |
| 337 | const DBusPropertiesMap &properties, |
| 338 | const std::vector<std::string> &invalidated_properties); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 339 | void On3GPPRegistrationChanged(MMModem3gppRegistrationState state, |
| 340 | const std::string &operator_code, |
| 341 | const std::string &operator_name); |
Prathmesh Prabhu | 8f6479f | 2013-05-15 12:56:13 -0700 | [diff] [blame] | 342 | void Handle3GPPRegistrationChange( |
| 343 | MMModem3gppRegistrationState updated_state, |
| 344 | std::string updated_operator_code, |
| 345 | std::string updated_operator_name); |
Prathmesh Prabhu | 9a0534e | 2013-10-10 16:20:34 -0700 | [diff] [blame] | 346 | void On3GPPSubscriptionStateChanged(MMModem3gppSubscriptionState state); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 347 | void OnFacilityLocksChanged(uint32 locks); |
| 348 | |
| 349 | // SIM property change handlers |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 350 | // TODO(armansito): Put these methods in a 3GPP-only subclass. |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 351 | void OnSimPropertiesChanged( |
| 352 | const DBusPropertiesMap &props, |
| 353 | const std::vector<std::string> &invalidated_properties); |
Arman Uguray | d73783f | 2013-01-31 16:11:21 -0800 | [diff] [blame] | 354 | void OnSpnChanged(const std::string &spn); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 355 | void OnSimIdentifierChanged(const std::string &id); |
| 356 | void OnOperatorIdChanged(const std::string &operator_id); |
| 357 | void OnOperatorNameChanged(const std::string &operator_name); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 358 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 359 | // Method callbacks |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 360 | void OnRegisterReply(const ResultCallback &callback, |
| 361 | const Error &error); |
Ben Chan | 5d0d32c | 2013-01-08 02:05:29 -0800 | [diff] [blame] | 362 | void OnResetReply(const ResultCallback &callback, const Error &error); |
Prathmesh Prabhu | 49ffffd | 2014-01-09 18:28:55 -0800 | [diff] [blame] | 363 | void OnScanReply(const ResultStringmapsCallback &callback, |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 364 | const ScanResults &results, |
| 365 | const Error &error); |
Nathan Williams | b54974f | 2012-04-19 11:16:30 -0400 | [diff] [blame] | 366 | void OnConnectReply(const ResultCallback &callback, |
| 367 | const DBus::Path &bearer, |
| 368 | const Error &error); |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 369 | |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 370 | // Timeout callback that is called if the modem takes too long to register to |
| 371 | // a network after online payment is complete. Resets the modem. |
| 372 | void OnActivationWaitForRegisterTimeout(); |
| 373 | |
Arman Uguray | 6552f8c | 2013-02-12 15:33:18 -0800 | [diff] [blame] | 374 | // Returns true, if |sim_path| constitutes a valid SIM path. Currently, a |
| 375 | // path is accepted to be valid, as long as it is not equal to one of "" |
| 376 | // and "/". |
| 377 | bool IsValidSimPath(const std::string &sim_path) const; |
| 378 | |
Ben Chan | d759252 | 2013-02-13 16:02:01 -0800 | [diff] [blame] | 379 | // Returns the normalized version of |mdn| by keeping only digits in |mdn| |
| 380 | // and removing other non-digit characters. |
| 381 | std::string NormalizeMdn(const std::string &mdn) const; |
| 382 | |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 383 | // Post-payment activation handlers. |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 384 | void ResetAfterActivation(); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 385 | void UpdateServiceActivationState(); |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 386 | void OnResetAfterActivationReply(const Error &error); |
| 387 | |
Prathmesh Prabhu | 8f6479f | 2013-05-15 12:56:13 -0700 | [diff] [blame] | 388 | static bool IsRegisteredState(MMModem3gppRegistrationState state); |
| 389 | |
Thieu Le | 43ce4d4 | 2013-10-04 16:08:55 -0700 | [diff] [blame] | 390 | // Returns the out-of-credits detection algorithm to be used on this modem. |
| 391 | OutOfCreditsDetector::OOCType GetOutOfCreditsDetectionType() const; |
| 392 | |
Thieu Le | 2849214 | 2014-04-08 16:41:13 -0700 | [diff] [blame] | 393 | // For unit tests. |
| 394 | void set_active_bearer(CellularBearer *bearer) { |
| 395 | active_bearer_.reset(bearer); // Takes ownership |
| 396 | } |
| 397 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 398 | scoped_ptr<mm1::ModemModem3gppProxyInterface> modem_3gpp_proxy_; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 399 | scoped_ptr<mm1::ModemProxyInterface> modem_proxy_; |
| 400 | scoped_ptr<mm1::ModemSimpleProxyInterface> modem_simple_proxy_; |
| 401 | scoped_ptr<mm1::SimProxyInterface> sim_proxy_; |
Prathmesh Prabhu | afe6366 | 2014-05-20 11:03:58 -0700 | [diff] [blame^] | 402 | // Used to enrich information about the network operator in |ParseScanResult|. |
| 403 | // TODO(pprabhu) Instead instantiate a local |MobileOperatorInfo| instance |
| 404 | // once the context has been separated out. (crbug.com/363874) |
| 405 | scoped_ptr<MobileOperatorInfo> mobile_operator_info_; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 406 | |
| 407 | base::WeakPtrFactory<CellularCapabilityUniversal> weak_ptr_factory_; |
| 408 | |
| 409 | MMModem3gppRegistrationState registration_state_; |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 410 | |
| 411 | // Bits based on MMModemCapabilities |
Ben Chan | 74924d8 | 2013-06-15 17:52:55 -0700 | [diff] [blame] | 412 | std::vector<uint32> supported_capabilities_; // Technologies supported |
| 413 | uint32 current_capabilities_; // Technologies supported without a reload |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 414 | uint32 access_technologies_; // Bits based on MMModemAccessTechnology |
Ben Chan | 74924d8 | 2013-06-15 17:52:55 -0700 | [diff] [blame] | 415 | std::vector<ModemModes> supported_modes_; |
| 416 | ModemModes current_modes_; |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 417 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 418 | Cellular::Operator serving_operator_; |
| 419 | std::string spn_; |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 420 | std::string operator_id_; |
Prathmesh Prabhu | 99ec94d | 2013-11-22 10:43:37 -0800 | [diff] [blame] | 421 | mobile_provider *home_provider_info_; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 422 | std::string desired_network_; |
| 423 | |
| 424 | // Properties. |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 425 | std::deque<Stringmap> apn_try_list_; |
Ben Chan | 5d0d32c | 2013-01-08 02:05:29 -0800 | [diff] [blame] | 426 | bool resetting_; |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 427 | SimLockStatus sim_lock_status_; |
Prathmesh Prabhu | 9a0534e | 2013-10-10 16:20:34 -0700 | [diff] [blame] | 428 | SubscriptionState subscription_state_; |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 429 | std::string sim_path_; |
Ben Chan | 539ab02 | 2014-02-03 16:34:57 -0800 | [diff] [blame] | 430 | scoped_ptr<CellularBearer> active_bearer_; |
Ben Chan | cbef812 | 2014-01-06 17:31:30 -0800 | [diff] [blame] | 431 | RpcIdentifiers bearer_paths_; |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 432 | bool reset_done_; |
| 433 | |
Gary Morain | e285a84 | 2012-08-15 08:23:57 -0700 | [diff] [blame] | 434 | // If the modem is not in a state to be enabled when StartModem is called, |
| 435 | // enabling is deferred using this callback. |
| 436 | base::Closure deferred_enable_modem_callback_; |
| 437 | |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 438 | base::CancelableClosure activation_wait_for_registration_callback_; |
| 439 | int64 activation_registration_timeout_milliseconds_; |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 440 | |
Prathmesh Prabhu | 8f6479f | 2013-05-15 12:56:13 -0700 | [diff] [blame] | 441 | // Sometimes flaky cellular network causes the 3GPP registration state to |
| 442 | // rapidly change from registered --> searching and back. Delay such updates |
| 443 | // a little to smooth over temporary registration loss. |
| 444 | base::CancelableClosure registration_dropped_update_callback_; |
| 445 | int64 registration_dropped_update_timeout_milliseconds_; |
| 446 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 447 | DISALLOW_COPY_AND_ASSIGN(CellularCapabilityUniversal); |
| 448 | }; |
| 449 | |
| 450 | } // namespace shill |
| 451 | |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 452 | #endif // SHILL_CELLULAR_CAPABILITY_UNIVERSAL_H_ |