1 /*
2 * Copyright (c) 2024 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 "netmgr_ext_log_wrapper.h"
17 #include "wearable_distributed_net_management.h"
18
19 namespace OHOS {
20 namespace NetManagerStandard {
GetInstance()21 WearableDistributedNetManagement &WearableDistributedNetManagement::GetInstance()
22 {
23 static WearableDistributedNetManagement instance;
24 return instance;
25 }
26
SetupWearableDistributedNetwork(const int32_t tcpPortId,const int32_t udpPortId,const bool isMetered)27 int32_t WearableDistributedNetManagement::SetupWearableDistributedNetwork(const int32_t tcpPortId,
28 const int32_t udpPortId, const bool isMetered)
29 {
30 NETMGR_EXT_LOG_I("Wearable Distributed Net Management Setup Network");
31 return WearableDistributedNetAgent::GetInstance().SetupWearableDistributedNetwork(tcpPortId, udpPortId, isMetered);
32 }
33
EnableWearableDistributedNetwork(bool enableFlag)34 int32_t WearableDistributedNetManagement::EnableWearableDistributedNetwork(bool enableFlag)
35 {
36 NETMGR_EXT_LOG_I("Wearable Distributed Net Management Start Network : %{public}u", enableFlag);
37 return WearableDistributedNetAgent::GetInstance().EnableWearableDistributedNetwork(enableFlag);
38 }
39
StopWearableDistributedNetwork()40 int32_t WearableDistributedNetManagement::StopWearableDistributedNetwork()
41 {
42 NETMGR_EXT_LOG_I("Wearable Distributed Net Management Stop Network");
43 return WearableDistributedNetAgent::GetInstance().TearDownWearableDistributedNetwork();
44 }
45
UpdateNetScore(const bool isCharging)46 void WearableDistributedNetManagement::UpdateNetScore(const bool isCharging)
47 {
48 WearableDistributedNetAgent::GetInstance().UpdateNetScore(isCharging);
49 }
50
UpdateMeteredStatus(const bool isMetered)51 int32_t WearableDistributedNetManagement::UpdateMeteredStatus(const bool isMetered)
52 {
53 NETMGR_EXT_LOG_I("Update wearable distributed net metered status");
54 return WearableDistributedNetAgent::GetInstance().UpdateMeteredStatus(isMetered);
55 }
56 } // namespace NetManagerStandard
57 } // namespace OHOS
58