Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [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> |
Patrik Fimml | c919f96 | 2019-09-11 14:31:56 +0200 | [diff] [blame^] | 21 | #include <android/hardware/wifi/1.4/IWifiApIface.h> |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 22 | |
Roshan Pius | 3b6705f | 2019-02-14 09:43:43 -0800 | [diff] [blame] | 23 | #include "wifi_feature_flags.h" |
Roshan Pius | 99dab38 | 2019-02-14 07:57:10 -0800 | [diff] [blame] | 24 | #include "wifi_iface_util.h" |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 25 | #include "wifi_legacy_hal.h" |
| 26 | |
| 27 | namespace android { |
| 28 | namespace hardware { |
| 29 | namespace wifi { |
Ahmed ElArabawy | f501a98 | 2019-07-23 15:02:22 -0700 | [diff] [blame] | 30 | namespace V1_4 { |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 31 | namespace implementation { |
Roshan Pius | dbd83ef | 2017-06-20 12:05:40 -0700 | [diff] [blame] | 32 | using namespace android::hardware::wifi::V1_0; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * HIDL interface object used to control a AP Iface instance. |
| 36 | */ |
Patrik Fimml | c919f96 | 2019-09-11 14:31:56 +0200 | [diff] [blame^] | 37 | class WifiApIface : public V1_4::IWifiApIface { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 38 | public: |
Roshan Pius | 3b6705f | 2019-02-14 09:43:43 -0800 | [diff] [blame] | 39 | WifiApIface( |
| 40 | const std::string& ifname, |
| 41 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal, |
| 42 | const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util, |
| 43 | const std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 44 | // Refer to |WifiChip::invalidate()|. |
| 45 | void invalidate(); |
| 46 | bool isValid(); |
Roshan Pius | 675609b | 2017-10-31 14:24:58 -0700 | [diff] [blame] | 47 | std::string getName(); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 48 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 49 | // HIDL methods exposed. |
| 50 | Return<void> getName(getName_cb hidl_status_cb) override; |
| 51 | Return<void> getType(getType_cb hidl_status_cb) override; |
| 52 | Return<void> setCountryCode(const hidl_array<int8_t, 2>& code, |
| 53 | setCountryCode_cb hidl_status_cb) override; |
| 54 | Return<void> getValidFrequenciesForBand( |
| 55 | WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override; |
Patrik Fimml | c919f96 | 2019-09-11 14:31:56 +0200 | [diff] [blame^] | 56 | Return<void> setMacAddress(const hidl_array<uint8_t, 6>& mac, |
| 57 | setMacAddress_cb hidl_status_cb) override; |
| 58 | Return<void> getFactoryMacAddress( |
| 59 | getFactoryMacAddress_cb hidl_status_cb) override; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 60 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 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>> |
| 67 | getValidFrequenciesForBandInternal(WifiBand band); |
Patrik Fimml | c919f96 | 2019-09-11 14:31:56 +0200 | [diff] [blame^] | 68 | WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac); |
| 69 | std::pair<WifiStatus, std::array<uint8_t, 6>> |
| 70 | getFactoryMacAddressInternal(); |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 71 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 72 | std::string ifname_; |
| 73 | std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; |
Roshan Pius | 99dab38 | 2019-02-14 07:57:10 -0800 | [diff] [blame] | 74 | std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_; |
Roshan Pius | 3b6705f | 2019-02-14 09:43:43 -0800 | [diff] [blame] | 75 | std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags_; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 76 | bool is_valid_; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 77 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 78 | DISALLOW_COPY_AND_ASSIGN(WifiApIface); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | } // namespace implementation |
Ahmed ElArabawy | f501a98 | 2019-07-23 15:02:22 -0700 | [diff] [blame] | 82 | } // namespace V1_4 |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 83 | } // namespace wifi |
| 84 | } // namespace hardware |
| 85 | } // namespace android |
| 86 | |
| 87 | #endif // WIFI_AP_IFACE_H_ |