wifi_sta_iface.cpp revision 6cedc97e95b3b3ee49fe0860ac8cfd8c5de2a2ab
1/* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include <android-base/logging.h> 18 19#include "hidl_return_util.h" 20#include "wifi_sta_iface.h" 21#include "wifi_status_util.h" 22 23namespace android { 24namespace hardware { 25namespace wifi { 26namespace V1_0 { 27namespace implementation { 28using hidl_return_util::validateAndCall; 29 30WifiStaIface::WifiStaIface( 31 const std::string& ifname, 32 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal) 33 : ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) {} 34 35void WifiStaIface::invalidate() { 36 legacy_hal_.reset(); 37 event_callbacks_.clear(); 38 is_valid_ = false; 39} 40 41bool WifiStaIface::isValid() { 42 return is_valid_; 43} 44 45Return<void> WifiStaIface::getName(getName_cb hidl_status_cb) { 46 return validateAndCall(this, 47 WifiStatusCode::ERROR_WIFI_IFACE_INVALID, 48 &WifiStaIface::getNameInternal, 49 hidl_status_cb); 50} 51 52Return<void> WifiStaIface::getType(getType_cb hidl_status_cb) { 53 return validateAndCall(this, 54 WifiStatusCode::ERROR_WIFI_IFACE_INVALID, 55 &WifiStaIface::getTypeInternal, 56 hidl_status_cb); 57} 58 59Return<void> WifiStaIface::registerEventCallback( 60 const sp<IWifiStaIfaceEventCallback>& callback, 61 registerEventCallback_cb hidl_status_cb) { 62 return validateAndCall(this, 63 WifiStatusCode::ERROR_WIFI_IFACE_INVALID, 64 &WifiStaIface::registerEventCallbackInternal, 65 hidl_status_cb, 66 callback); 67} 68 69Return<void> WifiStaIface::getCapabilities(getCapabilities_cb hidl_status_cb) { 70 return validateAndCall(this, 71 WifiStatusCode::ERROR_WIFI_IFACE_INVALID, 72 &WifiStaIface::getCapabilitiesInternal, 73 hidl_status_cb); 74} 75 76Return<void> WifiStaIface::getApfPacketFilterCapabilities( 77 getApfPacketFilterCapabilities_cb hidl_status_cb) { 78 return validateAndCall(this, 79 WifiStatusCode::ERROR_WIFI_IFACE_INVALID, 80 &WifiStaIface::getApfPacketFilterCapabilitiesInternal, 81 hidl_status_cb); 82} 83 84Return<void> WifiStaIface::installApfPacketFilter( 85 uint32_t cmd_id, 86 const hidl_vec<uint8_t>& program, 87 installApfPacketFilter_cb hidl_status_cb) { 88 return validateAndCall(this, 89 WifiStatusCode::ERROR_WIFI_IFACE_INVALID, 90 &WifiStaIface::installApfPacketFilterInternal, 91 hidl_status_cb, 92 cmd_id, 93 program); 94} 95 96Return<void> WifiStaIface::getBackgroundScanCapabilities( 97 getBackgroundScanCapabilities_cb hidl_status_cb) { 98 return validateAndCall(this, 99 WifiStatusCode::ERROR_WIFI_IFACE_INVALID, 100 &WifiStaIface::getBackgroundScanCapabilitiesInternal, 101 hidl_status_cb); 102} 103 104Return<void> WifiStaIface::getValidFrequenciesForBackgroundScan( 105 StaBackgroundScanBand band, 106 getValidFrequenciesForBackgroundScan_cb hidl_status_cb) { 107 return validateAndCall( 108 this, 109 WifiStatusCode::ERROR_WIFI_IFACE_INVALID, 110 &WifiStaIface::getValidFrequenciesForBackgroundScanInternal, 111 hidl_status_cb, 112 band); 113} 114 115Return<void> WifiStaIface::startBackgroundScan( 116 uint32_t cmd_id, 117 const StaBackgroundScanParameters& params, 118 startBackgroundScan_cb hidl_status_cb) { 119 return validateAndCall(this, 120 WifiStatusCode::ERROR_WIFI_IFACE_INVALID, 121 &WifiStaIface::startBackgroundScanInternal, 122 hidl_status_cb, 123 cmd_id, 124 params); 125} 126 127Return<void> WifiStaIface::stopBackgroundScan( 128 uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) { 129 return validateAndCall(this, 130 WifiStatusCode::ERROR_WIFI_IFACE_INVALID, 131 &WifiStaIface::stopBackgroundScanInternal, 132 hidl_status_cb, 133 cmd_id); 134} 135 136Return<void> WifiStaIface::enableLinkLayerStatsCollection( 137 bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) { 138 return validateAndCall(this, 139 WifiStatusCode::ERROR_WIFI_IFACE_INVALID, 140 &WifiStaIface::enableLinkLayerStatsCollectionInternal, 141 hidl_status_cb, 142 debug); 143} 144 145Return<void> WifiStaIface::disableLinkLayerStatsCollection( 146 disableLinkLayerStatsCollection_cb hidl_status_cb) { 147 return validateAndCall(this, 148 WifiStatusCode::ERROR_WIFI_IFACE_INVALID, 149 &WifiStaIface::disableLinkLayerStatsCollectionInternal, 150 hidl_status_cb); 151} 152 153Return<void> WifiStaIface::getLinkLayerStats( 154 getLinkLayerStats_cb hidl_status_cb) { 155 return validateAndCall(this, 156 WifiStatusCode::ERROR_WIFI_IFACE_INVALID, 157 &WifiStaIface::getLinkLayerStatsInternal, 158 hidl_status_cb); 159} 160 161Return<void> WifiStaIface::startDebugPacketFateMonitoring( 162 startDebugPacketFateMonitoring_cb hidl_status_cb) { 163 return validateAndCall(this, 164 WifiStatusCode::ERROR_WIFI_IFACE_INVALID, 165 &WifiStaIface::startDebugPacketFateMonitoringInternal, 166 hidl_status_cb); 167} 168 169Return<void> WifiStaIface::stopDebugPacketFateMonitoring( 170 stopDebugPacketFateMonitoring_cb hidl_status_cb) { 171 return validateAndCall(this, 172 WifiStatusCode::ERROR_WIFI_IFACE_INVALID, 173 &WifiStaIface::stopDebugPacketFateMonitoringInternal, 174 hidl_status_cb); 175} 176 177Return<void> WifiStaIface::getDebugTxPacketFates( 178 getDebugTxPacketFates_cb hidl_status_cb) { 179 return validateAndCall(this, 180 WifiStatusCode::ERROR_WIFI_IFACE_INVALID, 181 &WifiStaIface::getDebugTxPacketFatesInternal, 182 hidl_status_cb); 183} 184 185Return<void> WifiStaIface::getDebugRxPacketFates( 186 getDebugRxPacketFates_cb hidl_status_cb) { 187 return validateAndCall(this, 188 WifiStatusCode::ERROR_WIFI_IFACE_INVALID, 189 &WifiStaIface::getDebugRxPacketFatesInternal, 190 hidl_status_cb); 191} 192 193std::pair<WifiStatus, std::string> WifiStaIface::getNameInternal() { 194 return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_}; 195} 196 197std::pair<WifiStatus, IfaceType> WifiStaIface::getTypeInternal() { 198 return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::STA}; 199} 200 201WifiStatus WifiStaIface::registerEventCallbackInternal( 202 const sp<IWifiStaIfaceEventCallback>& callback) { 203 // TODO(b/31632518): remove the callback when the client is destroyed 204 event_callbacks_.emplace_back(callback); 205 return createWifiStatus(WifiStatusCode::SUCCESS); 206} 207 208std::pair<WifiStatus, uint32_t> WifiStaIface::getCapabilitiesInternal() { 209 // TODO implement 210 return {createWifiStatus(WifiStatusCode::SUCCESS), 0}; 211} 212 213std::pair<WifiStatus, StaApfPacketFilterCapabilities> 214WifiStaIface::getApfPacketFilterCapabilitiesInternal() { 215 // TODO implement 216 return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; 217} 218 219WifiStatus WifiStaIface::installApfPacketFilterInternal( 220 uint32_t /* cmd_id */, const std::vector<uint8_t>& /* program */) { 221 // TODO implement 222 return createWifiStatus(WifiStatusCode::SUCCESS); 223} 224 225std::pair<WifiStatus, StaBackgroundScanCapabilities> 226WifiStaIface::getBackgroundScanCapabilitiesInternal() { 227 // TODO implement 228 return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; 229} 230 231std::pair<WifiStatus, std::vector<WifiChannelInMhz>> 232WifiStaIface::getValidFrequenciesForBackgroundScanInternal( 233 StaBackgroundScanBand /* band */) { 234 // TODO implement 235 return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; 236} 237 238WifiStatus WifiStaIface::startBackgroundScanInternal( 239 uint32_t /* cmd_id */, const StaBackgroundScanParameters& /* params */) { 240 // TODO implement 241 return createWifiStatus(WifiStatusCode::SUCCESS); 242} 243 244WifiStatus WifiStaIface::stopBackgroundScanInternal(uint32_t /* cmd_id */) { 245 // TODO implement 246 return createWifiStatus(WifiStatusCode::SUCCESS); 247} 248 249WifiStatus WifiStaIface::enableLinkLayerStatsCollectionInternal( 250 bool /* debug */) { 251 // TODO implement 252 return createWifiStatus(WifiStatusCode::SUCCESS); 253} 254 255WifiStatus WifiStaIface::disableLinkLayerStatsCollectionInternal() { 256 // TODO implement 257 return createWifiStatus(WifiStatusCode::SUCCESS); 258} 259 260std::pair<WifiStatus, StaLinkLayerStats> 261WifiStaIface::getLinkLayerStatsInternal() { 262 // TODO implement 263 return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; 264} 265 266WifiStatus WifiStaIface::startDebugPacketFateMonitoringInternal() { 267 // TODO implement 268 return createWifiStatus(WifiStatusCode::SUCCESS); 269} 270 271WifiStatus WifiStaIface::stopDebugPacketFateMonitoringInternal() { 272 // TODO implement 273 return createWifiStatus(WifiStatusCode::SUCCESS); 274} 275 276std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>> 277WifiStaIface::getDebugTxPacketFatesInternal() { 278 // TODO implement 279 return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; 280} 281 282std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>> 283WifiStaIface::getDebugRxPacketFatesInternal() { 284 // TODO implement 285 return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; 286} 287 288} // namespace implementation 289} // namespace V1_0 290} // namespace wifi 291} // namespace hardware 292} // namespace android 293