wifi(implementation): Invoke radio mode change callbacks

Bug: 68349158
Test: Compiles
Change-Id: I319ef33775069bf10abe449670e8f0d50de746e3
This commit is contained in:
Roshan Pius 2018-01-22 17:58:40 -08:00
parent 1a7b1db2e8
commit 85c6441fba
2 changed files with 38 additions and 0 deletions

View file

@ -1044,6 +1044,13 @@ WifiStatus WifiChip::handleChipConfiguration(
<< legacyErrorToString(legacy_status);
return createWifiStatusFromLegacyError(legacy_status);
}
// Every time the HAL is restarted, we need to register the
// radio mode change callback.
WifiStatus status = registerRadioModeChangeCallback();
if (status.code != WifiStatusCode::SUCCESS) {
// This probably is not a critical failure?
LOG(ERROR) << "Failed to register radio mode change callback";
}
return createWifiStatus(WifiStatusCode::SUCCESS);
}
@ -1087,6 +1094,36 @@ WifiStatus WifiChip::registerDebugRingBufferCallback() {
return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiChip::registerRadioModeChangeCallback() {
android::wp<WifiChip> weak_ptr_this(this);
const auto& on_radio_mode_change_callback =
[weak_ptr_this](const std::vector<legacy_hal::WifiMacInfo>& mac_infos) {
const auto shared_ptr_this = weak_ptr_this.promote();
if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
LOG(ERROR) << "Callback invoked on an invalid object";
return;
}
std::vector<IWifiChipEventCallback::RadioModeInfo>
hidl_radio_mode_infos;
if (!hidl_struct_util::convertLegacyWifiMacInfosToHidl(
mac_infos, &hidl_radio_mode_infos)) {
LOG(ERROR) << "Error converting wifi mac info";
return;
}
for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
if (!callback->onRadioModeChange(hidl_radio_mode_infos)
.isOk()) {
LOG(ERROR) << "Failed to invoke onRadioModeChange"
<< " callback on: " << toString(callback);
}
}
};
legacy_hal::wifi_error legacy_status =
legacy_hal_.lock()->registerRadioModeChangeCallbackHandler(
getWlan0IfaceName(), on_radio_mode_change_callback);
return createWifiStatusFromLegacyError(legacy_status);
}
void WifiChip::populateModes() {
// The chip combination supported for current devices is fixed.
// They can be one of the following based on device features:

View file

@ -201,6 +201,7 @@ class WifiChip : public V1_2::IWifiChip {
WifiStatus handleChipConfiguration(
std::unique_lock<std::recursive_mutex>* lock, ChipModeId mode_id);
WifiStatus registerDebugRingBufferCallback();
WifiStatus registerRadioModeChangeCallback();
void populateModes();
std::vector<IWifiChip::ChipIfaceCombination>