Gabriel Biren | e58e263 | 2022-07-15 23:25:39 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2022 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef WIFI_AP_IFACE_H_ |
| 18 | #define WIFI_AP_IFACE_H_ |
| 19 | |
| 20 | #include <aidl/android/hardware/wifi/BnWifiApIface.h> |
| 21 | #include <android-base/macros.h> |
| 22 | |
| 23 | #include "wifi_iface_util.h" |
| 24 | #include "wifi_legacy_hal.h" |
| 25 | |
| 26 | namespace aidl { |
| 27 | namespace android { |
| 28 | namespace hardware { |
| 29 | namespace wifi { |
| 30 | |
| 31 | /** |
| 32 | * AIDL interface object used to control an AP Iface instance. |
| 33 | */ |
| 34 | class WifiApIface : public BnWifiApIface { |
| 35 | public: |
| 36 | WifiApIface(const std::string& ifname, const std::vector<std::string>& instances, |
| 37 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal, |
| 38 | const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util); |
| 39 | // Refer to |WifiChip::invalidate()|. |
| 40 | void invalidate(); |
| 41 | bool isValid(); |
| 42 | std::string getName(); |
| 43 | void removeInstance(std::string instance); |
| 44 | |
| 45 | // AIDL methods exposed. |
| 46 | ndk::ScopedAStatus getName(std::string* _aidl_return) override; |
| 47 | ndk::ScopedAStatus setCountryCode(const std::array<uint8_t, 2>& in_code) override; |
| 48 | ndk::ScopedAStatus getValidFrequenciesForBand(WifiBand in_band, |
| 49 | std::vector<int32_t>* _aidl_return) override; |
| 50 | ndk::ScopedAStatus setMacAddress(const std::array<uint8_t, 6>& in_mac) override; |
| 51 | ndk::ScopedAStatus getFactoryMacAddress(std::array<uint8_t, 6>* _aidl_return) override; |
| 52 | ndk::ScopedAStatus resetToFactoryMacAddress() override; |
| 53 | ndk::ScopedAStatus getBridgedInstances(std::vector<std::string>* _aidl_return) override; |
| 54 | |
| 55 | private: |
| 56 | // Corresponding worker functions for the AIDL methods. |
| 57 | std::pair<std::string, ndk::ScopedAStatus> getNameInternal(); |
| 58 | ndk::ScopedAStatus setCountryCodeInternal(const std::array<uint8_t, 2>& code); |
| 59 | std::pair<std::vector<int32_t>, ndk::ScopedAStatus> getValidFrequenciesForBandInternal( |
| 60 | WifiBand band); |
| 61 | ndk::ScopedAStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac); |
| 62 | std::pair<std::array<uint8_t, 6>, ndk::ScopedAStatus> getFactoryMacAddressInternal( |
| 63 | const std::string& ifaceName); |
| 64 | ndk::ScopedAStatus resetToFactoryMacAddressInternal(); |
| 65 | std::pair<std::vector<std::string>, ndk::ScopedAStatus> getBridgedInstancesInternal(); |
| 66 | |
| 67 | std::string ifname_; |
| 68 | std::vector<std::string> instances_; |
| 69 | std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; |
| 70 | std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_; |
| 71 | bool is_valid_; |
| 72 | |
| 73 | DISALLOW_COPY_AND_ASSIGN(WifiApIface); |
| 74 | }; |
| 75 | |
| 76 | } // namespace wifi |
| 77 | } // namespace hardware |
| 78 | } // namespace android |
| 79 | } // namespace aidl |
| 80 | |
| 81 | #endif // WIFI_AP_IFACE_H_ |