wifi: Add utility for struct conversions
Add a new utility file (hidl_struct_util) which would contain helper
functions to convert legacy HAL structures to HIDL structures and vice
versa.
Added utility functions to convert:
1. Background scan params from HIDL to legacy.
2. Scan Result from legacy to HIDL.
3. Cached Scan results from legacy to HIDL.
4. Link layer stats from legacy to HIDL.
Bug: 31991459
Test: Compiles
Change-Id: I48a49b43d425f8cc3059241c4bd652b2346f2381
diff --git a/wifi/1.0/default/hidl_struct_util.h b/wifi/1.0/default/hidl_struct_util.h
new file mode 100644
index 0000000..6c91e03
--- /dev/null
+++ b/wifi/1.0/default/hidl_struct_util.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef HIDL_STRUCT_UTIL_H_
+#define HIDL_STRUCT_UTIL_H_
+
+#include <vector>
+
+#include <android/hardware/wifi/1.0/IWifi.h>
+
+#include "wifi_legacy_hal.h"
+
+/**
+ * This file contains a bunch of functions to convert structs from the legacy
+ * HAL to HIDL and vice versa.
+ * TODO(b/32093047): Add unit tests for these conversion methods in the VTS test
+ * suite.
+ */
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+namespace hidl_struct_util {
+
+// Convert hidl gscan params to legacy gscan params.
+bool convertHidlScanParamsToLegacy(
+ const StaBackgroundScanParameters& hidl_scan_params,
+ legacy_hal::wifi_scan_cmd_params* legacy_scan_params);
+// Convert the blob of packed IE elements to vector of
+// |WifiInformationElement| structures.
+bool convertLegacyIeBlobToHidl(const uint8_t* ie_blob,
+ uint32_t ie_blob_len,
+ std::vector<WifiInformationElement>* hidl_ies);
+// |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11
+// Information Elements (IEs)
+bool convertLegacyScanResultToHidl(
+ const legacy_hal::wifi_scan_result& legacy_scan_result,
+ bool has_ie_data,
+ StaScanResult* hidl_scan_result);
+// |cached_results| is assumed to not include IEs.
+bool convertLegacyVectorOfCachedScanResultsToHidl(
+ const std::vector<legacy_hal::wifi_cached_scan_results>&
+ legacy_cached_scan_results,
+ std::vector<StaScanData>* hidl_scan_datas);
+bool convertLegacyLinkLayerStatsToHidl(
+ const legacy_hal::LinkLayerStats& legacy_stats,
+ StaLinkLayerStats* hidl_stats);
+} // namespace hidl_struct_util
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace hardware
+} // namespace android
+
+#endif // HIDL_STRUCT_UTIL_H_