1 //
2 // Copyright (C) 2012 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef SHILL_CELLULAR_CELLULAR_H_
18 #define SHILL_CELLULAR_CELLULAR_H_
19 
20 #include <map>
21 #include <memory>
22 #include <string>
23 #include <vector>
24 
25 #include <base/macros.h>
26 #include <base/memory/weak_ptr.h>
27 #include <gtest/gtest_prod.h>  // for FRIEND_TEST
28 
29 #include "shill/cellular/mobile_operator_info.h"
30 #include "shill/cellular/modem_info.h"
31 #include "shill/cellular/modem_proxy_interface.h"
32 #include "shill/device.h"
33 #include "shill/event_dispatcher.h"
34 #include "shill/metrics.h"
35 #include "shill/refptr_types.h"
36 #include "shill/rpc_task.h"
37 
38 namespace shill {
39 
40 class CellularCapability;
41 class Error;
42 class ExternalTask;
43 class MobileOperatorInfo;
44 class PPPDeviceFactory;
45 class ProcessManager;
46 
47 class Cellular : public Device, public RPCTaskDelegate {
48  public:
49   enum Type {
50     kTypeGSM,
51     kTypeCDMA,
52     kTypeUniversal,  // ModemManager1
53     kTypeUniversalCDMA,
54     kTypeInvalid,
55   };
56 
57   // The device states progress linearly from Disabled to Linked.
58   enum State {
59     // This is the initial state of the modem and indicates that the modem radio
60     // is not turned on.
61     kStateDisabled,
62     // This state indicates that the modem radio is turned on, and it should be
63     // possible to measure signal strength.
64     kStateEnabled,
65     // The modem has registered with a network and has signal quality
66     // measurements. A cellular service object is created.
67     kStateRegistered,
68     // The modem has connected to a network.
69     kStateConnected,
70     // The network interface is UP.
71     kStateLinked,
72   };
73 
74   // This enum must be kept in sync with ModemManager's MMModemState enum.
75   enum ModemState {
76     kModemStateFailed = -1,
77     kModemStateUnknown = 0,
78     kModemStateInitializing = 1,
79     kModemStateLocked = 2,
80     kModemStateDisabled = 3,
81     kModemStateDisabling = 4,
82     kModemStateEnabling = 5,
83     kModemStateEnabled = 6,
84     kModemStateSearching = 7,
85     kModemStateRegistered = 8,
86     kModemStateDisconnecting = 9,
87     kModemStateConnecting = 10,
88     kModemStateConnected = 11,
89   };
90 
91   // |path| is the ModemManager.Modem DBus object path (e.g.,
92   // "/org/chromium/ModemManager/Gobi/0").
93   // |service| is the modem mananager service name (e.g.,
94   // /org/chromium/ModemManager or /org/freedesktop/ModemManager1).
95   Cellular(ModemInfo* modem_info,
96            const std::string& link_name,
97            const std::string& address,
98            int interface_index,
99            Type type,
100            const std::string& service,
101            const std::string& path);
102   ~Cellular() override;
103 
104   // Load configuration for the device from |storage|.
105   bool Load(StoreInterface* storage) override;
106 
107   // Save configuration for the device to |storage|.
108   bool Save(StoreInterface* storage) override;
109 
110   // Asynchronously connects the modem to the network. Populates |error| on
111   // failure, leaves it unchanged otherwise.
112   virtual void Connect(Error* error);
113 
114   // Asynchronously disconnects the modem from the network and populates
115   // |error| on failure, leaves it unchanged otherwise.
116   virtual void Disconnect(Error* error, const char* reason);
117 
118   // Asynchronously activates the modem. Returns an error on failure.
119   void Activate(const std::string& carrier, Error* error,
120                 const ResultCallback& callback);
121 
122   // Performs the necessary steps to bring the service to the activated state,
123   // once an online payment has been done.
124   void CompleteActivation(Error* error);
125 
service()126   const CellularServiceRefPtr& service() const { return service_; }
home_provider_info()127   MobileOperatorInfo* home_provider_info() const {
128     return home_provider_info_.get();
129   }
serving_operator_info()130   MobileOperatorInfo* serving_operator_info() const {
131     return serving_operator_info_.get();
132   }
133 
134   // Deregisters and destructs the current service and destroys the connection,
135   // if any. This also eliminates the circular references between this device
136   // and the associated service, allowing eventual device destruction.
137   virtual void DestroyService();
138 
139   static std::string GetStateString(State state);
140   static std::string GetModemStateString(ModemState modem_state);
141 
142   std::string CreateDefaultFriendlyServiceName();
143   bool IsDefaultFriendlyServiceName(const std::string& service_name) const;
144 
145   // Update the home provider from the information in |operator_info|. This
146   // information may be from the SIM / received OTA.
147   void UpdateHomeProvider(const MobileOperatorInfo* operator_info);
148   // Update the serving operator using information in |operator_info|.
149   // Additionally, if |home_provider_info| is not nullptr, use it to come up
150   // with a better name.
151   void UpdateServingOperator(const MobileOperatorInfo* operator_info,
152                              const MobileOperatorInfo* home_provider_info);
153 
state()154   State state() const { return state_; }
155 
set_modem_state(ModemState state)156   void set_modem_state(ModemState state) { modem_state_ = state; }
modem_state()157   ModemState modem_state() const { return modem_state_; }
158   bool IsUnderlyingDeviceEnabled() const override;
159   bool IsModemRegistered() const;
160   static bool IsEnabledModemState(ModemState state);
161 
162   void HandleNewSignalQuality(uint32_t strength);
163 
164   // Processes a change in the modem registration state, possibly creating,
165   // destroying or updating the CellularService.
166   void HandleNewRegistrationState();
167 
168   virtual void OnPropertiesChanged(
169       const std::string& interface,
170       const KeyValueStore& changed_properties,
171       const std::vector<std::string>& invalidated_properties);
172 
173   // Inherited from Device.
174   void Start(Error* error,
175              const EnabledStateChangedCallback& callback) override;
176   void Stop(Error* error, const EnabledStateChangedCallback& callback) override;
177   void LinkEvent(unsigned int flags, unsigned int change) override;
178   void Scan(ScanType /*scan_type*/, Error* error,
179             const std::string& /*reason*/) override;
180   void RegisterOnNetwork(const std::string& network_id,
181                          Error* error,
182                          const ResultCallback& callback) override;
183   void RequirePIN(const std::string& pin, bool require,
184                   Error* error, const ResultCallback& callback) override;
185   void EnterPIN(const std::string& pin,
186                 Error* error, const ResultCallback& callback) override;
187   void UnblockPIN(const std::string& unblock_code,
188                   const std::string& pin,
189                   Error* error, const ResultCallback& callback) override;
190   void ChangePIN(const std::string& old_pin,
191                  const std::string& new_pin,
192                  Error* error, const ResultCallback& callback) override;
193   void Reset(Error* error, const ResultCallback& callback) override;
194   void SetCarrier(const std::string& carrier,
195                   Error* error, const ResultCallback& callback) override;
196   bool IsIPv6Allowed() const override;
197   void DropConnection() override;
198   void SetServiceState(Service::ConnectState state) override;
199   void SetServiceFailure(Service::ConnectFailure failure_state) override;
200   void SetServiceFailureSilent(Service::ConnectFailure failure_state) override;
201   void OnBeforeSuspend(const ResultCallback& callback) override;
202   void OnAfterResume() override;
203 
204   void StartModemCallback(const EnabledStateChangedCallback& callback,
205                           const Error& error);
206   void StopModemCallback(const EnabledStateChangedCallback& callback,
207                          const Error& error);
208   void OnDisabled();
209   void OnEnabled();
210   void OnConnecting();
211   void OnConnected() override;
212   void OnConnectFailed(const Error& error);
213   void OnDisconnected();
214   void OnDisconnectFailed();
215   std::string GetTechnologyFamily(Error* error);
216   void OnModemStateChanged(ModemState new_state);
217   void OnScanReply(const Stringmaps& found_networks, const Error& error);
218 
219   // accessor to read the allow roaming property
allow_roaming_property()220   bool allow_roaming_property() const { return allow_roaming_; }
221   // Is the underlying device in the process of activating?
222   bool IsActivating() const;
223 
224   // Initiate PPP link. Called from capabilities.
225   virtual void StartPPP(const std::string& serial_device);
226   // Callback for |ppp_task_|.
227   virtual void OnPPPDied(pid_t pid, int exit);
228   // Implements RPCTaskDelegate, for |ppp_task_|.
229   void GetLogin(std::string* user, std::string* password) override;
230   void Notify(const std::string& reason,
231               const std::map<std::string, std::string>& dict) override;
232 
233   // ///////////////////////////////////////////////////////////////////////////
234   // DBus Properties exposed by the Device interface of shill.
235   void RegisterProperties();
236 
237   // getters
dbus_service()238   const std::string& dbus_service() const { return dbus_service_; }
dbus_path()239   const std::string& dbus_path() const { return dbus_path_; }
home_provider()240   const Stringmap& home_provider() const { return home_provider_; }
carrier()241   const std::string& carrier() const { return carrier_; }
scanning_supported()242   bool scanning_supported() const { return scanning_supported_; }
esn()243   const std::string& esn() const { return esn_; }
firmware_revision()244   const std::string& firmware_revision() const { return firmware_revision_; }
hardware_revision()245   const std::string& hardware_revision() const { return hardware_revision_; }
imei()246   const std::string& imei() const { return imei_; }
imsi()247   const std::string& imsi() const { return imsi_; }
mdn()248   const std::string& mdn() const { return mdn_; }
meid()249   const std::string& meid() const { return meid_; }
min()250   const std::string& min() const { return min_; }
manufacturer()251   const std::string& manufacturer() const { return manufacturer_; }
model_id()252   const std::string& model_id() const { return model_id_; }
mm_plugin()253   const std::string& mm_plugin() const { return mm_plugin_; }
scanning()254   bool scanning() const { return scanning_; }
255 
selected_network()256   const std::string& selected_network() const { return selected_network_; }
found_networks()257   const Stringmaps& found_networks() const { return found_networks_; }
provider_requires_roaming()258   bool provider_requires_roaming() const { return provider_requires_roaming_; }
sim_present()259   bool sim_present() const { return sim_present_; }
apn_list()260   const Stringmaps& apn_list() const { return apn_list_; }
sim_identifier()261   const std::string& sim_identifier() const { return sim_identifier_; }
262 
supported_carriers()263   const Strings& supported_carriers() const { return supported_carriers_; }
prl_version()264   uint16_t prl_version() const { return prl_version_; }
265 
266   // setters
267   void set_home_provider(const Stringmap& home_provider);
268   void set_carrier(const std::string& carrier);
269   void set_scanning_supported(bool scanning_supported);
270   void set_esn(const std::string& esn);
271   void set_firmware_revision(const std::string& firmware_revision);
272   void set_hardware_revision(const std::string& hardware_revision);
273   void set_imei(const std::string& imei);
274   void set_imsi(const std::string& imsi);
275   void set_mdn(const std::string& mdn);
276   void set_meid(const std::string& meid);
277   void set_min(const std::string& min);
278   void set_manufacturer(const std::string& manufacturer);
279   void set_model_id(const std::string& model_id);
280   void set_mm_plugin(const std::string& mm_plugin);
281   void set_scanning(bool scanning);
282 
283   void set_selected_network(const std::string& selected_network);
284   void clear_found_networks();
285   void set_found_networks(const Stringmaps& found_networks);
286   void set_provider_requires_roaming(bool provider_requires_roaming);
287   void set_sim_present(bool sim_present);
288   void set_apn_list(const Stringmaps& apn_list);
289   void set_sim_identifier(const std::string& sim_identifier);
290 
291   void set_supported_carriers(const Strings& supported_carriers);
292   void set_prl_version(uint16_t prl_version);
293 
294   // Takes ownership.
295   void set_home_provider_info(MobileOperatorInfo* home_provider_info);
296   // Takes ownership.
297   void set_serving_operator_info(MobileOperatorInfo* serving_operator_info);
298 
299  private:
300   friend class ActivePassiveOutOfCreditsDetectorTest;
301   friend class CellularTest;
302   friend class CellularCapabilityTest;
303   friend class CellularCapabilityCDMATest;
304   friend class CellularCapabilityGSMTest;
305   friend class CellularCapabilityUniversalTest;
306   friend class CellularCapabilityUniversalCDMATest;
307   friend class CellularServiceTest;
308   friend class ModemTest;
309   friend class SubscriptionStateOutOfCreditsDetectorTest;
310   FRIEND_TEST(CellularCapabilityCDMATest, GetRegistrationState);
311   FRIEND_TEST(CellularCapabilityGSMTest, AllowRoaming);
312   FRIEND_TEST(CellularCapabilityTest, AllowRoaming);
313   FRIEND_TEST(CellularCapabilityTest, EnableModemFail);
314   FRIEND_TEST(CellularCapabilityTest, EnableModemSucceed);
315   FRIEND_TEST(CellularCapabilityTest, FinishEnable);
316   FRIEND_TEST(CellularCapabilityTest, GetModemInfo);
317   FRIEND_TEST(CellularCapabilityTest, GetModemStatus);
318   FRIEND_TEST(CellularCapabilityUniversalCDMATest, OnCDMARegistrationChanged);
319   FRIEND_TEST(CellularCapabilityUniversalMainTest, AllowRoaming);
320   FRIEND_TEST(CellularCapabilityUniversalMainTest, Connect);
321   FRIEND_TEST(CellularCapabilityUniversalMainTest, IsServiceActivationRequired);
322   FRIEND_TEST(CellularCapabilityUniversalMainTest, StartModemAlreadyEnabled);
323   FRIEND_TEST(CellularCapabilityUniversalMainTest, StopModemConnected);
324   FRIEND_TEST(CellularCapabilityUniversalMainTest,
325               UpdatePendingActivationState);
326   FRIEND_TEST(CellularCapabilityUniversalMainTest,
327               UpdateRegistrationState);
328   FRIEND_TEST(CellularCapabilityUniversalMainTest,
329               UpdateRegistrationStateModemNotConnected);
330   FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateScanningProperty);
331   FRIEND_TEST(CellularCapabilityUniversalMainTest,
332               UpdateServiceActivationState);
333   FRIEND_TEST(CellularTest, ChangeServiceState);
334   FRIEND_TEST(CellularTest, ChangeServiceStatePPP);
335   FRIEND_TEST(CellularTest, CreateService);
336   FRIEND_TEST(CellularTest, Connect);
337   FRIEND_TEST(CellularTest, ConnectFailure);
338   FRIEND_TEST(CellularTest, ConnectFailureNoService);
339   FRIEND_TEST(CellularTest, ConnectSuccessNoService);
340   FRIEND_TEST(CellularTest, CustomSetterNoopChange);
341   FRIEND_TEST(CellularTest, DisableModem);
342   FRIEND_TEST(CellularTest, Disconnect);
343   FRIEND_TEST(CellularTest, DisconnectFailure);
344   FRIEND_TEST(CellularTest, DisconnectWithCallback);
345   FRIEND_TEST(CellularTest, DropConnection);
346   FRIEND_TEST(CellularTest, DropConnectionPPP);
347   FRIEND_TEST(CellularTest, EnableTrafficMonitor);
348   FRIEND_TEST(CellularTest, EstablishLinkDHCP);
349   FRIEND_TEST(CellularTest, EstablishLinkPPP);
350   FRIEND_TEST(CellularTest, EstablishLinkStatic);
351   FRIEND_TEST(CellularTest, FriendlyServiceName);
352   FRIEND_TEST(CellularTest,
353               HandleNewRegistrationStateForServiceRequiringActivation);
354   FRIEND_TEST(CellularTest, HomeProviderServingOperator);
355   FRIEND_TEST(CellularTest, LinkEventUpWithPPP);
356   FRIEND_TEST(CellularTest, LinkEventUpWithoutPPP);
357   FRIEND_TEST(CellularTest, LinkEventWontDestroyService);
358   FRIEND_TEST(CellularTest, ModemStateChangeDisable);
359   FRIEND_TEST(CellularTest, ModemStateChangeEnable);
360   FRIEND_TEST(CellularTest, ModemStateChangeStaleConnected);
361   FRIEND_TEST(CellularTest, ModemStateChangeValidConnected);
362   FRIEND_TEST(CellularTest, Notify);
363   FRIEND_TEST(CellularTest, OnAfterResumeDisableInProgressWantDisabled);
364   FRIEND_TEST(CellularTest, OnAfterResumeDisableQueuedWantEnabled);
365   FRIEND_TEST(CellularTest, OnAfterResumeDisabledWantDisabled);
366   FRIEND_TEST(CellularTest, OnAfterResumeDisabledWantEnabled);
367   FRIEND_TEST(CellularTest, OnAfterResumePowerDownInProgressWantEnabled);
368   FRIEND_TEST(CellularTest, OnConnectionHealthCheckerResult);
369   FRIEND_TEST(CellularTest, OnPPPDied);
370   FRIEND_TEST(CellularTest, PPPConnectionFailedAfterAuth);
371   FRIEND_TEST(CellularTest, PPPConnectionFailedBeforeAuth);
372   FRIEND_TEST(CellularTest, PPPConnectionFailedDuringAuth);
373   FRIEND_TEST(CellularTest, ScanAsynchronousFailure);
374   FRIEND_TEST(CellularTest, ScanImmediateFailure);
375   FRIEND_TEST(CellularTest, ScanSuccess);
376   FRIEND_TEST(CellularTest, SetAllowRoaming);
377   FRIEND_TEST(CellularTest, StartModemCallback);
378   FRIEND_TEST(CellularTest, StartModemCallbackFail);
379   FRIEND_TEST(CellularTest, StopModemCallback);
380   FRIEND_TEST(CellularTest, StopModemCallbackFail);
381   FRIEND_TEST(CellularTest, StopPPPOnDisconnect);
382   FRIEND_TEST(CellularTest, StopPPPOnTermination);
383   FRIEND_TEST(CellularTest, StorageIdentifier);
384   FRIEND_TEST(CellularTest, StartConnected);
385   FRIEND_TEST(CellularTest, StartCDMARegister);
386   FRIEND_TEST(CellularTest, StartGSMRegister);
387   FRIEND_TEST(CellularTest, StartLinked);
388   FRIEND_TEST(CellularTest, StartPPP);
389   FRIEND_TEST(CellularTest, StartPPPAfterEthernetUp);
390   FRIEND_TEST(CellularTest, StartPPPAlreadyStarted);
391   FRIEND_TEST(CellularTest, UpdateScanning);
392   FRIEND_TEST(Modem1Test, CreateDeviceMM1);
393 
394   class MobileOperatorInfoObserver : public MobileOperatorInfo::Observer {
395    public:
396     // |cellular| must have lifespan longer than this object. In practice this
397     // is enforced because |cellular| owns this object.
398     explicit MobileOperatorInfoObserver(Cellular* cellular);
399     ~MobileOperatorInfoObserver() override;
400 
set_capability(CellularCapability * capability)401     void set_capability(CellularCapability* capability) {
402       capability_ = capability;
403     }
404 
405     // Inherited from MobileOperatorInfo::Observer
406     void OnOperatorChanged() override;
407 
408    private:
409     Cellular* const cellular_;
410     // Owned by |Cellular|.
411     CellularCapability* capability_;
412 
413     DISALLOW_COPY_AND_ASSIGN(MobileOperatorInfoObserver);
414   };
415 
416   // Names of properties in storage
417   static const char kAllowRoaming[];
418 
419   // the |kScanningProperty| exposed by Cellular device is sticky false. Every
420   // time it is set to true, it must be reset to false after a time equal to
421   // this constant.
422   static const int64_t kDefaultScanningTimeoutMilliseconds;
423 
424   // Generic service name prefix, shown when the correct carrier name is
425   // unknown.
426   static const char kGenericServiceNamePrefix[];
427   static unsigned int friendly_service_name_id_;
428 
429   void SetState(State state);
430 
431   // Invoked when the modem is connected to the cellular network to transition
432   // to the network-connected state and bring the network interface up.
433   void EstablishLink();
434 
435   void InitCapability(Type type);
436 
437   void CreateService();
438 
439   // HelpRegisterDerived*: Expose a property over RPC, with the name |name|.
440   //
441   // Reads of the property will be handled by invoking |get|.
442   // Writes to the property will be handled by invoking |set|.
443   // Clearing the property will be handled by PropertyStore.
444   void HelpRegisterDerivedBool(
445       const std::string& name,
446       bool(Cellular::*get)(Error* error),
447       bool(Cellular::*set)(const bool& value, Error* error));
448   void HelpRegisterConstDerivedString(
449       const std::string& name,
450       std::string(Cellular::*get)(Error* error));
451 
452   void OnConnectReply(const Error& error);
453   void OnDisconnectReply(const Error& error);
454 
455   // DBUS accessors to read/modify the allow roaming property
GetAllowRoaming(Error *)456   bool GetAllowRoaming(Error* /*error*/) { return allow_roaming_; }
457   bool SetAllowRoaming(const bool& value, Error* error);
458 
459   // When shill terminates or ChromeOS suspends, this function is called to
460   // disconnect from the cellular network.
461   void StartTermination();
462 
463   // This method is invoked upon the completion of StartTermination().
464   void OnTerminationCompleted(const Error& error);
465 
466   // This function does the final cleanup once a disconnect request terminates.
467   // Returns true, if the device state is successfully changed.
468   bool DisconnectCleanup();
469 
470   // Executed after the asynchronous CellularCapability::StartModem
471   // call from OnAfterResume completes.
472   static void LogRestartModemResult(const Error& error);
473 
474   // Terminate the pppd process associated with this Device, and remove the
475   // association between the PPPDevice and our CellularService. If this
476   // Device is not using PPP, the method has no effect.
477   void StopPPP();
478 
479   // Handlers for PPP events. Dispatched from Notify().
480   void OnPPPAuthenticated();
481   void OnPPPAuthenticating();
482   void OnPPPConnected(const std::map<std::string, std::string>& params);
483   void OnPPPDisconnected();
484 
485   void UpdateScanning();
486 
487   base::WeakPtrFactory<Cellular> weak_ptr_factory_;
488 
489   State state_;
490   ModemState modem_state_;
491 
492   std::unique_ptr<CellularCapability> capability_;
493 
494   // Operator info objects. These objects receive updates as we receive
495   // information about the network operators from the SIM or OTA. In turn, they
496   // send out updates through their observer interfaces whenever the identity of
497   // the network operator changes, or any other property of the operator
498   // changes.
499   std::unique_ptr<MobileOperatorInfo> home_provider_info_;
500   std::unique_ptr<MobileOperatorInfo> serving_operator_info_;
501   // Observer object to listen to updates from the operator info objects.
502   std::unique_ptr<MobileOperatorInfoObserver> mobile_operator_info_observer_;
503 
504   // ///////////////////////////////////////////////////////////////////////////
505   // All DBus Properties exposed by the Cellular device.
506   // Properties common to GSM and CDMA modems.
507   const std::string dbus_service_;  // org.*.ModemManager*
508   const std::string dbus_path_;  // ModemManager.Modem
509   Stringmap home_provider_;
510 
511   bool scanning_supported_;
512   std::string carrier_;
513   std::string esn_;
514   std::string firmware_revision_;
515   std::string hardware_revision_;
516   std::string imei_;
517   std::string imsi_;
518   std::string manufacturer_;
519   std::string mdn_;
520   std::string meid_;
521   std::string min_;
522   std::string model_id_;
523   std::string mm_plugin_;
524   bool scanning_;
525 
526   // GSM only properties.
527   // They are always exposed but are non empty only for GSM technology modems.
528   std::string selected_network_;
529   Stringmaps found_networks_;
530   bool provider_requires_roaming_;
531   uint16_t scan_interval_;
532   bool sim_present_;
533   Stringmaps apn_list_;
534   std::string sim_identifier_;
535 
536   // CDMA only properties.
537   uint16_t prl_version_;
538 
539   // This property is specific to Gobi modems.
540   Strings supported_carriers_;
541   // End of DBus properties.
542   // ///////////////////////////////////////////////////////////////////////////
543 
544   ModemInfo* modem_info_;
545   const Type type_;
546   PPPDeviceFactory* ppp_device_factory_;
547 
548   ProcessManager* process_manager_;
549 
550   CellularServiceRefPtr service_;
551 
552   // User preference to allow or disallow roaming
553   bool allow_roaming_;
554 
555   // Track whether a user initiated scan is in prgoress (initiated via ::Scan)
556   bool proposed_scan_in_progress_;
557 
558   // Flag indicating that a disconnect has been explicitly requested.
559   bool explicit_disconnect_;
560 
561   std::unique_ptr<ExternalTask> ppp_task_;
562   PPPDeviceRefPtr ppp_device_;
563   bool is_ppp_authenticating_;
564 
565   // Sometimes modems may be stuck in the SEARCHING state during the lack of
566   // presence of a network. During this indefinite duration of time, keeping
567   // the Device.Scanning property as |true| causes a bad user experience.
568   // This callback sets it to |false| after a timeout period has passed.
569   base::CancelableClosure scanning_timeout_callback_;
570   int64_t scanning_timeout_milliseconds_;
571 
572   DISALLOW_COPY_AND_ASSIGN(Cellular);
573 };
574 
575 }  // namespace shill
576 
577 #endif  // SHILL_CELLULAR_CELLULAR_H_
578