blob: f64e31ddbd6ff0b597af0ce186eb73cc5245bb97 [file] [log] [blame]
Darin Petkovac635a82012-01-10 16:51:58 +01001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Darin Petkovdaf43862011-10-27 11:37:28 +02002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef SHILL_CELLULAR_CAPABILITY_CDMA_
6#define SHILL_CELLULAR_CAPABILITY_CDMA_
7
Darin Petkov184c54e2011-11-15 12:44:39 +01008#include <base/memory/scoped_ptr.h>
Eric Shienbrood3e20a232012-02-16 11:35:56 -05009#include <base/memory/weak_ptr.h>
Jason Glasgow9f09aef2012-05-08 16:26:55 -040010#include <chromeos/dbus/service_constants.h>
Darin Petkovae0c64e2011-11-15 15:50:27 +010011#include <gtest/gtest_prod.h> // for FRIEND_TEST
Darin Petkova3d3be52011-11-14 21:34:16 +010012
Jason Glasgow82f9ab32012-04-04 14:27:19 -040013#include <string>
Jason Glasgow4c0724a2012-04-17 15:47:40 -040014#include <vector>
Jason Glasgow82f9ab32012-04-04 14:27:19 -040015
Darin Petkovdaf43862011-10-27 11:37:28 +020016#include "shill/cellular_capability.h"
Jason Glasgow82f9ab32012-04-04 14:27:19 -040017#include "shill/cellular_capability_classic.h"
Darin Petkov381928f2012-02-02 23:00:12 +010018#include "shill/cellular_service.h"
Darin Petkov184c54e2011-11-15 12:44:39 +010019#include "shill/modem_cdma_proxy_interface.h"
Darin Petkovdaf43862011-10-27 11:37:28 +020020
21namespace shill {
22
Jason Glasgow82f9ab32012-04-04 14:27:19 -040023class CellularCapabilityCDMA : public CellularCapabilityClassic {
Darin Petkovdaf43862011-10-27 11:37:28 +020024 public:
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050025 CellularCapabilityCDMA(Cellular *cellular, ProxyFactory *proxy_factory);
Darin Petkovdaf43862011-10-27 11:37:28 +020026
Darin Petkovb05315f2011-11-07 10:14:25 +010027 // Inherited from CellularCapability.
Eric Shienbrood9a245532012-03-07 14:20:39 -050028 virtual void StartModem(Error *error, const ResultCallback &callback);
Darin Petkov5f316f62011-11-18 12:10:26 +010029 virtual void OnServiceCreated();
Darin Petkovae0c64e2011-11-15 15:50:27 +010030 virtual void SetupConnectProperties(DBusPropertiesMap *properties);
Eric Shienbrood9a245532012-03-07 14:20:39 -050031 virtual void Activate(const std::string &carrier, Error *error,
32 const ResultCallback &callback);
Christopher Wiley8a468902012-11-30 11:52:38 -080033 virtual void DisconnectCleanup();
Christopher Wiley1582bdd2012-11-15 11:31:14 -080034 virtual bool IsActivating() const;
Darin Petkovb72cf402011-11-22 14:51:39 +010035 virtual bool IsRegistered();
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040036 virtual void SetUnregistered(bool searching);
Darin Petkovac635a82012-01-10 16:51:58 +010037 virtual std::string CreateFriendlyServiceName();
Darin Petkov20c13ec2011-11-09 15:07:15 +010038 virtual std::string GetNetworkTechnologyString() const;
39 virtual std::string GetRoamingStateString() const;
Darin Petkov3e509242011-11-10 14:46:44 +010040 virtual void GetSignalQuality();
Jason Glasgow9f09aef2012-05-08 16:26:55 -040041 virtual std::string GetTypeString() const {
42 return flimflam::kTechnologyFamilyCdma;
43 }
Jason Glasgow4c0724a2012-04-17 15:47:40 -040044 virtual bool AllowRoaming();
Eric Shienbrood9a245532012-03-07 14:20:39 -050045 virtual void GetRegistrationState();
46 virtual void GetProperties(const ResultCallback &callback);
Eric Shienbrood9a245532012-03-07 14:20:39 -050047 virtual void GetMEID(const ResultCallback &callback);
Darin Petkovcb547732011-11-09 13:55:26 +010048
Darin Petkovae0c64e2011-11-15 15:50:27 +010049 uint32 activation_state() const { return activation_state_; }
Darin Petkov184c54e2011-11-15 12:44:39 +010050 uint32 registration_state_evdo() const { return registration_state_evdo_; }
51 uint32 registration_state_1x() const { return registration_state_1x_; }
52
Eric Shienbrood9a245532012-03-07 14:20:39 -050053 protected:
54 virtual void InitProxies();
55 virtual void ReleaseProxies();
Jason Glasgow4380f0d2012-05-03 18:05:04 -040056 virtual void UpdateStatus(const DBusPropertiesMap &properties);
Eric Shienbrood9a245532012-03-07 14:20:39 -050057
Darin Petkovdaf43862011-10-27 11:37:28 +020058 private:
Darin Petkov184c54e2011-11-15 12:44:39 +010059 friend class CellularCapabilityCDMATest;
Eric Shienbrood9a245532012-03-07 14:20:39 -050060 friend class CellularTest;
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050061 FRIEND_TEST(CellularCapabilityCDMATest, Activate);
62 FRIEND_TEST(CellularCapabilityCDMATest, ActivateError);
Darin Petkovac635a82012-01-10 16:51:58 +010063 FRIEND_TEST(CellularCapabilityCDMATest, CreateFriendlyServiceName);
Darin Petkovae0c64e2011-11-15 15:50:27 +010064 FRIEND_TEST(CellularCapabilityCDMATest, GetActivationStateString);
65 FRIEND_TEST(CellularCapabilityCDMATest, GetActivationErrorString);
Christopher Wiley1582bdd2012-11-15 11:31:14 -080066 FRIEND_TEST(CellularServiceTest, IsAutoConnectable);
Darin Petkovae0c64e2011-11-15 15:50:27 +010067 FRIEND_TEST(CellularTest, CreateService);
68
69 static const char kPhoneNumber[];
Darin Petkov184c54e2011-11-15 12:44:39 +010070
Darin Petkovae0c64e2011-11-15 15:50:27 +010071 void HandleNewActivationState(uint32 error);
72
73 // Updates the serving operator on the active service.
74 void UpdateServingOperator();
75
76 static std::string GetActivationStateString(uint32 state);
77 static std::string GetActivationErrorString(uint32 error);
78
Eric Shienbrood9a245532012-03-07 14:20:39 -050079 // Signal callbacks from the Modem.CDMA interface
Nathan Williams3022be52012-04-19 17:40:49 -040080 void OnActivationStateChangedSignal(
Darin Petkov184c54e2011-11-15 12:44:39 +010081 uint32 activation_state,
82 uint32 activation_error,
83 const DBusPropertiesMap &status_changes);
Nathan Williams3022be52012-04-19 17:40:49 -040084 void OnRegistrationStateChangedSignal(
Eric Shienbrood9a245532012-03-07 14:20:39 -050085 uint32 state_1x, uint32 state_evdo);
Nathan Williams3022be52012-04-19 17:40:49 -040086 void OnSignalQualitySignal(uint32 strength);
Eric Shienbrood9a245532012-03-07 14:20:39 -050087
88 // Method reply callbacks from the Modem.CDMA interface
Nathan Williams3022be52012-04-19 17:40:49 -040089 void OnActivateReply(const ResultCallback &callback,
90 uint32 status, const Error &error);
Eric Shienbrood9a245532012-03-07 14:20:39 -050091
Nathan Williams3022be52012-04-19 17:40:49 -040092 void OnGetRegistrationStateReply(uint32 state_1x, uint32 state_evdo,
93 const Error &error);
94 void OnGetSignalQualityReply(uint32 strength, const Error &error);
Darin Petkov184c54e2011-11-15 12:44:39 +010095
96 scoped_ptr<ModemCDMAProxyInterface> proxy_;
Eric Shienbrood3e20a232012-02-16 11:35:56 -050097 base::WeakPtrFactory<CellularCapabilityCDMA> weak_ptr_factory_;
Darin Petkova3d3be52011-11-14 21:34:16 +010098
Christopher Wiley1582bdd2012-11-15 11:31:14 -080099 bool activation_starting_;
Christopher Wiley8a468902012-11-30 11:52:38 -0800100 ResultCallback pending_activation_callback_;
101 std::string pending_activation_carrier_;
Darin Petkovae0c64e2011-11-15 15:50:27 +0100102 uint32 activation_state_;
Darin Petkov184c54e2011-11-15 12:44:39 +0100103 uint32 registration_state_evdo_;
104 uint32 registration_state_1x_;
Darin Petkovae0c64e2011-11-15 15:50:27 +0100105 uint16 prl_version_;
Darin Petkov381928f2012-02-02 23:00:12 +0100106 CellularService::OLP olp_;
Darin Petkovae0c64e2011-11-15 15:50:27 +0100107 std::string usage_url_;
Darin Petkov184c54e2011-11-15 12:44:39 +0100108
Darin Petkovac635a82012-01-10 16:51:58 +0100109 static unsigned int friendly_service_name_id_;
110
Darin Petkovdaf43862011-10-27 11:37:28 +0200111 DISALLOW_COPY_AND_ASSIGN(CellularCapabilityCDMA);
112};
113
114} // namespace shill
115
116#endif // SHILL_CELLULAR_CAPABILITY_CDMA_