/* * 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_AP_IFACE_H_ #define WIFI_AP_IFACE_H_ #include #include #include "wifi_iface_util.h" #include "wifi_legacy_hal.h" namespace aidl { namespace android { namespace hardware { namespace wifi { /** * AIDL interface object used to control an AP Iface instance. */ class WifiApIface : public BnWifiApIface { public: WifiApIface(const std::string& ifname, const bool usesMlo, const std::vector& instances, const std::weak_ptr legacy_hal, const std::weak_ptr iface_util); // Refer to |WifiChip::invalidate()|. void invalidate(); bool isValid(); std::string getName(); bool usesMlo(); void removeInstance(std::string instance); // AIDL methods exposed. ndk::ScopedAStatus getName(std::string* _aidl_return) override; ndk::ScopedAStatus setCountryCode(const std::array& in_code) override; ndk::ScopedAStatus setMacAddress(const std::array& in_mac) override; ndk::ScopedAStatus getFactoryMacAddress(std::array* _aidl_return) override; ndk::ScopedAStatus resetToFactoryMacAddress() override; ndk::ScopedAStatus getBridgedInstances(std::vector* _aidl_return) override; ndk::ScopedAStatus usesMlo(bool* _aidl_return) override; private: // Corresponding worker functions for the AIDL methods. std::pair getNameInternal(); ndk::ScopedAStatus setCountryCodeInternal(const std::array& code); ndk::ScopedAStatus setMacAddressInternal(const std::array& mac); std::pair, ndk::ScopedAStatus> getFactoryMacAddressInternal( const std::string& ifaceName); ndk::ScopedAStatus resetToFactoryMacAddressInternal(); std::pair, ndk::ScopedAStatus> getBridgedInstancesInternal(); std::string ifname_; bool uses_mlo_; std::vector instances_; std::weak_ptr legacy_hal_; std::weak_ptr iface_util_; bool is_valid_; // The mlo is using one interface but owning two link instances. // The operating should be based on interface. inline std::string getOperatingInstanceName() { return (instances_.size() > 0 && !uses_mlo_) ? instances_[0] : ifname_; }; DISALLOW_COPY_AND_ASSIGN(WifiApIface); }; } // namespace wifi } // namespace hardware } // namespace android } // namespace aidl #endif // WIFI_AP_IFACE_H_