1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef DATA_CONNECTION_MANAGER_H 17 #define DATA_CONNECTION_MANAGER_H 18 19 #include <hril_data_parcel.h> 20 #include <map> 21 #include <memory> 22 23 #include "data_connection_monitor.h" 24 #include "state_machine.h" 25 26 namespace OHOS { 27 namespace Telephony { 28 class CellularDataStateMachine; 29 class DataConnectionManager : public StateMachine, public RefBase { 30 public: 31 DataConnectionManager(const std::shared_ptr<AppExecFwk::EventRunner> &runner, int32_t slotId); 32 ~DataConnectionManager(); 33 void AddConnectionStateMachine(const std::shared_ptr<CellularDataStateMachine> &stateMachine); 34 void RemoveConnectionStateMachine(const std::shared_ptr<CellularDataStateMachine> &stateMachine); 35 void AddActiveConnectionByCid(const std::shared_ptr<CellularDataStateMachine> &stateMachine); 36 std::shared_ptr<CellularDataStateMachine> GetActiveConnectionByCid(int32_t cid) const; 37 bool isNoActiveConnection() const; 38 std::map<int32_t, std::shared_ptr<CellularDataStateMachine>> GetActiveConnection() const; 39 void RemoveActiveConnectionByCid(int32_t cid); 40 void StartStallDetectionTimer(); 41 void StopStallDetectionTimer(); 42 void RegisterRadioObserver(); 43 void UnRegisterRadioObserver() const; 44 void BeginNetStatistics(); 45 void EndNetStatistics(); 46 int32_t GetDataFlowType(); 47 void SetDataFlowType(CellDataFlowType dataFlowType); 48 int32_t GetSlotId() const; 49 std::vector<std::shared_ptr<CellularDataStateMachine>> GetAllConnectionMachine(); 50 std::string GetDefaultBandWidthsConfig(); 51 std::string GetDefaultTcpBufferConfig(); 52 LinkBandwidthInfo GetBandwidthsByRadioTech(const int32_t radioTech); 53 std::string GetTcpBufferByRadioTech(const int32_t radioTech); 54 55 private: 56 std::shared_ptr<DataConnectionMonitor> connectionMonitor_; 57 std::vector<std::shared_ptr<CellularDataStateMachine>> stateMachines_; 58 std::map<int32_t, std::shared_ptr<CellularDataStateMachine>> cidActiveConnectionMap_; 59 sptr<State> ccmDefaultState_; 60 const int32_t slotId_; 61 std::map<std::string, LinkBandwidthInfo> bandwidthConfigMap_; 62 std::map<std::string, std::string> tcpBufferConfigMap_; 63 }; 64 65 class CcmDefaultState : public State { 66 public: CcmDefaultState(DataConnectionManager & connectManager,std::string && name)67 CcmDefaultState(DataConnectionManager &connectManager, std::string &&name) 68 : State(std::move(name)), connectManager_(connectManager) 69 {} 70 virtual ~CcmDefaultState() = default; 71 virtual void StateBegin(); 72 virtual void StateEnd(); 73 virtual bool StateProcess(const AppExecFwk::InnerEvent::Pointer &event); 74 75 protected: 76 void RadioDataCallListChanged(const AppExecFwk::InnerEvent::Pointer &event); 77 void UpdateNetworkInfo(const AppExecFwk::InnerEvent::Pointer &event); 78 79 private: 80 DataConnectionManager &connectManager_; 81 }; 82 } // namespace Telephony 83 } // namespace OHOS 84 #endif // DATA_CONNECTION_MANAGER_H 85