1 // 2 // Copyright (C) 2013 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_UNIVERSAL_CDMA_H_ 18 #define SHILL_CELLULAR_CELLULAR_CAPABILITY_UNIVERSAL_CDMA_H_ 19 20 #include <memory> 21 #include <string> 22 #include <vector> 23 24 #include <base/memory/weak_ptr.h> 25 #include <gtest/gtest_prod.h> // for FRIEND_TEST 26 27 #include "shill/cellular/cellular.h" 28 #include "shill/cellular/cellular_capability_universal.h" 29 #include "shill/cellular/mm1_modem_modemcdma_proxy_interface.h" 30 31 namespace shill { 32 33 class CellularCapabilityUniversalCDMA : public CellularCapabilityUniversal { 34 public: 35 CellularCapabilityUniversalCDMA(Cellular* cellular, 36 ControlInterface* control_interface, 37 ModemInfo* modem_info); 38 ~CellularCapabilityUniversalCDMA() override; 39 40 // Returns true if the service is activated. 41 bool IsActivated() const; 42 43 // Inherited from CellularCapability. 44 void OnPropertiesChanged( 45 const std::string& interface, 46 const KeyValueStore& changed_properties, 47 const std::vector<std::string>& invalidated_properties) override; 48 bool IsServiceActivationRequired() const override; 49 bool IsActivating() const override; 50 void Activate(const std::string& carrier, 51 Error* error, 52 const ResultCallback& callback) override; 53 void CompleteActivation(Error* error) override; 54 bool IsRegistered() const override; 55 void SetUnregistered(bool searching) override; 56 void OnServiceCreated() override; 57 std::string GetRoamingStateString() const override; 58 void SetupConnectProperties(KeyValueStore* properties) override; 59 60 // TODO(armansito): Remove once 3GPP is implemented in its own class 61 void Register(const ResultCallback& callback) override; 62 void RegisterOnNetwork(const std::string& network_id, Error* error, 63 const ResultCallback& callback) override; 64 void RequirePIN(const std::string& pin, bool require, Error* error, 65 const ResultCallback& callback) override; 66 void EnterPIN(const std::string& pin, Error* error, 67 const ResultCallback& callback) override; 68 void UnblockPIN(const std::string& unblock_code, 69 const std::string& pin, Error* error, 70 const ResultCallback& callback) override; 71 void ChangePIN(const std::string& old_pin, const std::string& new_pin, 72 Error* error, const ResultCallback& callback) override; 73 void Scan(Error* error, 74 const ResultStringmapsCallback& callback) override; 75 void OnSimPathChanged(const std::string& sim_path) override; 76 77 void GetProperties() override; 78 79 protected: 80 // Inherited from CellularCapabilityUniversal. 81 void InitProxies() override; 82 void ReleaseProxies() override; 83 void UpdateServiceOLP() override; 84 85 // Post-payment activation handlers. 86 void UpdatePendingActivationState() override; 87 88 private: 89 friend class CellularCapabilityUniversalCDMATest; 90 FRIEND_TEST(CellularCapabilityUniversalCDMADispatcherTest, 91 UpdatePendingActivationState); 92 FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, ActivateAutomatic); 93 FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, IsActivating); 94 FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, IsRegistered); 95 FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, 96 IsServiceActivationRequired); 97 FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, 98 OnCDMARegistrationChanged); 99 FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, PropertiesChanged); 100 FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, UpdateServiceOLP); 101 FRIEND_TEST(CellularCapabilityUniversalCDMAMainTest, 102 UpdateServiceActivationStateProperty); 103 104 // CDMA property change handlers 105 virtual void OnModemCDMAPropertiesChanged( 106 const KeyValueStore& properties, 107 const std::vector<std::string>& invalidated_properties); 108 void OnCDMARegistrationChanged(MMModemCdmaRegistrationState state_1x, 109 MMModemCdmaRegistrationState state_evdo, 110 uint32_t sid, uint32_t nid); 111 112 // CDMA activation handlers 113 void ActivateAutomatic(); 114 void OnActivationStateChangedSignal(uint32_t activation_state, 115 uint32_t activation_error, 116 const KeyValueStore& status_changes); 117 void OnActivateReply(const ResultCallback& callback, 118 const Error& error); 119 void HandleNewActivationStatus(uint32_t error); 120 121 void UpdateServiceActivationStateProperty(); 122 123 static std::string GetActivationStateString(uint32_t state); 124 static std::string GetActivationErrorString(uint32_t error); 125 126 std::unique_ptr<mm1::ModemModemCdmaProxyInterface> modem_cdma_proxy_; 127 // TODO(armansito): Should probably call this |weak_ptr_factory_| after 128 // 3gpp refactor 129 base::WeakPtrFactory<CellularCapabilityUniversalCDMA> weak_cdma_ptr_factory_; 130 131 // CDMA ActivationState property. 132 MMModemCdmaActivationState activation_state_; 133 134 MMModemCdmaRegistrationState cdma_1x_registration_state_; 135 MMModemCdmaRegistrationState cdma_evdo_registration_state_; 136 137 uint32_t nid_; 138 uint32_t sid_; 139 140 DISALLOW_COPY_AND_ASSIGN(CellularCapabilityUniversalCDMA); 141 }; 142 143 } // namespace shill 144 145 #endif // SHILL_CELLULAR_CELLULAR_CAPABILITY_UNIVERSAL_CDMA_H_ 146