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 17 #ifndef OHOS_WIFI_NETWORK_SELECTION_MANAGER_H 18 #define OHOS_WIFI_NETWORK_SELECTION_MANAGER_H 19 20 #include "network_selection.h" 21 #include "network_selector_factory.h" 22 23 namespace OHOS::Wifi { 24 struct NetworkSelectionResult { 25 InterScanInfo interScanInfo; 26 WifiDeviceConfig wifiDeviceConfig; 27 }; 28 29 class NetworkSelectionManager { 30 public: 31 NetworkSelectionManager(); 32 /** 33 * the function to select network. 34 * 35 * @param networkSelectionResult Network selection result 36 * @param type the type of networkSelection 37 * @param scanInfos scanInfos 38 * @return whether network selection is successful. 39 */ 40 bool SelectNetwork(NetworkSelectionResult &networkSelectionResult, 41 NetworkSelectType type, 42 const std::vector<InterScanInfo> &scanInfos); 43 private: 44 std::unique_ptr<NetworkSelectorFactory> pNetworkSelectorFactory = nullptr; 45 46 /** 47 * get the saved deviceConfig associated with scanInfo 48 * 49 * @param networkCandidates Candidate network 50 * @param scanInfos scanInfos 51 */ 52 static void GetAllDeviceConfigs(std::vector<NetworkSelection::NetworkCandidate> &networkCandidates, 53 const std::vector<InterScanInfo> &scanInfos); 54 55 /** 56 * Try nominator the candidate network. 57 * 58 * @param networkCandidates candidate networks 59 * @param networkSelector networkSelector 60 */ 61 static void TryNominate(std::vector<NetworkSelection::NetworkCandidate> &networkCandidates, 62 const std::unique_ptr<NetworkSelection::INetworkSelector> &networkSelector); 63 }; 64 } 65 #endif 66