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