wifi: Add support for alert handler
This is a debug mechanism provided for vendors to inform the framework
about the occurence of any fatal events.
Bug: 33620898
Test: Compiles
Change-Id: Ib6ac322131796792f66f87237a62eb8f5a013433
diff --git a/wifi/1.0/default/wifi_chip.cpp b/wifi/1.0/default/wifi_chip.cpp
index d70f548..d64dea6 100644
--- a/wifi/1.0/default/wifi_chip.cpp
+++ b/wifi/1.0/default/wifi_chip.cpp
@@ -69,6 +69,10 @@
return is_valid_;
}
+std::vector<sp<IWifiChipEventCallback>> WifiChip::getEventCallbacks() {
+ return event_callbacks_;
+}
+
Return<void> WifiChip::getId(getId_cb hidl_status_cb) {
return validateAndCall(this,
WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
@@ -319,6 +323,15 @@
hidl_status_cb);
}
+Return<void> WifiChip::enableDebugErrorAlerts(
+ bool enable, enableDebugErrorAlerts_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::enableDebugErrorAlertsInternal,
+ hidl_status_cb,
+ enable);
+}
+
void WifiChip::invalidateAndRemoveAllIfaces() {
invalidateAndClear(ap_iface_);
invalidateAndClear(nan_iface_);
@@ -706,6 +719,28 @@
return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_stats};
}
+WifiStatus WifiChip::enableDebugErrorAlertsInternal(bool enable) {
+ legacy_hal::wifi_error legacy_status;
+ if (enable) {
+ android::wp<WifiChip> weak_ptr_this(this);
+ const auto& on_alert_callback = [weak_ptr_this](
+ int32_t error_code, std::vector<uint8_t> debug_data) {
+ 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;
+ }
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ callback->onDebugErrorAlert(error_code, debug_data);
+ }
+ };
+ legacy_status = legacy_hal_.lock()->registerErrorAlertCallbackHandler(
+ on_alert_callback);
+ } else {
+ legacy_status = legacy_hal_.lock()->deregisterErrorAlertCallbackHandler();
+ }
+ return createWifiStatusFromLegacyError(legacy_status);
+}
} // namespace implementation
} // namespace V1_0
} // namespace wifi