• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-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 #ifndef OHOS_WIFI_NETWORK_SELECTION_UTILS_H_
17 #define OHOS_WIFI_NETWORK_SELECTION_UTILS_H_
18 
19 #include "network_selection.h"
20 
21 namespace OHOS::Wifi::NetworkSelection  {
22 class NetworkSelectionUtils {
23 public:
24 
25     /**
26      * the function to determine whether the network is Open
27      *
28      * @param networkCandidate candidate network.
29      * @return return ture if the candidate network is Open
30      */
31     static bool IsOpenNetwork(const NetworkCandidate &networkCandidate);
32 
33     /**
34      * the function to determine whether the network is Open and maybe portal.
35      *
36      * @param networkCandidate candidate network.
37      * @param filterName wififilter name
38      * @return return ture if the candidate network is Open and maybe portal.
39      */
40     static bool IsOpenAndMaybePortal(NetworkCandidate &networkCandidate, const std::string &filterName = "");
41 
42     /**
43      * the function to determine whether the network is owe network.
44      *
45      * @param networkCandidate candidate network.
46      * @return return ture if the candidate network is owe network.
47      */
48     static bool IsScanResultForOweNetwork(const NetworkCandidate &networkCandidate);
49 
50     /**
51      * the function to determine whether the network is low-priority .
52      *
53      * @param networkCandidate candidate network.
54      * @return return ture if the candidate network is low-priority .
55      */
56     static bool IsBlackListNetwork(const NetworkCandidate &networkCandidate);
57 
58     /**
59      * transfer the info of candidate networks to json format string.
60      *
61      * @param networkCandidates candidate network
62      * @param filterName wififilter Name
63      * @return json format string
64      */
65     static std::string GetNetworkCandidatesInfo(const std::vector<NetworkCandidate*> &networkCandidates,
66         const std::string &filterName = "");
67 
68     /**
69      * transfer the info of candidate networks to json format string.
70      *
71      * @param scoreResults scoreResults
72      * @return json format string
73      */
74     static std::string GetScoreResultsInfo(const std::vector<ScoreResult> &scoreResults);
75 
76     /**
77      * check if wifi is open.
78      *
79      * @param networkCandidate candidate network.
80      * @return return ture if the candidate network is Open, else false.
81      */
82     static bool IsConfigOpenType(const NetworkCandidate &networkCandidate);
83 
84     /**
85      * check if wifi is Is enterprise.
86      *
87      * @param networkCandidate candidate network.
88      * @return return ture if the candidate network is enterprise, else false.
89      */
90     static bool IsEnterprise(const NetworkCandidate &networkCandidate);
91 
92     /**
93      * check if wifi is open or enterprise.
94      *
95      * @param networkCandidate candidate network.
96      * @return return ture if the candidate network is enterprise, else false.
97      */
98     static bool IsConfigOpenOrEapType(const NetworkCandidate &networkCandidate);
99 
100     /**
101      * check if wifi has web keys.
102      *
103      * @param networkCandidate candidate network.
104      * @return return ture if wifi device config has web keys, else false.
105      */
106     static bool HasWepKeys(const WifiDeviceConfig &wifiConfig);
107 
108     static bool IsSameFreqAsP2p(const NetworkCandidate &networkCandidate);
109 };
110 }
111 #endif
112