Darin Petkov | ac635a8 | 2012-01-10 16:51:58 +0100 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 2 | // 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 Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 8 | #include <base/memory/scoped_ptr.h> |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 9 | #include <base/memory/weak_ptr.h> |
Jason Glasgow | 9f09aef | 2012-05-08 16:26:55 -0400 | [diff] [blame] | 10 | #include <chromeos/dbus/service_constants.h> |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 11 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Darin Petkov | a3d3be5 | 2011-11-14 21:34:16 +0100 | [diff] [blame] | 12 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 13 | #include <string> |
Jason Glasgow | 4c0724a | 2012-04-17 15:47:40 -0400 | [diff] [blame] | 14 | #include <vector> |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 15 | |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 16 | #include "shill/cellular_capability.h" |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 17 | #include "shill/cellular_capability_classic.h" |
Darin Petkov | 381928f | 2012-02-02 23:00:12 +0100 | [diff] [blame] | 18 | #include "shill/cellular_service.h" |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 19 | #include "shill/modem_cdma_proxy_interface.h" |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 20 | |
| 21 | namespace shill { |
| 22 | |
Jason Glasgow | 82f9ab3 | 2012-04-04 14:27:19 -0400 | [diff] [blame] | 23 | class CellularCapabilityCDMA : public CellularCapabilityClassic { |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 24 | public: |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 25 | CellularCapabilityCDMA(Cellular *cellular, ProxyFactory *proxy_factory); |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 26 | |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 27 | // Inherited from CellularCapability. |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 28 | virtual void StartModem(Error *error, const ResultCallback &callback); |
Darin Petkov | 5f316f6 | 2011-11-18 12:10:26 +0100 | [diff] [blame] | 29 | virtual void OnServiceCreated(); |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 30 | virtual void SetupConnectProperties(DBusPropertiesMap *properties); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 31 | virtual void Activate(const std::string &carrier, Error *error, |
| 32 | const ResultCallback &callback); |
Christopher Wiley | 8a46890 | 2012-11-30 11:52:38 -0800 | [diff] [blame] | 33 | virtual void DisconnectCleanup(); |
Christopher Wiley | 1582bdd | 2012-11-15 11:31:14 -0800 | [diff] [blame] | 34 | virtual bool IsActivating() const; |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame] | 35 | virtual bool IsRegistered(); |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 36 | virtual void SetUnregistered(bool searching); |
Darin Petkov | ac635a8 | 2012-01-10 16:51:58 +0100 | [diff] [blame] | 37 | virtual std::string CreateFriendlyServiceName(); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 38 | virtual std::string GetNetworkTechnologyString() const; |
| 39 | virtual std::string GetRoamingStateString() const; |
Darin Petkov | 3e50924 | 2011-11-10 14:46:44 +0100 | [diff] [blame] | 40 | virtual void GetSignalQuality(); |
Jason Glasgow | 9f09aef | 2012-05-08 16:26:55 -0400 | [diff] [blame] | 41 | virtual std::string GetTypeString() const { |
| 42 | return flimflam::kTechnologyFamilyCdma; |
| 43 | } |
Jason Glasgow | 4c0724a | 2012-04-17 15:47:40 -0400 | [diff] [blame] | 44 | virtual bool AllowRoaming(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 45 | virtual void GetRegistrationState(); |
| 46 | virtual void GetProperties(const ResultCallback &callback); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 47 | virtual void GetMEID(const ResultCallback &callback); |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 48 | |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 49 | uint32 activation_state() const { return activation_state_; } |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 50 | uint32 registration_state_evdo() const { return registration_state_evdo_; } |
| 51 | uint32 registration_state_1x() const { return registration_state_1x_; } |
| 52 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 53 | protected: |
| 54 | virtual void InitProxies(); |
| 55 | virtual void ReleaseProxies(); |
Jason Glasgow | 4380f0d | 2012-05-03 18:05:04 -0400 | [diff] [blame] | 56 | virtual void UpdateStatus(const DBusPropertiesMap &properties); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 57 | |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 58 | private: |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 59 | friend class CellularCapabilityCDMATest; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 60 | friend class CellularTest; |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 61 | FRIEND_TEST(CellularCapabilityCDMATest, Activate); |
| 62 | FRIEND_TEST(CellularCapabilityCDMATest, ActivateError); |
Darin Petkov | ac635a8 | 2012-01-10 16:51:58 +0100 | [diff] [blame] | 63 | FRIEND_TEST(CellularCapabilityCDMATest, CreateFriendlyServiceName); |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 64 | FRIEND_TEST(CellularCapabilityCDMATest, GetActivationStateString); |
| 65 | FRIEND_TEST(CellularCapabilityCDMATest, GetActivationErrorString); |
Christopher Wiley | 1582bdd | 2012-11-15 11:31:14 -0800 | [diff] [blame] | 66 | FRIEND_TEST(CellularServiceTest, IsAutoConnectable); |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 67 | FRIEND_TEST(CellularTest, CreateService); |
| 68 | |
| 69 | static const char kPhoneNumber[]; |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 70 | |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 71 | 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 Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 79 | // Signal callbacks from the Modem.CDMA interface |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 80 | void OnActivationStateChangedSignal( |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 81 | uint32 activation_state, |
| 82 | uint32 activation_error, |
| 83 | const DBusPropertiesMap &status_changes); |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 84 | void OnRegistrationStateChangedSignal( |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 85 | uint32 state_1x, uint32 state_evdo); |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 86 | void OnSignalQualitySignal(uint32 strength); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 87 | |
| 88 | // Method reply callbacks from the Modem.CDMA interface |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 89 | void OnActivateReply(const ResultCallback &callback, |
| 90 | uint32 status, const Error &error); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 91 | |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 92 | void OnGetRegistrationStateReply(uint32 state_1x, uint32 state_evdo, |
| 93 | const Error &error); |
| 94 | void OnGetSignalQualityReply(uint32 strength, const Error &error); |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 95 | |
| 96 | scoped_ptr<ModemCDMAProxyInterface> proxy_; |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 97 | base::WeakPtrFactory<CellularCapabilityCDMA> weak_ptr_factory_; |
Darin Petkov | a3d3be5 | 2011-11-14 21:34:16 +0100 | [diff] [blame] | 98 | |
Christopher Wiley | 1582bdd | 2012-11-15 11:31:14 -0800 | [diff] [blame] | 99 | bool activation_starting_; |
Christopher Wiley | 8a46890 | 2012-11-30 11:52:38 -0800 | [diff] [blame] | 100 | ResultCallback pending_activation_callback_; |
| 101 | std::string pending_activation_carrier_; |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 102 | uint32 activation_state_; |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 103 | uint32 registration_state_evdo_; |
| 104 | uint32 registration_state_1x_; |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 105 | uint16 prl_version_; |
Darin Petkov | 381928f | 2012-02-02 23:00:12 +0100 | [diff] [blame] | 106 | CellularService::OLP olp_; |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 107 | std::string usage_url_; |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 108 | |
Darin Petkov | ac635a8 | 2012-01-10 16:51:58 +0100 | [diff] [blame] | 109 | static unsigned int friendly_service_name_id_; |
| 110 | |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 111 | DISALLOW_COPY_AND_ASSIGN(CellularCapabilityCDMA); |
| 112 | }; |
| 113 | |
| 114 | } // namespace shill |
| 115 | |
| 116 | #endif // SHILL_CELLULAR_CAPABILITY_CDMA_ |