Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [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 | |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 17 | #include <android-base/logging.h> |
| 18 | |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 19 | #include "hidl_return_util.h" |
Roshan Pius | 970f031 | 2016-12-05 15:25:51 -0800 | [diff] [blame] | 20 | #include "hidl_struct_util.h" |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 21 | #include "wifi_sta_iface.h" |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 22 | #include "wifi_status_util.h" |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 23 | |
| 24 | namespace android { |
| 25 | namespace hardware { |
| 26 | namespace wifi { |
Etan Cohen | 6ce5090 | 2017-09-14 07:30:57 -0700 | [diff] [blame] | 27 | namespace V1_2 { |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 28 | namespace implementation { |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 29 | using hidl_return_util::validateAndCall; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 30 | |
Roshan Pius | 6cedc97 | 2016-10-28 10:11:17 -0700 | [diff] [blame] | 31 | WifiStaIface::WifiStaIface( |
| 32 | const std::string& ifname, |
| 33 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal) |
Roshan Pius | 08d1df4 | 2017-04-19 23:11:07 -0700 | [diff] [blame] | 34 | : ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 35 | // Turn on DFS channel usage for STA iface. |
| 36 | legacy_hal::wifi_error legacy_status = |
| 37 | legacy_hal_.lock()->setDfsFlag(ifname_, true); |
| 38 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 39 | LOG(ERROR) |
| 40 | << "Failed to set DFS flag; DFS channels may be unavailable."; |
| 41 | } |
Roshan Pius | 08d1df4 | 2017-04-19 23:11:07 -0700 | [diff] [blame] | 42 | } |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 43 | |
| 44 | void WifiStaIface::invalidate() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 45 | legacy_hal_.reset(); |
| 46 | event_cb_handler_.invalidate(); |
| 47 | is_valid_ = false; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 48 | } |
| 49 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 50 | bool WifiStaIface::isValid() { return is_valid_; } |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 51 | |
Roshan Pius | d37341f | 2017-01-31 13:13:28 -0800 | [diff] [blame] | 52 | std::set<sp<IWifiStaIfaceEventCallback>> WifiStaIface::getEventCallbacks() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 53 | return event_cb_handler_.getCallbacks(); |
Roshan Pius | 970f031 | 2016-12-05 15:25:51 -0800 | [diff] [blame] | 54 | } |
| 55 | |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 56 | Return<void> WifiStaIface::getName(getName_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 57 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 58 | &WifiStaIface::getNameInternal, hidl_status_cb); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 59 | } |
| 60 | |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 61 | Return<void> WifiStaIface::getType(getType_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 62 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 63 | &WifiStaIface::getTypeInternal, hidl_status_cb); |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 66 | Return<void> WifiStaIface::registerEventCallback( |
| 67 | const sp<IWifiStaIfaceEventCallback>& callback, |
| 68 | registerEventCallback_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 69 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 70 | &WifiStaIface::registerEventCallbackInternal, |
| 71 | hidl_status_cb, callback); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | Return<void> WifiStaIface::getCapabilities(getCapabilities_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 75 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 76 | &WifiStaIface::getCapabilitiesInternal, |
| 77 | hidl_status_cb); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | Return<void> WifiStaIface::getApfPacketFilterCapabilities( |
| 81 | getApfPacketFilterCapabilities_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 82 | return validateAndCall( |
| 83 | this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 84 | &WifiStaIface::getApfPacketFilterCapabilitiesInternal, hidl_status_cb); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | Return<void> WifiStaIface::installApfPacketFilter( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 88 | uint32_t cmd_id, const hidl_vec<uint8_t>& program, |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 89 | installApfPacketFilter_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 90 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 91 | &WifiStaIface::installApfPacketFilterInternal, |
| 92 | hidl_status_cb, cmd_id, program); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | Return<void> WifiStaIface::getBackgroundScanCapabilities( |
| 96 | getBackgroundScanCapabilities_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 97 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 98 | &WifiStaIface::getBackgroundScanCapabilitiesInternal, |
| 99 | hidl_status_cb); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Roshan Pius | 7f4574d | 2017-02-22 09:48:03 -0800 | [diff] [blame] | 102 | Return<void> WifiStaIface::getValidFrequenciesForBand( |
| 103 | WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 104 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 105 | &WifiStaIface::getValidFrequenciesForBandInternal, |
| 106 | hidl_status_cb, band); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | Return<void> WifiStaIface::startBackgroundScan( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 110 | uint32_t cmd_id, const StaBackgroundScanParameters& params, |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 111 | startBackgroundScan_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 112 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 113 | &WifiStaIface::startBackgroundScanInternal, |
| 114 | hidl_status_cb, cmd_id, params); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | Return<void> WifiStaIface::stopBackgroundScan( |
| 118 | uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 119 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 120 | &WifiStaIface::stopBackgroundScanInternal, |
| 121 | hidl_status_cb, cmd_id); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | Return<void> WifiStaIface::enableLinkLayerStatsCollection( |
| 125 | bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 126 | return validateAndCall( |
| 127 | this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 128 | &WifiStaIface::enableLinkLayerStatsCollectionInternal, hidl_status_cb, |
| 129 | debug); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | Return<void> WifiStaIface::disableLinkLayerStatsCollection( |
| 133 | disableLinkLayerStatsCollection_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 134 | return validateAndCall( |
| 135 | this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 136 | &WifiStaIface::disableLinkLayerStatsCollectionInternal, hidl_status_cb); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | Return<void> WifiStaIface::getLinkLayerStats( |
| 140 | getLinkLayerStats_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 141 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 142 | &WifiStaIface::getLinkLayerStatsInternal, |
| 143 | hidl_status_cb); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 144 | } |
| 145 | |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 146 | Return<void> WifiStaIface::startRssiMonitoring( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 147 | uint32_t cmd_id, int32_t max_rssi, int32_t min_rssi, |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 148 | startRssiMonitoring_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 149 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 150 | &WifiStaIface::startRssiMonitoringInternal, |
| 151 | hidl_status_cb, cmd_id, max_rssi, min_rssi); |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | Return<void> WifiStaIface::stopRssiMonitoring( |
| 155 | uint32_t cmd_id, stopRssiMonitoring_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 156 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 157 | &WifiStaIface::stopRssiMonitoringInternal, |
| 158 | hidl_status_cb, cmd_id); |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 159 | } |
| 160 | |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame] | 161 | Return<void> WifiStaIface::getRoamingCapabilities( |
| 162 | getRoamingCapabilities_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 163 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 164 | &WifiStaIface::getRoamingCapabilitiesInternal, |
| 165 | hidl_status_cb); |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | Return<void> WifiStaIface::configureRoaming( |
| 169 | const StaRoamingConfig& config, configureRoaming_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 170 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 171 | &WifiStaIface::configureRoamingInternal, |
| 172 | hidl_status_cb, config); |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | Return<void> WifiStaIface::setRoamingState(StaRoamingState state, |
| 176 | setRoamingState_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 177 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 178 | &WifiStaIface::setRoamingStateInternal, |
| 179 | hidl_status_cb, state); |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame] | 180 | } |
| 181 | |
Roshan Pius | af727c0 | 2017-01-11 15:37:25 -0800 | [diff] [blame] | 182 | Return<void> WifiStaIface::enableNdOffload(bool enable, |
| 183 | enableNdOffload_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 184 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 185 | &WifiStaIface::enableNdOffloadInternal, |
| 186 | hidl_status_cb, enable); |
Roshan Pius | af727c0 | 2017-01-11 15:37:25 -0800 | [diff] [blame] | 187 | } |
| 188 | |
Roshan Pius | 9a9869a | 2017-01-11 16:42:16 -0800 | [diff] [blame] | 189 | Return<void> WifiStaIface::startSendingKeepAlivePackets( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 190 | uint32_t cmd_id, const hidl_vec<uint8_t>& ip_packet_data, |
| 191 | uint16_t ether_type, const hidl_array<uint8_t, 6>& src_address, |
| 192 | const hidl_array<uint8_t, 6>& dst_address, uint32_t period_in_ms, |
Roshan Pius | 9a9869a | 2017-01-11 16:42:16 -0800 | [diff] [blame] | 193 | startSendingKeepAlivePackets_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 194 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 195 | &WifiStaIface::startSendingKeepAlivePacketsInternal, |
| 196 | hidl_status_cb, cmd_id, ip_packet_data, ether_type, |
| 197 | src_address, dst_address, period_in_ms); |
Roshan Pius | 9a9869a | 2017-01-11 16:42:16 -0800 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | Return<void> WifiStaIface::stopSendingKeepAlivePackets( |
| 201 | uint32_t cmd_id, stopSendingKeepAlivePackets_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 202 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 203 | &WifiStaIface::stopSendingKeepAlivePacketsInternal, |
| 204 | hidl_status_cb, cmd_id); |
Roshan Pius | 9a9869a | 2017-01-11 16:42:16 -0800 | [diff] [blame] | 205 | } |
| 206 | |
Roshan Pius | 795bb81 | 2017-02-01 13:09:08 -0800 | [diff] [blame] | 207 | Return<void> WifiStaIface::setScanningMacOui( |
| 208 | const hidl_array<uint8_t, 3>& oui, setScanningMacOui_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 209 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 210 | &WifiStaIface::setScanningMacOuiInternal, |
| 211 | hidl_status_cb, oui); |
Roshan Pius | 795bb81 | 2017-02-01 13:09:08 -0800 | [diff] [blame] | 212 | } |
| 213 | |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 214 | Return<void> WifiStaIface::startDebugPacketFateMonitoring( |
| 215 | startDebugPacketFateMonitoring_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 216 | return validateAndCall( |
| 217 | this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 218 | &WifiStaIface::startDebugPacketFateMonitoringInternal, hidl_status_cb); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 219 | } |
| 220 | |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 221 | Return<void> WifiStaIface::getDebugTxPacketFates( |
| 222 | getDebugTxPacketFates_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 223 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 224 | &WifiStaIface::getDebugTxPacketFatesInternal, |
| 225 | hidl_status_cb); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | Return<void> WifiStaIface::getDebugRxPacketFates( |
| 229 | getDebugRxPacketFates_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 230 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 231 | &WifiStaIface::getDebugRxPacketFatesInternal, |
| 232 | hidl_status_cb); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 233 | } |
| 234 | |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 235 | std::pair<WifiStatus, std::string> WifiStaIface::getNameInternal() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 236 | return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_}; |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | std::pair<WifiStatus, IfaceType> WifiStaIface::getTypeInternal() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 240 | return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::STA}; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 241 | } |
| 242 | |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 243 | WifiStatus WifiStaIface::registerEventCallbackInternal( |
| 244 | const sp<IWifiStaIfaceEventCallback>& callback) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 245 | if (!event_cb_handler_.addCallback(callback)) { |
| 246 | return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); |
| 247 | } |
| 248 | return createWifiStatus(WifiStatusCode::SUCCESS); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | std::pair<WifiStatus, uint32_t> WifiStaIface::getCapabilitiesInternal() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 252 | legacy_hal::wifi_error legacy_status; |
| 253 | uint32_t legacy_feature_set; |
| 254 | std::tie(legacy_status, legacy_feature_set) = |
| 255 | legacy_hal_.lock()->getSupportedFeatureSet(ifname_); |
| 256 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 257 | return {createWifiStatusFromLegacyError(legacy_status), 0}; |
| 258 | } |
| 259 | uint32_t legacy_logger_feature_set; |
| 260 | std::tie(legacy_status, legacy_logger_feature_set) = |
| 261 | legacy_hal_.lock()->getLoggerSupportedFeatureSet(ifname_); |
| 262 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 263 | // some devices don't support querying logger feature set |
| 264 | legacy_logger_feature_set = 0; |
| 265 | } |
| 266 | uint32_t hidl_caps; |
| 267 | if (!hidl_struct_util::convertLegacyFeaturesToHidlStaCapabilities( |
| 268 | legacy_feature_set, legacy_logger_feature_set, &hidl_caps)) { |
| 269 | return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), 0}; |
| 270 | } |
| 271 | return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps}; |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | std::pair<WifiStatus, StaApfPacketFilterCapabilities> |
| 275 | WifiStaIface::getApfPacketFilterCapabilitiesInternal() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 276 | legacy_hal::wifi_error legacy_status; |
| 277 | legacy_hal::PacketFilterCapabilities legacy_caps; |
| 278 | std::tie(legacy_status, legacy_caps) = |
| 279 | legacy_hal_.lock()->getPacketFilterCapabilities(ifname_); |
| 280 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 281 | return {createWifiStatusFromLegacyError(legacy_status), {}}; |
| 282 | } |
| 283 | StaApfPacketFilterCapabilities hidl_caps; |
| 284 | if (!hidl_struct_util::convertLegacyApfCapabilitiesToHidl(legacy_caps, |
| 285 | &hidl_caps)) { |
| 286 | return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}}; |
| 287 | } |
| 288 | return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps}; |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | WifiStatus WifiStaIface::installApfPacketFilterInternal( |
Roshan Pius | 970f031 | 2016-12-05 15:25:51 -0800 | [diff] [blame] | 292 | uint32_t /* cmd_id */, const std::vector<uint8_t>& program) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 293 | legacy_hal::wifi_error legacy_status = |
| 294 | legacy_hal_.lock()->setPacketFilter(ifname_, program); |
| 295 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | std::pair<WifiStatus, StaBackgroundScanCapabilities> |
| 299 | WifiStaIface::getBackgroundScanCapabilitiesInternal() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 300 | legacy_hal::wifi_error legacy_status; |
| 301 | legacy_hal::wifi_gscan_capabilities legacy_caps; |
| 302 | std::tie(legacy_status, legacy_caps) = |
| 303 | legacy_hal_.lock()->getGscanCapabilities(ifname_); |
| 304 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 305 | return {createWifiStatusFromLegacyError(legacy_status), {}}; |
| 306 | } |
| 307 | StaBackgroundScanCapabilities hidl_caps; |
| 308 | if (!hidl_struct_util::convertLegacyGscanCapabilitiesToHidl(legacy_caps, |
| 309 | &hidl_caps)) { |
| 310 | return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}}; |
| 311 | } |
| 312 | return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps}; |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | std::pair<WifiStatus, std::vector<WifiChannelInMhz>> |
Roshan Pius | 7f4574d | 2017-02-22 09:48:03 -0800 | [diff] [blame] | 316 | WifiStaIface::getValidFrequenciesForBandInternal(WifiBand band) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 317 | static_assert(sizeof(WifiChannelInMhz) == sizeof(uint32_t), |
| 318 | "Size mismatch"); |
| 319 | legacy_hal::wifi_error legacy_status; |
| 320 | std::vector<uint32_t> valid_frequencies; |
| 321 | std::tie(legacy_status, valid_frequencies) = |
| 322 | legacy_hal_.lock()->getValidFrequenciesForBand( |
| 323 | ifname_, hidl_struct_util::convertHidlWifiBandToLegacy(band)); |
| 324 | return {createWifiStatusFromLegacyError(legacy_status), valid_frequencies}; |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | WifiStatus WifiStaIface::startBackgroundScanInternal( |
Roshan Pius | 970f031 | 2016-12-05 15:25:51 -0800 | [diff] [blame] | 328 | uint32_t cmd_id, const StaBackgroundScanParameters& params) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 329 | legacy_hal::wifi_scan_cmd_params legacy_params; |
| 330 | if (!hidl_struct_util::convertHidlGscanParamsToLegacy(params, |
| 331 | &legacy_params)) { |
| 332 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 333 | } |
| 334 | android::wp<WifiStaIface> weak_ptr_this(this); |
| 335 | const auto& on_failure_callback = |
| 336 | [weak_ptr_this](legacy_hal::wifi_request_id id) { |
| 337 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 338 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 339 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 340 | return; |
| 341 | } |
| 342 | for (const auto& callback : shared_ptr_this->getEventCallbacks()) { |
| 343 | if (!callback->onBackgroundScanFailure(id).isOk()) { |
| 344 | LOG(ERROR) |
| 345 | << "Failed to invoke onBackgroundScanFailure callback"; |
| 346 | } |
| 347 | } |
| 348 | }; |
| 349 | const auto& on_results_callback = |
| 350 | [weak_ptr_this]( |
| 351 | legacy_hal::wifi_request_id id, |
| 352 | const std::vector<legacy_hal::wifi_cached_scan_results>& results) { |
| 353 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 354 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 355 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 356 | return; |
| 357 | } |
| 358 | std::vector<StaScanData> hidl_scan_datas; |
| 359 | if (!hidl_struct_util:: |
| 360 | convertLegacyVectorOfCachedGscanResultsToHidl( |
| 361 | results, &hidl_scan_datas)) { |
| 362 | LOG(ERROR) << "Failed to convert scan results to HIDL structs"; |
| 363 | return; |
| 364 | } |
| 365 | for (const auto& callback : shared_ptr_this->getEventCallbacks()) { |
| 366 | if (!callback->onBackgroundScanResults(id, hidl_scan_datas) |
| 367 | .isOk()) { |
| 368 | LOG(ERROR) |
| 369 | << "Failed to invoke onBackgroundScanResults callback"; |
| 370 | } |
| 371 | } |
| 372 | }; |
| 373 | const auto& on_full_result_callback = [weak_ptr_this]( |
| 374 | legacy_hal::wifi_request_id id, |
| 375 | const legacy_hal:: |
| 376 | wifi_scan_result* result, |
| 377 | uint32_t buckets_scanned) { |
Roshan Pius | 970f031 | 2016-12-05 15:25:51 -0800 | [diff] [blame] | 378 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 379 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 380 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 381 | return; |
| 382 | } |
| 383 | StaScanResult hidl_scan_result; |
| 384 | if (!hidl_struct_util::convertLegacyGscanResultToHidl( |
| 385 | *result, true, &hidl_scan_result)) { |
| 386 | LOG(ERROR) << "Failed to convert full scan results to HIDL structs"; |
| 387 | return; |
Roshan Pius | 970f031 | 2016-12-05 15:25:51 -0800 | [diff] [blame] | 388 | } |
| 389 | for (const auto& callback : shared_ptr_this->getEventCallbacks()) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 390 | if (!callback |
| 391 | ->onBackgroundFullScanResult(id, buckets_scanned, |
| 392 | hidl_scan_result) |
| 393 | .isOk()) { |
| 394 | LOG(ERROR) |
| 395 | << "Failed to invoke onBackgroundFullScanResult callback"; |
| 396 | } |
Roshan Pius | 970f031 | 2016-12-05 15:25:51 -0800 | [diff] [blame] | 397 | } |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 398 | }; |
| 399 | legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->startGscan( |
| 400 | ifname_, cmd_id, legacy_params, on_failure_callback, |
| 401 | on_results_callback, on_full_result_callback); |
| 402 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 403 | } |
| 404 | |
Roshan Pius | 970f031 | 2016-12-05 15:25:51 -0800 | [diff] [blame] | 405 | WifiStatus WifiStaIface::stopBackgroundScanInternal(uint32_t cmd_id) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 406 | legacy_hal::wifi_error legacy_status = |
| 407 | legacy_hal_.lock()->stopGscan(ifname_, cmd_id); |
| 408 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 409 | } |
| 410 | |
Roshan Pius | 970f031 | 2016-12-05 15:25:51 -0800 | [diff] [blame] | 411 | WifiStatus WifiStaIface::enableLinkLayerStatsCollectionInternal(bool debug) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 412 | legacy_hal::wifi_error legacy_status = |
| 413 | legacy_hal_.lock()->enableLinkLayerStats(ifname_, debug); |
| 414 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | WifiStatus WifiStaIface::disableLinkLayerStatsCollectionInternal() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 418 | legacy_hal::wifi_error legacy_status = |
| 419 | legacy_hal_.lock()->disableLinkLayerStats(ifname_); |
| 420 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | std::pair<WifiStatus, StaLinkLayerStats> |
| 424 | WifiStaIface::getLinkLayerStatsInternal() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 425 | legacy_hal::wifi_error legacy_status; |
| 426 | legacy_hal::LinkLayerStats legacy_stats; |
| 427 | std::tie(legacy_status, legacy_stats) = |
| 428 | legacy_hal_.lock()->getLinkLayerStats(ifname_); |
| 429 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 430 | return {createWifiStatusFromLegacyError(legacy_status), {}}; |
| 431 | } |
| 432 | StaLinkLayerStats hidl_stats; |
| 433 | if (!hidl_struct_util::convertLegacyLinkLayerStatsToHidl(legacy_stats, |
| 434 | &hidl_stats)) { |
| 435 | return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}}; |
| 436 | } |
| 437 | return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_stats}; |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 438 | } |
| 439 | |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 440 | WifiStatus WifiStaIface::startRssiMonitoringInternal(uint32_t cmd_id, |
| 441 | int32_t max_rssi, |
| 442 | int32_t min_rssi) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 443 | android::wp<WifiStaIface> weak_ptr_this(this); |
| 444 | const auto& on_threshold_breached_callback = |
| 445 | [weak_ptr_this](legacy_hal::wifi_request_id id, |
| 446 | std::array<uint8_t, 6> bssid, int8_t rssi) { |
| 447 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 448 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 449 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 450 | return; |
| 451 | } |
| 452 | for (const auto& callback : shared_ptr_this->getEventCallbacks()) { |
| 453 | if (!callback->onRssiThresholdBreached(id, bssid, rssi) |
| 454 | .isOk()) { |
| 455 | LOG(ERROR) |
| 456 | << "Failed to invoke onRssiThresholdBreached callback"; |
| 457 | } |
| 458 | } |
| 459 | }; |
| 460 | legacy_hal::wifi_error legacy_status = |
| 461 | legacy_hal_.lock()->startRssiMonitoring(ifname_, cmd_id, max_rssi, |
| 462 | min_rssi, |
| 463 | on_threshold_breached_callback); |
| 464 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | WifiStatus WifiStaIface::stopRssiMonitoringInternal(uint32_t cmd_id) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 468 | legacy_hal::wifi_error legacy_status = |
| 469 | legacy_hal_.lock()->stopRssiMonitoring(ifname_, cmd_id); |
| 470 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 471 | } |
| 472 | |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame] | 473 | std::pair<WifiStatus, StaRoamingCapabilities> |
| 474 | WifiStaIface::getRoamingCapabilitiesInternal() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 475 | legacy_hal::wifi_error legacy_status; |
| 476 | legacy_hal::wifi_roaming_capabilities legacy_caps; |
| 477 | std::tie(legacy_status, legacy_caps) = |
| 478 | legacy_hal_.lock()->getRoamingCapabilities(ifname_); |
| 479 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 480 | return {createWifiStatusFromLegacyError(legacy_status), {}}; |
| 481 | } |
| 482 | StaRoamingCapabilities hidl_caps; |
| 483 | if (!hidl_struct_util::convertLegacyRoamingCapabilitiesToHidl(legacy_caps, |
| 484 | &hidl_caps)) { |
| 485 | return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}}; |
| 486 | } |
| 487 | return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps}; |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame] | 488 | } |
| 489 | |
| 490 | WifiStatus WifiStaIface::configureRoamingInternal( |
| 491 | const StaRoamingConfig& config) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 492 | legacy_hal::wifi_roaming_config legacy_config; |
| 493 | if (!hidl_struct_util::convertHidlRoamingConfigToLegacy(config, |
| 494 | &legacy_config)) { |
| 495 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 496 | } |
| 497 | legacy_hal::wifi_error legacy_status = |
| 498 | legacy_hal_.lock()->configureRoaming(ifname_, legacy_config); |
| 499 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | WifiStatus WifiStaIface::setRoamingStateInternal(StaRoamingState state) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 503 | legacy_hal::wifi_error legacy_status = |
| 504 | legacy_hal_.lock()->enableFirmwareRoaming( |
| 505 | ifname_, hidl_struct_util::convertHidlRoamingStateToLegacy(state)); |
| 506 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame] | 507 | } |
| 508 | |
Roshan Pius | af727c0 | 2017-01-11 15:37:25 -0800 | [diff] [blame] | 509 | WifiStatus WifiStaIface::enableNdOffloadInternal(bool enable) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 510 | legacy_hal::wifi_error legacy_status = |
| 511 | legacy_hal_.lock()->configureNdOffload(ifname_, enable); |
| 512 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | af727c0 | 2017-01-11 15:37:25 -0800 | [diff] [blame] | 513 | } |
| 514 | |
Roshan Pius | 9a9869a | 2017-01-11 16:42:16 -0800 | [diff] [blame] | 515 | WifiStatus WifiStaIface::startSendingKeepAlivePacketsInternal( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 516 | uint32_t cmd_id, const std::vector<uint8_t>& ip_packet_data, |
| 517 | uint16_t /* ether_type */, const std::array<uint8_t, 6>& src_address, |
| 518 | const std::array<uint8_t, 6>& dst_address, uint32_t period_in_ms) { |
| 519 | legacy_hal::wifi_error legacy_status = |
| 520 | legacy_hal_.lock()->startSendingOffloadedPacket( |
| 521 | ifname_, cmd_id, ip_packet_data, src_address, dst_address, |
| 522 | period_in_ms); |
| 523 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 9a9869a | 2017-01-11 16:42:16 -0800 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | WifiStatus WifiStaIface::stopSendingKeepAlivePacketsInternal(uint32_t cmd_id) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 527 | legacy_hal::wifi_error legacy_status = |
| 528 | legacy_hal_.lock()->stopSendingOffloadedPacket(ifname_, cmd_id); |
| 529 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 9a9869a | 2017-01-11 16:42:16 -0800 | [diff] [blame] | 530 | } |
| 531 | |
Roshan Pius | d37341f | 2017-01-31 13:13:28 -0800 | [diff] [blame] | 532 | WifiStatus WifiStaIface::setScanningMacOuiInternal( |
| 533 | const std::array<uint8_t, 3>& oui) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 534 | legacy_hal::wifi_error legacy_status = |
| 535 | legacy_hal_.lock()->setScanningMacOui(ifname_, oui); |
| 536 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 795bb81 | 2017-02-01 13:09:08 -0800 | [diff] [blame] | 537 | } |
| 538 | |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 539 | WifiStatus WifiStaIface::startDebugPacketFateMonitoringInternal() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 540 | legacy_hal::wifi_error legacy_status = |
| 541 | legacy_hal_.lock()->startPktFateMonitoring(ifname_); |
| 542 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 543 | } |
| 544 | |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 545 | std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>> |
| 546 | WifiStaIface::getDebugTxPacketFatesInternal() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 547 | legacy_hal::wifi_error legacy_status; |
| 548 | std::vector<legacy_hal::wifi_tx_report> legacy_fates; |
| 549 | std::tie(legacy_status, legacy_fates) = |
| 550 | legacy_hal_.lock()->getTxPktFates(ifname_); |
| 551 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 552 | return {createWifiStatusFromLegacyError(legacy_status), {}}; |
| 553 | } |
| 554 | std::vector<WifiDebugTxPacketFateReport> hidl_fates; |
| 555 | if (!hidl_struct_util::convertLegacyVectorOfDebugTxPacketFateToHidl( |
| 556 | legacy_fates, &hidl_fates)) { |
| 557 | return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}}; |
| 558 | } |
| 559 | return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_fates}; |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>> |
| 563 | WifiStaIface::getDebugRxPacketFatesInternal() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 564 | legacy_hal::wifi_error legacy_status; |
| 565 | std::vector<legacy_hal::wifi_rx_report> legacy_fates; |
| 566 | std::tie(legacy_status, legacy_fates) = |
| 567 | legacy_hal_.lock()->getRxPktFates(ifname_); |
| 568 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 569 | return {createWifiStatusFromLegacyError(legacy_status), {}}; |
| 570 | } |
| 571 | std::vector<WifiDebugRxPacketFateReport> hidl_fates; |
| 572 | if (!hidl_struct_util::convertLegacyVectorOfDebugRxPacketFateToHidl( |
| 573 | legacy_fates, &hidl_fates)) { |
| 574 | return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}}; |
| 575 | } |
| 576 | return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_fates}; |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 577 | } |
| 578 | |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 579 | } // namespace implementation |
Etan Cohen | 6ce5090 | 2017-09-14 07:30:57 -0700 | [diff] [blame] | 580 | } // namespace V1_2 |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 581 | } // namespace wifi |
| 582 | } // namespace hardware |
| 583 | } // namespace android |