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