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