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 | |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame^] | 39 | // STA iface conversion methods. |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 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); |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame^] | 62 | |
| 63 | // NAN iface conversion methods. |
| 64 | bool convertHidlNanEnableRequestToLegacy( |
| 65 | const NanEnableRequest& hidl_request, |
| 66 | legacy_hal::NanEnableRequest* legacy_request); |
| 67 | bool convertHidlNanPublishRequestToLegacy( |
| 68 | const NanPublishRequest& hidl_request, |
| 69 | legacy_hal::NanPublishRequest* legacy_request); |
| 70 | bool convertHidlNanPublishCancelRequestToLegacy( |
| 71 | const NanPublishCancelRequest& hidl_request, |
| 72 | legacy_hal::NanPublishCancelRequest* legacy_request); |
| 73 | bool convertHidlNanSubscribeRequestToLegacy( |
| 74 | const NanSubscribeRequest& hidl_request, |
| 75 | legacy_hal::NanSubscribeRequest* legacy_request); |
| 76 | bool convertHidlNanSubscribeCancelRequestToLegacy( |
| 77 | const NanSubscribeCancelRequest& hidl_request, |
| 78 | legacy_hal::NanSubscribeCancelRequest* legacy_request); |
| 79 | bool convertHidlNanTransmitFollowupRequestToLegacy( |
| 80 | const NanTransmitFollowupRequest& hidl_request, |
| 81 | legacy_hal::NanTransmitFollowupRequest* legacy_request); |
| 82 | bool convertHidlNanConfigRequestToLegacy( |
| 83 | const NanConfigRequest& hidl_request, |
| 84 | legacy_hal::NanConfigRequest* legacy_request); |
| 85 | bool convertHidlNanBeaconSdfPayloadRequestToLegacy( |
| 86 | const NanBeaconSdfPayloadRequest& hidl_request, |
| 87 | legacy_hal::NanBeaconSdfPayloadRequest* legacy_request); |
| 88 | bool convertHidlNanDataPathInitiatorRequestToLegacy( |
| 89 | const NanDataPathInitiatorRequest& hidl_request, |
| 90 | legacy_hal::NanDataPathInitiatorRequest* legacy_request); |
| 91 | bool convertHidlNanDataPathIndicationResponseToLegacy( |
| 92 | const NanDataPathIndicationResponse& hidl_response, |
| 93 | legacy_hal::NanDataPathIndicationResponse* legacy_response); |
| 94 | bool convertHidlNanDataPathEndRequestToLegacy( |
| 95 | const NanDataPathEndRequest& hidl_request, |
| 96 | legacy_hal::NanDataPathEndRequest* legacy_request); |
| 97 | bool convertLegacyNanResponseHeaderToHidl( |
| 98 | const legacy_hal::NanResponseMsg& legacy_response, |
| 99 | NanResponseMsgHeader* hidl_response); |
| 100 | bool convertLegacyNanPublishResponseToHidl( |
| 101 | const legacy_hal::NanPublishResponse& legacy_response, |
| 102 | NanPublishResponse* hidl_response); |
| 103 | bool convertLegacyNanSubscribeResponseToHidl( |
| 104 | const legacy_hal::NanSubscribeResponse& legacy_response, |
| 105 | NanSubscribeResponse* hidl_response); |
| 106 | bool convertLegacyNanDataPathResponseToHidl( |
| 107 | const legacy_hal::NanDataPathRequestResponse& legacy_response, |
| 108 | NanDataPathResponse* hidl_response); |
| 109 | bool convertLegacyNanCapabilitiesResponseToHidl( |
| 110 | const legacy_hal::NanCapabilities& legacy_response, |
| 111 | NanCapabilitiesResponse* hidl_response); |
| 112 | bool convertLegacyNanPublishTerminatedIndToHidl( |
| 113 | const legacy_hal::NanPublishTerminatedInd& legacy_ind, |
| 114 | NanPublishTerminatedInd* hidl_ind); |
| 115 | bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind, |
| 116 | NanMatchInd* hidl_ind); |
| 117 | bool convertLegacyNanMatchExpiredIndToHidl( |
| 118 | const legacy_hal::NanMatchExpiredInd& legacy_ind, |
| 119 | NanMatchExpiredInd* hidl_ind); |
| 120 | bool convertLegacyNanSubscribeTerminatedIndToHidl( |
| 121 | const legacy_hal::NanSubscribeTerminatedInd& legacy_ind, |
| 122 | NanSubscribeTerminatedInd* hidl_ind); |
| 123 | bool convertLegacyNanFollowupIndToHidl( |
| 124 | const legacy_hal::NanFollowupInd& legacy_ind, NanFollowupInd* hidl_ind); |
| 125 | bool convertLegacyNanDiscEngEventIndToHidl( |
| 126 | const legacy_hal::NanDiscEngEventInd& legacy_ind, |
| 127 | NanDiscEngEventInd* hidl_ind); |
| 128 | bool convertLegacyNanDisabledIndToHidl( |
| 129 | const legacy_hal::NanDisabledInd& legacy_ind, NanDisabledInd* hidl_ind); |
| 130 | bool convertLegacyNanBeaconSdfPayloadIndToHidl( |
| 131 | const legacy_hal::NanBeaconSdfPayloadInd& legacy_ind, |
| 132 | NanBeaconSdfPayloadInd* hidl_ind); |
| 133 | bool convertLegacyNanDataPathRequestIndToHidl( |
| 134 | const legacy_hal::NanDataPathRequestInd& legacy_ind, |
| 135 | NanDataPathRequestInd* hidl_ind); |
| 136 | bool convertLegacyNanDataPathConfirmIndToHidl( |
| 137 | const legacy_hal::NanDataPathConfirmInd& legacy_ind, |
| 138 | NanDataPathConfirmInd* hidl_ind); |
| 139 | bool convertLegacyNanDataPathEndIndToHidl( |
| 140 | const legacy_hal::NanDataPathEndInd& legacy_ind, |
| 141 | NanDataPathEndInd* hidl_ind); |
| 142 | bool convertLegacyNanTransmitFollowupIndToHidl( |
| 143 | const legacy_hal::NanTransmitFollowupInd& legacy_ind, |
| 144 | NanTransmitFollowupInd* hidl_ind); |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 145 | } // namespace hidl_struct_util |
| 146 | } // namespace implementation |
| 147 | } // namespace V1_0 |
| 148 | } // namespace wifi |
| 149 | } // namespace hardware |
| 150 | } // namespace android |
| 151 | |
| 152 | #endif // HIDL_STRUCT_UTIL_H_ |