1 /* 2 * Copyright (C) 2021-2022 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_HOTSPOT_IMPL_H 17 #define OHOS_WIFI_HOTSPOT_IMPL_H 18 19 #include <cstdint> 20 #include <set> 21 #include <vector> 22 #include "i_wifi_hotspot.h" 23 #include "i_wifi_hotspot_callback.h" 24 #include "refbase.h" 25 #include "wifi_ap_msg.h" 26 #include "wifi_common_msg.h" 27 #include "wifi_errcode.h" 28 #include "wifi_hotspot.h" 29 30 namespace OHOS { 31 namespace Wifi { 32 class WifiHotspotImpl : public WifiHotspot { 33 public: 34 WifiHotspotImpl(); 35 virtual ~WifiHotspotImpl(); 36 /** 37 * @Description init ap client. 38 * 39 * @return bool - operation result 40 */ 41 bool Init(int systemAbilityId, int id); 42 43 /** 44 * @Description Check whether the hotspot is active. 45 * 46 * @param isActive - the flag of whether hotspot is active. 47 * @return ErrCode - operation result 48 */ 49 ErrCode IsHotspotActive(bool &isActive) override; 50 51 /** 52 * @Description Check whether the hotspot supports dual band. 53 * 54 * @param isSupported - the flag of whether dual band is supported. 55 * @return ErrCode - operation result 56 */ 57 ErrCode IsHotspotDualBandSupported(bool &isSupported) override; 58 59 /** 60 * @Description Get the Hotspot Config object 61 * 62 * @param state - Result of obtaining the hotspot status 63 * @return ErrCode - operation result 64 */ 65 ErrCode GetHotspotState(int &state) override; 66 67 /** 68 * @Description Get the Hotspot State object 69 * 70 * @param config - Current hotspot configuration 71 * @return ErrCode - operation result 72 */ 73 ErrCode GetHotspotConfig(HotspotConfig &config) override; 74 75 /** 76 * @Description Set the configuration of Hotspot 77 * 78 * @param config - HotspotConfig object, 79 * @return ErrCode - operation result 80 */ 81 ErrCode SetHotspotConfig(const HotspotConfig &config) override; 82 83 /** 84 * @Description Set the idel timeout of Hotspot 85 * 86 * @param time -input time, 87 * @return ErrCode - operation result 88 */ 89 ErrCode SetHotspotIdleTimeout(int time) override; 90 91 /** 92 * @Description Get the Station List object 93 * 94 * @param result - Get result vector of connect Station Info 95 * @return ErrCode - operation result 96 */ 97 ErrCode GetStationList(std::vector<StationInfo> &result) override; 98 99 /** 100 * @Description Disconnects a specified sta connection when ap is opened 101 * 102 * @param info - StationInfo object 103 * @return ErrCode - operation result 104 */ 105 ErrCode DisassociateSta(const StationInfo &info) override; 106 107 /** 108 * @Description Enable Hotspot 109 * 110 * @param type - service type 111 * @return ErrCode - operation result 112 */ 113 ErrCode EnableHotspot(const ServiceType type = ServiceType::DEFAULT) override; 114 115 /** 116 * @Description Disable Hotspot 117 * 118 * @param type - service type 119 * @return ErrCode - operation result 120 */ 121 ErrCode DisableHotspot(const ServiceType type = ServiceType::DEFAULT) override; 122 123 /** 124 * @Description Get the Block Lists object 125 * 126 * @param infos - Get Blocklist result vector of StationInfo 127 * @return ErrCode - operation result 128 */ 129 ErrCode GetBlockLists(std::vector<StationInfo> &infos) override; 130 131 /** 132 * @Description Add a StationInfo object to Blocklist when ap is opened 133 * 134 * @param info - StationInfo object 135 * @return ErrCode - operation result 136 */ 137 ErrCode AddBlockList(const StationInfo &info) override; 138 139 /** 140 * @Description Del a StationInfo object from Blocklist 141 * 142 * @param info - StationInfo object 143 * @return ErrCode - operation result 144 */ 145 ErrCode DelBlockList(const StationInfo &info) override; 146 147 /** 148 * @Description Get the Valid Bands object 149 * 150 * @param bands - Get result vector of BandType when ap is opened 151 * @return ErrCode - operation result 152 */ 153 ErrCode GetValidBands(std::vector<BandType> &bands) override; 154 155 /** 156 * @Description Get the Valid Channels object when ap is opened 157 * 158 * @param band - Specified Valid Band. 159 * @param validchannels - Obtains the channels corresponding to the specified band 160 * @return ErrCode - operation result 161 */ 162 ErrCode GetValidChannels(BandType band, std::vector<int32_t> &validchannels) override; 163 164 /** 165 * @Description Register callback client 166 * 167 * @param callback - callback struct 168 * @return ErrCode - operation result 169 */ 170 ErrCode RegisterCallBack(const sptr<IWifiHotspotCallback> &callback, 171 const std::vector<std::string> &event) override; 172 173 /** 174 * @Description Get supported features 175 * 176 * @param features - return supported features 177 * @return ErrCode - operation result 178 */ 179 ErrCode GetSupportedFeatures(long &features) override; 180 181 /** 182 * @Description Check if supported input feature 183 * 184 * @param feature - input feature 185 * @return true - supported 186 * @return false - unsupported 187 */ 188 bool IsFeatureSupported(long feature) override; 189 190 /** 191 * @Description Get supported power model list 192 * 193 * @param setPowerModelList - supported power model list 194 * @return ErrCode - operation result 195 */ 196 ErrCode GetSupportedPowerModel(std::set<PowerModel>& setPowerModelList) override; 197 198 /** 199 * @Description Get power model 200 * 201 * @param model - current power model 202 * @return ErrCode - operation result 203 */ 204 ErrCode GetPowerModel(PowerModel& model) override; 205 206 /** 207 * @Description Get supported power model list 208 * 209 * @param model - the model to be set 210 * @return ErrCode - operation result 211 */ 212 ErrCode SetPowerModel(const PowerModel& model) override; 213 214 /** 215 * @Description Check whether service is died. 216 * 217 * @return bool - true: service is died, false: service is not died. 218 */ 219 bool IsRemoteDied(void); 220 221 /** 222 * @Description Get ap iface name 223 * 224 * @param ifaceName - the ifaceName to be set 225 * @return ErrCode - operation result 226 */ 227 ErrCode GetApIfaceName(std::string& ifaceName) override; 228 229 private: 230 bool GetWifiHotspotProxy(); 231 std::atomic<int> systemAbilityId_; 232 std::mutex mutex_; 233 int instId; 234 sptr<IWifiHotspot> client_; 235 }; 236 } // namespace Wifi 237 } // namespace OHOS 238 #endif 239