diff --git a/wifi/1.0/default/wifi_sta_iface.cpp b/wifi/1.0/default/wifi_sta_iface.cpp index 83bd28db84..1f220f3a29 100644 --- a/wifi/1.0/default/wifi_sta_iface.cpp +++ b/wifi/1.0/default/wifi_sta_iface.cpp @@ -33,6 +33,7 @@ WifiStaIface::WifiStaIface(const std::string& ifname, void WifiStaIface::invalidate() { legacy_hal_.reset(); + event_callbacks_.clear(); is_valid_ = false; } @@ -54,6 +55,140 @@ Return WifiStaIface::getType(getType_cb hidl_status_cb) { hidl_status_cb); } +Return WifiStaIface::registerEventCallback( + const sp& callback, + registerEventCallback_cb hidl_status_cb) { + return validateAndCall(this, + WifiStatusCode::ERROR_WIFI_IFACE_INVALID, + &WifiStaIface::registerEventCallbackInternal, + hidl_status_cb, + callback); +} + +Return WifiStaIface::getCapabilities(getCapabilities_cb hidl_status_cb) { + return validateAndCall(this, + WifiStatusCode::ERROR_WIFI_IFACE_INVALID, + &WifiStaIface::getCapabilitiesInternal, + hidl_status_cb); +} + +Return WifiStaIface::getApfPacketFilterCapabilities( + getApfPacketFilterCapabilities_cb hidl_status_cb) { + return validateAndCall(this, + WifiStatusCode::ERROR_WIFI_IFACE_INVALID, + &WifiStaIface::getApfPacketFilterCapabilitiesInternal, + hidl_status_cb); +} + +Return WifiStaIface::installApfPacketFilter( + uint32_t cmd_id, + const hidl_vec& program, + installApfPacketFilter_cb hidl_status_cb) { + return validateAndCall(this, + WifiStatusCode::ERROR_WIFI_IFACE_INVALID, + &WifiStaIface::installApfPacketFilterInternal, + hidl_status_cb, + cmd_id, + program); +} + +Return WifiStaIface::getBackgroundScanCapabilities( + getBackgroundScanCapabilities_cb hidl_status_cb) { + return validateAndCall(this, + WifiStatusCode::ERROR_WIFI_IFACE_INVALID, + &WifiStaIface::getBackgroundScanCapabilitiesInternal, + hidl_status_cb); +} + +Return WifiStaIface::getValidFrequenciesForBackgroundScan( + StaBackgroundScanBand band, + getValidFrequenciesForBackgroundScan_cb hidl_status_cb) { + return validateAndCall( + this, + WifiStatusCode::ERROR_WIFI_IFACE_INVALID, + &WifiStaIface::getValidFrequenciesForBackgroundScanInternal, + hidl_status_cb, + band); +} + +Return WifiStaIface::startBackgroundScan( + uint32_t cmd_id, + const StaBackgroundScanParameters& params, + startBackgroundScan_cb hidl_status_cb) { + return validateAndCall(this, + WifiStatusCode::ERROR_WIFI_IFACE_INVALID, + &WifiStaIface::startBackgroundScanInternal, + hidl_status_cb, + cmd_id, + params); +} + +Return WifiStaIface::stopBackgroundScan( + uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) { + return validateAndCall(this, + WifiStatusCode::ERROR_WIFI_IFACE_INVALID, + &WifiStaIface::stopBackgroundScanInternal, + hidl_status_cb, + cmd_id); +} + +Return WifiStaIface::enableLinkLayerStatsCollection( + bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) { + return validateAndCall(this, + WifiStatusCode::ERROR_WIFI_IFACE_INVALID, + &WifiStaIface::enableLinkLayerStatsCollectionInternal, + hidl_status_cb, + debug); +} + +Return WifiStaIface::disableLinkLayerStatsCollection( + disableLinkLayerStatsCollection_cb hidl_status_cb) { + return validateAndCall(this, + WifiStatusCode::ERROR_WIFI_IFACE_INVALID, + &WifiStaIface::disableLinkLayerStatsCollectionInternal, + hidl_status_cb); +} + +Return WifiStaIface::getLinkLayerStats( + getLinkLayerStats_cb hidl_status_cb) { + return validateAndCall(this, + WifiStatusCode::ERROR_WIFI_IFACE_INVALID, + &WifiStaIface::getLinkLayerStatsInternal, + hidl_status_cb); +} + +Return WifiStaIface::startDebugPacketFateMonitoring( + startDebugPacketFateMonitoring_cb hidl_status_cb) { + return validateAndCall(this, + WifiStatusCode::ERROR_WIFI_IFACE_INVALID, + &WifiStaIface::startDebugPacketFateMonitoringInternal, + hidl_status_cb); +} + +Return WifiStaIface::stopDebugPacketFateMonitoring( + stopDebugPacketFateMonitoring_cb hidl_status_cb) { + return validateAndCall(this, + WifiStatusCode::ERROR_WIFI_IFACE_INVALID, + &WifiStaIface::stopDebugPacketFateMonitoringInternal, + hidl_status_cb); +} + +Return WifiStaIface::getDebugTxPacketFates( + getDebugTxPacketFates_cb hidl_status_cb) { + return validateAndCall(this, + WifiStatusCode::ERROR_WIFI_IFACE_INVALID, + &WifiStaIface::getDebugTxPacketFatesInternal, + hidl_status_cb); +} + +Return WifiStaIface::getDebugRxPacketFates( + getDebugRxPacketFates_cb hidl_status_cb) { + return validateAndCall(this, + WifiStatusCode::ERROR_WIFI_IFACE_INVALID, + &WifiStaIface::getDebugRxPacketFatesInternal, + hidl_status_cb); +} + std::pair WifiStaIface::getNameInternal() { return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_}; } @@ -62,6 +197,93 @@ std::pair WifiStaIface::getTypeInternal() { return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::STA}; } +WifiStatus WifiStaIface::registerEventCallbackInternal( + const sp& callback) { + // TODO(b/31632518): remove the callback when the client is destroyed + event_callbacks_.emplace_back(callback); + return createWifiStatus(WifiStatusCode::SUCCESS); +} + +std::pair WifiStaIface::getCapabilitiesInternal() { + // TODO implement + return {createWifiStatus(WifiStatusCode::SUCCESS), 0}; +} + +std::pair +WifiStaIface::getApfPacketFilterCapabilitiesInternal() { + // TODO implement + return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; +} + +WifiStatus WifiStaIface::installApfPacketFilterInternal( + uint32_t /* cmd_id */, const std::vector& /* program */) { + // TODO implement + return createWifiStatus(WifiStatusCode::SUCCESS); +} + +std::pair +WifiStaIface::getBackgroundScanCapabilitiesInternal() { + // TODO implement + return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; +} + +std::pair> +WifiStaIface::getValidFrequenciesForBackgroundScanInternal( + StaBackgroundScanBand /* band */) { + // TODO implement + return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; +} + +WifiStatus WifiStaIface::startBackgroundScanInternal( + uint32_t /* cmd_id */, const StaBackgroundScanParameters& /* params */) { + // TODO implement + return createWifiStatus(WifiStatusCode::SUCCESS); +} + +WifiStatus WifiStaIface::stopBackgroundScanInternal(uint32_t /* cmd_id */) { + // TODO implement + return createWifiStatus(WifiStatusCode::SUCCESS); +} + +WifiStatus WifiStaIface::enableLinkLayerStatsCollectionInternal( + bool /* debug */) { + // TODO implement + return createWifiStatus(WifiStatusCode::SUCCESS); +} + +WifiStatus WifiStaIface::disableLinkLayerStatsCollectionInternal() { + // TODO implement + return createWifiStatus(WifiStatusCode::SUCCESS); +} + +std::pair +WifiStaIface::getLinkLayerStatsInternal() { + // TODO implement + return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; +} + +WifiStatus WifiStaIface::startDebugPacketFateMonitoringInternal() { + // TODO implement + return createWifiStatus(WifiStatusCode::SUCCESS); +} + +WifiStatus WifiStaIface::stopDebugPacketFateMonitoringInternal() { + // TODO implement + return createWifiStatus(WifiStatusCode::SUCCESS); +} + +std::pair> +WifiStaIface::getDebugTxPacketFatesInternal() { + // TODO implement + return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; +} + +std::pair> +WifiStaIface::getDebugRxPacketFatesInternal() { + // TODO implement + return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; +} + } // namespace implementation } // namespace V1_0 } // namespace wifi diff --git a/wifi/1.0/default/wifi_sta_iface.h b/wifi/1.0/default/wifi_sta_iface.h index 6303305e63..a13feeb9a9 100644 --- a/wifi/1.0/default/wifi_sta_iface.h +++ b/wifi/1.0/default/wifi_sta_iface.h @@ -19,6 +19,7 @@ #include #include +#include #include "wifi_legacy_hal.h" @@ -42,14 +43,72 @@ class WifiStaIface : public IWifiStaIface { // HIDL methods exposed. Return getName(getName_cb hidl_status_cb) override; Return getType(getType_cb hidl_status_cb) override; + Return registerEventCallback( + const sp& callback, + registerEventCallback_cb hidl_status_cb) override; + Return getCapabilities(getCapabilities_cb hidl_status_cb) override; + Return getApfPacketFilterCapabilities( + getApfPacketFilterCapabilities_cb hidl_status_cb) override; + Return installApfPacketFilter( + uint32_t cmd_id, + const hidl_vec& program, + installApfPacketFilter_cb hidl_status_cb) override; + Return getBackgroundScanCapabilities( + getBackgroundScanCapabilities_cb hidl_status_cb) override; + Return getValidFrequenciesForBackgroundScan( + StaBackgroundScanBand band, + getValidFrequenciesForBackgroundScan_cb hidl_status_cb) override; + Return startBackgroundScan( + uint32_t cmd_id, + const StaBackgroundScanParameters& params, + startBackgroundScan_cb hidl_status_cb) override; + Return stopBackgroundScan( + uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) override; + Return enableLinkLayerStatsCollection( + bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) override; + Return disableLinkLayerStatsCollection( + disableLinkLayerStatsCollection_cb hidl_status_cb) override; + Return getLinkLayerStats(getLinkLayerStats_cb hidl_status_cb) override; + Return startDebugPacketFateMonitoring( + startDebugPacketFateMonitoring_cb hidl_status_cb) override; + Return stopDebugPacketFateMonitoring( + stopDebugPacketFateMonitoring_cb hidl_status_cb) override; + Return getDebugTxPacketFates( + getDebugTxPacketFates_cb hidl_status_cb) override; + Return getDebugRxPacketFates( + getDebugRxPacketFates_cb hidl_status_cb) override; private: // Corresponding worker functions for the HIDL methods. std::pair getNameInternal(); std::pair getTypeInternal(); + WifiStatus registerEventCallbackInternal( + const sp& callback); + std::pair getCapabilitiesInternal(); + std::pair + getApfPacketFilterCapabilitiesInternal(); + WifiStatus installApfPacketFilterInternal( + uint32_t cmd_id, const std::vector& program); + std::pair + getBackgroundScanCapabilitiesInternal(); + std::pair> + getValidFrequenciesForBackgroundScanInternal(StaBackgroundScanBand band); + WifiStatus startBackgroundScanInternal( + uint32_t cmd_id, const StaBackgroundScanParameters& params); + WifiStatus stopBackgroundScanInternal(uint32_t cmd_id); + WifiStatus enableLinkLayerStatsCollectionInternal(bool debug); + WifiStatus disableLinkLayerStatsCollectionInternal(); + std::pair getLinkLayerStatsInternal(); + WifiStatus startDebugPacketFateMonitoringInternal(); + WifiStatus stopDebugPacketFateMonitoringInternal(); + std::pair> + getDebugTxPacketFatesInternal(); + std::pair> + getDebugRxPacketFatesInternal(); std::string ifname_; std::weak_ptr legacy_hal_; + std::vector> event_callbacks_; bool is_valid_; DISALLOW_COPY_AND_ASSIGN(WifiStaIface);