blob: 0dd10ce42745010d1765f9b7dacadac0a5a822dd [file] [log] [blame]
Arman Uguray72fab6a2013-01-10 19:32:42 -08001// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
Jason Glasgow82f9ab32012-04-04 14:27:19 -04002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Jason Glasgow14521872012-05-07 19:12:15 -04005#ifndef SHILL_CELLULAR_CAPABILITY_UNIVERSAL_H_
6#define SHILL_CELLULAR_CAPABILITY_UNIVERSAL_H_
Jason Glasgow82f9ab32012-04-04 14:27:19 -04007
8#include <deque>
Jason Glasgowaf583282012-04-18 15:18:22 -04009#include <map>
Jason Glasgow82f9ab32012-04-04 14:27:19 -040010#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 Chan5c853ef2012-10-05 00:05:37 -070016#include <ModemManager/ModemManager.h>
Jason Glasgow82f9ab32012-04-04 14:27:19 -040017
18#include "shill/accessor_interface.h"
19#include "shill/cellular.h"
20#include "shill/cellular_capability.h"
Ben Chan07193fd2013-07-12 22:10:55 -070021#include "shill/cellular_operator_info.h"
Arman Uguray6e5639f2012-11-15 20:30:19 -080022#include "shill/mm1_bearer_proxy_interface.h"
Jason Glasgow82f9ab32012-04-04 14:27:19 -040023#include "shill/mm1_modem_modem3gpp_proxy_interface.h"
Jason Glasgow82f9ab32012-04-04 14:27:19 -040024#include "shill/mm1_modem_proxy_interface.h"
25#include "shill/mm1_modem_simple_proxy_interface.h"
26#include "shill/mm1_sim_proxy_interface.h"
27
Jason Glasgow82f9ab32012-04-04 14:27:19 -040028struct mobile_provider;
29
30namespace shill {
31
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070032class ModemInfo;
Arman Ugurayc7b15602013-02-16 00:56:18 -080033
Jason Glasgow82f9ab32012-04-04 14:27:19 -040034// 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.
37class CellularCapabilityUniversal : public CellularCapability {
38 public:
39 typedef std::vector<DBusPropertiesMap> ScanResults;
40 typedef DBusPropertiesMap ScanResult;
Ben Chan74924d82013-06-15 17:52:55 -070041 typedef std::map<uint32_t, uint32_t> LockRetryData;
Jason Glasgow82f9ab32012-04-04 14:27:19 -040042
Jason Glasgow14521872012-05-07 19:12:15 -040043 // Constants used in connect method call. Make available to test matchers.
44 // TODO(jglasgow): Generate from modem manager into
45 // ModemManager-names.h.
Paul Stewartee6b3d72013-07-12 16:07:51 -070046 // See http://crbug.com/212909.
Jason Glasgow14521872012-05-07 19:12:15 -040047 static const char kConnectPin[];
48 static const char kConnectOperatorId[];
Jason Glasgow14521872012-05-07 19:12:15 -040049 static const char kConnectApn[];
50 static const char kConnectIPType[];
51 static const char kConnectUser[];
52 static const char kConnectPassword[];
53 static const char kConnectNumber[];
54 static const char kConnectAllowRoaming[];
55 static const char kConnectRMProtocol[];
56
Thieu Lece4483e2013-01-23 15:12:03 -080057 CellularCapabilityUniversal(Cellular *cellular,
58 ProxyFactory *proxy_factory,
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070059 ModemInfo *modem_info);
Jason Glasgow82f9ab32012-04-04 14:27:19 -040060
61 // Inherited from CellularCapability.
Gary Moraine285a842012-08-15 08:23:57 -070062 // Checks the modem state. If the state is kModemStateDisabled, then the
63 // modem is enabled. Otherwise, the enable command is buffered until the
64 // modem becomes disabled. ModemManager rejects the enable command if the
65 // modem is not disabled, for exmaple, if it is initializing insted.
Jason Glasgow82f9ab32012-04-04 14:27:19 -040066 virtual void StartModem(Error *error, const ResultCallback &callback);
67 virtual void StopModem(Error *error, const ResultCallback &callback);
68 virtual void Connect(const DBusPropertiesMap &properties, Error *error,
69 const ResultCallback &callback);
70 virtual void Disconnect(Error *error, const ResultCallback &callback);
Christopher Wiley8a468902012-11-30 11:52:38 -080071 virtual void DisconnectCleanup();
Jason Glasgow82f9ab32012-04-04 14:27:19 -040072 virtual void Activate(const std::string &carrier,
73 Error *error, const ResultCallback &callback);
Arman Ugurayc7b15602013-02-16 00:56:18 -080074 virtual void CompleteActivation(Error *error);
Jason Glasgow82f9ab32012-04-04 14:27:19 -040075
76 virtual void OnServiceCreated();
Jason Glasgow82f9ab32012-04-04 14:27:19 -040077 virtual void SetupConnectProperties(DBusPropertiesMap *properties);
Jason Glasgowef965562012-04-10 16:12:35 -040078 virtual void GetProperties();
Arman Uguray72fab6a2013-01-10 19:32:42 -080079 virtual bool IsRegistered();
Ben Chan15786032012-11-04 21:28:02 -080080 virtual bool IsServiceActivationRequired() const;
Jason Glasgow82f9ab32012-04-04 14:27:19 -040081 virtual void Register(const ResultCallback &callback);
82
83 virtual void RegisterOnNetwork(const std::string &network_id,
84 Error *error,
85 const ResultCallback &callback);
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040086 virtual void SetUnregistered(bool searching);
Jason Glasgow82f9ab32012-04-04 14:27:19 -040087 virtual std::string CreateFriendlyServiceName();
88 virtual void RequirePIN(const std::string &pin, bool require,
89 Error *error, const ResultCallback &callback);
90 virtual void EnterPIN(const std::string &pin,
91 Error *error, const ResultCallback &callback);
92 virtual void UnblockPIN(const std::string &unblock_code,
93 const std::string &pin,
94 Error *error, const ResultCallback &callback);
95 virtual void ChangePIN(const std::string &old_pin,
96 const std::string &new_pin,
97 Error *error, const ResultCallback &callback);
Ben Chan5d0d32c2013-01-08 02:05:29 -080098 virtual void Reset(Error *error, const ResultCallback &callback);
Jason Glasgow82f9ab32012-04-04 14:27:19 -040099
100 virtual void Scan(Error *error, const ResultCallback &callback);
101 virtual std::string GetNetworkTechnologyString() const;
102 virtual std::string GetRoamingStateString() const;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400103 virtual void GetSignalQuality();
Jason Glasgow9f09aef2012-05-08 16:26:55 -0400104 virtual std::string GetTypeString() const;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400105 virtual void OnDBusPropertiesChanged(
106 const std::string &interface,
107 const DBusPropertiesMap &changed_properties,
108 const std::vector<std::string> &invalidated_properties);
Jason Glasgowaf583282012-04-18 15:18:22 -0400109 virtual bool AllowRoaming();
Arman Ugurayf84a4242013-04-09 20:01:07 -0700110 virtual bool ShouldDetectOutOfCredit() const;
Jason Glasgow14521872012-05-07 19:12:15 -0400111
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400112 protected:
113 virtual void InitProxies();
114 virtual void ReleaseProxies();
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400115
Arman Uguray72fab6a2013-01-10 19:32:42 -0800116 // Updates the |sim_path_| variable and creates a new proxy to the
117 // DBUS ModemManager1.Sim interface.
118 // TODO(armansito): Put this method in a 3GPP-only subclass.
119 virtual void OnSimPathChanged(const std::string &sim_path);
120
121 // Updates the online payment portal information, if any, for the cellular
122 // provider.
123 virtual void UpdateOLP();
124
Arman Uguray0a3e2792013-01-17 16:31:50 -0800125 // Post-payment activation handlers.
126 virtual void UpdatePendingActivationState();
127
Ben Chan07193fd2013-07-12 22:10:55 -0700128 // Returns the operator-specific form of |mdn_|, which is passed to the online
129 // payment portal of a cellular operator.
130 std::string GetMdnForOLP(
131 const CellularOperatorInfo::CellularOperator &cellular_operator) const;
132
Arman Uguray0a3e2792013-01-17 16:31:50 -0800133 const std::string &mdn() const { return mdn_; }
134 void set_mdn(const std::string &mdn) { mdn_ = mdn; }
135
136 const std::string &min() const { return min_; }
137 void set_min(const std::string &min) { min_ = min; }
Arman Uguray72fab6a2013-01-10 19:32:42 -0800138
139 const std::string &meid() const { return meid_; }
140 void set_meid(const std::string &meid) { meid_ = meid; }
141
142 const std::string &esn() const { return esn_; }
143 void set_esn(const std::string &esn) { esn_ = esn; }
144
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400145 private:
Ben Chan74924d82013-06-15 17:52:55 -0700146 struct ModemModes {
147 ModemModes()
148 : allowed_modes(MM_MODEM_MODE_NONE),
149 preferred_mode(MM_MODEM_MODE_NONE) {}
150
151 ModemModes(uint32 allowed, MMModemMode preferred)
152 : allowed_modes(allowed),
153 preferred_mode(preferred) {}
154
155 uint32 allowed_modes; // Bits based on MMModemMode.
156 MMModemMode preferred_mode; // A single MMModemMode bit.
157 };
158
Jason Glasgowcd0349c2012-05-03 23:32:15 -0400159 // Constants used in scan results. Make available to unit tests.
160 // TODO(jglasgow): Generate from modem manager into ModemManager-names.h.
Paul Stewartee6b3d72013-07-12 16:07:51 -0700161 // See http://crbug.com/212909.
Jason Glasgowcd0349c2012-05-03 23:32:15 -0400162 static const char kStatusProperty[];
163 static const char kOperatorLongProperty[];
164 static const char kOperatorShortProperty[];
165 static const char kOperatorCodeProperty[];
166 static const char kOperatorAccessTechnologyProperty[];
167
mukesh agrawal9da07772013-05-15 14:15:17 -0700168 // As above, consider having this in ModemManager-names.h.
169 static const char kIpConfigPropertyMethod[];
170
Jason Glasgow14521872012-05-07 19:12:15 -0400171 // Modem Model ID strings. From modem firmware via modemmanager.
172 static const char kE362ModelId[];
173
Arman Uguray2717a102013-01-29 23:36:06 -0800174 // Generic service name prefix, shown when the correct carrier name is
175 // unknown.
176 static const char kGenericServiceNamePrefix[];
177
Arman Uguraya14941d2013-04-12 16:58:26 -0700178 static const int64 kActivationRegistrationTimeoutMilliseconds;
179 static const int64 kDefaultScanningOrSearchingTimeoutMilliseconds;
Arman Ugurayf6366ac2013-06-12 16:02:28 -0700180 static const int64 kEnterPinTimeoutMilliseconds;
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700181 static const int64 kRegistrationDroppedUpdateTimeoutMilliseconds;
Thieu Le2cac2942013-03-05 18:41:08 -0800182 static const int kSetPowerStateTimeoutMilliseconds;
Arman Ugurayee464d32013-02-13 17:14:36 -0800183
Arman Uguray1361c032013-02-11 17:53:39 -0800184
Arman Uguray6552f8c2013-02-12 15:33:18 -0800185 // Root path. The SIM path is reported by ModemManager to be the root path
186 // when no SIM is present.
187 static const char kRootPath[];
188
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400189 friend class CellularTest;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400190 friend class CellularCapabilityTest;
Thieu Le3d275392012-07-20 15:32:58 -0700191 friend class CellularCapabilityUniversalTest;
Arman Uguray72fab6a2013-01-10 19:32:42 -0800192 friend class CellularCapabilityUniversalCDMATest;
Arman Uguray0a3e2792013-01-17 16:31:50 -0800193 FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, PropertiesChanged);
194 FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, UpdateOLP);
Arman Uguray1361c032013-02-11 17:53:39 -0800195 FRIEND_TEST(CellularCapabilityUniversalMainTest, AllowRoaming);
Arman Uguraya14941d2013-04-12 16:58:26 -0700196 FRIEND_TEST(CellularCapabilityUniversalMainTest,
197 ActivationWaitForRegisterTimeout);
Arman Uguray1361c032013-02-11 17:53:39 -0800198 FRIEND_TEST(CellularCapabilityUniversalMainTest, Connect);
199 FRIEND_TEST(CellularCapabilityUniversalMainTest, ConnectApns);
200 FRIEND_TEST(CellularCapabilityUniversalMainTest, CreateFriendlyServiceName);
201 FRIEND_TEST(CellularCapabilityUniversalMainTest, DisconnectNoProxy);
Arman Uguray7af0fac2013-03-18 17:35:35 -0700202 FRIEND_TEST(CellularCapabilityUniversalMainTest,
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700203 DisconnectWithDeferredCallback);
204 FRIEND_TEST(CellularCapabilityUniversalMainTest,
Arman Uguray7af0fac2013-03-18 17:35:35 -0700205 GetNetworkTechnologyStringOnE362);
Ben Chan07193fd2013-07-12 22:10:55 -0700206 FRIEND_TEST(CellularCapabilityUniversalMainTest, GetMdnForOLP);
Arman Uguray1361c032013-02-11 17:53:39 -0800207 FRIEND_TEST(CellularCapabilityUniversalMainTest, GetTypeString);
Arman Ugurayc7b15602013-02-16 00:56:18 -0800208 FRIEND_TEST(CellularCapabilityUniversalMainTest, IsMdnValid);
Arman Uguray1361c032013-02-11 17:53:39 -0800209 FRIEND_TEST(CellularCapabilityUniversalMainTest, IsServiceActivationRequired);
Arman Uguray6552f8c2013-02-12 15:33:18 -0800210 FRIEND_TEST(CellularCapabilityUniversalMainTest, IsValidSimPath);
Ben Chand7592522013-02-13 16:02:01 -0800211 FRIEND_TEST(CellularCapabilityUniversalMainTest, NormalizeMdn);
Arman Uguray1361c032013-02-11 17:53:39 -0800212 FRIEND_TEST(CellularCapabilityUniversalMainTest, OnListBearersReply);
Arman Ugurayc7e63af2013-06-13 17:07:32 -0700213 FRIEND_TEST(CellularCapabilityUniversalMainTest, OnLockRetriesChanged);
214 FRIEND_TEST(CellularCapabilityUniversalMainTest, OnLockTypeChanged);
Arman Uguray1361c032013-02-11 17:53:39 -0800215 FRIEND_TEST(CellularCapabilityUniversalMainTest,
Ben Chanfcca27b2013-01-22 15:03:44 -0800216 OnModemCurrentCapabilitiesChanged);
Arman Ugurayc7e63af2013-06-13 17:07:32 -0700217 FRIEND_TEST(CellularCapabilityUniversalMainTest, OnSimLockPropertiesChanged);
Arman Uguray1361c032013-02-11 17:53:39 -0800218 FRIEND_TEST(CellularCapabilityUniversalMainTest, PropertiesChanged);
219 FRIEND_TEST(CellularCapabilityUniversalMainTest, Reset);
220 FRIEND_TEST(CellularCapabilityUniversalMainTest, Scan);
221 FRIEND_TEST(CellularCapabilityUniversalMainTest, ScanFailure);
222 FRIEND_TEST(CellularCapabilityUniversalMainTest, SetHomeProvider);
Arman Ugurayd42d8ec2013-04-08 19:28:21 -0700223 FRIEND_TEST(CellularCapabilityUniversalMainTest,
Arman Ugurayf84a4242013-04-09 20:01:07 -0700224 ShouldDetectOutOfCredit);
Arman Uguray1361c032013-02-11 17:53:39 -0800225 FRIEND_TEST(CellularCapabilityUniversalMainTest, SimLockStatusChanged);
Arman Ugurayc7e63af2013-06-13 17:07:32 -0700226 FRIEND_TEST(CellularCapabilityUniversalMainTest, SimLockStatusToProperty);
Arman Uguray1361c032013-02-11 17:53:39 -0800227 FRIEND_TEST(CellularCapabilityUniversalMainTest, SimPathChanged);
228 FRIEND_TEST(CellularCapabilityUniversalMainTest, SimPropertiesChanged);
229 FRIEND_TEST(CellularCapabilityUniversalMainTest, StartModem);
230 FRIEND_TEST(CellularCapabilityUniversalMainTest, StopModem);
231 FRIEND_TEST(CellularCapabilityUniversalMainTest, StopModemConnected);
Arman Uguray0a3e2792013-01-17 16:31:50 -0800232 FRIEND_TEST(CellularCapabilityUniversalMainTest,
233 UpdatePendingActivationState);
Arman Ugurayefea6e02013-02-21 13:28:04 -0800234 FRIEND_TEST(CellularCapabilityUniversalMainTest,
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700235 UpdateRegistrationState);
236 FRIEND_TEST(CellularCapabilityUniversalMainTest,
237 UpdateRegistrationStateModemNotConnected);
238 FRIEND_TEST(CellularCapabilityUniversalMainTest,
Arman Ugurayefea6e02013-02-21 13:28:04 -0800239 UpdateServiceActivationState);
Arman Uguray1361c032013-02-11 17:53:39 -0800240 FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateServiceName);
241 FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateStorageIdentifier);
242 FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateOLP);
243 FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateOperatorInfo);
244 FRIEND_TEST(CellularCapabilityUniversalMainTest,
245 UpdateOperatorInfoViaOperatorId);
246 FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateScanningProperty);
Arman Uguraya14941d2013-04-12 16:58:26 -0700247 FRIEND_TEST(CellularCapabilityUniversalTimerTest, CompleteActivation);
Arman Uguray1361c032013-02-11 17:53:39 -0800248 FRIEND_TEST(CellularCapabilityUniversalTimerTest,
249 UpdateScanningPropertyTimeout);
Arman Ugurayd42d8ec2013-04-08 19:28:21 -0700250 FRIEND_TEST(CellularTest, EnableTrafficMonitor);
Ben Chan09fa2a02012-11-07 22:09:09 -0800251 FRIEND_TEST(CellularTest,
252 HandleNewRegistrationStateForServiceRequiringActivation);
Thieu Le5218cf22012-11-26 11:52:57 -0800253 FRIEND_TEST(CellularTest, ModemStateChangeLostRegistration);
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400254
Arman Ugurayc7e63af2013-06-13 17:07:32 -0700255 // SimLockStatus represents the fields in the Cellular.SIMLockStatus
256 // DBUS property of the shill device.
257 struct SimLockStatus {
258 public:
259 SimLockStatus() : enabled(false),
260 lock_type(MM_MODEM_LOCK_UNKNOWN),
261 retries_left(0) {}
262
263 bool enabled;
264 MMModemLock lock_type;
265 uint32 retries_left;
266 };
267
Jason Glasgowef965562012-04-10 16:12:35 -0400268 // Methods used in starting a modem
Gary Moraine285a842012-08-15 08:23:57 -0700269 void EnableModem(Error *error, const ResultCallback &callback);
Thieu Leb9c05e02013-03-04 14:09:32 -0800270 void Start_ModemAlreadyEnabled(const ResultCallback &callback);
Jason Glasgowef965562012-04-10 16:12:35 -0400271 void Start_EnableModemCompleted(const ResultCallback &callback,
272 const Error &error);
Jason Glasgowef965562012-04-10 16:12:35 -0400273
274 // Methods used in stopping a modem
275 void Stop_DisconnectCompleted(const ResultCallback &callback,
276 const Error &error);
277 void Stop_Disable(const ResultCallback &callback);
278 void Stop_DisableCompleted(const ResultCallback &callback,
279 const Error &error);
Arman Ugurayee464d32013-02-13 17:14:36 -0800280 void Stop_PowerDown(const ResultCallback &callback);
281 void Stop_PowerDownCompleted(const ResultCallback &callback,
282 const Error &error);
Jason Glasgowef965562012-04-10 16:12:35 -0400283
Arman Uguray2717a102013-01-29 23:36:06 -0800284 // Updates the name property that is exposed by the service to Chrome.
285 void UpdateServiceName();
286
Ben Chan8a2c01e2013-01-23 10:09:14 -0800287 void UpdateScanningProperty();
288
Arman Ugurayd73783f2013-01-31 16:11:21 -0800289 // Methods used in acquiring information related to the carrier;
290
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400291 // Updates the Universal operator name and country based on a newly
292 // obtained network id.
293 void UpdateOperatorInfo();
294
Arman Ugurayd73783f2013-01-31 16:11:21 -0800295 // Sets the upper level information about the home cellular provider from the
296 // modem's IMSI and SPN.
297 void SetHomeProvider();
298
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400299 // Updates the serving operator on the active service.
300 void UpdateServingOperator();
301
Arman Ugurayd73783f2013-01-31 16:11:21 -0800302 // Initializes the |apn_list_| property based on the current |home_provider_|.
303 void InitAPNList();
304
Arman Uguray6e5639f2012-11-15 20:30:19 -0800305 // Updates |bearer_path_| to match the currently active bearer.
306 void UpdateBearerPath();
307
Arman Ugurayc9533572013-01-22 17:34:20 -0800308 // Updates the storage identifier used for the current cellular service.
309 void UpdateStorageIdentifier();
310
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400311
312 Stringmap ParseScanResult(const ScanResult &result);
313
314 KeyValueStore SimLockStatusToProperty(Error *error);
315
316 void SetupApnTryList();
317 void FillConnectPropertyMap(DBusPropertiesMap *properties);
318
mukesh agrawalbebf1b82013-04-23 15:06:33 -0700319 void HelpRegisterConstDerivedKeyValueStore(
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400320 const std::string &name,
mukesh agrawalbebf1b82013-04-23 15:06:33 -0700321 KeyValueStore(CellularCapabilityUniversal::*get)(Error *error));
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400322
Jason Glasgow14521872012-05-07 19:12:15 -0400323 // Returns true if a connect error should be retried. This function
324 // abstracts modem specific behavior for modems which do a lousy job
325 // of returning specific errors on connect failures.
326 bool RetriableConnectError(const Error &error) const;
327
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400328 // Signal callbacks
Nathan Williams3022be52012-04-19 17:40:49 -0400329 void OnNetworkModeSignal(uint32 mode);
Eric Shienbrood7fce52c2012-04-13 19:11:02 -0400330 void OnModemStateChangedSignal(int32 old_state,
331 int32 new_state,
332 uint32 reason);
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400333
334 // Property Change notification handlers
Nathan Williams3022be52012-04-19 17:40:49 -0400335 void OnModemPropertiesChanged(
Jason Glasgow4c0724a2012-04-17 15:47:40 -0400336 const DBusPropertiesMap &properties,
337 const std::vector<std::string> &invalidated_properties);
338
Nathan Williams3022be52012-04-19 17:40:49 -0400339 void OnSignalQualityChanged(uint32 quality);
Ben Chan74924d82013-06-15 17:52:55 -0700340
341 void OnSupportedCapabilitesChanged(
342 const std::vector<uint32> &supported_capabilities);
Jason Glasgowaf583282012-04-18 15:18:22 -0400343 void OnModemCurrentCapabilitiesChanged(uint32 current_capabilities);
344 void OnMdnChanged(const std::string &mdn);
345 void OnModemManufacturerChanged(const std::string &manufacturer);
346 void OnModemModelChanged(const std::string &model);
347 void OnModemRevisionChanged(const std::string &revision);
348 void OnModemStateChanged(Cellular::ModemState state);
349 void OnAccessTechnologiesChanged(uint32 access_technologies);
Ben Chan74924d82013-06-15 17:52:55 -0700350 void OnSupportedModesChanged(const std::vector<ModemModes> &supported_modes);
351 void OnCurrentModesChanged(const ModemModes &current_modes);
Arman Ugurayc7e63af2013-06-13 17:07:32 -0700352 void OnLockRetriesChanged(const LockRetryData &lock_retries);
353 void OnLockTypeChanged(MMModemLock unlock_required);
Jason Glasgowaf583282012-04-18 15:18:22 -0400354 void OnSimLockStatusChanged();
355
Arman Ugurayc7b15602013-02-16 00:56:18 -0800356 // Returns false if the MDN is empty or if the MDN consists of all 0s.
357 bool IsMdnValid() const;
358
Jason Glasgowaf583282012-04-18 15:18:22 -0400359 // 3GPP property change handlers
360 virtual void OnModem3GPPPropertiesChanged(
361 const DBusPropertiesMap &properties,
362 const std::vector<std::string> &invalidated_properties);
363 void OnImeiChanged(const std::string &imei);
364 void On3GPPRegistrationChanged(MMModem3gppRegistrationState state,
365 const std::string &operator_code,
366 const std::string &operator_name);
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700367 void Handle3GPPRegistrationChange(
368 MMModem3gppRegistrationState updated_state,
369 std::string updated_operator_code,
370 std::string updated_operator_name);
Jason Glasgowaf583282012-04-18 15:18:22 -0400371 void OnFacilityLocksChanged(uint32 locks);
372
373 // SIM property change handlers
Arman Uguray72fab6a2013-01-10 19:32:42 -0800374 // TODO(armansito): Put these methods in a 3GPP-only subclass.
Jason Glasgowaf583282012-04-18 15:18:22 -0400375 void OnSimPropertiesChanged(
376 const DBusPropertiesMap &props,
377 const std::vector<std::string> &invalidated_properties);
378 void OnImsiChanged(const std::string &imsi);
Arman Ugurayd73783f2013-01-31 16:11:21 -0800379 void OnSpnChanged(const std::string &spn);
Jason Glasgowaf583282012-04-18 15:18:22 -0400380 void OnSimIdentifierChanged(const std::string &id);
381 void OnOperatorIdChanged(const std::string &operator_id);
382 void OnOperatorNameChanged(const std::string &operator_name);
Jason Glasgowef965562012-04-10 16:12:35 -0400383
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400384 // Method callbacks
Nathan Williams3022be52012-04-19 17:40:49 -0400385 void OnRegisterReply(const ResultCallback &callback,
386 const Error &error);
Ben Chan5d0d32c2013-01-08 02:05:29 -0800387 void OnResetReply(const ResultCallback &callback, const Error &error);
Nathan Williams3022be52012-04-19 17:40:49 -0400388 void OnScanReply(const ResultCallback &callback,
389 const ScanResults &results,
390 const Error &error);
Nathan Williamsb54974f2012-04-19 11:16:30 -0400391 void OnConnectReply(const ResultCallback &callback,
392 const DBus::Path &bearer,
393 const Error &error);
Arman Uguray6e5639f2012-11-15 20:30:19 -0800394 void OnListBearersReply(const std::vector<DBus::Path> &paths,
395 const Error &error);
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400396
Arman Uguray1361c032013-02-11 17:53:39 -0800397 // Timeout callback for the network scan initiated when Cellular connectivity
398 // gets enabled.
399 void OnScanningOrSearchingTimeout();
400
Arman Uguraya14941d2013-04-12 16:58:26 -0700401 // Timeout callback that is called if the modem takes too long to register to
402 // a network after online payment is complete. Resets the modem.
403 void OnActivationWaitForRegisterTimeout();
404
Arman Uguray6552f8c2013-02-12 15:33:18 -0800405 // Returns true, if |sim_path| constitutes a valid SIM path. Currently, a
406 // path is accepted to be valid, as long as it is not equal to one of ""
407 // and "/".
408 bool IsValidSimPath(const std::string &sim_path) const;
409
Ben Chand7592522013-02-13 16:02:01 -0800410 // Returns the normalized version of |mdn| by keeping only digits in |mdn|
411 // and removing other non-digit characters.
412 std::string NormalizeMdn(const std::string &mdn) const;
413
Arman Uguray2717a102013-01-29 23:36:06 -0800414 static std::string GenerateNewGenericServiceName();
415
Arman Ugurayc7b15602013-02-16 00:56:18 -0800416 // Post-payment activation handlers.
Arman Ugurayc7b15602013-02-16 00:56:18 -0800417 void ResetAfterActivation();
Arman Ugurayefea6e02013-02-21 13:28:04 -0800418 void UpdateServiceActivationState();
Arman Ugurayc7b15602013-02-16 00:56:18 -0800419 void OnResetAfterActivationReply(const Error &error);
420
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700421 static bool IsRegisteredState(MMModem3gppRegistrationState state);
422
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400423 scoped_ptr<mm1::ModemModem3gppProxyInterface> modem_3gpp_proxy_;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400424 scoped_ptr<mm1::ModemProxyInterface> modem_proxy_;
425 scoped_ptr<mm1::ModemSimpleProxyInterface> modem_simple_proxy_;
426 scoped_ptr<mm1::SimProxyInterface> sim_proxy_;
427
428 base::WeakPtrFactory<CellularCapabilityUniversal> weak_ptr_factory_;
429
430 MMModem3gppRegistrationState registration_state_;
Jason Glasgowaf583282012-04-18 15:18:22 -0400431
432 // Bits based on MMModemCapabilities
Ben Chan74924d82013-06-15 17:52:55 -0700433 std::vector<uint32> supported_capabilities_; // Technologies supported
434 uint32 current_capabilities_; // Technologies supported without a reload
Jason Glasgow14521872012-05-07 19:12:15 -0400435 uint32 access_technologies_; // Bits based on MMModemAccessTechnology
Ben Chan74924d82013-06-15 17:52:55 -0700436 std::vector<ModemModes> supported_modes_;
437 ModemModes current_modes_;
Jason Glasgowaf583282012-04-18 15:18:22 -0400438
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400439 Cellular::Operator serving_operator_;
440 std::string spn_;
Jason Glasgowaf583282012-04-18 15:18:22 -0400441 std::string sim_identifier_;
442 std::string operator_id_;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400443 mobile_provider *home_provider_;
Darin Petkovf508c822012-09-21 13:43:17 +0200444 bool provider_requires_roaming_;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400445 std::string desired_network_;
446
447 // Properties.
448 std::string carrier_;
449 std::string esn_;
450 std::string firmware_revision_;
451 std::string hardware_revision_;
452 std::string imei_;
453 std::string imsi_;
454 std::string manufacturer_;
455 std::string mdn_;
456 std::string meid_;
457 std::string min_;
458 std::string model_id_;
459 std::string selected_network_;
460 Stringmaps found_networks_;
461 std::deque<Stringmap> apn_try_list_;
Ben Chan5d0d32c2013-01-08 02:05:29 -0800462 bool resetting_;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400463 bool scanning_supported_;
464 bool scanning_;
Ben Chan8a2c01e2013-01-23 10:09:14 -0800465 bool scanning_or_searching_;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400466 uint16 scan_interval_;
467 SimLockStatus sim_lock_status_;
468 Stringmaps apn_list_;
Jason Glasgowef965562012-04-10 16:12:35 -0400469 std::string sim_path_;
Ben Chanbd3aee82012-10-16 23:52:04 -0700470 bool sim_present_;
Nathan Williamsb54974f2012-04-19 11:16:30 -0400471 DBus::Path bearer_path_;
Arman Ugurayc7b15602013-02-16 00:56:18 -0800472 bool reset_done_;
473
Gary Moraine285a842012-08-15 08:23:57 -0700474 // If the modem is not in a state to be enabled when StartModem is called,
475 // enabling is deferred using this callback.
476 base::Closure deferred_enable_modem_callback_;
477
Arman Uguray1361c032013-02-11 17:53:39 -0800478 // Sometimes modems may be stuck in the SEARCHING state during the lack of
479 // presence of a network. During this indefinite duration of time, keeping
480 // the Device.Scanning property as |true| causes a bad user experience.
481 // This callback sets it to |false| after a timeout period has passed.
482 base::CancelableClosure scanning_or_searching_timeout_callback_;
Arman Uguraya14941d2013-04-12 16:58:26 -0700483 int64 scanning_or_searching_timeout_milliseconds_;
484
485 base::CancelableClosure activation_wait_for_registration_callback_;
486 int64 activation_registration_timeout_milliseconds_;
Arman Uguray1361c032013-02-11 17:53:39 -0800487
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700488 // Sometimes flaky cellular network causes the 3GPP registration state to
489 // rapidly change from registered --> searching and back. Delay such updates
490 // a little to smooth over temporary registration loss.
491 base::CancelableClosure registration_dropped_update_callback_;
492 int64 registration_dropped_update_timeout_milliseconds_;
493
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400494 static unsigned int friendly_service_name_id_;
495
496 DISALLOW_COPY_AND_ASSIGN(CellularCapabilityUniversal);
497};
498
499} // namespace shill
500
Jason Glasgow14521872012-05-07 19:12:15 -0400501#endif // SHILL_CELLULAR_CAPABILITY_UNIVERSAL_H_