Gabriel Biren | 631a811 | 2022-12-01 22:29:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 <android-base/macros.h> |
| 21 | #include <android/hardware/wifi/1.5/IWifiApIface.h> |
| 22 | |
| 23 | #include "wifi_iface_util.h" |
| 24 | #include "wifi_legacy_hal.h" |
| 25 | |
| 26 | namespace android { |
| 27 | namespace hardware { |
| 28 | namespace wifi { |
| 29 | namespace V1_6 { |
| 30 | namespace implementation { |
| 31 | using namespace android::hardware::wifi::V1_0; |
| 32 | |
| 33 | /** |
| 34 | * HIDL interface object used to control a AP Iface instance. |
| 35 | */ |
| 36 | class WifiApIface : public V1_5::IWifiApIface { |
| 37 | public: |
| 38 | WifiApIface(const std::string& ifname, const std::vector<std::string>& instances, |
| 39 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal, |
| 40 | const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util); |
| 41 | // Refer to |WifiChip::invalidate()|. |
| 42 | void invalidate(); |
| 43 | bool isValid(); |
| 44 | std::string getName(); |
| 45 | void removeInstance(std::string instance); |
| 46 | |
| 47 | // HIDL methods exposed. |
| 48 | Return<void> getName(getName_cb hidl_status_cb) override; |
| 49 | Return<void> getType(getType_cb hidl_status_cb) override; |
| 50 | Return<void> setCountryCode(const hidl_array<int8_t, 2>& code, |
| 51 | setCountryCode_cb hidl_status_cb) override; |
| 52 | Return<void> getValidFrequenciesForBand(V1_0::WifiBand band, |
| 53 | getValidFrequenciesForBand_cb hidl_status_cb) override; |
| 54 | Return<void> setMacAddress(const hidl_array<uint8_t, 6>& mac, |
| 55 | setMacAddress_cb hidl_status_cb) override; |
| 56 | Return<void> getFactoryMacAddress(getFactoryMacAddress_cb hidl_status_cb) override; |
| 57 | Return<void> resetToFactoryMacAddress(resetToFactoryMacAddress_cb hidl_status_cb) override; |
| 58 | |
| 59 | Return<void> getBridgedInstances(getBridgedInstances_cb hidl_status_cb) override; |
| 60 | |
| 61 | private: |
| 62 | // Corresponding worker functions for the HIDL methods. |
| 63 | std::pair<WifiStatus, std::string> getNameInternal(); |
| 64 | std::pair<WifiStatus, IfaceType> getTypeInternal(); |
| 65 | WifiStatus setCountryCodeInternal(const std::array<int8_t, 2>& code); |
| 66 | std::pair<WifiStatus, std::vector<WifiChannelInMhz>> getValidFrequenciesForBandInternal( |
| 67 | V1_0::WifiBand band); |
| 68 | WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac); |
| 69 | std::pair<WifiStatus, std::array<uint8_t, 6>> getFactoryMacAddressInternal( |
| 70 | const std::string& ifaceName); |
| 71 | WifiStatus resetToFactoryMacAddressInternal(); |
| 72 | std::pair<WifiStatus, std::vector<hidl_string>> getBridgedInstancesInternal(); |
| 73 | |
| 74 | std::string ifname_; |
| 75 | std::vector<std::string> instances_; |
| 76 | std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; |
| 77 | std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_; |
| 78 | bool is_valid_; |
| 79 | |
| 80 | DISALLOW_COPY_AND_ASSIGN(WifiApIface); |
| 81 | }; |
| 82 | |
| 83 | } // namespace implementation |
| 84 | } // namespace V1_6 |
| 85 | } // namespace wifi |
| 86 | } // namespace hardware |
| 87 | } // namespace android |
| 88 | |
| 89 | #endif // WIFI_AP_IFACE_H_ |