• 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      * @return return ture if the candidate network is Open and maybe portal.
38      */
39     static bool IsOpenAndMaybePortal(const NetworkCandidate &networkCandidate);
40 
41     /**
42      * the function to determine whether the network is owe network.
43      *
44      * @param networkCandidate candidate network.
45      * @return return ture if the candidate network is owe network.
46      */
47     static bool IsScanResultForOweNetwork(const NetworkCandidate &networkCandidate);
48 
49     /**
50      * the function to determine whether the network is low-priority .
51      *
52      * @param networkCandidate candidate network.
53      * @return return ture if the candidate network is low-priority .
54      */
55     static bool IsBlackListNetwork(const NetworkCandidate &networkCandidate);
56 
57     /**
58      * transfer the info of candidate networks to json format string.
59      *
60      * @param networkCandidates candidate network
61      * @return json format string
62      */
63     static std::string GetNetworkCandidatesInfo(const std::vector<NetworkCandidate*> &networkCandidates);
64 
65     /**
66      * transfer the info of candidate networks to json format string.
67      *
68      * @param scoreResults scoreResults
69      * @return json format string
70      */
71     static std::string GetScoreResultsInfo(const std::vector<ScoreResult> &scoreResults);
72 
73     /**
74      * check if wifi is open.
75      *
76      * @param networkCandidate candidate network.
77      * @return return ture if the candidate network is Open, else false.
78      */
79     static bool IsConfigOpenType(const NetworkCandidate &networkCandidate);
80 
81     /**
82      * check if wifi is Is enterprise.
83      *
84      * @param networkCandidate candidate network.
85      * @return return ture if the candidate network is enterprise, else false.
86      */
87     static bool IsEnterprise(const NetworkCandidate &networkCandidate);
88 
89     /**
90      * check if wifi is open or enterprise.
91      *
92      * @param networkCandidate candidate network.
93      * @return return ture if the candidate network is enterprise, else false.
94      */
95     static bool IsConfigOpenOrEapType(const NetworkCandidate &networkCandidate);
96 
97     /**
98      * check if wifi has web keys.
99      *
100      * @param networkCandidate candidate network.
101      * @return return ture if wifi device config has web keys, else false.
102      */
103     static bool HasWepKeys(const WifiDeviceConfig &wifiConfig);
104 
105     static bool IsSameFreqAsP2p(const NetworkCandidate &networkCandidate);
106 
107 #ifdef FEATURE_ITNETWORK_PREFERRED_SUPPORT
108     /**
109      * Get vendor country from param to determine it is ItDevice.
110      * @param non
111      * @return return true if the vendor country is ItDevice
112      */
113     static bool CheckDeviceTypeByVendorCountry();
114 #endif
115 };
116 }
117 #endif
118