1 /* 2 * Copyright (c) 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_SCAN_MANAGER_H 17 #define OHOS_WIFI_SCAN_MANAGER_H 18 19 #include <mutex> 20 #include <functional> 21 #include "wifi_errcode.h" 22 #include "iscan_service_callbacks.h" 23 #include "sta_service_callback.h" 24 #include "wifi_internal_msg.h" 25 26 namespace OHOS { 27 namespace Wifi { 28 class WifiScanManager { 29 public: 30 WifiScanManager(); 31 ~WifiScanManager() = default; 32 33 IScanSerivceCallbacks& GetScanCallback(void); 34 StaServiceCallback GetStaCallback() const; 35 void StopUnloadScanSaTimer(void); 36 void StartUnloadScanSaTimer(void); 37 void CheckAndStartScanService(int instId = 0); 38 ErrCode TryToStartScanService(int instId = 0); 39 void CheckAndStopScanService(int instId = 0); 40 void CloseScanService(int instId = 0); 41 void DealStaOpened(int instId = 0); 42 43 private: 44 void InitScanCallback(void); 45 void DealScanOpenRes(int instId = 0); 46 void DealScanCloseRes(int instId = 0); 47 void DealScanFinished(int state, int instId = 0); 48 void DealScanInfoNotify(std::vector<InterScanInfo> &results, int instId = 0); 49 void DealStoreScanInfoEvent(std::vector<InterScanInfo> &results, int instId = 0); 50 51 private: 52 IScanSerivceCallbacks mScanCallback; 53 uint32_t unloadScanSaTimerId{0}; 54 std::mutex unloadScanSaTimerMutex; 55 StaServiceCallback mStaCallback; 56 }; 57 58 } // namespace Wifi 59 } // namespace OHOS 60 #endif // OHOS_WIFI_SCAN_MANAGER_H