Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2016 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 HIDL_STRUCT_UTIL_H_ |
| 18 | #define HIDL_STRUCT_UTIL_H_ |
| 19 | |
| 20 | #include <vector> |
| 21 | |
| 22 | #include <android/hardware/wifi/1.0/IWifi.h> |
| 23 | |
| 24 | #include "wifi_legacy_hal.h" |
| 25 | |
| 26 | /** |
| 27 | * This file contains a bunch of functions to convert structs from the legacy |
| 28 | * HAL to HIDL and vice versa. |
| 29 | * TODO(b/32093047): Add unit tests for these conversion methods in the VTS test |
| 30 | * suite. |
| 31 | */ |
| 32 | namespace android { |
| 33 | namespace hardware { |
| 34 | namespace wifi { |
| 35 | namespace V1_0 { |
| 36 | namespace implementation { |
| 37 | namespace hidl_struct_util { |
| 38 | |
| 39 | // Convert hidl gscan params to legacy gscan params. |
| 40 | bool convertHidlScanParamsToLegacy( |
| 41 | const StaBackgroundScanParameters& hidl_scan_params, |
| 42 | legacy_hal::wifi_scan_cmd_params* legacy_scan_params); |
| 43 | // Convert the blob of packed IE elements to vector of |
| 44 | // |WifiInformationElement| structures. |
| 45 | bool convertLegacyIeBlobToHidl(const uint8_t* ie_blob, |
| 46 | uint32_t ie_blob_len, |
| 47 | std::vector<WifiInformationElement>* hidl_ies); |
| 48 | // |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11 |
| 49 | // Information Elements (IEs) |
| 50 | bool convertLegacyScanResultToHidl( |
| 51 | const legacy_hal::wifi_scan_result& legacy_scan_result, |
| 52 | bool has_ie_data, |
| 53 | StaScanResult* hidl_scan_result); |
| 54 | // |cached_results| is assumed to not include IEs. |
| 55 | bool convertLegacyVectorOfCachedScanResultsToHidl( |
| 56 | const std::vector<legacy_hal::wifi_cached_scan_results>& |
| 57 | legacy_cached_scan_results, |
| 58 | std::vector<StaScanData>* hidl_scan_datas); |
| 59 | bool convertLegacyLinkLayerStatsToHidl( |
| 60 | const legacy_hal::LinkLayerStats& legacy_stats, |
| 61 | StaLinkLayerStats* hidl_stats); |
| 62 | } // namespace hidl_struct_util |
| 63 | } // namespace implementation |
| 64 | } // namespace V1_0 |
| 65 | } // namespace wifi |
| 66 | } // namespace hardware |
| 67 | } // namespace android |
| 68 | |
| 69 | #endif // HIDL_STRUCT_UTIL_H_ |