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 #ifndef OHOS_MOCK_AUTH_CENTER_H 17 #define OHOS_MOCK_AUTH_CENTER_H 18 19 #include "wifi_event_handler.h" 20 #include "wifi_errcode.h" 21 #include "network_selection.h" 22 #include "network_selector_factory.h" 23 #include "wifi_internal_msg.h" 24 #include "wifi_log.h" 25 #include "i_net_conn_service.h" 26 #include "net_all_capabilities.h" 27 #include "net_supplier_callback_base.h" 28 #include <any> 29 30 namespace OHOS { 31 namespace Wifi { 32 class WifiAuthCenter { 33 public: 34 static WifiAuthCenter &GetInstance(); 35 36 int Init(); 37 38 static bool IsSystemAccess(); 39 40 static bool IsNativeProcess(); 41 42 int VerifySetWifiInfoPermission(const int &pid, const int &uid); 43 44 int VerifyGetWifiInfoPermission(const int &pid, const int &uid); 45 46 int VerifyGetScanInfosPermission(const int &pid, const int &uid); 47 48 int VerifyGetWifiLocalMacPermission(const int &pid, const int &uid); 49 50 int VerifyWifiConnectionPermission(const int &pid, const int &uid); 51 52 int VerifySetWifiConfigPermission(const int &pid, const int &uid); 53 54 int VerifyGetWifiDirectDevicePermission(const int &pid, const int &uid); 55 56 int VerifyManageWifiHotspotPermission(const int &pid, const int &uid); 57 58 int VerifyGetWifiPeersMacPermission(const int &pid, const int &uid); 59 60 int VerifyGetWifiPeersMacPermissionEx(const int &pid, const int &uid, const int &tokenId); 61 62 int VerifyGetWifiInfoInternalPermission(const int &pid, const int &uid); 63 64 int VerifyManageWifiHotspotExtPermission(const int &pid, const int &uid); 65 66 int VerifyGetWifiConfigPermission(const int &pid, const int &uid); 67 }; 68 69 70 class WifiAppStateAware { 71 public: 72 static WifiAppStateAware &GetInstance(); 73 74 explicit WifiAppStateAware(); 75 ~WifiAppStateAware(); 76 bool IsForegroundApp(int32_t uid); 77 bool IsForegroundApp(const std::string &bundleName); 78 }; 79 80 class WifiNetAgent { 81 public: 82 static WifiNetAgent &GetInstance(); 83 84 explicit WifiNetAgent(); 85 ~WifiNetAgent(); 86 void OnStaMachineUpdateNetLinkInfo(IpInfo &wifiIpInfo, IpV6Info &wifiIpV6Info, WifiProxyConfig &wifiProxyConfig, 87 int instId = 0); 88 void OnStaMachineUpdateNetSupplierInfo(const sptr<NetManagerStandard::NetSupplierInfo> &netSupplierInfo); 89 void OnStaMachineNetManagerRestart(const sptr<NetManagerStandard::NetSupplierInfo> &netSupplierInfo, 90 int instId = 0); 91 void OnStaMachineWifiStart(); 92 }; 93 94 struct NetworkSelectionResult { 95 InterScanInfo interScanInfo; 96 WifiDeviceConfig wifiDeviceConfig; 97 }; 98 99 class NetworkSelectionManager { 100 public: 101 NetworkSelectionManager(); 102 103 bool SelectNetwork(NetworkSelectionResult &networkSelectionResult, 104 NetworkSelectType type, 105 const std::vector<InterScanInfo> &scanInfos); 106 107 std::unique_ptr<NetworkSelectorFactory> pNetworkSelectorFactory = nullptr; 108 109 static void TryNominate(std::vector<NetworkSelection::NetworkCandidate> &networkCandidates, 110 const std::unique_ptr<NetworkSelection::INetworkSelector> &networkSelector); 111 }; 112 113 } // namespace Wifi 114 } // namespace OHOS 115 #endif