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