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 #ifndef OHOS_WIFI_SCAN_CONFIG_H
16 #define OHOS_WIFI_SCAN_CONFIG_H
17 
18 #include <mutex>
19 #include "wifi_scan_control_msg.h"
20 
21 namespace OHOS {
22 namespace Wifi {
23 
24 class WifiScanConfig {
25 public:
26     WifiScanConfig();
27     ~WifiScanConfig();
28 
29     void GetScanDeviceInfo(WifiScanDeviceInfo &scanDeviceInfo);
30 
31     void SaveScanDeviceInfo(WifiScanDeviceInfo &scanDeviceInfo);
32 
33     void SetAppRunningState(ScanMode appRunMode);
34 
35     ScanMode GetAppRunningState();
36 
37     void SetStaScene(const int &scene);
38 
39     void SetStaSceneForbidCount(int count);
40 
41     int GetStaSceneForbidCount();
42 
43     void SetScanControlInfo(const ScanControlInfo &info, int instId = 0);
44 
45     int GetScanControlInfo(ScanControlInfo &info, int instId = 0);
46 
47     void SetPackageFilter(std::map<std::string, std::vector<std::string>> &filterMap);
48 
49     void SetMovingFreezeScaned(bool scanned);
50 
51     bool GetMovingFreezeScaned();
52 
53     void SetAbnormalApps(const std::vector<std::string> &abnormalAppList);
54 
55     void SetAppPackageName(const std::string &appPackageName);
56 
57     std::string GetAppPackageName();
58 
59     void SetStaCurrentTime(time_t time);
60 
61     time_t GetStaCurrentTime();
62 
63     int SaveScanInfoList(const std::vector<WifiScanInfo> &results);
64 
65     int ClearScanInfoList();
66 
67     int GetScanInfoList(std::vector<WifiScanInfo> &results);
68 
69     void GetScanInfoListInner(std::vector<WifiScanInfo> &results);
70 
71     void RecordWifiCategory(const std::string bssid, WifiCategory category);
72 
73     WifiCategory GetWifiCategoryRecord(const std::string bssid);
74 
75     void CleanWifiCategoryRecord();
76 
77 private:
78     void InitScanControlForbidList();
79     void InitScanControlIntervalList();
80 
81     std::mutex mScanDeviceInfoMutex;
82     WifiScanDeviceInfo mScanDeviceInfo;
83     std::mutex mScanMutex;
84     std::map<std::string, WifiCategory> mWifiCategoryRecord;
85     std::vector<WifiScanInfo> mWifiScanInfoList;
86 };
87 }  // namespace Wifi
88 }  // namespace OHOS
89 #endif
90