/* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef WIFI_STA_IFACE_H_ #define WIFI_STA_IFACE_H_ #include #include #include #include "aidl_callback_util.h" #include "wifi_iface_util.h" #include "wifi_legacy_hal.h" namespace aidl { namespace android { namespace hardware { namespace wifi { /** * AIDL interface object used to control a STA Iface instance. */ class WifiStaIface : public BnWifiStaIface { public: WifiStaIface(const std::string& ifname, const std::weak_ptr legacy_hal, const std::weak_ptr iface_util); // Factory method - use instead of default constructor. static std::shared_ptr create( const std::string& ifname, const std::weak_ptr legacy_hal, const std::weak_ptr iface_util); // Refer to |WifiChip::invalidate()|. void invalidate(); bool isValid(); std::set> getEventCallbacks(); std::string getName(); // AIDL methods exposed. ndk::ScopedAStatus getName(std::string* _aidl_return) override; ndk::ScopedAStatus registerEventCallback( const std::shared_ptr& in_callback) override; ndk::ScopedAStatus getFeatureSet(int32_t* _aidl_return) override; ndk::ScopedAStatus getApfPacketFilterCapabilities( StaApfPacketFilterCapabilities* _aidl_return) override; ndk::ScopedAStatus installApfPacketFilter(const std::vector& in_program) override; ndk::ScopedAStatus readApfPacketFilterData(std::vector* _aidl_return) override; ndk::ScopedAStatus getBackgroundScanCapabilities( StaBackgroundScanCapabilities* _aidl_return) override; ndk::ScopedAStatus startBackgroundScan(int32_t in_cmdId, const StaBackgroundScanParameters& in_params) override; ndk::ScopedAStatus stopBackgroundScan(int32_t in_cmdId) override; ndk::ScopedAStatus enableLinkLayerStatsCollection(bool in_debug) override; ndk::ScopedAStatus disableLinkLayerStatsCollection() override; ndk::ScopedAStatus getLinkLayerStats(StaLinkLayerStats* _aidl_return) override; ndk::ScopedAStatus startRssiMonitoring(int32_t in_cmdId, int32_t in_maxRssi, int32_t in_minRssi) override; ndk::ScopedAStatus stopRssiMonitoring(int32_t in_cmdId) override; ndk::ScopedAStatus getRoamingCapabilities(StaRoamingCapabilities* _aidl_return) override; ndk::ScopedAStatus configureRoaming(const StaRoamingConfig& in_config) override; ndk::ScopedAStatus setRoamingState(StaRoamingState in_state) override; ndk::ScopedAStatus enableNdOffload(bool in_enable) override; ndk::ScopedAStatus startSendingKeepAlivePackets(int32_t in_cmdId, const std::vector& in_ipPacketData, char16_t in_etherType, const std::array& in_srcAddress, const std::array& in_dstAddress, int32_t in_periodInMs) override; ndk::ScopedAStatus stopSendingKeepAlivePackets(int32_t in_cmdId) override; ndk::ScopedAStatus startDebugPacketFateMonitoring() override; ndk::ScopedAStatus getDebugTxPacketFates( std::vector* _aidl_return) override; ndk::ScopedAStatus getDebugRxPacketFates( std::vector* _aidl_return) override; ndk::ScopedAStatus setMacAddress(const std::array& in_mac) override; ndk::ScopedAStatus getFactoryMacAddress(std::array* _aidl_return) override; ndk::ScopedAStatus setScanMode(bool in_enable) override; ndk::ScopedAStatus setDtimMultiplier(int32_t in_multiplier) override; ndk::ScopedAStatus getCachedScanData(CachedScanData* _aidl_return) override; ndk::ScopedAStatus twtGetCapabilities(TwtCapabilities* _aidl_return) override; ndk::ScopedAStatus twtSessionSetup(int in_cmdId, const TwtRequest& in_twtRequest) override; ndk::ScopedAStatus twtSessionUpdate(int in_cmdId, int32_t in_sessionId, const TwtRequest& in_twtRequest) override; ndk::ScopedAStatus twtSessionSuspend(int in_cmdId, int32_t in_sessionId) override; ndk::ScopedAStatus twtSessionResume(int in_cmdId, int32_t in_sessionId) override; ndk::ScopedAStatus twtSessionTeardown(int in_cmdId, int32_t in_sessionId) override; ndk::ScopedAStatus twtSessionGetStats(int in_cmdId, int32_t in_sessionId) override; private: // Corresponding worker functions for the AIDL methods. std::pair getNameInternal(); ndk::ScopedAStatus registerTwtEventCallbackInternal(); ndk::ScopedAStatus registerEventCallbackInternal( const std::shared_ptr& callback); std::pair getFeatureSetInternal(); std::pair getApfPacketFilterCapabilitiesInternal(); ndk::ScopedAStatus installApfPacketFilterInternal(const std::vector& program); std::pair, ndk::ScopedAStatus> readApfPacketFilterDataInternal(); std::pair getBackgroundScanCapabilitiesInternal(); ndk::ScopedAStatus startBackgroundScanInternal(int32_t cmd_id, const StaBackgroundScanParameters& params); ndk::ScopedAStatus stopBackgroundScanInternal(int32_t cmd_id); ndk::ScopedAStatus enableLinkLayerStatsCollectionInternal(bool debug); ndk::ScopedAStatus disableLinkLayerStatsCollectionInternal(); std::pair getLinkLayerStatsInternal(); ndk::ScopedAStatus startRssiMonitoringInternal(int32_t cmd_id, int32_t max_rssi, int32_t min_rssi); ndk::ScopedAStatus stopRssiMonitoringInternal(int32_t cmd_id); std::pair getRoamingCapabilitiesInternal(); ndk::ScopedAStatus configureRoamingInternal(const StaRoamingConfig& config); ndk::ScopedAStatus setRoamingStateInternal(StaRoamingState state); ndk::ScopedAStatus enableNdOffloadInternal(bool enable); ndk::ScopedAStatus startSendingKeepAlivePacketsInternal( int32_t cmd_id, const std::vector& ip_packet_data, char16_t ether_type, const std::array& src_address, const std::array& dst_address, int32_t period_in_ms); ndk::ScopedAStatus stopSendingKeepAlivePacketsInternal(int32_t cmd_id); ndk::ScopedAStatus startDebugPacketFateMonitoringInternal(); std::pair, ndk::ScopedAStatus> getDebugTxPacketFatesInternal(); std::pair, ndk::ScopedAStatus> getDebugRxPacketFatesInternal(); ndk::ScopedAStatus setMacAddressInternal(const std::array& mac); std::pair, ndk::ScopedAStatus> getFactoryMacAddressInternal(); ndk::ScopedAStatus setScanModeInternal(bool enable); ndk::ScopedAStatus setDtimMultiplierInternal(const int multiplier); std::pair getCachedScanDataInternal(); std::pair twtGetCapabilitiesInternal(); ndk::ScopedAStatus twtSessionSetupInternal(int cmdId, const TwtRequest& twtRequest); ndk::ScopedAStatus twtSessionUpdateInternal(int cmdId, int32_t sessionId, const TwtRequest& twtRequest); ndk::ScopedAStatus twtSessionSuspendInternal(int cmdId, int32_t sessionId); ndk::ScopedAStatus twtSessionResumeInternal(int cmdId, int32_t sessionId); ndk::ScopedAStatus twtSessionTeardownInternal(int cmdId, int32_t sessionId); ndk::ScopedAStatus twtSessionGetStatsInternal(int cmdId, int32_t sessionId); void setWeakPtr(std::weak_ptr ptr); std::string ifname_; std::weak_ptr legacy_hal_; std::weak_ptr iface_util_; std::weak_ptr weak_ptr_this_; bool is_valid_; aidl_callback_util::AidlCallbackHandler event_cb_handler_; bool is_twt_registered_; DISALLOW_COPY_AND_ASSIGN(WifiStaIface); }; } // namespace wifi } // namespace hardware } // namespace android } // namespace aidl #endif // WIFI_STA_IFACE_H_