1 /* 2 * Copyright (C) 2023 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 #include "devattest_network_manager.h" 17 18 #include "net_conn_client.h" 19 #include "devattest_log.h" 20 #include "devattest_errno.h" 21 22 namespace OHOS { 23 namespace DevAttest { DevAttestNetworkManager()24DevAttestNetworkManager::DevAttestNetworkManager() 25 { 26 } 27 ~DevAttestNetworkManager()28DevAttestNetworkManager::~DevAttestNetworkManager() 29 { 30 } 31 RegisterNetConnCallback(void)32void DevAttestNetworkManager::RegisterNetConnCallback(void) 33 { 34 if (netCallback_ == NULL) { 35 netCallback_ = (std::make_unique<DevAttestNetworkCallback>()).release(); 36 } 37 38 int32_t ret = NetConnClient::GetInstance().RegisterNetConnCallback(netCallback_); 39 if (ret != NETMANAGER_SUCCESS) { 40 HILOGE("[RegisterNetConnCallback] RegisterNetConnCallback failed."); 41 return; 42 } 43 } 44 UnregisterNetConnCallback(void)45void DevAttestNetworkManager::UnregisterNetConnCallback(void) 46 { 47 if (netCallback_ == NULL) { 48 return; 49 } 50 51 int32_t ret = NetConnClient::GetInstance().UnregisterNetConnCallback(netCallback_); 52 if (ret != NETMANAGER_SUCCESS) { 53 HILOGE("[UnregisterNetConnCallback] RegisterNetConnCallback failed."); 54 return; 55 } 56 } 57 } // DevAttest 58 } // OHOS