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_SCAN_SERVICE_H 17 #define OHOS_WIFI_SCAN_SERVICE_H 18 19 #ifdef OHOS_ARCH_LITE 20 #include "wifi_scan_stub_lite.h" 21 #else 22 #include "system_ability.h" 23 #include "wifi_scan_stub.h" 24 #include "iremote_object.h" 25 #endif 26 27 namespace OHOS { 28 namespace Wifi { 29 #ifdef OHOS_ARCH_LITE 30 enum ServiceRunningState { STATE_NOT_START, STATE_RUNNING }; 31 #endif 32 33 class WifiScanServiceImpl : public WifiScanStub { 34 public: 35 WifiScanServiceImpl(); 36 #ifdef OHOS_ARCH_LITE 37 static std::shared_ptr<WifiScanServiceImpl> GetInstance(); 38 void OnStart(); 39 void OnStop(); 40 #else 41 explicit WifiScanServiceImpl(int instId); 42 #endif 43 virtual ~WifiScanServiceImpl(); 44 45 ErrCode SetScanControlInfo(const ScanControlInfo &info) override; 46 ErrCode Scan(bool compatible) override; 47 ErrCode PermissionVerification(); 48 ErrCode AdvanceScan(const WifiScanParams ¶ms) override; 49 ErrCode IsWifiClosedScan(bool &bOpen) override; 50 ErrCode GetScanInfoList(std::vector<WifiScanInfo> &result, bool compatible) override; 51 ErrCode SetScanOnlyAvailable(bool bScanOnlyAvailable) override; 52 ErrCode GetScanOnlyAvailable(bool &bScanOnlyAvailable) override; 53 ErrCode StartWifiPnoScan(bool isStartAction, int periodMs, int suspendReason) override; 54 #ifdef OHOS_ARCH_LITE 55 ErrCode RegisterCallBack(const std::shared_ptr<IWifiScanCallback> &callback, 56 const std::vector<std::string> &event) override; 57 #else 58 ErrCode RegisterCallBack(const sptr<IWifiScanCallback> &callback, const std::vector<std::string> &event) override; 59 #endif 60 ErrCode GetSupportedFeatures(long &features) override; 61 bool IsRemoteDied(void) override; 62 static void SaBasicDump(std::string& result); 63 64 private: 65 bool Init(); 66 bool IsScanServiceRunning(); 67 bool IsWifiScanAllowed(bool externFlag = true); 68 #ifndef OHOS_ARCH_LITE 69 void UpdateScanMode(); 70 #endif 71 72 private: 73 #ifdef OHOS_ARCH_LITE 74 static std::mutex g_instanceLock; 75 static std::shared_ptr<WifiScanServiceImpl> g_instance; 76 ServiceRunningState mState; 77 #endif 78 }; 79 } // namespace Wifi 80 } // namespace OHOS 81 #endif 82