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 CELLULAR_DATA_NET_AGENT_H 17 #define CELLULAR_DATA_NET_AGENT_H 18 19 #include <memory> 20 #include <string> 21 #include <singleton.h> 22 #include <utility> 23 24 #include "i_net_conn_service.h" 25 #include "if_system_ability_manager.h" 26 #include "iservice_registry.h" 27 #include "system_ability_definition.h" 28 29 #include "cellular_data_constant.h" 30 #include "net_manager_call_back.h" 31 #include "net_manager_tactics_call_back.h" 32 33 namespace OHOS { 34 namespace Telephony { 35 class CellularDataNetAgent : public DelayedRefSingleton<CellularDataNetAgent> { 36 DECLARE_DELAYED_REF_SINGLETON(CellularDataNetAgent); 37 38 public: 39 /** 40 * Register the network information with the network management module 41 * 42 * @return true if register success else return false; 43 */ 44 bool RegisterNetSupplier(const int32_t slotId); 45 46 /** 47 * Cancel the registration information to the network management 48 */ 49 void UnregisterNetSupplier(); 50 51 bool RegisterPolicyCallback(); 52 void UnregisterPolicyCallback(); 53 54 /** 55 * Update network information 56 * 57 * @param supplierId network unique identity id returned after network registration 58 * @param netSupplierInfo network data information 59 */ 60 void UpdateNetSupplierInfo(int32_t supplierId, sptr<NetManagerStandard::NetSupplierInfo> &netSupplierInfo); 61 62 /** 63 * Update link information 64 * 65 * @param supplierId network unique identity id returned after network registration 66 * @param netLinkInfo network link data information 67 */ 68 void UpdateNetLinkInfo(int32_t supplierId, sptr<NetManagerStandard::NetLinkInfo> &netLinkInfo); 69 70 /** 71 * Collect all network 72 * 73 * @param netSupplier a specific network 74 */ 75 void AddNetSupplier(const NetSupplier &netSupplier); 76 77 /** 78 * Clear all network 79 */ 80 void ClearNetSupplier(); 81 82 /** 83 * Gets the unique identity of successful registered registration 84 * 85 * @param slotId card slot identification 86 * @param capability a network capability 87 * @return unique identify 88 */ 89 int32_t GetSupplierId(const int32_t slotId, uint64_t capability) const; 90 91 private: 92 std::vector<NetSupplier> netSuppliers_; 93 sptr<NetManagerCallBack> callBack_; 94 sptr<NetManagerTacticsCallBack> tacticsCallBack_; 95 }; 96 } // namespace Telephony 97 } // namespace OHOS 98 #endif // CELLULAR_DATA_NET_AGENT_H 99