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