Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 17 | #include <android-base/logging.h> |
| 18 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 19 | #include "hidl_return_util.h" |
| 20 | #include "wifi_chip.h" |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 21 | #include "wifi_status_util.h" |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 22 | |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 23 | namespace { |
| 24 | using android::sp; |
| 25 | using android::hardware::hidl_vec; |
| 26 | using android::hardware::hidl_string; |
| 27 | |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 28 | template <typename Iface> |
| 29 | void invalidateAndClear(sp<Iface>& iface) { |
| 30 | if (iface.get()) { |
| 31 | iface->invalidate(); |
| 32 | iface.clear(); |
| 33 | } |
| 34 | } |
| 35 | } // namepsace |
| 36 | |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 37 | namespace android { |
| 38 | namespace hardware { |
| 39 | namespace wifi { |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 40 | namespace V1_0 { |
| 41 | namespace implementation { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 42 | using hidl_return_util::validateAndCall; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 43 | |
Roshan Pius | cd566bd | 2016-10-10 08:03:42 -0700 | [diff] [blame] | 44 | WifiChip::WifiChip(ChipId chip_id, |
Roshan Pius | 6cedc97 | 2016-10-28 10:11:17 -0700 | [diff] [blame] | 45 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal) |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 46 | : chip_id_(chip_id), legacy_hal_(legacy_hal), is_valid_(true) {} |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 47 | |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 48 | void WifiChip::invalidate() { |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 49 | invalidateAndRemoveAllIfaces(); |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 50 | legacy_hal_.reset(); |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 51 | event_callbacks_.clear(); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 52 | is_valid_ = false; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 55 | bool WifiChip::isValid() { |
| 56 | return is_valid_; |
| 57 | } |
| 58 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 59 | Return<void> WifiChip::getId(getId_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 60 | return validateAndCall(this, |
| 61 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 62 | &WifiChip::getIdInternal, |
| 63 | hidl_status_cb); |
Roshan Pius | cd566bd | 2016-10-10 08:03:42 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 66 | Return<void> WifiChip::registerEventCallback( |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 67 | const sp<IWifiChipEventCallback>& event_callback, |
| 68 | registerEventCallback_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 69 | return validateAndCall(this, |
| 70 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 71 | &WifiChip::registerEventCallbackInternal, |
| 72 | hidl_status_cb, |
| 73 | event_callback); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 74 | } |
| 75 | |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 76 | Return<void> WifiChip::getCapabilities(getCapabilities_cb hidl_status_cb) { |
| 77 | return validateAndCall(this, |
| 78 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 79 | &WifiChip::getCapabilitiesInternal, |
| 80 | hidl_status_cb); |
| 81 | } |
| 82 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 83 | Return<void> WifiChip::getAvailableModes(getAvailableModes_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 84 | return validateAndCall(this, |
| 85 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 86 | &WifiChip::getAvailableModesInternal, |
| 87 | hidl_status_cb); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 88 | } |
| 89 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 90 | Return<void> WifiChip::configureChip(uint32_t mode_id, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 91 | configureChip_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 92 | return validateAndCall(this, |
| 93 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 94 | &WifiChip::configureChipInternal, |
| 95 | hidl_status_cb, |
| 96 | mode_id); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 97 | } |
| 98 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 99 | Return<void> WifiChip::getMode(getMode_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 100 | return validateAndCall(this, |
| 101 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 102 | &WifiChip::getModeInternal, |
| 103 | hidl_status_cb); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 104 | } |
| 105 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 106 | Return<void> WifiChip::requestChipDebugInfo( |
| 107 | requestChipDebugInfo_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 108 | return validateAndCall(this, |
| 109 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 110 | &WifiChip::requestChipDebugInfoInternal, |
| 111 | hidl_status_cb); |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | Return<void> WifiChip::requestDriverDebugDump( |
| 115 | requestDriverDebugDump_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 116 | return validateAndCall(this, |
| 117 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 118 | &WifiChip::requestDriverDebugDumpInternal, |
| 119 | hidl_status_cb); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 120 | } |
| 121 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 122 | Return<void> WifiChip::requestFirmwareDebugDump( |
| 123 | requestFirmwareDebugDump_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 124 | return validateAndCall(this, |
| 125 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 126 | &WifiChip::requestFirmwareDebugDumpInternal, |
| 127 | hidl_status_cb); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 128 | } |
| 129 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 130 | Return<void> WifiChip::createApIface(createApIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 131 | return validateAndCall(this, |
| 132 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 133 | &WifiChip::createApIfaceInternal, |
| 134 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 135 | } |
| 136 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 137 | Return<void> WifiChip::getApIfaceNames(getApIfaceNames_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 138 | return validateAndCall(this, |
| 139 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 140 | &WifiChip::getApIfaceNamesInternal, |
| 141 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 142 | } |
| 143 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 144 | Return<void> WifiChip::getApIface(const hidl_string& ifname, |
| 145 | getApIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 146 | return validateAndCall(this, |
| 147 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 148 | &WifiChip::getApIfaceInternal, |
| 149 | hidl_status_cb, |
| 150 | ifname); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 153 | Return<void> WifiChip::createNanIface(createNanIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 154 | return validateAndCall(this, |
| 155 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 156 | &WifiChip::createNanIfaceInternal, |
| 157 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 158 | } |
| 159 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 160 | Return<void> WifiChip::getNanIfaceNames(getNanIfaceNames_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 161 | return validateAndCall(this, |
| 162 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 163 | &WifiChip::getNanIfaceNamesInternal, |
| 164 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | Return<void> WifiChip::getNanIface(const hidl_string& ifname, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 168 | getNanIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 169 | return validateAndCall(this, |
| 170 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 171 | &WifiChip::getNanIfaceInternal, |
| 172 | hidl_status_cb, |
| 173 | ifname); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 174 | } |
| 175 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 176 | Return<void> WifiChip::createP2pIface(createP2pIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 177 | return validateAndCall(this, |
| 178 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 179 | &WifiChip::createP2pIfaceInternal, |
| 180 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 181 | } |
| 182 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 183 | Return<void> WifiChip::getP2pIfaceNames(getP2pIfaceNames_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 184 | return validateAndCall(this, |
| 185 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 186 | &WifiChip::getP2pIfaceNamesInternal, |
| 187 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | Return<void> WifiChip::getP2pIface(const hidl_string& ifname, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 191 | getP2pIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 192 | return validateAndCall(this, |
| 193 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 194 | &WifiChip::getP2pIfaceInternal, |
| 195 | hidl_status_cb, |
| 196 | ifname); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 197 | } |
| 198 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 199 | Return<void> WifiChip::createStaIface(createStaIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 200 | return validateAndCall(this, |
| 201 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 202 | &WifiChip::createStaIfaceInternal, |
| 203 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 204 | } |
| 205 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 206 | Return<void> WifiChip::getStaIfaceNames(getStaIfaceNames_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 207 | return validateAndCall(this, |
| 208 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 209 | &WifiChip::getStaIfaceNamesInternal, |
| 210 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | Return<void> WifiChip::getStaIface(const hidl_string& ifname, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 214 | getStaIface_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::getStaIfaceInternal, |
| 218 | hidl_status_cb, |
| 219 | ifname); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 220 | } |
| 221 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 222 | Return<void> WifiChip::createRttController( |
| 223 | const sp<IWifiIface>& bound_iface, createRttController_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 224 | return validateAndCall(this, |
| 225 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 226 | &WifiChip::createRttControllerInternal, |
| 227 | hidl_status_cb, |
| 228 | bound_iface); |
Roshan Pius | 5926828 | 2016-10-06 20:23:47 -0700 | [diff] [blame] | 229 | } |
| 230 | |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 231 | Return<void> WifiChip::getDebugRingBuffersStatus( |
| 232 | getDebugRingBuffersStatus_cb hidl_status_cb) { |
| 233 | return validateAndCall(this, |
| 234 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 235 | &WifiChip::getDebugRingBuffersStatusInternal, |
| 236 | hidl_status_cb); |
| 237 | } |
| 238 | |
| 239 | Return<void> WifiChip::startLoggingToDebugRingBuffer( |
| 240 | const hidl_string& ring_name, |
| 241 | WifiDebugRingBufferVerboseLevel verbose_level, |
| 242 | uint32_t max_interval_in_sec, |
| 243 | uint32_t min_data_size_in_bytes, |
| 244 | startLoggingToDebugRingBuffer_cb hidl_status_cb) { |
| 245 | return validateAndCall(this, |
| 246 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 247 | &WifiChip::startLoggingToDebugRingBufferInternal, |
| 248 | hidl_status_cb, |
| 249 | ring_name, |
| 250 | verbose_level, |
| 251 | max_interval_in_sec, |
| 252 | min_data_size_in_bytes); |
| 253 | } |
| 254 | |
| 255 | Return<void> WifiChip::forceDumpToDebugRingBuffer( |
| 256 | const hidl_string& ring_name, |
| 257 | forceDumpToDebugRingBuffer_cb hidl_status_cb) { |
| 258 | return validateAndCall(this, |
| 259 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 260 | &WifiChip::forceDumpToDebugRingBufferInternal, |
| 261 | hidl_status_cb, |
| 262 | ring_name); |
| 263 | } |
| 264 | |
| 265 | Return<void> WifiChip::getDebugHostWakeReasonStats( |
| 266 | getDebugHostWakeReasonStats_cb hidl_status_cb) { |
| 267 | return validateAndCall(this, |
| 268 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 269 | &WifiChip::getDebugHostWakeReasonStatsInternal, |
| 270 | hidl_status_cb); |
| 271 | } |
| 272 | |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 273 | void WifiChip::invalidateAndRemoveAllIfaces() { |
| 274 | invalidateAndClear(ap_iface_); |
| 275 | invalidateAndClear(nan_iface_); |
| 276 | invalidateAndClear(p2p_iface_); |
| 277 | invalidateAndClear(sta_iface_); |
Roshan Pius | 5926828 | 2016-10-06 20:23:47 -0700 | [diff] [blame] | 278 | // Since all the ifaces are invalid now, all RTT controller objects |
| 279 | // using those ifaces also need to be invalidated. |
| 280 | for (const auto& rtt : rtt_controllers_) { |
| 281 | rtt->invalidate(); |
| 282 | } |
| 283 | rtt_controllers_.clear(); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 284 | } |
| 285 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 286 | std::pair<WifiStatus, ChipId> WifiChip::getIdInternal() { |
| 287 | return {createWifiStatus(WifiStatusCode::SUCCESS), chip_id_}; |
| 288 | } |
| 289 | |
| 290 | WifiStatus WifiChip::registerEventCallbackInternal( |
| 291 | const sp<IWifiChipEventCallback>& event_callback) { |
| 292 | // TODO(b/31632518): remove the callback when the client is destroyed |
| 293 | event_callbacks_.emplace_back(event_callback); |
| 294 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 295 | } |
| 296 | |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 297 | std::pair<WifiStatus, uint32_t> WifiChip::getCapabilitiesInternal() { |
| 298 | // TODO add implementation |
| 299 | return {createWifiStatus(WifiStatusCode::SUCCESS), 0}; |
| 300 | } |
| 301 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 302 | std::pair<WifiStatus, std::vector<IWifiChip::ChipMode>> |
| 303 | WifiChip::getAvailableModesInternal() { |
| 304 | // TODO add implementation |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 305 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | WifiStatus WifiChip::configureChipInternal(uint32_t /* mode_id */) { |
| 309 | invalidateAndRemoveAllIfaces(); |
| 310 | // TODO add implementation |
| 311 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 312 | } |
| 313 | |
| 314 | std::pair<WifiStatus, uint32_t> WifiChip::getModeInternal() { |
| 315 | // TODO add implementation |
| 316 | return {createWifiStatus(WifiStatusCode::SUCCESS), 0}; |
| 317 | } |
| 318 | |
| 319 | std::pair<WifiStatus, IWifiChip::ChipDebugInfo> |
| 320 | WifiChip::requestChipDebugInfoInternal() { |
| 321 | IWifiChip::ChipDebugInfo result; |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 322 | legacy_hal::wifi_error legacy_status; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 323 | std::string driver_desc; |
| 324 | std::tie(legacy_status, driver_desc) = legacy_hal_.lock()->getDriverVersion(); |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 325 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 326 | LOG(ERROR) << "Failed to get driver version: " |
| 327 | << legacyErrorToString(legacy_status); |
| 328 | WifiStatus status = createWifiStatusFromLegacyError( |
| 329 | legacy_status, "failed to get driver version"); |
| 330 | return {status, result}; |
| 331 | } |
| 332 | result.driverDescription = driver_desc.c_str(); |
| 333 | |
| 334 | std::string firmware_desc; |
| 335 | std::tie(legacy_status, firmware_desc) = |
| 336 | legacy_hal_.lock()->getFirmwareVersion(); |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 337 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 338 | LOG(ERROR) << "Failed to get firmware version: " |
| 339 | << legacyErrorToString(legacy_status); |
| 340 | WifiStatus status = createWifiStatusFromLegacyError( |
| 341 | legacy_status, "failed to get firmware version"); |
| 342 | return {status, result}; |
| 343 | } |
| 344 | result.firmwareDescription = firmware_desc.c_str(); |
| 345 | |
| 346 | return {createWifiStatus(WifiStatusCode::SUCCESS), result}; |
| 347 | } |
| 348 | |
| 349 | std::pair<WifiStatus, std::vector<uint8_t>> |
| 350 | WifiChip::requestDriverDebugDumpInternal() { |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 351 | legacy_hal::wifi_error legacy_status; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 352 | std::vector<uint8_t> driver_dump; |
| 353 | std::tie(legacy_status, driver_dump) = |
| 354 | legacy_hal_.lock()->requestDriverMemoryDump(); |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 355 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 356 | LOG(ERROR) << "Failed to get driver debug dump: " |
| 357 | << legacyErrorToString(legacy_status); |
| 358 | return {createWifiStatusFromLegacyError(legacy_status), |
| 359 | std::vector<uint8_t>()}; |
| 360 | } |
| 361 | return {createWifiStatus(WifiStatusCode::SUCCESS), driver_dump}; |
| 362 | } |
| 363 | |
| 364 | std::pair<WifiStatus, std::vector<uint8_t>> |
| 365 | WifiChip::requestFirmwareDebugDumpInternal() { |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 366 | legacy_hal::wifi_error legacy_status; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 367 | std::vector<uint8_t> firmware_dump; |
| 368 | std::tie(legacy_status, firmware_dump) = |
| 369 | legacy_hal_.lock()->requestFirmwareMemoryDump(); |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 370 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 371 | LOG(ERROR) << "Failed to get firmware debug dump: " |
| 372 | << legacyErrorToString(legacy_status); |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 373 | return {createWifiStatusFromLegacyError(legacy_status), {}}; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 374 | } |
| 375 | return {createWifiStatus(WifiStatusCode::SUCCESS), firmware_dump}; |
| 376 | } |
| 377 | |
| 378 | std::pair<WifiStatus, sp<IWifiApIface>> WifiChip::createApIfaceInternal() { |
| 379 | // TODO(b/31997422): Disallow this based on the chip combination. |
| 380 | std::string ifname = legacy_hal_.lock()->getApIfaceName(); |
| 381 | ap_iface_ = new WifiApIface(ifname, legacy_hal_); |
| 382 | return {createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_}; |
| 383 | } |
| 384 | |
| 385 | std::pair<WifiStatus, std::vector<hidl_string>> |
| 386 | WifiChip::getApIfaceNamesInternal() { |
| 387 | if (!ap_iface_.get()) { |
| 388 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 389 | } |
| 390 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 391 | {legacy_hal_.lock()->getApIfaceName()}}; |
| 392 | } |
| 393 | |
| 394 | std::pair<WifiStatus, sp<IWifiApIface>> WifiChip::getApIfaceInternal( |
| 395 | const hidl_string& ifname) { |
| 396 | if (!ap_iface_.get() || |
| 397 | (ifname.c_str() != legacy_hal_.lock()->getApIfaceName())) { |
| 398 | return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr}; |
| 399 | } |
| 400 | return {createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_}; |
| 401 | } |
| 402 | |
| 403 | std::pair<WifiStatus, sp<IWifiNanIface>> WifiChip::createNanIfaceInternal() { |
| 404 | // TODO(b/31997422): Disallow this based on the chip combination. |
| 405 | std::string ifname = legacy_hal_.lock()->getNanIfaceName(); |
| 406 | nan_iface_ = new WifiNanIface(ifname, legacy_hal_); |
| 407 | return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_}; |
| 408 | } |
| 409 | |
| 410 | std::pair<WifiStatus, std::vector<hidl_string>> |
| 411 | WifiChip::getNanIfaceNamesInternal() { |
| 412 | if (!nan_iface_.get()) { |
| 413 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 414 | } |
| 415 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 416 | {legacy_hal_.lock()->getNanIfaceName()}}; |
| 417 | } |
| 418 | |
| 419 | std::pair<WifiStatus, sp<IWifiNanIface>> WifiChip::getNanIfaceInternal( |
| 420 | const hidl_string& ifname) { |
| 421 | if (!nan_iface_.get() || |
| 422 | (ifname.c_str() != legacy_hal_.lock()->getNanIfaceName())) { |
| 423 | return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr}; |
| 424 | } |
| 425 | return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_}; |
| 426 | } |
| 427 | |
| 428 | std::pair<WifiStatus, sp<IWifiP2pIface>> WifiChip::createP2pIfaceInternal() { |
| 429 | // TODO(b/31997422): Disallow this based on the chip combination. |
| 430 | std::string ifname = legacy_hal_.lock()->getP2pIfaceName(); |
| 431 | p2p_iface_ = new WifiP2pIface(ifname, legacy_hal_); |
| 432 | return {createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_}; |
| 433 | } |
| 434 | |
| 435 | std::pair<WifiStatus, std::vector<hidl_string>> |
| 436 | WifiChip::getP2pIfaceNamesInternal() { |
| 437 | if (!p2p_iface_.get()) { |
| 438 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 439 | } |
| 440 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 441 | {legacy_hal_.lock()->getP2pIfaceName()}}; |
| 442 | } |
| 443 | |
| 444 | std::pair<WifiStatus, sp<IWifiP2pIface>> WifiChip::getP2pIfaceInternal( |
| 445 | const hidl_string& ifname) { |
| 446 | if (!p2p_iface_.get() || |
| 447 | (ifname.c_str() != legacy_hal_.lock()->getP2pIfaceName())) { |
| 448 | return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr}; |
| 449 | } |
| 450 | return {createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_}; |
| 451 | } |
| 452 | |
| 453 | std::pair<WifiStatus, sp<IWifiStaIface>> WifiChip::createStaIfaceInternal() { |
| 454 | // TODO(b/31997422): Disallow this based on the chip combination. |
| 455 | std::string ifname = legacy_hal_.lock()->getStaIfaceName(); |
| 456 | sta_iface_ = new WifiStaIface(ifname, legacy_hal_); |
| 457 | return {createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_}; |
| 458 | } |
| 459 | |
| 460 | std::pair<WifiStatus, std::vector<hidl_string>> |
| 461 | WifiChip::getStaIfaceNamesInternal() { |
| 462 | if (!sta_iface_.get()) { |
| 463 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 464 | } |
| 465 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 466 | {legacy_hal_.lock()->getStaIfaceName()}}; |
| 467 | } |
| 468 | |
| 469 | std::pair<WifiStatus, sp<IWifiStaIface>> WifiChip::getStaIfaceInternal( |
| 470 | const hidl_string& ifname) { |
| 471 | if (!sta_iface_.get() || |
| 472 | (ifname.c_str() != legacy_hal_.lock()->getStaIfaceName())) { |
| 473 | return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr}; |
| 474 | } |
| 475 | return {createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_}; |
| 476 | } |
| 477 | |
| 478 | std::pair<WifiStatus, sp<IWifiRttController>> |
| 479 | WifiChip::createRttControllerInternal(const sp<IWifiIface>& bound_iface) { |
| 480 | sp<WifiRttController> rtt = new WifiRttController(bound_iface, legacy_hal_); |
| 481 | rtt_controllers_.emplace_back(rtt); |
| 482 | return {createWifiStatus(WifiStatusCode::SUCCESS), rtt}; |
| 483 | } |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 484 | |
| 485 | std::pair<WifiStatus, std::vector<WifiDebugRingBufferStatus>> |
| 486 | WifiChip::getDebugRingBuffersStatusInternal() { |
| 487 | // TODO implement |
| 488 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 489 | } |
| 490 | |
| 491 | WifiStatus WifiChip::startLoggingToDebugRingBufferInternal( |
| 492 | const hidl_string& /* ring_name */, |
| 493 | WifiDebugRingBufferVerboseLevel /* verbose_level */, |
| 494 | uint32_t /* max_interval_in_sec */, |
| 495 | uint32_t /* min_data_size_in_bytes */) { |
| 496 | // TODO implement |
| 497 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 498 | } |
| 499 | |
| 500 | WifiStatus WifiChip::forceDumpToDebugRingBufferInternal( |
| 501 | const hidl_string& /* ring_name */) { |
| 502 | // TODO implement |
| 503 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 504 | } |
| 505 | |
| 506 | std::pair<WifiStatus, WifiDebugHostWakeReasonStats> |
| 507 | WifiChip::getDebugHostWakeReasonStatsInternal() { |
| 508 | // TODO implement |
| 509 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 510 | } |
| 511 | |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 512 | } // namespace implementation |
| 513 | } // namespace V1_0 |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 514 | } // namespace wifi |
| 515 | } // namespace hardware |
| 516 | } // namespace android |