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_CAPABILITY_CDMA_H_ 18 #define SHILL_CELLULAR_CELLULAR_CAPABILITY_CDMA_H_ 19 20 #include <memory> 21 #include <string> 22 #include <vector> 23 24 #include <base/memory/weak_ptr.h> 25 #if defined(__ANDROID__) 26 #include <dbus/service_constants.h> 27 #else 28 #include <chromeos/dbus/service_constants.h> 29 #endif // __ANDROID__ 30 #include <gtest/gtest_prod.h> // for FRIEND_TEST 31 32 #include "shill/cellular/cellular_capability.h" 33 #include "shill/cellular/cellular_capability_classic.h" 34 #include "shill/cellular/cellular_service.h" 35 #include "shill/cellular/modem_cdma_proxy_interface.h" 36 37 namespace shill { 38 39 class ModemInfo; 40 41 class CellularCapabilityCDMA : public CellularCapabilityClassic { 42 public: 43 CellularCapabilityCDMA(Cellular* cellular, 44 ControlInterface* control_interface, 45 ModemInfo* modem_info); 46 ~CellularCapabilityCDMA() override; 47 48 // Inherited from CellularCapability. 49 std::string GetTypeString() const override; 50 void StartModem(Error* error, 51 const ResultCallback& callback) override; 52 bool AreProxiesInitialized() const override; 53 void Activate(const std::string& carrier, 54 Error* error, 55 const ResultCallback& callback) override; 56 bool IsActivating() const override; 57 bool IsRegistered() const override; 58 void SetUnregistered(bool searching) override; 59 void OnServiceCreated() override; 60 std::string GetNetworkTechnologyString() const override; 61 std::string GetRoamingStateString() const override; 62 bool AllowRoaming() override; 63 void GetSignalQuality() override; 64 void SetupConnectProperties(KeyValueStore* properties) override; 65 void DisconnectCleanup() override; 66 67 // Inherited from CellularCapabilityClassic. 68 void GetRegistrationState() override; 69 void GetProperties(const ResultCallback& callback) override; 70 71 virtual void GetMEID(const ResultCallback& callback); 72 activation_state()73 uint32_t activation_state() const { return activation_state_; } registration_state_evdo()74 uint32_t registration_state_evdo() const { return registration_state_evdo_; } registration_state_1x()75 uint32_t registration_state_1x() const { return registration_state_1x_; } 76 77 protected: 78 // Inherited from CellularCapabilityClassic. 79 void InitProxies() override; 80 void ReleaseProxies() override; 81 void UpdateStatus(const KeyValueStore& properties) override; 82 83 private: 84 friend class CellularCapabilityCDMATest; 85 friend class CellularTest; 86 FRIEND_TEST(CellularCapabilityCDMATest, Activate); 87 FRIEND_TEST(CellularCapabilityCDMATest, ActivateError); 88 FRIEND_TEST(CellularCapabilityCDMATest, GetActivationStateString); 89 FRIEND_TEST(CellularCapabilityCDMATest, GetActivationErrorString); 90 FRIEND_TEST(CellularServiceTest, IsAutoConnectable); 91 FRIEND_TEST(CellularTest, CreateService); 92 93 static const char kPhoneNumber[]; 94 95 void HandleNewActivationState(uint32_t error); 96 97 static std::string GetActivationStateString(uint32_t state); 98 static std::string GetActivationErrorString(uint32_t error); 99 100 // Signal callbacks from the Modem.CDMA interface 101 void OnActivationStateChangedSignal( 102 uint32_t activation_state, 103 uint32_t activation_error, 104 const KeyValueStore& status_changes); 105 void OnRegistrationStateChangedSignal( 106 uint32_t state_1x, uint32_t state_evdo); 107 void OnSignalQualitySignal(uint32_t strength); 108 109 // Method reply callbacks from the Modem.CDMA interface 110 void OnActivateReply(const ResultCallback& callback, 111 uint32_t status, const Error& error); 112 113 void OnGetRegistrationStateReply(uint32_t state_1x, uint32_t state_evdo, 114 const Error& error); 115 void OnGetSignalQualityReply(uint32_t strength, const Error& error); 116 117 std::unique_ptr<ModemCDMAProxyInterface> proxy_; 118 base::WeakPtrFactory<CellularCapabilityCDMA> weak_ptr_factory_; 119 120 // Helper method to extract the online portal information from properties. 121 void UpdateOnlinePortal(const KeyValueStore& properties); 122 void UpdateServiceOLP() override; 123 124 bool activation_starting_; 125 ResultCallback pending_activation_callback_; 126 std::string pending_activation_carrier_; 127 uint32_t activation_state_; 128 uint32_t registration_state_evdo_; 129 uint32_t registration_state_1x_; 130 std::string usage_url_; 131 132 DISALLOW_COPY_AND_ASSIGN(CellularCapabilityCDMA); 133 }; 134 135 } // namespace shill 136 137 #endif // SHILL_CELLULAR_CELLULAR_CAPABILITY_CDMA_H_ 138