blob: dcc0f9cafcb61175ff9e11545651b55dd2889d6d [file] [log] [blame]
Darin Petkovc64fe5e2012-01-11 12:46:13 +01001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Chris Masone3bd3c8c2011-06-13 08:20:26 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Darin Petkova4ca3c32012-08-17 16:05:24 +02005#ifndef SHILL_CELLULAR_H_
6#define SHILL_CELLULAR_H_
Chris Masone3bd3c8c2011-06-13 08:20:26 -07007
8#include <string>
Jason Glasgow82f9ab32012-04-04 14:27:19 -04009#include <vector>
Chris Masone3bd3c8c2011-06-13 08:20:26 -070010
11#include <base/basictypes.h>
Thieu Le64b0fe52012-08-08 14:57:36 -070012#include <base/memory/weak_ptr.h>
Liam McLoughlin0fec81c2013-02-28 10:31:47 -050013#include <base/gtest_prod_util.h> // for FRIEND_TEST_ALL_PREFIXES
Darin Petkove9d12e02011-07-27 15:09:37 -070014#include <gtest/gtest_prod.h> // for FRIEND_TEST
Chris Masone3bd3c8c2011-06-13 08:20:26 -070015
Darin Petkovc5f56562011-08-06 16:40:05 -070016#include "shill/dbus_properties.h"
Chris Masone3bd3c8c2011-06-13 08:20:26 -070017#include "shill/device.h"
Paul Stewart26b327e2011-10-19 11:38:09 -070018#include "shill/event_dispatcher.h"
Thieu Le26fc01b2013-01-28 12:08:48 -080019#include "shill/metrics.h"
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070020#include "shill/modem_info.h"
Darin Petkovc5f56562011-08-06 16:40:05 -070021#include "shill/modem_proxy_interface.h"
Chris Masone2b105542011-06-22 10:58:09 -070022#include "shill/refptr_types.h"
mukesh agrawal9da07772013-05-15 14:15:17 -070023#include "shill/rpc_task.h"
Chris Masone3bd3c8c2011-06-13 08:20:26 -070024
Darin Petkov137884a2011-10-26 18:52:47 +020025struct mobile_provider_db;
26
Chris Masone3bd3c8c2011-06-13 08:20:26 -070027namespace shill {
28
Darin Petkovdaf43862011-10-27 11:37:28 +020029class CellularCapability;
Darin Petkov4d6d9412011-08-24 13:19:54 -070030class Error;
mukesh agrawal9da07772013-05-15 14:15:17 -070031class ExternalTask;
Darin Petkovab565bb2011-10-06 02:55:51 -070032class ProxyFactory;
Darin Petkove9d12e02011-07-27 15:09:37 -070033
mukesh agrawal9da07772013-05-15 14:15:17 -070034class Cellular : public Device, public RPCTaskDelegate {
Chris Masone3bd3c8c2011-06-13 08:20:26 -070035 public:
Darin Petkove9d12e02011-07-27 15:09:37 -070036 enum Type {
37 kTypeGSM,
David Rochbergfa1d31d2012-03-20 10:38:07 -040038 kTypeCDMA,
39 kTypeUniversal, // ModemManager1
Arman Uguray72fab6a2013-01-10 19:32:42 -080040 kTypeUniversalCDMA,
David Rochbergfa1d31d2012-03-20 10:38:07 -040041 kTypeInvalid,
Darin Petkove9d12e02011-07-27 15:09:37 -070042 };
43
Darin Petkov0828f5f2011-08-11 10:18:52 -070044 // The device states progress linearly from Disabled to Linked.
Darin Petkove9d12e02011-07-27 15:09:37 -070045 enum State {
Darin Petkov0828f5f2011-08-11 10:18:52 -070046 // This is the initial state of the modem and indicates that the modem radio
47 // is not turned on.
Darin Petkove9d12e02011-07-27 15:09:37 -070048 kStateDisabled,
Darin Petkov0828f5f2011-08-11 10:18:52 -070049 // This state indicates that the modem radio is turned on, and it should be
50 // possible to measure signal strength.
Darin Petkove9d12e02011-07-27 15:09:37 -070051 kStateEnabled,
Darin Petkov0828f5f2011-08-11 10:18:52 -070052 // The modem has registered with a network and has signal quality
Darin Petkov51489002011-08-18 13:13:20 -070053 // measurements. A cellular service object is created.
Darin Petkove9d12e02011-07-27 15:09:37 -070054 kStateRegistered,
Darin Petkov0828f5f2011-08-11 10:18:52 -070055 // The modem has connected to a network.
Darin Petkove9d12e02011-07-27 15:09:37 -070056 kStateConnected,
Darin Petkov0828f5f2011-08-11 10:18:52 -070057 // The network interface is UP.
58 kStateLinked,
Darin Petkove9d12e02011-07-27 15:09:37 -070059 };
60
Darin Petkovbac96002011-08-09 13:22:00 -070061 enum ModemState {
62 kModemStateUnknown = 0,
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040063 kModemStateInitializing = 1,
64 kModemStateLocked = 2,
65 kModemStateDisabled = 3,
David Rochbergfa1d31d2012-03-20 10:38:07 -040066 kModemStateDisabling = 4,
67 kModemStateEnabling = 5,
68 kModemStateEnabled = 6,
69 kModemStateSearching = 7,
70 kModemStateRegistered = 8,
71 kModemStateDisconnecting = 9,
72 kModemStateConnecting = 10,
73 kModemStateConnected = 11,
Darin Petkovbac96002011-08-09 13:22:00 -070074 };
75
Darin Petkov3335b372011-08-22 11:05:32 -070076 class Operator {
77 public:
78 Operator();
79 ~Operator();
80
81 void CopyFrom(const Operator &oper);
Darin Petkov9cb02682012-01-28 00:17:38 +010082 bool Equals(const Operator &oper) const { return dict_ == oper.dict_; }
Darin Petkov3335b372011-08-22 11:05:32 -070083
84 const std::string &GetName() const;
85 void SetName(const std::string &name);
86
87 const std::string &GetCode() const;
88 void SetCode(const std::string &code);
89
90 const std::string &GetCountry() const;
91 void SetCountry(const std::string &country);
92
93 const Stringmap &ToDict() const;
94
95 private:
96 Stringmap dict_;
97
98 DISALLOW_COPY_AND_ASSIGN(Operator);
99 };
100
Jason Glasgowa585fc32012-06-06 11:04:09 -0400101 // |owner| is the ModemManager DBus service owner (e.g., ":1.17").
102 // |path| is the ModemManager.Modem DBus object path (e.g.,
Darin Petkove9d12e02011-07-27 15:09:37 -0700103 // "/org/chromium/ModemManager/Gobi/0").
Jason Glasgowa585fc32012-06-06 11:04:09 -0400104 // |service| is the modem mananager service name (e.g.,
Ben Chan8799a4a2013-04-13 16:00:13 -0700105 // /org/chromium/ModemManager or /org/freedesktop/ModemManager1).
Prathmesh Prabhu27526f12013-03-25 19:42:18 -0700106 Cellular(ModemInfo *modem_info,
Darin Petkove9d12e02011-07-27 15:09:37 -0700107 const std::string &link_name,
Chris Masone626719f2011-08-18 16:58:48 -0700108 const std::string &address,
Darin Petkove9d12e02011-07-27 15:09:37 -0700109 int interface_index,
110 Type type,
111 const std::string &owner,
Jason Glasgowa585fc32012-06-06 11:04:09 -0400112 const std::string &service,
Darin Petkov137884a2011-10-26 18:52:47 +0200113 const std::string &path,
Ben Chan3ecdf822012-08-06 12:29:23 -0700114 ProxyFactory *proxy_factory);
Darin Petkove9d12e02011-07-27 15:09:37 -0700115 virtual ~Cellular();
116
Jason Glasgow7b461df2012-05-01 16:38:45 -0400117 // Load configuration for the device from |storage|.
118 virtual bool Load(StoreInterface *storage);
119
120 // Save configuration for the device to |storage|.
121 virtual bool Save(StoreInterface *storage);
122
Darin Petkov4d6d9412011-08-24 13:19:54 -0700123 // Asynchronously connects the modem to the network. Populates |error| on
124 // failure, leaves it unchanged otherwise.
Thieu Le398b1da2013-03-11 17:31:10 -0700125 virtual void Connect(Error *error);
Darin Petkovc5f56562011-08-06 16:40:05 -0700126
Christopher Wiley8a468902012-11-30 11:52:38 -0800127 // Asynchronously disconnects the modem from the network and populates
128 // |error| on failure, leaves it unchanged otherwise.
Christopher Wiley7d0953e2012-11-16 00:37:10 -0800129 virtual void Disconnect(Error *error);
Darin Petkovfb0625e2012-01-16 13:05:56 +0100130
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500131 // Asynchronously activates the modem. Returns an error on failure.
Eric Shienbrood9a245532012-03-07 14:20:39 -0500132 void Activate(const std::string &carrier, Error *error,
133 const ResultCallback &callback);
Darin Petkovc408e692011-08-17 13:47:15 -0700134
Arman Ugurayc7b15602013-02-16 00:56:18 -0800135 // Performs the necessary steps to bring the service to the activated state,
136 // once an online payment has been done.
137 void CompleteActivation(Error *error);
138
Darin Petkov3e509242011-11-10 14:46:44 +0100139 const CellularServiceRefPtr &service() const { return service_; }
140
Darin Petkova0a0efe2012-06-27 12:50:01 +0200141 // Deregisters and destructs the current service and destroys the connection,
142 // if any. This also eliminates the circular references between this device
143 // and the associated service, allowing eventual device destruction.
144 virtual void DestroyService();
145
Darin Petkova3d3be52011-11-14 21:34:16 +0100146 static std::string GetStateString(State state);
147
Darin Petkovac635a82012-01-10 16:51:58 +0100148 std::string CreateFriendlyServiceName();
149
Darin Petkova3d3be52011-11-14 21:34:16 +0100150 State state() const { return state_; }
151
Darin Petkovbac96002011-08-09 13:22:00 -0700152 void set_modem_state(ModemState state) { modem_state_ = state; }
153 ModemState modem_state() const { return modem_state_; }
Eric Shienbrood7fce52c2012-04-13 19:11:02 -0400154 bool IsUnderlyingDeviceEnabled() const;
Thieu Led0012052012-07-25 16:09:09 -0700155 bool IsModemRegistered() const;
Eric Shienbrood7fce52c2012-04-13 19:11:02 -0400156 static bool IsEnabledModemState(ModemState state);
Darin Petkovbac96002011-08-09 13:22:00 -0700157
Darin Petkovdaf43862011-10-27 11:37:28 +0200158 const std::string &dbus_owner() const { return dbus_owner_; }
159 const std::string &dbus_path() const { return dbus_path_; }
160
Darin Petkovae0c64e2011-11-15 15:50:27 +0100161 const Operator &home_provider() const { return home_provider_; }
162 void set_home_provider(const Operator &oper);
Darin Petkov184c54e2011-11-15 12:44:39 +0100163
Darin Petkov3e509242011-11-10 14:46:44 +0100164 void HandleNewSignalQuality(uint32 strength);
165
Darin Petkov184c54e2011-11-15 12:44:39 +0100166 // Processes a change in the modem registration state, possibly creating,
167 // destroying or updating the CellularService.
168 void HandleNewRegistrationState();
169
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400170 virtual void OnDBusPropertiesChanged(
171 const std::string &interface,
172 const DBusPropertiesMap &changed_properties,
173 const std::vector<std::string> &invalidated_properties);
Darin Petkov184c54e2011-11-15 12:44:39 +0100174
Darin Petkove9d12e02011-07-27 15:09:37 -0700175 // Inherited from Device.
Eric Shienbrood9a245532012-03-07 14:20:39 -0500176 virtual void Start(Error *error, const EnabledStateChangedCallback &callback);
177 virtual void Stop(Error *error, const EnabledStateChangedCallback &callback);
Darin Petkov0828f5f2011-08-11 10:18:52 -0700178 virtual void LinkEvent(unsigned int flags, unsigned int change);
Wade Guthrie4823f4f2013-07-25 10:03:03 -0700179 virtual void Scan(ScanType /*scan_type*/, Error *error,
180 const std::string &/*reason*/);
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500181 virtual void RegisterOnNetwork(const std::string &network_id,
Eric Shienbrood9a245532012-03-07 14:20:39 -0500182 Error *error,
183 const ResultCallback &callback);
184 virtual void RequirePIN(const std::string &pin, bool require,
185 Error *error, const ResultCallback &callback);
186 virtual void EnterPIN(const std::string &pin,
187 Error *error, const ResultCallback &callback);
Darin Petkove42e1012011-08-31 12:35:04 -0700188 virtual void UnblockPIN(const std::string &unblock_code,
189 const std::string &pin,
Eric Shienbrood9a245532012-03-07 14:20:39 -0500190 Error *error, const ResultCallback &callback);
Darin Petkove42e1012011-08-31 12:35:04 -0700191 virtual void ChangePIN(const std::string &old_pin,
192 const std::string &new_pin,
Eric Shienbrood9a245532012-03-07 14:20:39 -0500193 Error *error, const ResultCallback &callback);
Ben Chan5d0d32c2013-01-08 02:05:29 -0800194 virtual void Reset(Error *error, const ResultCallback &callback);
Darin Petkovc37a9c42012-09-06 15:28:22 +0200195 virtual void SetCarrier(const std::string &carrier,
196 Error *error, const ResultCallback &callback);
mukesh agrawal5d851b12013-07-11 14:09:41 -0700197 virtual void DropConnection() override;
mukesh agrawal0381f9a2013-07-11 16:41:52 -0700198 virtual void SetServiceState(Service::ConnectState state) override;
199 virtual void SetServiceFailure(Service::ConnectFailure failure_state)
200 override;
201 virtual void SetServiceFailureSilent(Service::ConnectFailure failure_state)
202 override;
203 virtual void OnNoNetworkRouting() override;
Chris Masone3bd3c8c2011-06-13 08:20:26 -0700204
Thieu Le37b90032012-05-15 15:18:41 -0700205 void StartModemCallback(const EnabledStateChangedCallback &callback,
206 const Error &error);
207 void StopModemCallback(const EnabledStateChangedCallback &callback,
208 const Error &error);
Eric Shienbrood7fce52c2012-04-13 19:11:02 -0400209 void OnConnecting();
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500210 void OnConnected();
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -0400211 void OnConnectFailed(const Error &error);
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500212 void OnDisconnected();
213 void OnDisconnectFailed();
Eric Shienbrood0db6a9b2012-03-30 16:11:39 -0400214 std::string GetTechnologyFamily(Error *error);
Eric Shienbrood7fce52c2012-04-13 19:11:02 -0400215 void OnModemStateChanged(ModemState old_state,
216 ModemState new_state,
217 uint32 reason);
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500218
Jason Glasgow7b461df2012-05-01 16:38:45 -0400219 // accessor to read the allow roaming property
220 bool allow_roaming_property() const { return allow_roaming_; }
Christopher Wiley1582bdd2012-11-15 11:31:14 -0800221 // Is the underlying device in the process of activating?
222 bool IsActivating() const;
Jason Glasgow7b461df2012-05-01 16:38:45 -0400223
Arman Ugurayf84a4242013-04-09 20:01:07 -0700224 virtual void OnConnectionHealthCheckerResult(
225 ConnectionHealthChecker::Result result);
226 virtual void PortalDetectorCallback(const PortalDetector::Result &result);
227
mukesh agrawal9da07772013-05-15 14:15:17 -0700228 // Initiate PPP link. Called from capabilities.
229 virtual void StartPPP(const std::string &serial_device);
230 // Callback for |ppp_task_|.
231 virtual void OnPPPDied(pid_t pid, int exit);
232 // Implements RPCTaskDelegate, for |ppp_task_|.
233 virtual void GetLogin(std::string *user, std::string *password) override;
234 virtual void Notify(const std::string &reason,
235 const std::map<std::string, std::string> &dict) override;
236
Chris Masone3bd3c8c2011-06-13 08:20:26 -0700237 private:
Darin Petkovab565bb2011-10-06 02:55:51 -0700238 friend class CellularTest;
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500239 friend class CellularCapabilityTest;
Darin Petkov20c13ec2011-11-09 15:07:15 +0100240 friend class CellularCapabilityCDMATest;
241 friend class CellularCapabilityGSMTest;
Jason Glasgowef965562012-04-10 16:12:35 -0400242 friend class CellularCapabilityUniversalTest;
Arman Uguray72fab6a2013-01-10 19:32:42 -0800243 friend class CellularCapabilityUniversalCDMATest;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400244 friend class CellularServiceTest;
Darin Petkov721ac932011-11-16 15:43:09 +0100245 friend class ModemTest;
Darin Petkovac635a82012-01-10 16:51:58 +0100246 FRIEND_TEST(CellularCapabilityCDMATest, CreateFriendlyServiceName);
Eric Shienbrood9a245532012-03-07 14:20:39 -0500247 FRIEND_TEST(CellularCapabilityCDMATest, GetRegistrationState);
Darin Petkovf508c822012-09-21 13:43:17 +0200248 FRIEND_TEST(CellularCapabilityGSMTest, AllowRoaming);
Darin Petkovac635a82012-01-10 16:51:58 +0100249 FRIEND_TEST(CellularCapabilityGSMTest, CreateFriendlyServiceName);
Darin Petkova4ca3c32012-08-17 16:05:24 +0200250 FRIEND_TEST(CellularCapabilityTest, AllowRoaming);
251 FRIEND_TEST(CellularCapabilityTest, EnableModemFail);
252 FRIEND_TEST(CellularCapabilityTest, EnableModemSucceed);
253 FRIEND_TEST(CellularCapabilityTest, FinishEnable);
254 FRIEND_TEST(CellularCapabilityTest, GetModemInfo);
255 FRIEND_TEST(CellularCapabilityTest, GetModemStatus);
Arman Uguray72fab6a2013-01-10 19:32:42 -0800256 FRIEND_TEST(CellularCapabilityUniversalCDMATest, CreateFriendlyServiceName);
257 FRIEND_TEST(CellularCapabilityUniversalCDMATest, OnCDMARegistrationChanged);
258 FRIEND_TEST(CellularCapabilityUniversalCDMATest, UpdateOLP);
259 FRIEND_TEST(CellularCapabilityUniversalCDMATest, UpdateOperatorInfo);
Arman Uguray1361c032013-02-11 17:53:39 -0800260 FRIEND_TEST(CellularCapabilityUniversalMainTest, AllowRoaming);
261 FRIEND_TEST(CellularCapabilityUniversalMainTest, CreateFriendlyServiceName);
262 FRIEND_TEST(CellularCapabilityUniversalMainTest, Connect);
263 FRIEND_TEST(CellularCapabilityUniversalMainTest, IsServiceActivationRequired);
264 FRIEND_TEST(CellularCapabilityUniversalMainTest, SetHomeProvider);
Thieu Leb9c05e02013-03-04 14:09:32 -0800265 FRIEND_TEST(CellularCapabilityUniversalMainTest, StartModemAlreadyEnabled);
Arman Uguray1361c032013-02-11 17:53:39 -0800266 FRIEND_TEST(CellularCapabilityUniversalMainTest, StopModemConnected);
Arman Uguray0a3e2792013-01-17 16:31:50 -0800267 FRIEND_TEST(CellularCapabilityUniversalMainTest,
268 UpdatePendingActivationState);
Arman Uguray1361c032013-02-11 17:53:39 -0800269 FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateOLP);
270 FRIEND_TEST(CellularCapabilityUniversalMainTest,
271 UpdateOperatorInfoViaOperatorId);
Prathmesh Prabhu8f6479f2013-05-15 12:56:13 -0700272 FRIEND_TEST(CellularCapabilityUniversalMainTest,
273 UpdateRegistrationState);
274 FRIEND_TEST(CellularCapabilityUniversalMainTest,
275 UpdateRegistrationStateModemNotConnected);
Arman Uguray1361c032013-02-11 17:53:39 -0800276 FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateScanningProperty);
Arman Ugurayefea6e02013-02-21 13:28:04 -0800277 FRIEND_TEST(CellularCapabilityUniversalMainTest,
278 UpdateServiceActivationState);
Arman Uguray1361c032013-02-11 17:53:39 -0800279 FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateServiceName);
280 FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateStorageIdentifier);
Darin Petkovac635a82012-01-10 16:51:58 +0100281 FRIEND_TEST(CellularServiceTest, FriendlyName);
mukesh agrawal0381f9a2013-07-11 16:41:52 -0700282 FRIEND_TEST(CellularTest, ChangeServiceState);
283 FRIEND_TEST(CellularTest, ChangeServiceStatePPP);
Darin Petkov3335b372011-08-22 11:05:32 -0700284 FRIEND_TEST(CellularTest, CreateService);
Darin Petkovc5f56562011-08-06 16:40:05 -0700285 FRIEND_TEST(CellularTest, Connect);
Liam McLoughlin0fec81c2013-02-28 10:31:47 -0500286 FRIEND_TEST_ALL_PREFIXES(CellularTest, ConnectAddsTerminationAction);
Eric Shienbroodcc95c5d2012-03-30 15:25:49 -0400287 FRIEND_TEST(CellularTest, ConnectFailure);
Thieu Leb5954a22012-05-18 10:37:34 -0700288 FRIEND_TEST(CellularTest, ConnectFailureNoService);
Thieu Led4974cd2013-05-23 10:39:28 -0700289 FRIEND_TEST(CellularTest, ConnectSuccessNoService);
mukesh agrawalbebf1b82013-04-23 15:06:33 -0700290 FRIEND_TEST(CellularTest, CustomSetterNoopChange);
Darin Petkovfb0625e2012-01-16 13:05:56 +0100291 FRIEND_TEST(CellularTest, DisableModem);
Eric Shienbrood9a245532012-03-07 14:20:39 -0500292 FRIEND_TEST(CellularTest, Disconnect);
Arman Uguray539c4232012-09-11 10:00:22 -0700293 FRIEND_TEST(CellularTest, DisconnectFailure);
Christopher Wiley7d0953e2012-11-16 00:37:10 -0800294 FRIEND_TEST(CellularTest, DisconnectWithCallback);
mukesh agrawal5d851b12013-07-11 14:09:41 -0700295 FRIEND_TEST(CellularTest, DropConnection);
296 FRIEND_TEST(CellularTest, DropConnectionPPP);
Arman Ugurayd42d8ec2013-04-08 19:28:21 -0700297 FRIEND_TEST(CellularTest, EnableTrafficMonitor);
Ben Chan09fa2a02012-11-07 22:09:09 -0800298 FRIEND_TEST(CellularTest,
299 HandleNewRegistrationStateForServiceRequiringActivation);
mukesh agrawalfbc40d22013-06-28 00:25:13 -0700300 FRIEND_TEST(CellularTest, LinkEventUpWithPPP);
301 FRIEND_TEST(CellularTest, LinkEventUpWithoutPPP);
Arman Uguray32c76402012-11-27 14:01:13 -0800302 FRIEND_TEST(CellularTest, LinkEventWontDestroyService);
Eric Shienbrood7fce52c2012-04-13 19:11:02 -0400303 FRIEND_TEST(CellularTest, ModemStateChangeDisable);
304 FRIEND_TEST(CellularTest, ModemStateChangeEnable);
Thieu Led0012052012-07-25 16:09:09 -0700305 FRIEND_TEST(CellularTest, ModemStateChangeStaleConnected);
306 FRIEND_TEST(CellularTest, ModemStateChangeValidConnected);
Arman Ugurayf84a4242013-04-09 20:01:07 -0700307 FRIEND_TEST(CellularTest, OnConnectionHealthCheckerResult);
Darin Petkove7c6ad32012-06-29 10:22:09 +0200308 FRIEND_TEST(CellularTest, SetAllowRoaming);
Thieu Le37b90032012-05-15 15:18:41 -0700309 FRIEND_TEST(CellularTest, StartModemCallback);
310 FRIEND_TEST(CellularTest, StartModemCallbackFail);
311 FRIEND_TEST(CellularTest, StopModemCallback);
312 FRIEND_TEST(CellularTest, StopModemCallbackFail);
Darin Petkovbac96002011-08-09 13:22:00 -0700313 FRIEND_TEST(CellularTest, StartConnected);
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700314 FRIEND_TEST(CellularTest, StartCDMARegister);
Darin Petkov9bac6fe2011-08-26 12:49:05 -0700315 FRIEND_TEST(CellularTest, StartGSMRegister);
Darin Petkov0828f5f2011-08-11 10:18:52 -0700316 FRIEND_TEST(CellularTest, StartLinked);
mukesh agrawal35ec8402013-07-19 14:49:08 -0700317 FRIEND_TEST(CellularTest, StartPPPAfterEthernetUp);
318 FRIEND_TEST(CellularTest, StartPPPWithoutEthernet);
Ben Chan876efd32012-09-28 15:25:13 -0700319 FRIEND_TEST(Modem1Test, CreateDeviceMM1);
Darin Petkove9d12e02011-07-27 15:09:37 -0700320
Jason Glasgow7b461df2012-05-01 16:38:45 -0400321 // Names of properties in storage
322 static const char kAllowRoaming[];
323
Darin Petkov0828f5f2011-08-11 10:18:52 -0700324 void SetState(State state);
325
Darin Petkovbac96002011-08-09 13:22:00 -0700326 // Invoked when the modem is connected to the cellular network to transition
327 // to the network-connected state and bring the network interface up.
328 void EstablishLink();
329
Ben Chan3ecdf822012-08-06 12:29:23 -0700330 void InitCapability(Type type);
Darin Petkovf5f61e02011-07-29 11:35:40 -0700331
Darin Petkovd9661952011-08-03 16:25:42 -0700332 void CreateService();
333
Eric Shienbrood0db6a9b2012-03-30 16:11:39 -0400334 // HelpRegisterDerived*: Expose a property over RPC, with the name |name|.
335 //
336 // Reads of the property will be handled by invoking |get|.
337 // Writes to the property will be handled by invoking |set|.
338 // Clearing the property will be handled by PropertyStore.
Jason Glasgow7b461df2012-05-01 16:38:45 -0400339 void HelpRegisterDerivedBool(
340 const std::string &name,
341 bool(Cellular::*get)(Error *error),
mukesh agrawalbebf1b82013-04-23 15:06:33 -0700342 bool(Cellular::*set)(const bool &value, Error *error));
343 void HelpRegisterConstDerivedString(
Eric Shienbrood0db6a9b2012-03-30 16:11:39 -0400344 const std::string &name,
mukesh agrawalbebf1b82013-04-23 15:06:33 -0700345 std::string(Cellular::*get)(Error *error));
Eric Shienbrood0db6a9b2012-03-30 16:11:39 -0400346
Nathan Williamsb54974f2012-04-19 11:16:30 -0400347 void OnConnectReply(const Error &error);
Christopher Wiley8a468902012-11-30 11:52:38 -0800348 void OnDisconnectReply(const Error &error);
Nathan Williamsb54974f2012-04-19 11:16:30 -0400349
Jason Glasgow7b461df2012-05-01 16:38:45 -0400350 // DBUS accessors to read/modify the allow roaming property
351 bool GetAllowRoaming(Error */*error*/) { return allow_roaming_; }
mukesh agrawalbebf1b82013-04-23 15:06:33 -0700352 bool SetAllowRoaming(const bool &value, Error *error);
Jason Glasgow7b461df2012-05-01 16:38:45 -0400353
Gary Moraina9fb3252012-05-31 12:05:31 -0700354 // When shill terminates or ChromeOS suspends, this function is called to
355 // disconnect from the cellular network.
356 void StartTermination();
357
Arman Uguray539c4232012-09-11 10:00:22 -0700358 // This function does the final cleanup once a disconnect request terminates.
359 // Returns true, if the device state is successfully changed.
360 bool DisconnectCleanup();
361
Thieu Le64b0fe52012-08-08 14:57:36 -0700362 base::WeakPtrFactory<Cellular> weak_ptr_factory_;
363
Darin Petkove9d12e02011-07-27 15:09:37 -0700364 State state_;
Darin Petkovbac96002011-08-09 13:22:00 -0700365 ModemState modem_state_;
Darin Petkove9d12e02011-07-27 15:09:37 -0700366
Darin Petkovdaf43862011-10-27 11:37:28 +0200367 scoped_ptr<CellularCapability> capability_;
368
Jason Glasgowa585fc32012-06-06 11:04:09 -0400369 const std::string dbus_owner_; // :x.y
370 const std::string dbus_service_; // org.*.ModemManager*
Darin Petkove9d12e02011-07-27 15:09:37 -0700371 const std::string dbus_path_; // ModemManager.Modem
Darin Petkovbec79a22011-08-01 14:47:17 -0700372
Prathmesh Prabhu27526f12013-03-25 19:42:18 -0700373 ModemInfo *modem_info_;
Ben Chan3ecdf822012-08-06 12:29:23 -0700374 ProxyFactory *proxy_factory_;
Darin Petkov137884a2011-10-26 18:52:47 +0200375
Darin Petkovd9661952011-08-03 16:25:42 -0700376 CellularServiceRefPtr service_;
Chris Masone853b81b2011-06-24 14:11:41 -0700377
Chris Masoneb925cc82011-06-22 15:39:57 -0700378 // Properties
Darin Petkov3335b372011-08-22 11:05:32 -0700379 Operator home_provider_;
Chris Masoneb925cc82011-06-22 15:39:57 -0700380
Jason Glasgow7b461df2012-05-01 16:38:45 -0400381 // User preference to allow or disallow roaming
382 bool allow_roaming_;
383
Thieu Le26fc01b2013-01-28 12:08:48 -0800384 // Flag indicating that a disconnect has been explicitly requested.
385 bool explicit_disconnect_;
386
mukesh agrawal9da07772013-05-15 14:15:17 -0700387 scoped_ptr<ExternalTask> ppp_task_;
388 PPPDeviceRefPtr ppp_device_;
389
Chris Masone3bd3c8c2011-06-13 08:20:26 -0700390 DISALLOW_COPY_AND_ASSIGN(Cellular);
391};
392
393} // namespace shill
394
Darin Petkova4ca3c32012-08-17 16:05:24 +0200395#endif // SHILL_CELLULAR_H_