blob: 2717b96c074d410712006208fda4ef1715670780 [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"
Arman Uguray6e5639f2012-11-15 20:30:19 -080021#include "shill/mm1_bearer_proxy_interface.h"
Jason Glasgow82f9ab32012-04-04 14:27:19 -040022#include "shill/mm1_modem_modem3gpp_proxy_interface.h"
Jason Glasgow82f9ab32012-04-04 14:27:19 -040023#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
28struct 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;
Jason Glasgowaf583282012-04-18 15:18:22 -040041 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.
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 Lece4483e2013-01-23 15:12:03 -080060 CellularCapabilityUniversal(Cellular *cellular,
61 ProxyFactory *proxy_factory,
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070062 ModemInfo *modem_info);
Jason Glasgow82f9ab32012-04-04 14:27:19 -040063
64 // Inherited from CellularCapability.
Gary Moraine285a842012-08-15 08:23:57 -070065 // 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 Glasgow82f9ab32012-04-04 14:27:19 -040069 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 Wiley8a468902012-11-30 11:52:38 -080074 virtual void DisconnectCleanup();
Jason Glasgow82f9ab32012-04-04 14:27:19 -040075 virtual void Activate(const std::string &carrier,
76 Error *error, const ResultCallback &callback);
Arman Ugurayc7b15602013-02-16 00:56:18 -080077 virtual void CompleteActivation(Error *error);
Jason Glasgow82f9ab32012-04-04 14:27:19 -040078
79 virtual void OnServiceCreated();
Jason Glasgow82f9ab32012-04-04 14:27:19 -040080 virtual void SetupConnectProperties(DBusPropertiesMap *properties);
Jason Glasgowef965562012-04-10 16:12:35 -040081 virtual void GetProperties();
Arman Uguray72fab6a2013-01-10 19:32:42 -080082 virtual bool IsRegistered();
Ben Chan15786032012-11-04 21:28:02 -080083 virtual bool IsServiceActivationRequired() const;
Jason Glasgow82f9ab32012-04-04 14:27:19 -040084 virtual void Register(const ResultCallback &callback);
85
86 virtual void RegisterOnNetwork(const std::string &network_id,
87 Error *error,
88 const ResultCallback &callback);
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040089 virtual void SetUnregistered(bool searching);
Jason Glasgow82f9ab32012-04-04 14:27:19 -040090 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 Chan5d0d32c2013-01-08 02:05:29 -0800101 virtual void Reset(Error *error, const ResultCallback &callback);
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400102
103 virtual void Scan(Error *error, const ResultCallback &callback);
104 virtual std::string GetNetworkTechnologyString() const;
105 virtual std::string GetRoamingStateString() const;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400106 virtual void GetSignalQuality();
Jason Glasgow9f09aef2012-05-08 16:26:55 -0400107 virtual std::string GetTypeString() const;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400108 virtual void OnDBusPropertiesChanged(
109 const std::string &interface,
110 const DBusPropertiesMap &changed_properties,
111 const std::vector<std::string> &invalidated_properties);
Jason Glasgowaf583282012-04-18 15:18:22 -0400112 virtual bool AllowRoaming();
Arman Ugurayf84a4242013-04-09 20:01:07 -0700113 virtual bool ShouldDetectOutOfCredit() const;
Jason Glasgow14521872012-05-07 19:12:15 -0400114
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400115 protected:
116 virtual void InitProxies();
117 virtual void ReleaseProxies();
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400118
Arman Uguray72fab6a2013-01-10 19:32:42 -0800119 // 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 Uguray0a3e2792013-01-17 16:31:50 -0800128 // 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 Uguray72fab6a2013-01-10 19:32:42 -0800136
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 Glasgow82f9ab32012-04-04 14:27:19 -0400143 private:
Jason Glasgowcd0349c2012-05-03 23:32:15 -0400144 // 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 Glasgow14521872012-05-07 19:12:15 -0400153 // Modem Model ID strings. From modem firmware via modemmanager.
154 static const char kE362ModelId[];
155
Arman Uguray2717a102013-01-29 23:36:06 -0800156 // Generic service name prefix, shown when the correct carrier name is
157 // unknown.
158 static const char kGenericServiceNamePrefix[];
159
Arman Uguraya14941d2013-04-12 16:58:26 -0700160 static const int64 kActivationRegistrationTimeoutMilliseconds;
161 static const int64 kDefaultScanningOrSearchingTimeoutMilliseconds;
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700162 static const int64 kRegistrationDroppedUpdateTimeoutMilliseconds;
Thieu Le2cac2942013-03-05 18:41:08 -0800163 static const int kSetPowerStateTimeoutMilliseconds;
Arman Ugurayee464d32013-02-13 17:14:36 -0800164
Arman Uguray1361c032013-02-11 17:53:39 -0800165
Arman Uguray6552f8c2013-02-12 15:33:18 -0800166 // Root path. The SIM path is reported by ModemManager to be the root path
167 // when no SIM is present.
168 static const char kRootPath[];
169
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400170 friend class CellularTest;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400171 friend class CellularCapabilityTest;
Thieu Le3d275392012-07-20 15:32:58 -0700172 friend class CellularCapabilityUniversalTest;
Arman Uguray72fab6a2013-01-10 19:32:42 -0800173 friend class CellularCapabilityUniversalCDMATest;
Arman Uguray0a3e2792013-01-17 16:31:50 -0800174 FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, PropertiesChanged);
175 FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, UpdateOLP);
Arman Uguray1361c032013-02-11 17:53:39 -0800176 FRIEND_TEST(CellularCapabilityUniversalMainTest, AllowRoaming);
Arman Uguraya14941d2013-04-12 16:58:26 -0700177 FRIEND_TEST(CellularCapabilityUniversalMainTest,
178 ActivationWaitForRegisterTimeout);
Arman Uguray1361c032013-02-11 17:53:39 -0800179 FRIEND_TEST(CellularCapabilityUniversalMainTest, Connect);
180 FRIEND_TEST(CellularCapabilityUniversalMainTest, ConnectApns);
181 FRIEND_TEST(CellularCapabilityUniversalMainTest, CreateFriendlyServiceName);
182 FRIEND_TEST(CellularCapabilityUniversalMainTest, DisconnectNoProxy);
Arman Uguray7af0fac2013-03-18 17:35:35 -0700183 FRIEND_TEST(CellularCapabilityUniversalMainTest,
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700184 DisconnectWithDeferredCallback);
185 FRIEND_TEST(CellularCapabilityUniversalMainTest,
Arman Uguray7af0fac2013-03-18 17:35:35 -0700186 GetNetworkTechnologyStringOnE362);
Arman Uguray1361c032013-02-11 17:53:39 -0800187 FRIEND_TEST(CellularCapabilityUniversalMainTest, GetTypeString);
Arman Ugurayc7b15602013-02-16 00:56:18 -0800188 FRIEND_TEST(CellularCapabilityUniversalMainTest, IsMdnValid);
Arman Uguray1361c032013-02-11 17:53:39 -0800189 FRIEND_TEST(CellularCapabilityUniversalMainTest, IsServiceActivationRequired);
Arman Uguray6552f8c2013-02-12 15:33:18 -0800190 FRIEND_TEST(CellularCapabilityUniversalMainTest, IsValidSimPath);
Ben Chand7592522013-02-13 16:02:01 -0800191 FRIEND_TEST(CellularCapabilityUniversalMainTest, NormalizeMdn);
Arman Uguray1361c032013-02-11 17:53:39 -0800192 FRIEND_TEST(CellularCapabilityUniversalMainTest, OnListBearersReply);
193 FRIEND_TEST(CellularCapabilityUniversalMainTest,
Ben Chanfcca27b2013-01-22 15:03:44 -0800194 OnModemCurrentCapabilitiesChanged);
Arman Uguray1361c032013-02-11 17:53:39 -0800195 FRIEND_TEST(CellularCapabilityUniversalMainTest, PropertiesChanged);
196 FRIEND_TEST(CellularCapabilityUniversalMainTest, Reset);
197 FRIEND_TEST(CellularCapabilityUniversalMainTest, Scan);
198 FRIEND_TEST(CellularCapabilityUniversalMainTest, ScanFailure);
199 FRIEND_TEST(CellularCapabilityUniversalMainTest, SetHomeProvider);
Arman Ugurayd42d8ec2013-04-08 19:28:21 -0700200 FRIEND_TEST(CellularCapabilityUniversalMainTest,
Arman Ugurayf84a4242013-04-09 20:01:07 -0700201 ShouldDetectOutOfCredit);
Arman Uguray1361c032013-02-11 17:53:39 -0800202 FRIEND_TEST(CellularCapabilityUniversalMainTest, SimLockStatusChanged);
203 FRIEND_TEST(CellularCapabilityUniversalMainTest, SimPathChanged);
204 FRIEND_TEST(CellularCapabilityUniversalMainTest, SimPropertiesChanged);
205 FRIEND_TEST(CellularCapabilityUniversalMainTest, StartModem);
206 FRIEND_TEST(CellularCapabilityUniversalMainTest, StopModem);
207 FRIEND_TEST(CellularCapabilityUniversalMainTest, StopModemConnected);
Arman Uguray0a3e2792013-01-17 16:31:50 -0800208 FRIEND_TEST(CellularCapabilityUniversalMainTest,
209 UpdatePendingActivationState);
Arman Ugurayefea6e02013-02-21 13:28:04 -0800210 FRIEND_TEST(CellularCapabilityUniversalMainTest,
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700211 UpdateRegistrationState);
212 FRIEND_TEST(CellularCapabilityUniversalMainTest,
213 UpdateRegistrationStateModemNotConnected);
214 FRIEND_TEST(CellularCapabilityUniversalMainTest,
Arman Ugurayefea6e02013-02-21 13:28:04 -0800215 UpdateServiceActivationState);
Arman Uguray1361c032013-02-11 17:53:39 -0800216 FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateServiceName);
217 FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateStorageIdentifier);
218 FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateOLP);
219 FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateOperatorInfo);
220 FRIEND_TEST(CellularCapabilityUniversalMainTest,
221 UpdateOperatorInfoViaOperatorId);
222 FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateScanningProperty);
Arman Uguraya14941d2013-04-12 16:58:26 -0700223 FRIEND_TEST(CellularCapabilityUniversalTimerTest, CompleteActivation);
Arman Uguray1361c032013-02-11 17:53:39 -0800224 FRIEND_TEST(CellularCapabilityUniversalTimerTest,
225 UpdateScanningPropertyTimeout);
Arman Ugurayd42d8ec2013-04-08 19:28:21 -0700226 FRIEND_TEST(CellularTest, EnableTrafficMonitor);
Ben Chan09fa2a02012-11-07 22:09:09 -0800227 FRIEND_TEST(CellularTest,
228 HandleNewRegistrationStateForServiceRequiringActivation);
Thieu Le5218cf22012-11-26 11:52:57 -0800229 FRIEND_TEST(CellularTest, ModemStateChangeLostRegistration);
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400230
Jason Glasgowef965562012-04-10 16:12:35 -0400231 // Methods used in starting a modem
Gary Moraine285a842012-08-15 08:23:57 -0700232 void EnableModem(Error *error, const ResultCallback &callback);
Thieu Leb9c05e02013-03-04 14:09:32 -0800233 void Start_ModemAlreadyEnabled(const ResultCallback &callback);
Jason Glasgowef965562012-04-10 16:12:35 -0400234 void Start_EnableModemCompleted(const ResultCallback &callback,
235 const Error &error);
Jason Glasgowef965562012-04-10 16:12:35 -0400236
237 // Methods used in stopping a modem
238 void Stop_DisconnectCompleted(const ResultCallback &callback,
239 const Error &error);
240 void Stop_Disable(const ResultCallback &callback);
241 void Stop_DisableCompleted(const ResultCallback &callback,
242 const Error &error);
Arman Ugurayee464d32013-02-13 17:14:36 -0800243 void Stop_PowerDown(const ResultCallback &callback);
244 void Stop_PowerDownCompleted(const ResultCallback &callback,
245 const Error &error);
Jason Glasgowef965562012-04-10 16:12:35 -0400246
Arman Uguray2717a102013-01-29 23:36:06 -0800247 // Updates the name property that is exposed by the service to Chrome.
248 void UpdateServiceName();
249
Ben Chan8a2c01e2013-01-23 10:09:14 -0800250 void UpdateScanningProperty();
251
Arman Ugurayd73783f2013-01-31 16:11:21 -0800252 // Methods used in acquiring information related to the carrier;
253
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400254 // Updates the Universal operator name and country based on a newly
255 // obtained network id.
256 void UpdateOperatorInfo();
257
Arman Ugurayd73783f2013-01-31 16:11:21 -0800258 // Sets the upper level information about the home cellular provider from the
259 // modem's IMSI and SPN.
260 void SetHomeProvider();
261
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400262 // Updates the serving operator on the active service.
263 void UpdateServingOperator();
264
Arman Ugurayd73783f2013-01-31 16:11:21 -0800265 // Initializes the |apn_list_| property based on the current |home_provider_|.
266 void InitAPNList();
267
Arman Uguray6e5639f2012-11-15 20:30:19 -0800268 // Updates |bearer_path_| to match the currently active bearer.
269 void UpdateBearerPath();
270
Arman Ugurayc9533572013-01-22 17:34:20 -0800271 // Updates the storage identifier used for the current cellular service.
272 void UpdateStorageIdentifier();
273
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400274
275 Stringmap ParseScanResult(const ScanResult &result);
276
277 KeyValueStore SimLockStatusToProperty(Error *error);
278
279 void SetupApnTryList();
280 void FillConnectPropertyMap(DBusPropertiesMap *properties);
281
mukesh agrawalbebf1b82013-04-23 15:06:33 -0700282 void HelpRegisterConstDerivedKeyValueStore(
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400283 const std::string &name,
mukesh agrawalbebf1b82013-04-23 15:06:33 -0700284 KeyValueStore(CellularCapabilityUniversal::*get)(Error *error));
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400285
Jason Glasgow14521872012-05-07 19:12:15 -0400286 // Returns true if a connect error should be retried. This function
287 // abstracts modem specific behavior for modems which do a lousy job
288 // of returning specific errors on connect failures.
289 bool RetriableConnectError(const Error &error) const;
290
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400291 // Signal callbacks
Nathan Williams3022be52012-04-19 17:40:49 -0400292 void OnNetworkModeSignal(uint32 mode);
Eric Shienbrood7fce52c2012-04-13 19:11:02 -0400293 void OnModemStateChangedSignal(int32 old_state,
294 int32 new_state,
295 uint32 reason);
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400296
297 // Property Change notification handlers
Nathan Williams3022be52012-04-19 17:40:49 -0400298 void OnModemPropertiesChanged(
Jason Glasgow4c0724a2012-04-17 15:47:40 -0400299 const DBusPropertiesMap &properties,
300 const std::vector<std::string> &invalidated_properties);
301
Nathan Williams3022be52012-04-19 17:40:49 -0400302 void OnSignalQualityChanged(uint32 quality);
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400303
Jason Glasgowaf583282012-04-18 15:18:22 -0400304 void OnModemCapabilitesChanged(uint32 capabilities);
305 void OnModemCurrentCapabilitiesChanged(uint32 current_capabilities);
306 void OnMdnChanged(const std::string &mdn);
307 void OnModemManufacturerChanged(const std::string &manufacturer);
308 void OnModemModelChanged(const std::string &model);
309 void OnModemRevisionChanged(const std::string &revision);
310 void OnModemStateChanged(Cellular::ModemState state);
311 void OnAccessTechnologiesChanged(uint32 access_technologies);
312 void OnSupportedModesChanged(uint32 supported_modes);
313 void OnAllowedModesChanged(uint32 allowed_modes);
314 void OnPreferredModeChanged(MMModemMode preferred_mode);
315 void OnLockRetriesChanged(MMModemLock unlock_required,
316 const LockRetryData &lock_retries);
317 void OnSimLockStatusChanged();
318
Arman Ugurayc7b15602013-02-16 00:56:18 -0800319 // Returns false if the MDN is empty or if the MDN consists of all 0s.
320 bool IsMdnValid() const;
321
Jason Glasgowaf583282012-04-18 15:18:22 -0400322 // 3GPP property change handlers
323 virtual void OnModem3GPPPropertiesChanged(
324 const DBusPropertiesMap &properties,
325 const std::vector<std::string> &invalidated_properties);
326 void OnImeiChanged(const std::string &imei);
327 void On3GPPRegistrationChanged(MMModem3gppRegistrationState state,
328 const std::string &operator_code,
329 const std::string &operator_name);
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700330 void Handle3GPPRegistrationChange(
331 MMModem3gppRegistrationState updated_state,
332 std::string updated_operator_code,
333 std::string updated_operator_name);
Jason Glasgowaf583282012-04-18 15:18:22 -0400334 void OnFacilityLocksChanged(uint32 locks);
335
336 // SIM property change handlers
Arman Uguray72fab6a2013-01-10 19:32:42 -0800337 // TODO(armansito): Put these methods in a 3GPP-only subclass.
Jason Glasgowaf583282012-04-18 15:18:22 -0400338 void OnSimPropertiesChanged(
339 const DBusPropertiesMap &props,
340 const std::vector<std::string> &invalidated_properties);
341 void OnImsiChanged(const std::string &imsi);
Arman Ugurayd73783f2013-01-31 16:11:21 -0800342 void OnSpnChanged(const std::string &spn);
Jason Glasgowaf583282012-04-18 15:18:22 -0400343 void OnSimIdentifierChanged(const std::string &id);
344 void OnOperatorIdChanged(const std::string &operator_id);
345 void OnOperatorNameChanged(const std::string &operator_name);
Jason Glasgowef965562012-04-10 16:12:35 -0400346
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400347 // Method callbacks
Nathan Williams3022be52012-04-19 17:40:49 -0400348 void OnRegisterReply(const ResultCallback &callback,
349 const Error &error);
Ben Chan5d0d32c2013-01-08 02:05:29 -0800350 void OnResetReply(const ResultCallback &callback, const Error &error);
Nathan Williams3022be52012-04-19 17:40:49 -0400351 void OnScanReply(const ResultCallback &callback,
352 const ScanResults &results,
353 const Error &error);
Nathan Williamsb54974f2012-04-19 11:16:30 -0400354 void OnConnectReply(const ResultCallback &callback,
355 const DBus::Path &bearer,
356 const Error &error);
Arman Uguray6e5639f2012-11-15 20:30:19 -0800357 void OnListBearersReply(const std::vector<DBus::Path> &paths,
358 const Error &error);
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400359
Arman Uguray1361c032013-02-11 17:53:39 -0800360 // Timeout callback for the network scan initiated when Cellular connectivity
361 // gets enabled.
362 void OnScanningOrSearchingTimeout();
363
Arman Uguraya14941d2013-04-12 16:58:26 -0700364 // Timeout callback that is called if the modem takes too long to register to
365 // a network after online payment is complete. Resets the modem.
366 void OnActivationWaitForRegisterTimeout();
367
Arman Uguray6552f8c2013-02-12 15:33:18 -0800368 // Returns true, if |sim_path| constitutes a valid SIM path. Currently, a
369 // path is accepted to be valid, as long as it is not equal to one of ""
370 // and "/".
371 bool IsValidSimPath(const std::string &sim_path) const;
372
Ben Chand7592522013-02-13 16:02:01 -0800373 // Returns the normalized version of |mdn| by keeping only digits in |mdn|
374 // and removing other non-digit characters.
375 std::string NormalizeMdn(const std::string &mdn) const;
376
Arman Uguray2717a102013-01-29 23:36:06 -0800377 static std::string GenerateNewGenericServiceName();
378
Arman Ugurayc7b15602013-02-16 00:56:18 -0800379 // Post-payment activation handlers.
Arman Ugurayc7b15602013-02-16 00:56:18 -0800380 void ResetAfterActivation();
Arman Ugurayefea6e02013-02-21 13:28:04 -0800381 void UpdateServiceActivationState();
Arman Ugurayc7b15602013-02-16 00:56:18 -0800382 void OnResetAfterActivationReply(const Error &error);
383
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700384 static bool IsRegisteredState(MMModem3gppRegistrationState state);
385
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400386 scoped_ptr<mm1::ModemModem3gppProxyInterface> modem_3gpp_proxy_;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400387 scoped_ptr<mm1::ModemProxyInterface> modem_proxy_;
388 scoped_ptr<mm1::ModemSimpleProxyInterface> modem_simple_proxy_;
389 scoped_ptr<mm1::SimProxyInterface> sim_proxy_;
390
391 base::WeakPtrFactory<CellularCapabilityUniversal> weak_ptr_factory_;
392
393 MMModem3gppRegistrationState registration_state_;
Jason Glasgowaf583282012-04-18 15:18:22 -0400394
395 // Bits based on MMModemCapabilities
Jason Glasgow14521872012-05-07 19:12:15 -0400396 uint32 capabilities_; // technologies supported, may require reload
397 uint32 current_capabilities_; // technologies supportsed without a reload
398 uint32 access_technologies_; // Bits based on MMModemAccessTechnology
399 uint32 supported_modes_; // Bits based on MMModemMode
400 uint32 allowed_modes_; // Bits based on MMModemMode
401 MMModemMode preferred_mode_; // A single MMModemMode bit
Jason Glasgowaf583282012-04-18 15:18:22 -0400402
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400403 Cellular::Operator serving_operator_;
404 std::string spn_;
Jason Glasgowaf583282012-04-18 15:18:22 -0400405 std::string sim_identifier_;
406 std::string operator_id_;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400407 mobile_provider *home_provider_;
Darin Petkovf508c822012-09-21 13:43:17 +0200408 bool provider_requires_roaming_;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400409 std::string desired_network_;
410
411 // Properties.
412 std::string carrier_;
413 std::string esn_;
414 std::string firmware_revision_;
415 std::string hardware_revision_;
416 std::string imei_;
417 std::string imsi_;
418 std::string manufacturer_;
419 std::string mdn_;
420 std::string meid_;
421 std::string min_;
422 std::string model_id_;
423 std::string selected_network_;
424 Stringmaps found_networks_;
425 std::deque<Stringmap> apn_try_list_;
Ben Chan5d0d32c2013-01-08 02:05:29 -0800426 bool resetting_;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400427 bool scanning_supported_;
428 bool scanning_;
Ben Chan8a2c01e2013-01-23 10:09:14 -0800429 bool scanning_or_searching_;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400430 uint16 scan_interval_;
431 SimLockStatus sim_lock_status_;
432 Stringmaps apn_list_;
Jason Glasgowef965562012-04-10 16:12:35 -0400433 std::string sim_path_;
Ben Chanbd3aee82012-10-16 23:52:04 -0700434 bool sim_present_;
Nathan Williamsb54974f2012-04-19 11:16:30 -0400435 DBus::Path bearer_path_;
Arman Ugurayc7b15602013-02-16 00:56:18 -0800436 bool reset_done_;
437
Gary Moraine285a842012-08-15 08:23:57 -0700438 // If the modem is not in a state to be enabled when StartModem is called,
439 // enabling is deferred using this callback.
440 base::Closure deferred_enable_modem_callback_;
441
Arman Uguray1361c032013-02-11 17:53:39 -0800442 // Sometimes modems may be stuck in the SEARCHING state during the lack of
443 // presence of a network. During this indefinite duration of time, keeping
444 // the Device.Scanning property as |true| causes a bad user experience.
445 // This callback sets it to |false| after a timeout period has passed.
446 base::CancelableClosure scanning_or_searching_timeout_callback_;
Arman Uguraya14941d2013-04-12 16:58:26 -0700447 int64 scanning_or_searching_timeout_milliseconds_;
448
449 base::CancelableClosure activation_wait_for_registration_callback_;
450 int64 activation_registration_timeout_milliseconds_;
Arman Uguray1361c032013-02-11 17:53:39 -0800451
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700452 // Sometimes flaky cellular network causes the 3GPP registration state to
453 // rapidly change from registered --> searching and back. Delay such updates
454 // a little to smooth over temporary registration loss.
455 base::CancelableClosure registration_dropped_update_callback_;
456 int64 registration_dropped_update_timeout_milliseconds_;
457
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400458 static unsigned int friendly_service_name_id_;
459
460 DISALLOW_COPY_AND_ASSIGN(CellularCapabilityUniversal);
461};
462
463} // namespace shill
464
Jason Glasgow14521872012-05-07 19:12:15 -0400465#endif // SHILL_CELLULAR_CAPABILITY_UNIVERSAL_H_