Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -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 | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 17 | #include <android-base/logging.h> |
| 18 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 19 | #include "hidl_return_util.h" |
| 20 | #include "wifi_chip.h" |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 21 | #include "wifi_status_util.h" |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 22 | |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 23 | namespace { |
| 24 | using android::sp; |
| 25 | using android::hardware::hidl_vec; |
| 26 | using android::hardware::hidl_string; |
| 27 | |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 28 | template <typename Iface> |
| 29 | void invalidateAndClear(sp<Iface>& iface) { |
| 30 | if (iface.get()) { |
| 31 | iface->invalidate(); |
| 32 | iface.clear(); |
| 33 | } |
| 34 | } |
| 35 | } // namepsace |
| 36 | |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 37 | namespace android { |
| 38 | namespace hardware { |
| 39 | namespace wifi { |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 40 | namespace V1_0 { |
| 41 | namespace implementation { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 42 | using hidl_return_util::validateAndCall; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 43 | |
Roshan Pius | cd566bd | 2016-10-10 08:03:42 -0700 | [diff] [blame] | 44 | WifiChip::WifiChip(ChipId chip_id, |
| 45 | const std::weak_ptr<WifiLegacyHal> legacy_hal) |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 46 | : chip_id_(chip_id), legacy_hal_(legacy_hal), is_valid_(true) {} |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 47 | |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 48 | void WifiChip::invalidate() { |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 49 | invalidateAndRemoveAllIfaces(); |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 50 | legacy_hal_.reset(); |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 51 | event_callbacks_.clear(); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 52 | is_valid_ = false; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 55 | bool WifiChip::isValid() { |
| 56 | return is_valid_; |
| 57 | } |
| 58 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 59 | Return<void> WifiChip::getId(getId_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 60 | return validateAndCall(this, |
| 61 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 62 | &WifiChip::getIdInternal, |
| 63 | hidl_status_cb); |
Roshan Pius | cd566bd | 2016-10-10 08:03:42 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 66 | Return<void> WifiChip::registerEventCallback( |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 67 | const sp<IWifiChipEventCallback>& event_callback, |
| 68 | registerEventCallback_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 69 | return validateAndCall(this, |
| 70 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 71 | &WifiChip::registerEventCallbackInternal, |
| 72 | hidl_status_cb, |
| 73 | event_callback); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 74 | } |
| 75 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 76 | Return<void> WifiChip::getAvailableModes(getAvailableModes_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 77 | return validateAndCall(this, |
| 78 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 79 | &WifiChip::getAvailableModesInternal, |
| 80 | hidl_status_cb); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 83 | Return<void> WifiChip::configureChip(uint32_t mode_id, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 84 | configureChip_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 85 | return validateAndCall(this, |
| 86 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 87 | &WifiChip::configureChipInternal, |
| 88 | hidl_status_cb, |
| 89 | mode_id); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 92 | Return<void> WifiChip::getMode(getMode_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 93 | return validateAndCall(this, |
| 94 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 95 | &WifiChip::getModeInternal, |
| 96 | hidl_status_cb); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 97 | } |
| 98 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 99 | Return<void> WifiChip::requestChipDebugInfo( |
| 100 | requestChipDebugInfo_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 101 | return validateAndCall(this, |
| 102 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 103 | &WifiChip::requestChipDebugInfoInternal, |
| 104 | hidl_status_cb); |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | Return<void> WifiChip::requestDriverDebugDump( |
| 108 | requestDriverDebugDump_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 109 | return validateAndCall(this, |
| 110 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 111 | &WifiChip::requestDriverDebugDumpInternal, |
| 112 | hidl_status_cb); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 115 | Return<void> WifiChip::requestFirmwareDebugDump( |
| 116 | requestFirmwareDebugDump_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 117 | return validateAndCall(this, |
| 118 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 119 | &WifiChip::requestFirmwareDebugDumpInternal, |
| 120 | hidl_status_cb); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 121 | } |
| 122 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 123 | Return<void> WifiChip::createApIface(createApIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 124 | return validateAndCall(this, |
| 125 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 126 | &WifiChip::createApIfaceInternal, |
| 127 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 128 | } |
| 129 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 130 | Return<void> WifiChip::getApIfaceNames(getApIfaceNames_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 131 | return validateAndCall(this, |
| 132 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 133 | &WifiChip::getApIfaceNamesInternal, |
| 134 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 135 | } |
| 136 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 137 | Return<void> WifiChip::getApIface(const hidl_string& ifname, |
| 138 | getApIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 139 | return validateAndCall(this, |
| 140 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 141 | &WifiChip::getApIfaceInternal, |
| 142 | hidl_status_cb, |
| 143 | ifname); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 144 | } |
| 145 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 146 | Return<void> WifiChip::createNanIface(createNanIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 147 | return validateAndCall(this, |
| 148 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 149 | &WifiChip::createNanIfaceInternal, |
| 150 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 153 | Return<void> WifiChip::getNanIfaceNames(getNanIfaceNames_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 154 | return validateAndCall(this, |
| 155 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 156 | &WifiChip::getNanIfaceNamesInternal, |
| 157 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | Return<void> WifiChip::getNanIface(const hidl_string& ifname, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 161 | getNanIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 162 | return validateAndCall(this, |
| 163 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 164 | &WifiChip::getNanIfaceInternal, |
| 165 | hidl_status_cb, |
| 166 | ifname); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 167 | } |
| 168 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 169 | Return<void> WifiChip::createP2pIface(createP2pIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 170 | return validateAndCall(this, |
| 171 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 172 | &WifiChip::createP2pIfaceInternal, |
| 173 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 174 | } |
| 175 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 176 | Return<void> WifiChip::getP2pIfaceNames(getP2pIfaceNames_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 177 | return validateAndCall(this, |
| 178 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 179 | &WifiChip::getP2pIfaceNamesInternal, |
| 180 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | Return<void> WifiChip::getP2pIface(const hidl_string& ifname, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 184 | getP2pIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 185 | return validateAndCall(this, |
| 186 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 187 | &WifiChip::getP2pIfaceInternal, |
| 188 | hidl_status_cb, |
| 189 | ifname); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 190 | } |
| 191 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 192 | Return<void> WifiChip::createStaIface(createStaIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 193 | return validateAndCall(this, |
| 194 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 195 | &WifiChip::createStaIfaceInternal, |
| 196 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 197 | } |
| 198 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 199 | Return<void> WifiChip::getStaIfaceNames(getStaIfaceNames_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 200 | return validateAndCall(this, |
| 201 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 202 | &WifiChip::getStaIfaceNamesInternal, |
| 203 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | Return<void> WifiChip::getStaIface(const hidl_string& ifname, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 207 | getStaIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 208 | return validateAndCall(this, |
| 209 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 210 | &WifiChip::getStaIfaceInternal, |
| 211 | hidl_status_cb, |
| 212 | ifname); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 213 | } |
| 214 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 215 | Return<void> WifiChip::createRttController( |
| 216 | const sp<IWifiIface>& bound_iface, createRttController_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 217 | return validateAndCall(this, |
| 218 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 219 | &WifiChip::createRttControllerInternal, |
| 220 | hidl_status_cb, |
| 221 | bound_iface); |
Roshan Pius | 5926828 | 2016-10-06 20:23:47 -0700 | [diff] [blame] | 222 | } |
| 223 | |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 224 | void WifiChip::invalidateAndRemoveAllIfaces() { |
| 225 | invalidateAndClear(ap_iface_); |
| 226 | invalidateAndClear(nan_iface_); |
| 227 | invalidateAndClear(p2p_iface_); |
| 228 | invalidateAndClear(sta_iface_); |
Roshan Pius | 5926828 | 2016-10-06 20:23:47 -0700 | [diff] [blame] | 229 | // Since all the ifaces are invalid now, all RTT controller objects |
| 230 | // using those ifaces also need to be invalidated. |
| 231 | for (const auto& rtt : rtt_controllers_) { |
| 232 | rtt->invalidate(); |
| 233 | } |
| 234 | rtt_controllers_.clear(); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 237 | std::pair<WifiStatus, ChipId> WifiChip::getIdInternal() { |
| 238 | return {createWifiStatus(WifiStatusCode::SUCCESS), chip_id_}; |
| 239 | } |
| 240 | |
| 241 | WifiStatus WifiChip::registerEventCallbackInternal( |
| 242 | const sp<IWifiChipEventCallback>& event_callback) { |
| 243 | // TODO(b/31632518): remove the callback when the client is destroyed |
| 244 | event_callbacks_.emplace_back(event_callback); |
| 245 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 246 | } |
| 247 | |
| 248 | std::pair<WifiStatus, std::vector<IWifiChip::ChipMode>> |
| 249 | WifiChip::getAvailableModesInternal() { |
| 250 | // TODO add implementation |
| 251 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 252 | std::vector<IWifiChip::ChipMode>()}; |
| 253 | } |
| 254 | |
| 255 | WifiStatus WifiChip::configureChipInternal(uint32_t /* mode_id */) { |
| 256 | invalidateAndRemoveAllIfaces(); |
| 257 | // TODO add implementation |
| 258 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 259 | } |
| 260 | |
| 261 | std::pair<WifiStatus, uint32_t> WifiChip::getModeInternal() { |
| 262 | // TODO add implementation |
| 263 | return {createWifiStatus(WifiStatusCode::SUCCESS), 0}; |
| 264 | } |
| 265 | |
| 266 | std::pair<WifiStatus, IWifiChip::ChipDebugInfo> |
| 267 | WifiChip::requestChipDebugInfoInternal() { |
| 268 | IWifiChip::ChipDebugInfo result; |
| 269 | wifi_error legacy_status; |
| 270 | std::string driver_desc; |
| 271 | std::tie(legacy_status, driver_desc) = legacy_hal_.lock()->getDriverVersion(); |
| 272 | if (legacy_status != WIFI_SUCCESS) { |
| 273 | LOG(ERROR) << "Failed to get driver version: " |
| 274 | << legacyErrorToString(legacy_status); |
| 275 | WifiStatus status = createWifiStatusFromLegacyError( |
| 276 | legacy_status, "failed to get driver version"); |
| 277 | return {status, result}; |
| 278 | } |
| 279 | result.driverDescription = driver_desc.c_str(); |
| 280 | |
| 281 | std::string firmware_desc; |
| 282 | std::tie(legacy_status, firmware_desc) = |
| 283 | legacy_hal_.lock()->getFirmwareVersion(); |
| 284 | if (legacy_status != WIFI_SUCCESS) { |
| 285 | LOG(ERROR) << "Failed to get firmware version: " |
| 286 | << legacyErrorToString(legacy_status); |
| 287 | WifiStatus status = createWifiStatusFromLegacyError( |
| 288 | legacy_status, "failed to get firmware version"); |
| 289 | return {status, result}; |
| 290 | } |
| 291 | result.firmwareDescription = firmware_desc.c_str(); |
| 292 | |
| 293 | return {createWifiStatus(WifiStatusCode::SUCCESS), result}; |
| 294 | } |
| 295 | |
| 296 | std::pair<WifiStatus, std::vector<uint8_t>> |
| 297 | WifiChip::requestDriverDebugDumpInternal() { |
| 298 | wifi_error legacy_status; |
| 299 | std::vector<uint8_t> driver_dump; |
| 300 | std::tie(legacy_status, driver_dump) = |
| 301 | legacy_hal_.lock()->requestDriverMemoryDump(); |
| 302 | if (legacy_status != WIFI_SUCCESS) { |
| 303 | LOG(ERROR) << "Failed to get driver debug dump: " |
| 304 | << legacyErrorToString(legacy_status); |
| 305 | return {createWifiStatusFromLegacyError(legacy_status), |
| 306 | std::vector<uint8_t>()}; |
| 307 | } |
| 308 | return {createWifiStatus(WifiStatusCode::SUCCESS), driver_dump}; |
| 309 | } |
| 310 | |
| 311 | std::pair<WifiStatus, std::vector<uint8_t>> |
| 312 | WifiChip::requestFirmwareDebugDumpInternal() { |
| 313 | wifi_error legacy_status; |
| 314 | std::vector<uint8_t> firmware_dump; |
| 315 | std::tie(legacy_status, firmware_dump) = |
| 316 | legacy_hal_.lock()->requestFirmwareMemoryDump(); |
| 317 | if (legacy_status != WIFI_SUCCESS) { |
| 318 | LOG(ERROR) << "Failed to get firmware debug dump: " |
| 319 | << legacyErrorToString(legacy_status); |
| 320 | return {createWifiStatusFromLegacyError(legacy_status), |
| 321 | std::vector<uint8_t>()}; |
| 322 | } |
| 323 | return {createWifiStatus(WifiStatusCode::SUCCESS), firmware_dump}; |
| 324 | } |
| 325 | |
| 326 | std::pair<WifiStatus, sp<IWifiApIface>> WifiChip::createApIfaceInternal() { |
| 327 | // TODO(b/31997422): Disallow this based on the chip combination. |
| 328 | std::string ifname = legacy_hal_.lock()->getApIfaceName(); |
| 329 | ap_iface_ = new WifiApIface(ifname, legacy_hal_); |
| 330 | return {createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_}; |
| 331 | } |
| 332 | |
| 333 | std::pair<WifiStatus, std::vector<hidl_string>> |
| 334 | WifiChip::getApIfaceNamesInternal() { |
| 335 | if (!ap_iface_.get()) { |
| 336 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 337 | } |
| 338 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 339 | {legacy_hal_.lock()->getApIfaceName()}}; |
| 340 | } |
| 341 | |
| 342 | std::pair<WifiStatus, sp<IWifiApIface>> WifiChip::getApIfaceInternal( |
| 343 | const hidl_string& ifname) { |
| 344 | if (!ap_iface_.get() || |
| 345 | (ifname.c_str() != legacy_hal_.lock()->getApIfaceName())) { |
| 346 | return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr}; |
| 347 | } |
| 348 | return {createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_}; |
| 349 | } |
| 350 | |
| 351 | std::pair<WifiStatus, sp<IWifiNanIface>> WifiChip::createNanIfaceInternal() { |
| 352 | // TODO(b/31997422): Disallow this based on the chip combination. |
| 353 | std::string ifname = legacy_hal_.lock()->getNanIfaceName(); |
| 354 | nan_iface_ = new WifiNanIface(ifname, legacy_hal_); |
| 355 | return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_}; |
| 356 | } |
| 357 | |
| 358 | std::pair<WifiStatus, std::vector<hidl_string>> |
| 359 | WifiChip::getNanIfaceNamesInternal() { |
| 360 | if (!nan_iface_.get()) { |
| 361 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 362 | } |
| 363 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 364 | {legacy_hal_.lock()->getNanIfaceName()}}; |
| 365 | } |
| 366 | |
| 367 | std::pair<WifiStatus, sp<IWifiNanIface>> WifiChip::getNanIfaceInternal( |
| 368 | const hidl_string& ifname) { |
| 369 | if (!nan_iface_.get() || |
| 370 | (ifname.c_str() != legacy_hal_.lock()->getNanIfaceName())) { |
| 371 | return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr}; |
| 372 | } |
| 373 | return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_}; |
| 374 | } |
| 375 | |
| 376 | std::pair<WifiStatus, sp<IWifiP2pIface>> WifiChip::createP2pIfaceInternal() { |
| 377 | // TODO(b/31997422): Disallow this based on the chip combination. |
| 378 | std::string ifname = legacy_hal_.lock()->getP2pIfaceName(); |
| 379 | p2p_iface_ = new WifiP2pIface(ifname, legacy_hal_); |
| 380 | return {createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_}; |
| 381 | } |
| 382 | |
| 383 | std::pair<WifiStatus, std::vector<hidl_string>> |
| 384 | WifiChip::getP2pIfaceNamesInternal() { |
| 385 | if (!p2p_iface_.get()) { |
| 386 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 387 | } |
| 388 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 389 | {legacy_hal_.lock()->getP2pIfaceName()}}; |
| 390 | } |
| 391 | |
| 392 | std::pair<WifiStatus, sp<IWifiP2pIface>> WifiChip::getP2pIfaceInternal( |
| 393 | const hidl_string& ifname) { |
| 394 | if (!p2p_iface_.get() || |
| 395 | (ifname.c_str() != legacy_hal_.lock()->getP2pIfaceName())) { |
| 396 | return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr}; |
| 397 | } |
| 398 | return {createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_}; |
| 399 | } |
| 400 | |
| 401 | std::pair<WifiStatus, sp<IWifiStaIface>> WifiChip::createStaIfaceInternal() { |
| 402 | // TODO(b/31997422): Disallow this based on the chip combination. |
| 403 | std::string ifname = legacy_hal_.lock()->getStaIfaceName(); |
| 404 | sta_iface_ = new WifiStaIface(ifname, legacy_hal_); |
| 405 | return {createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_}; |
| 406 | } |
| 407 | |
| 408 | std::pair<WifiStatus, std::vector<hidl_string>> |
| 409 | WifiChip::getStaIfaceNamesInternal() { |
| 410 | if (!sta_iface_.get()) { |
| 411 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 412 | } |
| 413 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 414 | {legacy_hal_.lock()->getStaIfaceName()}}; |
| 415 | } |
| 416 | |
| 417 | std::pair<WifiStatus, sp<IWifiStaIface>> WifiChip::getStaIfaceInternal( |
| 418 | const hidl_string& ifname) { |
| 419 | if (!sta_iface_.get() || |
| 420 | (ifname.c_str() != legacy_hal_.lock()->getStaIfaceName())) { |
| 421 | return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr}; |
| 422 | } |
| 423 | return {createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_}; |
| 424 | } |
| 425 | |
| 426 | std::pair<WifiStatus, sp<IWifiRttController>> |
| 427 | WifiChip::createRttControllerInternal(const sp<IWifiIface>& bound_iface) { |
| 428 | sp<WifiRttController> rtt = new WifiRttController(bound_iface, legacy_hal_); |
| 429 | rtt_controllers_.emplace_back(rtt); |
| 430 | return {createWifiStatus(WifiStatusCode::SUCCESS), rtt}; |
| 431 | } |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 432 | } // namespace implementation |
| 433 | } // namespace V1_0 |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 434 | } // namespace wifi |
| 435 | } // namespace hardware |
| 436 | } // namespace android |