blob: 1a2efff59628fdebe07e468ee56fcc75bb63af72 [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"
Thieu Le28492142014-04-08 16:41:13 -070020#include "shill/cellular_bearer.h"
Jason Glasgow82f9ab32012-04-04 14:27:19 -040021#include "shill/cellular_capability.h"
Ben Chan07193fd2013-07-12 22:10:55 -070022#include "shill/cellular_operator_info.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"
Thieu Le43ce4d42013-10-04 16:08:55 -070027#include "shill/out_of_credits_detector.h"
Jason Glasgow82f9ab32012-04-04 14:27:19 -040028
Jason Glasgow82f9ab32012-04-04 14:27:19 -040029struct mobile_provider;
30
31namespace shill {
32
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070033class ModemInfo;
Arman Ugurayc7b15602013-02-16 00:56:18 -080034
Jason Glasgow82f9ab32012-04-04 14:27:19 -040035// 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.
38class CellularCapabilityUniversal : public CellularCapability {
39 public:
40 typedef std::vector<DBusPropertiesMap> ScanResults;
41 typedef DBusPropertiesMap ScanResult;
Ben Chan74924d82013-06-15 17:52:55 -070042 typedef std::map<uint32_t, uint32_t> LockRetryData;
Jason Glasgow82f9ab32012-04-04 14:27:19 -040043
Jason Glasgow14521872012-05-07 19:12:15 -040044 // Constants used in connect method call. Make available to test matchers.
45 // TODO(jglasgow): Generate from modem manager into
46 // ModemManager-names.h.
Paul Stewartee6b3d72013-07-12 16:07:51 -070047 // See http://crbug.com/212909.
Jason Glasgow14521872012-05-07 19:12:15 -040048 static const char kConnectPin[];
49 static const char kConnectOperatorId[];
Jason Glasgow14521872012-05-07 19:12:15 -040050 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 Lece4483e2013-01-23 15:12:03 -080058 CellularCapabilityUniversal(Cellular *cellular,
59 ProxyFactory *proxy_factory,
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070060 ModemInfo *modem_info);
Ben Chanf98f00e2014-02-05 14:48:43 -080061 virtual ~CellularCapabilityUniversal();
Jason Glasgow82f9ab32012-04-04 14:27:19 -040062
63 // Inherited from CellularCapability.
Ben Chanf98f00e2014-02-05 14:48:43 -080064 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 Moraine285a842012-08-15 08:23:57 -070069 // 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 Uguray1ee93912013-09-24 21:24:10 -070072 // modem is not disabled, for example, if it is initializing instead.
Ben Chanf98f00e2014-02-05 14:48:43 -080073 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 Glasgow82f9ab32012-04-04 14:27:19 -040081 virtual void RegisterOnNetwork(const std::string &network_id,
82 Error *error,
Ben Chanf98f00e2014-02-05 14:48:43 -080083 const ResultCallback &callback) override;
84 virtual bool IsRegistered() const override;
85 virtual void SetUnregistered(bool searching) override;
86 virtual void OnServiceCreated() override;
Ben Chanf98f00e2014-02-05 14:48:43 -080087 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 Glasgow82f9ab32012-04-04 14:27:19 -0400102 virtual void EnterPIN(const std::string &pin,
Ben Chanf98f00e2014-02-05 14:48:43 -0800103 Error *error,
104 const ResultCallback &callback) override;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400105 virtual void UnblockPIN(const std::string &unblock_code,
106 const std::string &pin,
Ben Chanf98f00e2014-02-05 14:48:43 -0800107 Error *error,
108 const ResultCallback &callback) override;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400109 virtual void ChangePIN(const std::string &old_pin,
110 const std::string &new_pin,
Ben Chanf98f00e2014-02-05 14:48:43 -0800111 Error *error,
112 const ResultCallback &callback) override;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400113
Ben Chanf98f00e2014-02-05 14:48:43 -0800114 virtual void GetProperties();
115 virtual void Register(const ResultCallback &callback);
Jason Glasgow14521872012-05-07 19:12:15 -0400116
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400117 protected:
118 virtual void InitProxies();
119 virtual void ReleaseProxies();
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400120
Arman Uguray72fab6a2013-01-10 19:32:42 -0800121 // 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 Prabhu92df6192014-04-29 18:08:08 -0700128 virtual void UpdateServiceOLP() override;
Arman Uguray72fab6a2013-01-10 19:32:42 -0800129
Arman Uguray0a3e2792013-01-17 16:31:50 -0800130 // Post-payment activation handlers.
131 virtual void UpdatePendingActivationState();
132
Prathmesh Prabhu9f06c872013-11-21 14:08:23 -0800133 // Returns the operator-specific form of |mdn|, which is passed to the online
Ben Chan07193fd2013-07-12 22:10:55 -0700134 // payment portal of a cellular operator.
Prathmesh Prabhu92df6192014-04-29 18:08:08 -0700135 std::string GetMdnForOLP(const MobileOperatorInfo *operator_info) const;
Ben Chan07193fd2013-07-12 22:10:55 -0700136
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400137 private:
Ben Chan74924d82013-06-15 17:52:55 -0700138 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 Glasgowcd0349c2012-05-03 23:32:15 -0400151 // Constants used in scan results. Make available to unit tests.
152 // TODO(jglasgow): Generate from modem manager into ModemManager-names.h.
Paul Stewartee6b3d72013-07-12 16:07:51 -0700153 // See http://crbug.com/212909.
Jason Glasgowcd0349c2012-05-03 23:32:15 -0400154 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 Glasgow14521872012-05-07 19:12:15 -0400160 // Modem Model ID strings. From modem firmware via modemmanager.
Thieu Le43ce4d42013-10-04 16:08:55 -0700161 static const char kALT3100ModelId[];
Jason Glasgow14521872012-05-07 19:12:15 -0400162 static const char kE362ModelId[];
163
Arman Uguraya14941d2013-04-12 16:58:26 -0700164 static const int64 kActivationRegistrationTimeoutMilliseconds;
Arman Ugurayf6366ac2013-06-12 16:02:28 -0700165 static const int64 kEnterPinTimeoutMilliseconds;
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700166 static const int64 kRegistrationDroppedUpdateTimeoutMilliseconds;
Thieu Le2cac2942013-03-05 18:41:08 -0800167 static const int kSetPowerStateTimeoutMilliseconds;
Arman Ugurayee464d32013-02-13 17:14:36 -0800168
Arman Uguray1361c032013-02-11 17:53:39 -0800169
Arman Uguray6552f8c2013-02-12 15:33:18 -0800170 // 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 Glasgow82f9ab32012-04-04 14:27:19 -0400174 friend class CellularTest;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400175 friend class CellularCapabilityTest;
Thieu Le3d275392012-07-20 15:32:58 -0700176 friend class CellularCapabilityUniversalTest;
Arman Uguray72fab6a2013-01-10 19:32:42 -0800177 friend class CellularCapabilityUniversalCDMATest;
Arman Uguray0a3e2792013-01-17 16:31:50 -0800178 FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, PropertiesChanged);
Arman Uguray1361c032013-02-11 17:53:39 -0800179 FRIEND_TEST(CellularCapabilityUniversalMainTest, AllowRoaming);
Arman Uguraya14941d2013-04-12 16:58:26 -0700180 FRIEND_TEST(CellularCapabilityUniversalMainTest,
181 ActivationWaitForRegisterTimeout);
Arman Uguray1361c032013-02-11 17:53:39 -0800182 FRIEND_TEST(CellularCapabilityUniversalMainTest, Connect);
183 FRIEND_TEST(CellularCapabilityUniversalMainTest, ConnectApns);
Arman Uguray1361c032013-02-11 17:53:39 -0800184 FRIEND_TEST(CellularCapabilityUniversalMainTest, DisconnectNoProxy);
Arman Uguray7af0fac2013-03-18 17:35:35 -0700185 FRIEND_TEST(CellularCapabilityUniversalMainTest,
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700186 DisconnectWithDeferredCallback);
Thieu Le43ce4d42013-10-04 16:08:55 -0700187 FRIEND_TEST(CellularCapabilityUniversalMainTest, ExtractPcoValue);
188 FRIEND_TEST(CellularCapabilityUniversalMainTest, GetMdnForOLP);
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700189 FRIEND_TEST(CellularCapabilityUniversalMainTest,
Arman Uguray7af0fac2013-03-18 17:35:35 -0700190 GetNetworkTechnologyStringOnE362);
Thieu Le43ce4d42013-10-04 16:08:55 -0700191 FRIEND_TEST(CellularCapabilityUniversalMainTest,
192 GetOutOfCreditsDetectionType);
Arman Uguray1361c032013-02-11 17:53:39 -0800193 FRIEND_TEST(CellularCapabilityUniversalMainTest, GetTypeString);
Arman Ugurayc7b15602013-02-16 00:56:18 -0800194 FRIEND_TEST(CellularCapabilityUniversalMainTest, IsMdnValid);
Ben Chan31ce5642013-11-14 13:37:40 -0800195 FRIEND_TEST(CellularCapabilityUniversalMainTest, IsRegistered);
Arman Uguray1361c032013-02-11 17:53:39 -0800196 FRIEND_TEST(CellularCapabilityUniversalMainTest, IsServiceActivationRequired);
Arman Uguray6552f8c2013-02-12 15:33:18 -0800197 FRIEND_TEST(CellularCapabilityUniversalMainTest, IsValidSimPath);
Ben Chand7592522013-02-13 16:02:01 -0800198 FRIEND_TEST(CellularCapabilityUniversalMainTest, NormalizeMdn);
Arman Ugurayc7e63af2013-06-13 17:07:32 -0700199 FRIEND_TEST(CellularCapabilityUniversalMainTest, OnLockRetriesChanged);
200 FRIEND_TEST(CellularCapabilityUniversalMainTest, OnLockTypeChanged);
Arman Uguray1361c032013-02-11 17:53:39 -0800201 FRIEND_TEST(CellularCapabilityUniversalMainTest,
Ben Chanfcca27b2013-01-22 15:03:44 -0800202 OnModemCurrentCapabilitiesChanged);
Arman Ugurayc7e63af2013-06-13 17:07:32 -0700203 FRIEND_TEST(CellularCapabilityUniversalMainTest, OnSimLockPropertiesChanged);
Arman Uguray1361c032013-02-11 17:53:39 -0800204 FRIEND_TEST(CellularCapabilityUniversalMainTest, PropertiesChanged);
205 FRIEND_TEST(CellularCapabilityUniversalMainTest, Reset);
206 FRIEND_TEST(CellularCapabilityUniversalMainTest, Scan);
207 FRIEND_TEST(CellularCapabilityUniversalMainTest, ScanFailure);
Arman Uguray1361c032013-02-11 17:53:39 -0800208 FRIEND_TEST(CellularCapabilityUniversalMainTest, SimLockStatusChanged);
Arman Ugurayc7e63af2013-06-13 17:07:32 -0700209 FRIEND_TEST(CellularCapabilityUniversalMainTest, SimLockStatusToProperty);
Arman Uguray1361c032013-02-11 17:53:39 -0800210 FRIEND_TEST(CellularCapabilityUniversalMainTest, SimPathChanged);
211 FRIEND_TEST(CellularCapabilityUniversalMainTest, SimPropertiesChanged);
212 FRIEND_TEST(CellularCapabilityUniversalMainTest, StartModem);
Ben Chan151d4472013-09-06 13:29:46 -0700213 FRIEND_TEST(CellularCapabilityUniversalMainTest, StartModemFailure);
214 FRIEND_TEST(CellularCapabilityUniversalMainTest, StartModemInWrongState);
215 FRIEND_TEST(CellularCapabilityUniversalMainTest,
216 StartModemWithDeferredEnableFailure);
Arman Uguray1361c032013-02-11 17:53:39 -0800217 FRIEND_TEST(CellularCapabilityUniversalMainTest, StopModem);
Thieu Le28492142014-04-08 16:41:13 -0700218 FRIEND_TEST(CellularCapabilityUniversalMainTest, StopModemALT3100);
Thieu Leb0074e82014-04-15 14:28:21 -0700219 FRIEND_TEST(CellularCapabilityUniversalMainTest,
220 StopModemALT3100DeleteBearerFailure);
221 FRIEND_TEST(CellularCapabilityUniversalMainTest,
222 StopModemALT3100NotConnected);
Arman Uguray1361c032013-02-11 17:53:39 -0800223 FRIEND_TEST(CellularCapabilityUniversalMainTest, StopModemConnected);
Ben Chan9f3dcf82013-09-25 18:04:58 -0700224 FRIEND_TEST(CellularCapabilityUniversalMainTest, TerminationAction);
225 FRIEND_TEST(CellularCapabilityUniversalMainTest,
226 TerminationActionRemovedByStopModem);
Ben Chan539ab022014-02-03 16:34:57 -0800227 FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateActiveBearer);
Arman Uguray0a3e2792013-01-17 16:31:50 -0800228 FRIEND_TEST(CellularCapabilityUniversalMainTest,
229 UpdatePendingActivationState);
Arman Ugurayefea6e02013-02-21 13:28:04 -0800230 FRIEND_TEST(CellularCapabilityUniversalMainTest,
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700231 UpdateRegistrationState);
232 FRIEND_TEST(CellularCapabilityUniversalMainTest,
233 UpdateRegistrationStateModemNotConnected);
234 FRIEND_TEST(CellularCapabilityUniversalMainTest,
Arman Ugurayefea6e02013-02-21 13:28:04 -0800235 UpdateServiceActivationState);
Prathmesh Prabhu92df6192014-04-29 18:08:08 -0700236 FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateServiceOLP);
Arman Uguraya14941d2013-04-12 16:58:26 -0700237 FRIEND_TEST(CellularCapabilityUniversalTimerTest, CompleteActivation);
Arman Ugurayd42d8ec2013-04-08 19:28:21 -0700238 FRIEND_TEST(CellularTest, EnableTrafficMonitor);
Ben Chan09fa2a02012-11-07 22:09:09 -0800239 FRIEND_TEST(CellularTest,
240 HandleNewRegistrationStateForServiceRequiringActivation);
Thieu Le5218cf22012-11-26 11:52:57 -0800241 FRIEND_TEST(CellularTest, ModemStateChangeLostRegistration);
mukesh agrawalf407d592013-07-31 11:37:57 -0700242 FRIEND_TEST(CellularTest, OnPPPDied);
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400243
Arman Ugurayc7e63af2013-06-13 17:07:32 -0700244 // 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 Prabhu9a0534e2013-10-10 16:20:34 -0700257 // 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 Glasgowef965562012-04-10 16:12:35 -0400267 // Methods used in starting a modem
Ben Chan151d4472013-09-06 13:29:46 -0700268 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 Glasgowef965562012-04-10 16:12:35 -0400274
275 // Methods used in stopping a modem
Thieu Le28492142014-04-08 16:41:13 -0700276 void Stop_DeleteActiveBearer(const ResultCallback &callback);
277 void Stop_DeleteActiveBearerCompleted(const ResultCallback &callback,
278 const Error &error);
Jason Glasgowef965562012-04-10 16:12:35 -0400279 void Stop_Disable(const ResultCallback &callback);
280 void Stop_DisableCompleted(const ResultCallback &callback,
281 const Error &error);
Arman Ugurayee464d32013-02-13 17:14:36 -0800282 void Stop_PowerDown(const ResultCallback &callback);
283 void Stop_PowerDownCompleted(const ResultCallback &callback,
284 const Error &error);
Jason Glasgowef965562012-04-10 16:12:35 -0400285
Ben Chan539ab022014-02-03 16:34:57 -0800286 // Updates |active_bearer_| to match the currently active bearer.
287 void UpdateActiveBearer();
Arman Uguray6e5639f2012-11-15 20:30:19 -0800288
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400289 Stringmap ParseScanResult(const ScanResult &result);
290
291 KeyValueStore SimLockStatusToProperty(Error *error);
292
293 void SetupApnTryList();
294 void FillConnectPropertyMap(DBusPropertiesMap *properties);
295
mukesh agrawalbebf1b82013-04-23 15:06:33 -0700296 void HelpRegisterConstDerivedKeyValueStore(
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400297 const std::string &name,
mukesh agrawalbebf1b82013-04-23 15:06:33 -0700298 KeyValueStore(CellularCapabilityUniversal::*get)(Error *error));
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400299
Jason Glasgow14521872012-05-07 19:12:15 -0400300 // 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 Glasgow82f9ab32012-04-04 14:27:19 -0400305 // Signal callbacks
Nathan Williams3022be52012-04-19 17:40:49 -0400306 void OnNetworkModeSignal(uint32 mode);
Eric Shienbrood7fce52c2012-04-13 19:11:02 -0400307 void OnModemStateChangedSignal(int32 old_state,
308 int32 new_state,
309 uint32 reason);
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400310
311 // Property Change notification handlers
Nathan Williams3022be52012-04-19 17:40:49 -0400312 void OnModemPropertiesChanged(
Jason Glasgow4c0724a2012-04-17 15:47:40 -0400313 const DBusPropertiesMap &properties,
314 const std::vector<std::string> &invalidated_properties);
315
Nathan Williams3022be52012-04-19 17:40:49 -0400316 void OnSignalQualityChanged(uint32 quality);
Ben Chan74924d82013-06-15 17:52:55 -0700317
318 void OnSupportedCapabilitesChanged(
319 const std::vector<uint32> &supported_capabilities);
Jason Glasgowaf583282012-04-18 15:18:22 -0400320 void OnModemCurrentCapabilitiesChanged(uint32 current_capabilities);
321 void OnMdnChanged(const std::string &mdn);
Jason Glasgowaf583282012-04-18 15:18:22 -0400322 void OnModemRevisionChanged(const std::string &revision);
323 void OnModemStateChanged(Cellular::ModemState state);
324 void OnAccessTechnologiesChanged(uint32 access_technologies);
Ben Chan74924d82013-06-15 17:52:55 -0700325 void OnSupportedModesChanged(const std::vector<ModemModes> &supported_modes);
326 void OnCurrentModesChanged(const ModemModes &current_modes);
Ben Chancbef8122014-01-06 17:31:30 -0800327 void OnBearersChanged(const RpcIdentifiers &bearers);
Arman Ugurayc7e63af2013-06-13 17:07:32 -0700328 void OnLockRetriesChanged(const LockRetryData &lock_retries);
329 void OnLockTypeChanged(MMModemLock unlock_required);
Jason Glasgowaf583282012-04-18 15:18:22 -0400330 void OnSimLockStatusChanged();
331
Arman Ugurayc7b15602013-02-16 00:56:18 -0800332 // Returns false if the MDN is empty or if the MDN consists of all 0s.
333 bool IsMdnValid() const;
334
Jason Glasgowaf583282012-04-18 15:18:22 -0400335 // 3GPP property change handlers
336 virtual void OnModem3GPPPropertiesChanged(
337 const DBusPropertiesMap &properties,
338 const std::vector<std::string> &invalidated_properties);
Jason Glasgowaf583282012-04-18 15:18:22 -0400339 void On3GPPRegistrationChanged(MMModem3gppRegistrationState state,
340 const std::string &operator_code,
341 const std::string &operator_name);
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700342 void Handle3GPPRegistrationChange(
343 MMModem3gppRegistrationState updated_state,
344 std::string updated_operator_code,
345 std::string updated_operator_name);
Prathmesh Prabhu9a0534e2013-10-10 16:20:34 -0700346 void On3GPPSubscriptionStateChanged(MMModem3gppSubscriptionState state);
Jason Glasgowaf583282012-04-18 15:18:22 -0400347 void OnFacilityLocksChanged(uint32 locks);
348
349 // SIM property change handlers
Arman Uguray72fab6a2013-01-10 19:32:42 -0800350 // TODO(armansito): Put these methods in a 3GPP-only subclass.
Jason Glasgowaf583282012-04-18 15:18:22 -0400351 void OnSimPropertiesChanged(
352 const DBusPropertiesMap &props,
353 const std::vector<std::string> &invalidated_properties);
Arman Ugurayd73783f2013-01-31 16:11:21 -0800354 void OnSpnChanged(const std::string &spn);
Jason Glasgowaf583282012-04-18 15:18:22 -0400355 void OnSimIdentifierChanged(const std::string &id);
356 void OnOperatorIdChanged(const std::string &operator_id);
357 void OnOperatorNameChanged(const std::string &operator_name);
Jason Glasgowef965562012-04-10 16:12:35 -0400358
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400359 // Method callbacks
Nathan Williams3022be52012-04-19 17:40:49 -0400360 void OnRegisterReply(const ResultCallback &callback,
361 const Error &error);
Ben Chan5d0d32c2013-01-08 02:05:29 -0800362 void OnResetReply(const ResultCallback &callback, const Error &error);
Prathmesh Prabhu49ffffd2014-01-09 18:28:55 -0800363 void OnScanReply(const ResultStringmapsCallback &callback,
Nathan Williams3022be52012-04-19 17:40:49 -0400364 const ScanResults &results,
365 const Error &error);
Nathan Williamsb54974f2012-04-19 11:16:30 -0400366 void OnConnectReply(const ResultCallback &callback,
367 const DBus::Path &bearer,
368 const Error &error);
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400369
Arman Uguraya14941d2013-04-12 16:58:26 -0700370 // 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 Uguray6552f8c2013-02-12 15:33:18 -0800374 // 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 Chand7592522013-02-13 16:02:01 -0800379 // 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 Ugurayc7b15602013-02-16 00:56:18 -0800383 // Post-payment activation handlers.
Arman Ugurayc7b15602013-02-16 00:56:18 -0800384 void ResetAfterActivation();
Arman Ugurayefea6e02013-02-21 13:28:04 -0800385 void UpdateServiceActivationState();
Arman Ugurayc7b15602013-02-16 00:56:18 -0800386 void OnResetAfterActivationReply(const Error &error);
387
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700388 static bool IsRegisteredState(MMModem3gppRegistrationState state);
389
Thieu Le43ce4d42013-10-04 16:08:55 -0700390 // Returns the out-of-credits detection algorithm to be used on this modem.
391 OutOfCreditsDetector::OOCType GetOutOfCreditsDetectionType() const;
392
Thieu Le28492142014-04-08 16:41:13 -0700393 // For unit tests.
394 void set_active_bearer(CellularBearer *bearer) {
395 active_bearer_.reset(bearer); // Takes ownership
396 }
397
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400398 scoped_ptr<mm1::ModemModem3gppProxyInterface> modem_3gpp_proxy_;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400399 scoped_ptr<mm1::ModemProxyInterface> modem_proxy_;
400 scoped_ptr<mm1::ModemSimpleProxyInterface> modem_simple_proxy_;
401 scoped_ptr<mm1::SimProxyInterface> sim_proxy_;
Prathmesh Prabhuafe63662014-05-20 11:03:58 -0700402 // 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 Glasgow82f9ab32012-04-04 14:27:19 -0400406
407 base::WeakPtrFactory<CellularCapabilityUniversal> weak_ptr_factory_;
408
409 MMModem3gppRegistrationState registration_state_;
Jason Glasgowaf583282012-04-18 15:18:22 -0400410
411 // Bits based on MMModemCapabilities
Ben Chan74924d82013-06-15 17:52:55 -0700412 std::vector<uint32> supported_capabilities_; // Technologies supported
413 uint32 current_capabilities_; // Technologies supported without a reload
Jason Glasgow14521872012-05-07 19:12:15 -0400414 uint32 access_technologies_; // Bits based on MMModemAccessTechnology
Ben Chan74924d82013-06-15 17:52:55 -0700415 std::vector<ModemModes> supported_modes_;
416 ModemModes current_modes_;
Jason Glasgowaf583282012-04-18 15:18:22 -0400417
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400418 Cellular::Operator serving_operator_;
419 std::string spn_;
Jason Glasgowaf583282012-04-18 15:18:22 -0400420 std::string operator_id_;
Prathmesh Prabhu99ec94d2013-11-22 10:43:37 -0800421 mobile_provider *home_provider_info_;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400422 std::string desired_network_;
423
424 // Properties.
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400425 std::deque<Stringmap> apn_try_list_;
Ben Chan5d0d32c2013-01-08 02:05:29 -0800426 bool resetting_;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400427 SimLockStatus sim_lock_status_;
Prathmesh Prabhu9a0534e2013-10-10 16:20:34 -0700428 SubscriptionState subscription_state_;
Jason Glasgowef965562012-04-10 16:12:35 -0400429 std::string sim_path_;
Ben Chan539ab022014-02-03 16:34:57 -0800430 scoped_ptr<CellularBearer> active_bearer_;
Ben Chancbef8122014-01-06 17:31:30 -0800431 RpcIdentifiers bearer_paths_;
Arman Ugurayc7b15602013-02-16 00:56:18 -0800432 bool reset_done_;
433
Gary Moraine285a842012-08-15 08:23:57 -0700434 // 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 Uguraya14941d2013-04-12 16:58:26 -0700438 base::CancelableClosure activation_wait_for_registration_callback_;
439 int64 activation_registration_timeout_milliseconds_;
Arman Uguray1361c032013-02-11 17:53:39 -0800440
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700441 // 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 Glasgow82f9ab32012-04-04 14:27:19 -0400447 DISALLOW_COPY_AND_ASSIGN(CellularCapabilityUniversal);
448};
449
450} // namespace shill
451
Jason Glasgow14521872012-05-07 19:12:15 -0400452#endif // SHILL_CELLULAR_CAPABILITY_UNIVERSAL_H_