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" |
Roshan Pius | e2d0ab5 | 2016-12-05 15:24:20 -0800 | [diff] [blame] | 20 | #include "hidl_struct_util.h" |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 21 | #include "wifi_chip.h" |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 22 | #include "wifi_status_util.h" |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 23 | |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 24 | namespace { |
| 25 | using android::sp; |
| 26 | using android::hardware::hidl_vec; |
| 27 | using android::hardware::hidl_string; |
Roshan Pius | 52947fb | 2016-11-18 11:38:07 -0800 | [diff] [blame] | 28 | using android::hardware::wifi::V1_0::IWifiChip; |
| 29 | using android::hardware::wifi::V1_0::IfaceType; |
| 30 | |
| 31 | constexpr uint32_t kStaChipModeId = 0; |
| 32 | constexpr uint32_t kApChipModeId = 1; |
| 33 | constexpr uint32_t kInvalidModeId = UINT32_MAX; |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 34 | |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 35 | template <typename Iface> |
| 36 | void invalidateAndClear(sp<Iface>& iface) { |
| 37 | if (iface.get()) { |
| 38 | iface->invalidate(); |
| 39 | iface.clear(); |
| 40 | } |
| 41 | } |
| 42 | } // namepsace |
| 43 | |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 44 | namespace android { |
| 45 | namespace hardware { |
| 46 | namespace wifi { |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 47 | namespace V1_0 { |
| 48 | namespace implementation { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 49 | using hidl_return_util::validateAndCall; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 50 | |
Roshan Pius | 52947fb | 2016-11-18 11:38:07 -0800 | [diff] [blame] | 51 | WifiChip::WifiChip( |
| 52 | ChipId chip_id, |
| 53 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal, |
| 54 | const std::weak_ptr<mode_controller::WifiModeController> mode_controller) |
| 55 | : chip_id_(chip_id), |
| 56 | legacy_hal_(legacy_hal), |
| 57 | mode_controller_(mode_controller), |
| 58 | is_valid_(true), |
| 59 | current_mode_id_(kInvalidModeId) {} |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 60 | |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 61 | void WifiChip::invalidate() { |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 62 | invalidateAndRemoveAllIfaces(); |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 63 | legacy_hal_.reset(); |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 64 | event_callbacks_.clear(); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 65 | is_valid_ = false; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 66 | } |
| 67 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 68 | bool WifiChip::isValid() { |
| 69 | return is_valid_; |
| 70 | } |
| 71 | |
Roshan Pius | 203cb03 | 2016-12-14 17:41:20 -0800 | [diff] [blame^] | 72 | std::vector<sp<IWifiChipEventCallback>> WifiChip::getEventCallbacks() { |
| 73 | return event_callbacks_; |
| 74 | } |
| 75 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 76 | Return<void> WifiChip::getId(getId_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::getIdInternal, |
| 80 | hidl_status_cb); |
Roshan Pius | cd566bd | 2016-10-10 08:03:42 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 83 | Return<void> WifiChip::registerEventCallback( |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 84 | const sp<IWifiChipEventCallback>& event_callback, |
| 85 | registerEventCallback_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 86 | return validateAndCall(this, |
| 87 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 88 | &WifiChip::registerEventCallbackInternal, |
| 89 | hidl_status_cb, |
| 90 | event_callback); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 91 | } |
| 92 | |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 93 | Return<void> WifiChip::getCapabilities(getCapabilities_cb hidl_status_cb) { |
| 94 | return validateAndCall(this, |
| 95 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 96 | &WifiChip::getCapabilitiesInternal, |
| 97 | hidl_status_cb); |
| 98 | } |
| 99 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 100 | Return<void> WifiChip::getAvailableModes(getAvailableModes_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::getAvailableModesInternal, |
| 104 | hidl_status_cb); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 105 | } |
| 106 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 107 | Return<void> WifiChip::configureChip(uint32_t mode_id, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 108 | configureChip_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::configureChipInternal, |
| 112 | hidl_status_cb, |
| 113 | mode_id); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 114 | } |
| 115 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 116 | Return<void> WifiChip::getMode(getMode_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::getModeInternal, |
| 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::requestChipDebugInfo( |
| 124 | requestChipDebugInfo_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 125 | return validateAndCall(this, |
| 126 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 127 | &WifiChip::requestChipDebugInfoInternal, |
| 128 | hidl_status_cb); |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | Return<void> WifiChip::requestDriverDebugDump( |
| 132 | requestDriverDebugDump_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 133 | return validateAndCall(this, |
| 134 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 135 | &WifiChip::requestDriverDebugDumpInternal, |
| 136 | hidl_status_cb); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 137 | } |
| 138 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 139 | Return<void> WifiChip::requestFirmwareDebugDump( |
| 140 | requestFirmwareDebugDump_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 141 | return validateAndCall(this, |
| 142 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 143 | &WifiChip::requestFirmwareDebugDumpInternal, |
| 144 | hidl_status_cb); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 145 | } |
| 146 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 147 | Return<void> WifiChip::createApIface(createApIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 148 | return validateAndCall(this, |
| 149 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 150 | &WifiChip::createApIfaceInternal, |
| 151 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 152 | } |
| 153 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 154 | Return<void> WifiChip::getApIfaceNames(getApIfaceNames_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 155 | return validateAndCall(this, |
| 156 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 157 | &WifiChip::getApIfaceNamesInternal, |
| 158 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 159 | } |
| 160 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 161 | Return<void> WifiChip::getApIface(const hidl_string& ifname, |
| 162 | getApIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 163 | return validateAndCall(this, |
| 164 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 165 | &WifiChip::getApIfaceInternal, |
| 166 | hidl_status_cb, |
| 167 | ifname); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 168 | } |
| 169 | |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame] | 170 | Return<void> WifiChip::removeApIface(const hidl_string& ifname, |
| 171 | removeApIface_cb hidl_status_cb) { |
| 172 | return validateAndCall(this, |
| 173 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 174 | &WifiChip::removeApIfaceInternal, |
| 175 | hidl_status_cb, |
| 176 | ifname); |
| 177 | } |
| 178 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 179 | Return<void> WifiChip::createNanIface(createNanIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 180 | return validateAndCall(this, |
| 181 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 182 | &WifiChip::createNanIfaceInternal, |
| 183 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 184 | } |
| 185 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 186 | Return<void> WifiChip::getNanIfaceNames(getNanIfaceNames_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 187 | return validateAndCall(this, |
| 188 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 189 | &WifiChip::getNanIfaceNamesInternal, |
| 190 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | Return<void> WifiChip::getNanIface(const hidl_string& ifname, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 194 | getNanIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 195 | return validateAndCall(this, |
| 196 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 197 | &WifiChip::getNanIfaceInternal, |
| 198 | hidl_status_cb, |
| 199 | ifname); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame] | 202 | Return<void> WifiChip::removeNanIface(const hidl_string& ifname, |
| 203 | removeNanIface_cb hidl_status_cb) { |
| 204 | return validateAndCall(this, |
| 205 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 206 | &WifiChip::removeNanIfaceInternal, |
| 207 | hidl_status_cb, |
| 208 | ifname); |
| 209 | } |
| 210 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 211 | Return<void> WifiChip::createP2pIface(createP2pIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 212 | return validateAndCall(this, |
| 213 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 214 | &WifiChip::createP2pIfaceInternal, |
| 215 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 218 | Return<void> WifiChip::getP2pIfaceNames(getP2pIfaceNames_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 219 | return validateAndCall(this, |
| 220 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 221 | &WifiChip::getP2pIfaceNamesInternal, |
| 222 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | Return<void> WifiChip::getP2pIface(const hidl_string& ifname, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 226 | getP2pIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 227 | return validateAndCall(this, |
| 228 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 229 | &WifiChip::getP2pIfaceInternal, |
| 230 | hidl_status_cb, |
| 231 | ifname); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 232 | } |
| 233 | |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame] | 234 | Return<void> WifiChip::removeP2pIface(const hidl_string& ifname, |
| 235 | removeP2pIface_cb hidl_status_cb) { |
| 236 | return validateAndCall(this, |
| 237 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 238 | &WifiChip::removeP2pIfaceInternal, |
| 239 | hidl_status_cb, |
| 240 | ifname); |
| 241 | } |
| 242 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 243 | Return<void> WifiChip::createStaIface(createStaIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 244 | return validateAndCall(this, |
| 245 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 246 | &WifiChip::createStaIfaceInternal, |
| 247 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 248 | } |
| 249 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 250 | Return<void> WifiChip::getStaIfaceNames(getStaIfaceNames_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 251 | return validateAndCall(this, |
| 252 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 253 | &WifiChip::getStaIfaceNamesInternal, |
| 254 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | Return<void> WifiChip::getStaIface(const hidl_string& ifname, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 258 | getStaIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 259 | return validateAndCall(this, |
| 260 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 261 | &WifiChip::getStaIfaceInternal, |
| 262 | hidl_status_cb, |
| 263 | ifname); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 264 | } |
| 265 | |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame] | 266 | Return<void> WifiChip::removeStaIface(const hidl_string& ifname, |
| 267 | removeStaIface_cb hidl_status_cb) { |
| 268 | return validateAndCall(this, |
| 269 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 270 | &WifiChip::removeStaIfaceInternal, |
| 271 | hidl_status_cb, |
| 272 | ifname); |
| 273 | } |
| 274 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 275 | Return<void> WifiChip::createRttController( |
| 276 | const sp<IWifiIface>& bound_iface, createRttController_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 277 | return validateAndCall(this, |
| 278 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 279 | &WifiChip::createRttControllerInternal, |
| 280 | hidl_status_cb, |
| 281 | bound_iface); |
Roshan Pius | 5926828 | 2016-10-06 20:23:47 -0700 | [diff] [blame] | 282 | } |
| 283 | |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 284 | Return<void> WifiChip::getDebugRingBuffersStatus( |
| 285 | getDebugRingBuffersStatus_cb hidl_status_cb) { |
| 286 | return validateAndCall(this, |
| 287 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 288 | &WifiChip::getDebugRingBuffersStatusInternal, |
| 289 | hidl_status_cb); |
| 290 | } |
| 291 | |
| 292 | Return<void> WifiChip::startLoggingToDebugRingBuffer( |
| 293 | const hidl_string& ring_name, |
| 294 | WifiDebugRingBufferVerboseLevel verbose_level, |
| 295 | uint32_t max_interval_in_sec, |
| 296 | uint32_t min_data_size_in_bytes, |
| 297 | startLoggingToDebugRingBuffer_cb hidl_status_cb) { |
| 298 | return validateAndCall(this, |
| 299 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 300 | &WifiChip::startLoggingToDebugRingBufferInternal, |
| 301 | hidl_status_cb, |
| 302 | ring_name, |
| 303 | verbose_level, |
| 304 | max_interval_in_sec, |
| 305 | min_data_size_in_bytes); |
| 306 | } |
| 307 | |
| 308 | Return<void> WifiChip::forceDumpToDebugRingBuffer( |
| 309 | const hidl_string& ring_name, |
| 310 | forceDumpToDebugRingBuffer_cb hidl_status_cb) { |
| 311 | return validateAndCall(this, |
| 312 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 313 | &WifiChip::forceDumpToDebugRingBufferInternal, |
| 314 | hidl_status_cb, |
| 315 | ring_name); |
| 316 | } |
| 317 | |
| 318 | Return<void> WifiChip::getDebugHostWakeReasonStats( |
| 319 | getDebugHostWakeReasonStats_cb hidl_status_cb) { |
| 320 | return validateAndCall(this, |
| 321 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 322 | &WifiChip::getDebugHostWakeReasonStatsInternal, |
| 323 | hidl_status_cb); |
| 324 | } |
| 325 | |
Roshan Pius | 203cb03 | 2016-12-14 17:41:20 -0800 | [diff] [blame^] | 326 | Return<void> WifiChip::enableDebugErrorAlerts( |
| 327 | bool enable, enableDebugErrorAlerts_cb hidl_status_cb) { |
| 328 | return validateAndCall(this, |
| 329 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 330 | &WifiChip::enableDebugErrorAlertsInternal, |
| 331 | hidl_status_cb, |
| 332 | enable); |
| 333 | } |
| 334 | |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 335 | void WifiChip::invalidateAndRemoveAllIfaces() { |
| 336 | invalidateAndClear(ap_iface_); |
| 337 | invalidateAndClear(nan_iface_); |
| 338 | invalidateAndClear(p2p_iface_); |
| 339 | invalidateAndClear(sta_iface_); |
Roshan Pius | 5926828 | 2016-10-06 20:23:47 -0700 | [diff] [blame] | 340 | // Since all the ifaces are invalid now, all RTT controller objects |
| 341 | // using those ifaces also need to be invalidated. |
| 342 | for (const auto& rtt : rtt_controllers_) { |
| 343 | rtt->invalidate(); |
| 344 | } |
| 345 | rtt_controllers_.clear(); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 346 | } |
| 347 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 348 | std::pair<WifiStatus, ChipId> WifiChip::getIdInternal() { |
| 349 | return {createWifiStatus(WifiStatusCode::SUCCESS), chip_id_}; |
| 350 | } |
| 351 | |
| 352 | WifiStatus WifiChip::registerEventCallbackInternal( |
| 353 | const sp<IWifiChipEventCallback>& event_callback) { |
| 354 | // TODO(b/31632518): remove the callback when the client is destroyed |
| 355 | event_callbacks_.emplace_back(event_callback); |
| 356 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 357 | } |
| 358 | |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 359 | std::pair<WifiStatus, uint32_t> WifiChip::getCapabilitiesInternal() { |
Roshan Pius | e2d0ab5 | 2016-12-05 15:24:20 -0800 | [diff] [blame] | 360 | legacy_hal::wifi_error legacy_status; |
| 361 | uint32_t legacy_logger_feature_set; |
| 362 | std::tie(legacy_status, legacy_logger_feature_set) = |
| 363 | legacy_hal_.lock()->getLoggerSupportedFeatureSet(); |
| 364 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 365 | return {createWifiStatusFromLegacyError(legacy_status), 0}; |
| 366 | } |
| 367 | uint32_t hidl_caps; |
| 368 | if (!hidl_struct_util::convertLegacyFeaturesToHidlChipCapabilities( |
| 369 | legacy_logger_feature_set, &hidl_caps)) { |
| 370 | return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), 0}; |
| 371 | } |
| 372 | return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps}; |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 373 | } |
| 374 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 375 | std::pair<WifiStatus, std::vector<IWifiChip::ChipMode>> |
| 376 | WifiChip::getAvailableModesInternal() { |
Roshan Pius | 52947fb | 2016-11-18 11:38:07 -0800 | [diff] [blame] | 377 | // The chip combination supported for current devices is fixed for now with |
| 378 | // 2 separate modes of operation: |
| 379 | // Mode 1 (STA mode): Will support 1 STA and 1 P2P or NAN iface operations |
| 380 | // concurrently. |
| 381 | // Mode 2 (AP mode): Will support 1 AP iface operations. |
| 382 | // TODO (b/32997844): Read this from some device specific flags in the |
| 383 | // makefile. |
| 384 | // STA mode iface combinations. |
| 385 | const IWifiChip::ChipIfaceCombinationLimit |
| 386 | sta_chip_iface_combination_limit_1 = {{IfaceType::STA}, 1}; |
| 387 | const IWifiChip::ChipIfaceCombinationLimit |
| 388 | sta_chip_iface_combination_limit_2 = {{IfaceType::P2P, IfaceType::NAN}, |
| 389 | 1}; |
| 390 | const IWifiChip::ChipIfaceCombination sta_chip_iface_combination = { |
| 391 | {sta_chip_iface_combination_limit_1, sta_chip_iface_combination_limit_2}}; |
| 392 | const IWifiChip::ChipMode sta_chip_mode = {kStaChipModeId, |
| 393 | {sta_chip_iface_combination}}; |
| 394 | // AP mode iface combinations. |
| 395 | const IWifiChip::ChipIfaceCombinationLimit ap_chip_iface_combination_limit = { |
| 396 | {IfaceType::AP}, 1}; |
| 397 | const IWifiChip::ChipIfaceCombination ap_chip_iface_combination = { |
| 398 | {ap_chip_iface_combination_limit}}; |
| 399 | const IWifiChip::ChipMode ap_chip_mode = {kApChipModeId, |
| 400 | {ap_chip_iface_combination}}; |
| 401 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 402 | {sta_chip_mode, ap_chip_mode}}; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 403 | } |
| 404 | |
Roshan Pius | 52947fb | 2016-11-18 11:38:07 -0800 | [diff] [blame] | 405 | WifiStatus WifiChip::configureChipInternal(uint32_t mode_id) { |
| 406 | if (mode_id != kStaChipModeId && mode_id != kApChipModeId) { |
| 407 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 408 | } |
| 409 | if (mode_id == current_mode_id_) { |
| 410 | LOG(DEBUG) << "Already in the specified mode " << mode_id; |
| 411 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 412 | } |
| 413 | // If the chip is already configured in a different mode, stop |
| 414 | // the legacy HAL and then start it after firmware mode change. |
| 415 | if (current_mode_id_ != kInvalidModeId) { |
| 416 | invalidateAndRemoveAllIfaces(); |
| 417 | legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->stop([]() {}); |
| 418 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 419 | LOG(ERROR) << "Failed to stop legacy HAL: " |
| 420 | << legacyErrorToString(legacy_status); |
| 421 | // TODO(b/33038823): Need to invoke onChipReconfigureFailure() |
| 422 | return createWifiStatusFromLegacyError(legacy_status); |
| 423 | } |
| 424 | } |
| 425 | bool success; |
| 426 | if (mode_id == kStaChipModeId) { |
| 427 | success = mode_controller_.lock()->changeFirmwareMode(IfaceType::STA); |
| 428 | } else { |
| 429 | success = mode_controller_.lock()->changeFirmwareMode(IfaceType::AP); |
| 430 | } |
| 431 | if (!success) { |
| 432 | // TODO(b/33038823): Need to invoke onChipReconfigureFailure() |
| 433 | return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); |
| 434 | } |
| 435 | legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->start(); |
| 436 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 437 | LOG(ERROR) << "Failed to start legacy HAL: " |
| 438 | << legacyErrorToString(legacy_status); |
| 439 | // TODO(b/33038823): Need to invoke onChipReconfigureFailure() |
| 440 | return createWifiStatusFromLegacyError(legacy_status); |
| 441 | } |
| 442 | for (const auto& callback : event_callbacks_) { |
| 443 | callback->onChipReconfigured(mode_id); |
| 444 | } |
| 445 | current_mode_id_ = mode_id; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 446 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 447 | } |
| 448 | |
| 449 | std::pair<WifiStatus, uint32_t> WifiChip::getModeInternal() { |
Roshan Pius | 52947fb | 2016-11-18 11:38:07 -0800 | [diff] [blame] | 450 | if (current_mode_id_ == kInvalidModeId) { |
| 451 | return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), |
| 452 | current_mode_id_}; |
| 453 | } |
| 454 | return {createWifiStatus(WifiStatusCode::SUCCESS), current_mode_id_}; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | std::pair<WifiStatus, IWifiChip::ChipDebugInfo> |
| 458 | WifiChip::requestChipDebugInfoInternal() { |
| 459 | IWifiChip::ChipDebugInfo result; |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 460 | legacy_hal::wifi_error legacy_status; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 461 | std::string driver_desc; |
| 462 | std::tie(legacy_status, driver_desc) = legacy_hal_.lock()->getDriverVersion(); |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 463 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 464 | LOG(ERROR) << "Failed to get driver version: " |
| 465 | << legacyErrorToString(legacy_status); |
| 466 | WifiStatus status = createWifiStatusFromLegacyError( |
| 467 | legacy_status, "failed to get driver version"); |
| 468 | return {status, result}; |
| 469 | } |
| 470 | result.driverDescription = driver_desc.c_str(); |
| 471 | |
| 472 | std::string firmware_desc; |
| 473 | std::tie(legacy_status, firmware_desc) = |
| 474 | legacy_hal_.lock()->getFirmwareVersion(); |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 475 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 476 | LOG(ERROR) << "Failed to get firmware version: " |
| 477 | << legacyErrorToString(legacy_status); |
| 478 | WifiStatus status = createWifiStatusFromLegacyError( |
| 479 | legacy_status, "failed to get firmware version"); |
| 480 | return {status, result}; |
| 481 | } |
| 482 | result.firmwareDescription = firmware_desc.c_str(); |
| 483 | |
| 484 | return {createWifiStatus(WifiStatusCode::SUCCESS), result}; |
| 485 | } |
| 486 | |
| 487 | std::pair<WifiStatus, std::vector<uint8_t>> |
| 488 | WifiChip::requestDriverDebugDumpInternal() { |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 489 | legacy_hal::wifi_error legacy_status; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 490 | std::vector<uint8_t> driver_dump; |
| 491 | std::tie(legacy_status, driver_dump) = |
| 492 | legacy_hal_.lock()->requestDriverMemoryDump(); |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 493 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 494 | LOG(ERROR) << "Failed to get driver debug dump: " |
| 495 | << legacyErrorToString(legacy_status); |
| 496 | return {createWifiStatusFromLegacyError(legacy_status), |
| 497 | std::vector<uint8_t>()}; |
| 498 | } |
| 499 | return {createWifiStatus(WifiStatusCode::SUCCESS), driver_dump}; |
| 500 | } |
| 501 | |
| 502 | std::pair<WifiStatus, std::vector<uint8_t>> |
| 503 | WifiChip::requestFirmwareDebugDumpInternal() { |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 504 | legacy_hal::wifi_error legacy_status; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 505 | std::vector<uint8_t> firmware_dump; |
| 506 | std::tie(legacy_status, firmware_dump) = |
| 507 | legacy_hal_.lock()->requestFirmwareMemoryDump(); |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 508 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 509 | LOG(ERROR) << "Failed to get firmware debug dump: " |
| 510 | << legacyErrorToString(legacy_status); |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 511 | return {createWifiStatusFromLegacyError(legacy_status), {}}; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 512 | } |
| 513 | return {createWifiStatus(WifiStatusCode::SUCCESS), firmware_dump}; |
| 514 | } |
| 515 | |
| 516 | std::pair<WifiStatus, sp<IWifiApIface>> WifiChip::createApIfaceInternal() { |
Roshan Pius | 073d5b9 | 2016-12-08 19:10:06 -0800 | [diff] [blame] | 517 | if (current_mode_id_ != kApChipModeId || ap_iface_.get()) { |
| 518 | return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}}; |
| 519 | } |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 520 | std::string ifname = legacy_hal_.lock()->getApIfaceName(); |
| 521 | ap_iface_ = new WifiApIface(ifname, legacy_hal_); |
| 522 | return {createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_}; |
| 523 | } |
| 524 | |
| 525 | std::pair<WifiStatus, std::vector<hidl_string>> |
| 526 | WifiChip::getApIfaceNamesInternal() { |
| 527 | if (!ap_iface_.get()) { |
| 528 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 529 | } |
| 530 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 531 | {legacy_hal_.lock()->getApIfaceName()}}; |
| 532 | } |
| 533 | |
| 534 | std::pair<WifiStatus, sp<IWifiApIface>> WifiChip::getApIfaceInternal( |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame] | 535 | const std::string& ifname) { |
| 536 | if (!ap_iface_.get() || (ifname != legacy_hal_.lock()->getApIfaceName())) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 537 | return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr}; |
| 538 | } |
| 539 | return {createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_}; |
| 540 | } |
| 541 | |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame] | 542 | WifiStatus WifiChip::removeApIfaceInternal(const std::string& ifname) { |
| 543 | if (!ap_iface_.get() || (ifname != legacy_hal_.lock()->getApIfaceName())) { |
| 544 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 545 | } |
| 546 | invalidateAndClear(ap_iface_); |
| 547 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 548 | } |
| 549 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 550 | std::pair<WifiStatus, sp<IWifiNanIface>> WifiChip::createNanIfaceInternal() { |
Roshan Pius | 073d5b9 | 2016-12-08 19:10:06 -0800 | [diff] [blame] | 551 | // Only 1 of NAN or P2P iface can be active at a time. |
| 552 | if (current_mode_id_ != kStaChipModeId || nan_iface_.get() || |
| 553 | p2p_iface_.get()) { |
| 554 | return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}}; |
| 555 | } |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 556 | std::string ifname = legacy_hal_.lock()->getNanIfaceName(); |
| 557 | nan_iface_ = new WifiNanIface(ifname, legacy_hal_); |
| 558 | return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_}; |
| 559 | } |
| 560 | |
| 561 | std::pair<WifiStatus, std::vector<hidl_string>> |
| 562 | WifiChip::getNanIfaceNamesInternal() { |
| 563 | if (!nan_iface_.get()) { |
| 564 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 565 | } |
| 566 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 567 | {legacy_hal_.lock()->getNanIfaceName()}}; |
| 568 | } |
| 569 | |
| 570 | std::pair<WifiStatus, sp<IWifiNanIface>> WifiChip::getNanIfaceInternal( |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame] | 571 | const std::string& ifname) { |
| 572 | if (!nan_iface_.get() || (ifname != legacy_hal_.lock()->getNanIfaceName())) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 573 | return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr}; |
| 574 | } |
| 575 | return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_}; |
| 576 | } |
| 577 | |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame] | 578 | WifiStatus WifiChip::removeNanIfaceInternal(const std::string& ifname) { |
| 579 | if (!nan_iface_.get() || (ifname != legacy_hal_.lock()->getNanIfaceName())) { |
| 580 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 581 | } |
| 582 | invalidateAndClear(nan_iface_); |
| 583 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 584 | } |
| 585 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 586 | std::pair<WifiStatus, sp<IWifiP2pIface>> WifiChip::createP2pIfaceInternal() { |
Roshan Pius | 073d5b9 | 2016-12-08 19:10:06 -0800 | [diff] [blame] | 587 | // Only 1 of NAN or P2P iface can be active at a time. |
| 588 | if (current_mode_id_ != kStaChipModeId || p2p_iface_.get() || |
| 589 | nan_iface_.get()) { |
| 590 | return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}}; |
| 591 | } |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 592 | std::string ifname = legacy_hal_.lock()->getP2pIfaceName(); |
| 593 | p2p_iface_ = new WifiP2pIface(ifname, legacy_hal_); |
| 594 | return {createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_}; |
| 595 | } |
| 596 | |
| 597 | std::pair<WifiStatus, std::vector<hidl_string>> |
| 598 | WifiChip::getP2pIfaceNamesInternal() { |
| 599 | if (!p2p_iface_.get()) { |
| 600 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 601 | } |
| 602 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 603 | {legacy_hal_.lock()->getP2pIfaceName()}}; |
| 604 | } |
| 605 | |
| 606 | std::pair<WifiStatus, sp<IWifiP2pIface>> WifiChip::getP2pIfaceInternal( |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame] | 607 | const std::string& ifname) { |
| 608 | if (!p2p_iface_.get() || (ifname != legacy_hal_.lock()->getP2pIfaceName())) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 609 | return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr}; |
| 610 | } |
| 611 | return {createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_}; |
| 612 | } |
| 613 | |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame] | 614 | WifiStatus WifiChip::removeP2pIfaceInternal(const std::string& ifname) { |
| 615 | if (!p2p_iface_.get() || (ifname != legacy_hal_.lock()->getP2pIfaceName())) { |
| 616 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 617 | } |
| 618 | invalidateAndClear(p2p_iface_); |
| 619 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 620 | } |
| 621 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 622 | std::pair<WifiStatus, sp<IWifiStaIface>> WifiChip::createStaIfaceInternal() { |
Roshan Pius | 073d5b9 | 2016-12-08 19:10:06 -0800 | [diff] [blame] | 623 | if (current_mode_id_ != kStaChipModeId || sta_iface_.get()) { |
| 624 | return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}}; |
| 625 | } |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 626 | std::string ifname = legacy_hal_.lock()->getStaIfaceName(); |
| 627 | sta_iface_ = new WifiStaIface(ifname, legacy_hal_); |
| 628 | return {createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_}; |
| 629 | } |
| 630 | |
| 631 | std::pair<WifiStatus, std::vector<hidl_string>> |
| 632 | WifiChip::getStaIfaceNamesInternal() { |
| 633 | if (!sta_iface_.get()) { |
| 634 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 635 | } |
| 636 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 637 | {legacy_hal_.lock()->getStaIfaceName()}}; |
| 638 | } |
| 639 | |
| 640 | std::pair<WifiStatus, sp<IWifiStaIface>> WifiChip::getStaIfaceInternal( |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame] | 641 | const std::string& ifname) { |
| 642 | if (!sta_iface_.get() || (ifname != legacy_hal_.lock()->getStaIfaceName())) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 643 | return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr}; |
| 644 | } |
| 645 | return {createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_}; |
| 646 | } |
| 647 | |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame] | 648 | WifiStatus WifiChip::removeStaIfaceInternal(const std::string& ifname) { |
| 649 | if (!sta_iface_.get() || (ifname != legacy_hal_.lock()->getStaIfaceName())) { |
| 650 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 651 | } |
| 652 | invalidateAndClear(sta_iface_); |
| 653 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 654 | } |
| 655 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 656 | std::pair<WifiStatus, sp<IWifiRttController>> |
| 657 | WifiChip::createRttControllerInternal(const sp<IWifiIface>& bound_iface) { |
| 658 | sp<WifiRttController> rtt = new WifiRttController(bound_iface, legacy_hal_); |
| 659 | rtt_controllers_.emplace_back(rtt); |
| 660 | return {createWifiStatus(WifiStatusCode::SUCCESS), rtt}; |
| 661 | } |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 662 | |
| 663 | std::pair<WifiStatus, std::vector<WifiDebugRingBufferStatus>> |
| 664 | WifiChip::getDebugRingBuffersStatusInternal() { |
Roshan Pius | e2d0ab5 | 2016-12-05 15:24:20 -0800 | [diff] [blame] | 665 | legacy_hal::wifi_error legacy_status; |
| 666 | std::vector<legacy_hal::wifi_ring_buffer_status> |
| 667 | legacy_ring_buffer_status_vec; |
| 668 | std::tie(legacy_status, legacy_ring_buffer_status_vec) = |
| 669 | legacy_hal_.lock()->getRingBuffersStatus(); |
| 670 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 671 | return {createWifiStatusFromLegacyError(legacy_status), {}}; |
| 672 | } |
| 673 | std::vector<WifiDebugRingBufferStatus> hidl_ring_buffer_status_vec; |
| 674 | if (!hidl_struct_util::convertLegacyVectorOfDebugRingBufferStatusToHidl( |
| 675 | legacy_ring_buffer_status_vec, &hidl_ring_buffer_status_vec)) { |
| 676 | return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}}; |
| 677 | } |
| 678 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 679 | hidl_ring_buffer_status_vec}; |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 680 | } |
| 681 | |
| 682 | WifiStatus WifiChip::startLoggingToDebugRingBufferInternal( |
Roshan Pius | e2d0ab5 | 2016-12-05 15:24:20 -0800 | [diff] [blame] | 683 | const hidl_string& ring_name, |
| 684 | WifiDebugRingBufferVerboseLevel verbose_level, |
| 685 | uint32_t max_interval_in_sec, |
| 686 | uint32_t min_data_size_in_bytes) { |
| 687 | legacy_hal::wifi_error legacy_status = |
| 688 | legacy_hal_.lock()->startRingBufferLogging( |
| 689 | ring_name, |
| 690 | static_cast< |
| 691 | std::underlying_type<WifiDebugRingBufferVerboseLevel>::type>( |
| 692 | verbose_level), |
| 693 | max_interval_in_sec, |
| 694 | min_data_size_in_bytes); |
| 695 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 696 | } |
| 697 | |
| 698 | WifiStatus WifiChip::forceDumpToDebugRingBufferInternal( |
Roshan Pius | e2d0ab5 | 2016-12-05 15:24:20 -0800 | [diff] [blame] | 699 | const hidl_string& ring_name) { |
| 700 | legacy_hal::wifi_error legacy_status = |
| 701 | legacy_hal_.lock()->getRingBufferData(ring_name); |
| 702 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | std::pair<WifiStatus, WifiDebugHostWakeReasonStats> |
| 706 | WifiChip::getDebugHostWakeReasonStatsInternal() { |
Roshan Pius | e2d0ab5 | 2016-12-05 15:24:20 -0800 | [diff] [blame] | 707 | legacy_hal::wifi_error legacy_status; |
| 708 | legacy_hal::WakeReasonStats legacy_stats; |
| 709 | std::tie(legacy_status, legacy_stats) = |
| 710 | legacy_hal_.lock()->getWakeReasonStats(); |
| 711 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 712 | return {createWifiStatusFromLegacyError(legacy_status), {}}; |
| 713 | } |
| 714 | WifiDebugHostWakeReasonStats hidl_stats; |
| 715 | if (!hidl_struct_util::convertLegacyWakeReasonStatsToHidl(legacy_stats, |
| 716 | &hidl_stats)) { |
| 717 | return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}}; |
| 718 | } |
| 719 | return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_stats}; |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 720 | } |
| 721 | |
Roshan Pius | 203cb03 | 2016-12-14 17:41:20 -0800 | [diff] [blame^] | 722 | WifiStatus WifiChip::enableDebugErrorAlertsInternal(bool enable) { |
| 723 | legacy_hal::wifi_error legacy_status; |
| 724 | if (enable) { |
| 725 | android::wp<WifiChip> weak_ptr_this(this); |
| 726 | const auto& on_alert_callback = [weak_ptr_this]( |
| 727 | int32_t error_code, std::vector<uint8_t> debug_data) { |
| 728 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 729 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 730 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 731 | return; |
| 732 | } |
| 733 | for (const auto& callback : shared_ptr_this->getEventCallbacks()) { |
| 734 | callback->onDebugErrorAlert(error_code, debug_data); |
| 735 | } |
| 736 | }; |
| 737 | legacy_status = legacy_hal_.lock()->registerErrorAlertCallbackHandler( |
| 738 | on_alert_callback); |
| 739 | } else { |
| 740 | legacy_status = legacy_hal_.lock()->deregisterErrorAlertCallbackHandler(); |
| 741 | } |
| 742 | return createWifiStatusFromLegacyError(legacy_status); |
| 743 | } |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 744 | } // namespace implementation |
| 745 | } // namespace V1_0 |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 746 | } // namespace wifi |
| 747 | } // namespace hardware |
| 748 | } // namespace android |