1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CHRE_WIFI_OFFLOAD_CHRE_SCAN_PARAMS_SAFE_H_
18 #define CHRE_WIFI_OFFLOAD_CHRE_SCAN_PARAMS_SAFE_H_
19 
20 #include "chre/apps/wifi_offload/scan_params.h"
21 #include "chre/apps/wifi_offload/wifi_offload.h"
22 
23 namespace wifi_offload {
24 
25 /* A class to encapsulate chreWifiScanParams struct with pointers to its const
26  * fields and some useful conversion methods */
27 class ChreScanParamsSafe {
28  public:
29   ChreScanParamsSafe() = delete;
30 
31   ChreScanParamsSafe(const ScanParams &scan_params);
32 
33   ~ChreScanParamsSafe() = default;
34 
35   const chreWifiScanParams *GetChreWifiScanParams();
36 
37   void Log() const;
38 
39  private:
40   void UpdateFromScanParams(const ScanParams &scan_params);
41 
42   chreWifiScanParams chre_scan_params_;
43   // Storage for *(chre_scan_params_.frequencyList)
44   uint32_t chre_scan_params_frequencies_[CHRE_WIFI_FREQUENCY_LIST_MAX_LEN];
45   // Storage for *(chre_scan_params_.ssidList)
46   chreWifiSsidListItem chre_scan_params_ssids_[CHRE_WIFI_SSID_LIST_MAX_LEN];
47 };
48 
49 }  // namespace wifi_offload
50 
51 #endif  // CHRE_WIFI_OFFLOAD_CHRE_SCAN_PARAMS_SAFE_H_
52