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); |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame] | 33 | virtual bool IsRegistered(); |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 34 | virtual void SetUnregistered(bool searching); |
Darin Petkov | ac635a8 | 2012-01-10 16:51:58 +0100 | [diff] [blame] | 35 | virtual std::string CreateFriendlyServiceName(); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 36 | virtual std::string GetNetworkTechnologyString() const; |
| 37 | virtual std::string GetRoamingStateString() const; |
Darin Petkov | 3e50924 | 2011-11-10 14:46:44 +0100 | [diff] [blame] | 38 | virtual void GetSignalQuality(); |
Jason Glasgow | 9f09aef | 2012-05-08 16:26:55 -0400 | [diff] [blame] | 39 | virtual std::string GetTypeString() const { |
| 40 | return flimflam::kTechnologyFamilyCdma; |
| 41 | } |
Jason Glasgow | 4c0724a | 2012-04-17 15:47:40 -0400 | [diff] [blame] | 42 | virtual bool AllowRoaming(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 43 | virtual void GetRegistrationState(); |
| 44 | virtual void GetProperties(const ResultCallback &callback); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 45 | virtual void GetMEID(const ResultCallback &callback); |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 46 | |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 47 | uint32 activation_state() const { return activation_state_; } |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 48 | uint32 registration_state_evdo() const { return registration_state_evdo_; } |
| 49 | uint32 registration_state_1x() const { return registration_state_1x_; } |
| 50 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 51 | protected: |
| 52 | virtual void InitProxies(); |
| 53 | virtual void ReleaseProxies(); |
Jason Glasgow | 4380f0d | 2012-05-03 18:05:04 -0400 | [diff] [blame] | 54 | virtual void UpdateStatus(const DBusPropertiesMap &properties); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 55 | |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 56 | private: |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 57 | friend class CellularCapabilityCDMATest; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 58 | friend class CellularTest; |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 59 | FRIEND_TEST(CellularCapabilityCDMATest, Activate); |
| 60 | FRIEND_TEST(CellularCapabilityCDMATest, ActivateError); |
Darin Petkov | ac635a8 | 2012-01-10 16:51:58 +0100 | [diff] [blame] | 61 | FRIEND_TEST(CellularCapabilityCDMATest, CreateFriendlyServiceName); |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 62 | FRIEND_TEST(CellularCapabilityCDMATest, GetActivationStateString); |
| 63 | FRIEND_TEST(CellularCapabilityCDMATest, GetActivationErrorString); |
| 64 | FRIEND_TEST(CellularTest, CreateService); |
| 65 | |
| 66 | static const char kPhoneNumber[]; |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 67 | |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 68 | void HandleNewActivationState(uint32 error); |
| 69 | |
| 70 | // Updates the serving operator on the active service. |
| 71 | void UpdateServingOperator(); |
| 72 | |
| 73 | static std::string GetActivationStateString(uint32 state); |
| 74 | static std::string GetActivationErrorString(uint32 error); |
| 75 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 76 | // Signal callbacks from the Modem.CDMA interface |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 77 | void OnActivationStateChangedSignal( |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 78 | uint32 activation_state, |
| 79 | uint32 activation_error, |
| 80 | const DBusPropertiesMap &status_changes); |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 81 | void OnRegistrationStateChangedSignal( |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 82 | uint32 state_1x, uint32 state_evdo); |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 83 | void OnSignalQualitySignal(uint32 strength); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 84 | |
| 85 | // Method reply callbacks from the Modem.CDMA interface |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 86 | void OnActivateReply(const ResultCallback &callback, |
| 87 | uint32 status, const Error &error); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 88 | |
Nathan Williams | 3022be5 | 2012-04-19 17:40:49 -0400 | [diff] [blame] | 89 | void OnGetRegistrationStateReply(uint32 state_1x, uint32 state_evdo, |
| 90 | const Error &error); |
| 91 | void OnGetSignalQualityReply(uint32 strength, const Error &error); |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 92 | |
| 93 | scoped_ptr<ModemCDMAProxyInterface> proxy_; |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 94 | base::WeakPtrFactory<CellularCapabilityCDMA> weak_ptr_factory_; |
Darin Petkov | a3d3be5 | 2011-11-14 21:34:16 +0100 | [diff] [blame] | 95 | |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 96 | uint32 activation_state_; |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 97 | uint32 registration_state_evdo_; |
| 98 | uint32 registration_state_1x_; |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 99 | uint16 prl_version_; |
Darin Petkov | 381928f | 2012-02-02 23:00:12 +0100 | [diff] [blame] | 100 | CellularService::OLP olp_; |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 101 | std::string usage_url_; |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 102 | |
Darin Petkov | ac635a8 | 2012-01-10 16:51:58 +0100 | [diff] [blame] | 103 | static unsigned int friendly_service_name_id_; |
| 104 | |
Darin Petkov | daf4386 | 2011-10-27 11:37:28 +0200 | [diff] [blame] | 105 | DISALLOW_COPY_AND_ASSIGN(CellularCapabilityCDMA); |
| 106 | }; |
| 107 | |
| 108 | } // namespace shill |
| 109 | |
| 110 | #endif // SHILL_CELLULAR_CAPABILITY_CDMA_ |