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> |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 18 | |
Roshan Pius | 5647665 | 2016-10-26 14:43:05 -0700 | [diff] [blame] | 19 | #include "hidl_return_util.h" |
| 20 | #include "wifi.h" |
Roshan Pius | 503582e | 2016-10-11 08:25:30 -0700 | [diff] [blame] | 21 | #include "wifi_status_util.h" |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 22 | |
Roshan Pius | cd566bd | 2016-10-10 08:03:42 -0700 | [diff] [blame] | 23 | namespace { |
Jimmy Chen | 2dddd79 | 2019-12-23 17:50:39 +0200 | [diff] [blame] | 24 | // Starting Chip ID, will be assigned to primary chip |
| 25 | static constexpr android::hardware::wifi::V1_0::ChipId kPrimaryChipId = 0; |
Roshan Pius | cd566bd | 2016-10-10 08:03:42 -0700 | [diff] [blame] | 26 | } // namespace |
| 27 | |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 28 | namespace android { |
| 29 | namespace hardware { |
| 30 | namespace wifi { |
Jimmy Chen | d460df3 | 2019-11-29 17:31:22 +0200 | [diff] [blame] | 31 | namespace V1_5 { |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 32 | namespace implementation { |
Roshan Pius | 5647665 | 2016-10-26 14:43:05 -0700 | [diff] [blame] | 33 | using hidl_return_util::validateAndCall; |
Roshan Pius | 155344b | 2017-08-11 15:47:42 -0700 | [diff] [blame] | 34 | using hidl_return_util::validateAndCallWithLock; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 35 | |
Roshan Pius | 200a17d | 2017-11-01 13:03:35 -0700 | [diff] [blame] | 36 | Wifi::Wifi( |
Roshan Pius | c885df0 | 2019-05-21 14:49:05 -0700 | [diff] [blame] | 37 | const std::shared_ptr<wifi_system::InterfaceTool> iface_tool, |
Jimmy Chen | 2dddd79 | 2019-12-23 17:50:39 +0200 | [diff] [blame] | 38 | const std::shared_ptr<legacy_hal::WifiLegacyHalFactory> legacy_hal_factory, |
Roshan Pius | 200a17d | 2017-11-01 13:03:35 -0700 | [diff] [blame] | 39 | const std::shared_ptr<mode_controller::WifiModeController> mode_controller, |
| 40 | const std::shared_ptr<feature_flags::WifiFeatureFlags> feature_flags) |
Roshan Pius | c885df0 | 2019-05-21 14:49:05 -0700 | [diff] [blame] | 41 | : iface_tool_(iface_tool), |
Jimmy Chen | 2dddd79 | 2019-12-23 17:50:39 +0200 | [diff] [blame] | 42 | legacy_hal_factory_(legacy_hal_factory), |
Roshan Pius | 200a17d | 2017-11-01 13:03:35 -0700 | [diff] [blame] | 43 | mode_controller_(mode_controller), |
| 44 | feature_flags_(feature_flags), |
Roshan Pius | 6cedc97 | 2016-10-28 10:11:17 -0700 | [diff] [blame] | 45 | run_state_(RunState::STOPPED) {} |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 46 | |
Roshan Pius | 5647665 | 2016-10-26 14:43:05 -0700 | [diff] [blame] | 47 | bool Wifi::isValid() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 48 | // This object is always valid. |
| 49 | return true; |
Roshan Pius | 5647665 | 2016-10-26 14:43:05 -0700 | [diff] [blame] | 50 | } |
| 51 | |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 52 | Return<void> Wifi::registerEventCallback( |
chenpaul | b690fb8 | 2021-03-16 22:49:18 +0800 | [diff] [blame^] | 53 | const sp<V1_0::IWifiEventCallback>& event_callback, |
Roshan Pius | 5647665 | 2016-10-26 14:43:05 -0700 | [diff] [blame] | 54 | registerEventCallback_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 55 | return validateAndCall(this, WifiStatusCode::ERROR_UNKNOWN, |
| 56 | &Wifi::registerEventCallbackInternal, hidl_status_cb, |
| 57 | event_callback); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 58 | } |
| 59 | |
chenpaul | b690fb8 | 2021-03-16 22:49:18 +0800 | [diff] [blame^] | 60 | Return<void> Wifi::registerEventCallback_1_5( |
| 61 | const sp<V1_5::IWifiEventCallback>& event_callback, |
| 62 | registerEventCallback_1_5_cb hidl_status_cb) { |
| 63 | return validateAndCall(this, WifiStatusCode::ERROR_UNKNOWN, |
| 64 | &Wifi::registerEventCallbackInternal_1_5, |
| 65 | hidl_status_cb, event_callback); |
| 66 | } |
| 67 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 68 | Return<bool> Wifi::isStarted() { return run_state_ != RunState::STOPPED; } |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 69 | |
Roshan Pius | 503582e | 2016-10-11 08:25:30 -0700 | [diff] [blame] | 70 | Return<void> Wifi::start(start_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 71 | return validateAndCall(this, WifiStatusCode::ERROR_UNKNOWN, |
| 72 | &Wifi::startInternal, hidl_status_cb); |
Roshan Pius | 5647665 | 2016-10-26 14:43:05 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | Return<void> Wifi::stop(stop_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 76 | return validateAndCallWithLock(this, WifiStatusCode::ERROR_UNKNOWN, |
| 77 | &Wifi::stopInternal, hidl_status_cb); |
Roshan Pius | 5647665 | 2016-10-26 14:43:05 -0700 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | Return<void> Wifi::getChipIds(getChipIds_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 81 | return validateAndCall(this, WifiStatusCode::ERROR_UNKNOWN, |
| 82 | &Wifi::getChipIdsInternal, hidl_status_cb); |
Roshan Pius | 5647665 | 2016-10-26 14:43:05 -0700 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | Return<void> Wifi::getChip(ChipId chip_id, getChip_cb hidl_status_cb) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 86 | return validateAndCall(this, WifiStatusCode::ERROR_UNKNOWN, |
| 87 | &Wifi::getChipInternal, hidl_status_cb, chip_id); |
Roshan Pius | 5647665 | 2016-10-26 14:43:05 -0700 | [diff] [blame] | 88 | } |
| 89 | |
xshu | 5899e8e | 2018-01-09 15:36:03 -0800 | [diff] [blame] | 90 | Return<void> Wifi::debug(const hidl_handle& handle, |
| 91 | const hidl_vec<hidl_string>&) { |
| 92 | LOG(INFO) << "-----------Debug is called----------------"; |
Jimmy Chen | 2dddd79 | 2019-12-23 17:50:39 +0200 | [diff] [blame] | 93 | if (chips_.size() == 0) { |
Roshan Pius | 7cf1df7 | 2018-01-24 19:13:09 -0800 | [diff] [blame] | 94 | return Void(); |
| 95 | } |
Jimmy Chen | 2dddd79 | 2019-12-23 17:50:39 +0200 | [diff] [blame] | 96 | |
| 97 | for (sp<WifiChip> chip : chips_) { |
| 98 | if (!chip.get()) continue; |
| 99 | |
| 100 | chip->debug(handle, {}); |
| 101 | } |
| 102 | return Void(); |
xshu | 5899e8e | 2018-01-09 15:36:03 -0800 | [diff] [blame] | 103 | } |
| 104 | |
Roshan Pius | 5647665 | 2016-10-26 14:43:05 -0700 | [diff] [blame] | 105 | WifiStatus Wifi::registerEventCallbackInternal( |
chenpaul | b690fb8 | 2021-03-16 22:49:18 +0800 | [diff] [blame^] | 106 | const sp<V1_0::IWifiEventCallback>& event_callback __unused) { |
| 107 | // Deprecated support for this callback. |
| 108 | return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED); |
| 109 | } |
| 110 | |
| 111 | WifiStatus Wifi::registerEventCallbackInternal_1_5( |
| 112 | const sp<V1_5::IWifiEventCallback>& event_callback) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 113 | if (!event_cb_handler_.addCallback(event_callback)) { |
| 114 | return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); |
| 115 | } |
| 116 | return createWifiStatus(WifiStatusCode::SUCCESS); |
Roshan Pius | 5647665 | 2016-10-26 14:43:05 -0700 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | WifiStatus Wifi::startInternal() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 120 | if (run_state_ == RunState::STARTED) { |
| 121 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 122 | } else if (run_state_ == RunState::STOPPING) { |
| 123 | return createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE, |
| 124 | "HAL is stopping"); |
Roshan Pius | 52947fb | 2016-11-18 11:38:07 -0800 | [diff] [blame] | 125 | } |
Roshan Pius | 8fc6d17 | 2017-11-27 16:08:27 -0800 | [diff] [blame] | 126 | WifiStatus wifi_status = initializeModeControllerAndLegacyHal(); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 127 | if (wifi_status.code == WifiStatusCode::SUCCESS) { |
Ahmed ElArabawy | 2134bf7 | 2020-06-18 15:07:12 -0700 | [diff] [blame] | 128 | // Register the callback for subsystem restart |
| 129 | const auto& on_subsystem_restart_callback = |
| 130 | [this](const std::string& error) { |
| 131 | WifiStatus wifi_status = |
| 132 | createWifiStatus(WifiStatusCode::ERROR_UNKNOWN, error); |
| 133 | for (const auto& callback : event_cb_handler_.getCallbacks()) { |
| 134 | if (!callback->onFailure(wifi_status).isOk()) { |
| 135 | LOG(ERROR) << "Failed to invoke onFailure callback"; |
| 136 | } |
| 137 | } |
| 138 | }; |
| 139 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 140 | // Create the chip instance once the HAL is started. |
Jimmy Chen | 2dddd79 | 2019-12-23 17:50:39 +0200 | [diff] [blame] | 141 | android::hardware::wifi::V1_0::ChipId chipId = kPrimaryChipId; |
| 142 | for (auto& hal : legacy_hals_) { |
| 143 | chips_.push_back(new WifiChip( |
| 144 | chipId, chipId == kPrimaryChipId, hal, mode_controller_, |
Roshan Pius | 8c1a67b | 2021-03-02 10:00:23 -0800 | [diff] [blame] | 145 | std::make_shared<iface_util::WifiIfaceUtil>(iface_tool_, hal), |
| 146 | feature_flags_, on_subsystem_restart_callback)); |
Jimmy Chen | 2dddd79 | 2019-12-23 17:50:39 +0200 | [diff] [blame] | 147 | chipId++; |
| 148 | } |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 149 | run_state_ = RunState::STARTED; |
| 150 | for (const auto& callback : event_cb_handler_.getCallbacks()) { |
| 151 | if (!callback->onStart().isOk()) { |
| 152 | LOG(ERROR) << "Failed to invoke onStart callback"; |
| 153 | }; |
| 154 | } |
| 155 | LOG(INFO) << "Wifi HAL started"; |
| 156 | } else { |
| 157 | for (const auto& callback : event_cb_handler_.getCallbacks()) { |
| 158 | if (!callback->onFailure(wifi_status).isOk()) { |
| 159 | LOG(ERROR) << "Failed to invoke onFailure callback"; |
| 160 | } |
| 161 | } |
| 162 | LOG(ERROR) << "Wifi HAL start failed"; |
Kyounghan Lee | f2e21c2 | 2020-01-29 14:56:15 +0900 | [diff] [blame] | 163 | // Clear the event callback objects since the HAL start failed. |
| 164 | event_cb_handler_.invalidate(); |
Roshan Pius | 52947fb | 2016-11-18 11:38:07 -0800 | [diff] [blame] | 165 | } |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 166 | return wifi_status; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 167 | } |
| 168 | |
Roshan Pius | 155344b | 2017-08-11 15:47:42 -0700 | [diff] [blame] | 169 | WifiStatus Wifi::stopInternal( |
| 170 | /* NONNULL */ std::unique_lock<std::recursive_mutex>* lock) { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 171 | if (run_state_ == RunState::STOPPED) { |
| 172 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 173 | } else if (run_state_ == RunState::STOPPING) { |
| 174 | return createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE, |
| 175 | "HAL is stopping"); |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 176 | } |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 177 | // Clear the chip object and its child objects since the HAL is now |
| 178 | // stopped. |
Jimmy Chen | 2dddd79 | 2019-12-23 17:50:39 +0200 | [diff] [blame] | 179 | for (auto& chip : chips_) { |
| 180 | if (chip.get()) { |
| 181 | chip->invalidate(); |
| 182 | chip.clear(); |
| 183 | } |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 184 | } |
Jimmy Chen | 2dddd79 | 2019-12-23 17:50:39 +0200 | [diff] [blame] | 185 | chips_.clear(); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 186 | WifiStatus wifi_status = stopLegacyHalAndDeinitializeModeController(lock); |
| 187 | if (wifi_status.code == WifiStatusCode::SUCCESS) { |
| 188 | for (const auto& callback : event_cb_handler_.getCallbacks()) { |
| 189 | if (!callback->onStop().isOk()) { |
| 190 | LOG(ERROR) << "Failed to invoke onStop callback"; |
| 191 | }; |
| 192 | } |
| 193 | LOG(INFO) << "Wifi HAL stopped"; |
| 194 | } else { |
| 195 | for (const auto& callback : event_cb_handler_.getCallbacks()) { |
| 196 | if (!callback->onFailure(wifi_status).isOk()) { |
| 197 | LOG(ERROR) << "Failed to invoke onFailure callback"; |
| 198 | } |
| 199 | } |
| 200 | LOG(ERROR) << "Wifi HAL stop failed"; |
| 201 | } |
Kyounghan Lee | f2e21c2 | 2020-01-29 14:56:15 +0900 | [diff] [blame] | 202 | // Clear the event callback objects since the HAL is now stopped. |
| 203 | event_cb_handler_.invalidate(); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 204 | return wifi_status; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 205 | } |
| 206 | |
Roshan Pius | 5647665 | 2016-10-26 14:43:05 -0700 | [diff] [blame] | 207 | std::pair<WifiStatus, std::vector<ChipId>> Wifi::getChipIdsInternal() { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 208 | std::vector<ChipId> chip_ids; |
Jimmy Chen | 2dddd79 | 2019-12-23 17:50:39 +0200 | [diff] [blame] | 209 | |
| 210 | for (auto& chip : chips_) { |
| 211 | ChipId chip_id = getChipIdFromWifiChip(chip); |
| 212 | if (chip_id != UINT32_MAX) chip_ids.emplace_back(chip_id); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 213 | } |
| 214 | return {createWifiStatus(WifiStatusCode::SUCCESS), std::move(chip_ids)}; |
Roshan Pius | cd566bd | 2016-10-10 08:03:42 -0700 | [diff] [blame] | 215 | } |
| 216 | |
Jimmy Chen | d460df3 | 2019-11-29 17:31:22 +0200 | [diff] [blame] | 217 | std::pair<WifiStatus, sp<V1_4::IWifiChip>> Wifi::getChipInternal( |
| 218 | ChipId chip_id) { |
Jimmy Chen | 2dddd79 | 2019-12-23 17:50:39 +0200 | [diff] [blame] | 219 | for (auto& chip : chips_) { |
| 220 | ChipId cand_id = getChipIdFromWifiChip(chip); |
| 221 | if ((cand_id != UINT32_MAX) && (cand_id == chip_id)) |
| 222 | return {createWifiStatus(WifiStatusCode::SUCCESS), chip}; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 223 | } |
Jimmy Chen | 2dddd79 | 2019-12-23 17:50:39 +0200 | [diff] [blame] | 224 | |
| 225 | return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr}; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 226 | } |
Roshan Pius | 52947fb | 2016-11-18 11:38:07 -0800 | [diff] [blame] | 227 | |
Roshan Pius | 8fc6d17 | 2017-11-27 16:08:27 -0800 | [diff] [blame] | 228 | WifiStatus Wifi::initializeModeControllerAndLegacyHal() { |
| 229 | if (!mode_controller_->initialize()) { |
| 230 | LOG(ERROR) << "Failed to initialize firmware mode controller"; |
| 231 | return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); |
| 232 | } |
Jimmy Chen | 2dddd79 | 2019-12-23 17:50:39 +0200 | [diff] [blame] | 233 | |
| 234 | legacy_hals_ = legacy_hal_factory_->getHals(); |
| 235 | if (legacy_hals_.empty()) |
| 236 | return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); |
| 237 | int index = 0; // for failure log |
| 238 | for (auto& hal : legacy_hals_) { |
| 239 | legacy_hal::wifi_error legacy_status = hal->initialize(); |
| 240 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 241 | // Currently WifiLegacyHal::initialize does not allocate extra mem, |
| 242 | // only initializes the function table. If this changes, need to |
| 243 | // implement WifiLegacyHal::deinitialize and deinitalize the |
| 244 | // HALs already initialized |
| 245 | LOG(ERROR) << "Failed to initialize legacy HAL index: " << index |
| 246 | << " error: " << legacyErrorToString(legacy_status); |
| 247 | return createWifiStatusFromLegacyError(legacy_status); |
| 248 | } |
| 249 | index++; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 250 | } |
| 251 | return createWifiStatus(WifiStatusCode::SUCCESS); |
Roshan Pius | 52947fb | 2016-11-18 11:38:07 -0800 | [diff] [blame] | 252 | } |
| 253 | |
Roshan Pius | 155344b | 2017-08-11 15:47:42 -0700 | [diff] [blame] | 254 | WifiStatus Wifi::stopLegacyHalAndDeinitializeModeController( |
| 255 | /* NONNULL */ std::unique_lock<std::recursive_mutex>* lock) { |
Jimmy Chen | 2dddd79 | 2019-12-23 17:50:39 +0200 | [diff] [blame] | 256 | legacy_hal::wifi_error legacy_status = legacy_hal::WIFI_SUCCESS; |
| 257 | int index = 0; |
| 258 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 259 | run_state_ = RunState::STOPPING; |
Jimmy Chen | 2dddd79 | 2019-12-23 17:50:39 +0200 | [diff] [blame] | 260 | for (auto& hal : legacy_hals_) { |
| 261 | legacy_hal::wifi_error tmp = hal->stop(lock, [&]() {}); |
| 262 | if (tmp != legacy_hal::WIFI_SUCCESS) { |
| 263 | LOG(ERROR) << "Failed to stop legacy HAL index: " << index |
| 264 | << " error: " << legacyErrorToString(legacy_status); |
| 265 | legacy_status = tmp; |
| 266 | } |
| 267 | index++; |
| 268 | } |
| 269 | run_state_ = RunState::STOPPED; |
| 270 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 271 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
Jimmy Chen | 2dddd79 | 2019-12-23 17:50:39 +0200 | [diff] [blame] | 272 | LOG(ERROR) << "One or more legacy HALs failed to stop"; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 273 | return createWifiStatusFromLegacyError(legacy_status); |
| 274 | } |
| 275 | if (!mode_controller_->deinitialize()) { |
| 276 | LOG(ERROR) << "Failed to deinitialize firmware mode controller"; |
| 277 | return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); |
| 278 | } |
| 279 | return createWifiStatus(WifiStatusCode::SUCCESS); |
Roshan Pius | 52947fb | 2016-11-18 11:38:07 -0800 | [diff] [blame] | 280 | } |
Jimmy Chen | 2dddd79 | 2019-12-23 17:50:39 +0200 | [diff] [blame] | 281 | |
| 282 | ChipId Wifi::getChipIdFromWifiChip(sp<WifiChip>& chip) { |
| 283 | ChipId chip_id = UINT32_MAX; |
| 284 | if (chip.get()) { |
| 285 | chip->getId([&](WifiStatus status, uint32_t id) { |
| 286 | if (status.code == WifiStatusCode::SUCCESS) { |
| 287 | chip_id = id; |
| 288 | } |
| 289 | }); |
| 290 | } |
| 291 | |
| 292 | return chip_id; |
| 293 | } |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 294 | } // namespace implementation |
Jimmy Chen | d460df3 | 2019-11-29 17:31:22 +0200 | [diff] [blame] | 295 | } // namespace V1_5 |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 296 | } // namespace wifi |
| 297 | } // namespace hardware |
| 298 | } // namespace android |