blob: 8f8387deaef51702ce9b5a5d25a5188387e2948c [file] [log] [blame]
Roshan Pius3e2d6712016-10-06 13:16:23 -07001/*
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>
lesl420c4fc2020-11-23 19:33:04 +080021#include <android/hardware/wifi/1.5/IWifiApIface.h>
Roshan Pius3e2d6712016-10-06 13:16:23 -070022
Roshan Pius99dab382019-02-14 07:57:10 -080023#include "wifi_iface_util.h"
Roshan Pius3e2d6712016-10-06 13:16:23 -070024#include "wifi_legacy_hal.h"
25
26namespace android {
27namespace hardware {
28namespace wifi {
Jimmy Chend460df32019-11-29 17:31:22 +020029namespace V1_5 {
Roshan Pius3e2d6712016-10-06 13:16:23 -070030namespace implementation {
Roshan Piusdbd83ef2017-06-20 12:05:40 -070031using namespace android::hardware::wifi::V1_0;
Roshan Pius3e2d6712016-10-06 13:16:23 -070032
33/**
34 * HIDL interface object used to control a AP Iface instance.
35 */
lesl420c4fc2020-11-23 19:33:04 +080036class WifiApIface : public V1_5::IWifiApIface {
Roshan Piusabcf78f2017-10-06 16:30:38 -070037 public:
Patrik Fimml6beae322019-10-09 17:34:01 +020038 WifiApIface(const std::string& ifname,
lesl420c4fc2020-11-23 19:33:04 +080039 const std::vector<std::string>& instances,
Patrik Fimml6beae322019-10-09 17:34:01 +020040 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
41 const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util);
Roshan Piusabcf78f2017-10-06 16:30:38 -070042 // Refer to |WifiChip::invalidate()|.
43 void invalidate();
44 bool isValid();
Roshan Pius675609b2017-10-31 14:24:58 -070045 std::string getName();
lesl669c9062021-01-22 19:37:47 +080046 void removeInstance(std::string instance);
Roshan Pius3e2d6712016-10-06 13:16:23 -070047
Roshan Piusabcf78f2017-10-06 16:30:38 -070048 // HIDL methods exposed.
49 Return<void> getName(getName_cb hidl_status_cb) override;
50 Return<void> getType(getType_cb hidl_status_cb) override;
51 Return<void> setCountryCode(const hidl_array<int8_t, 2>& code,
52 setCountryCode_cb hidl_status_cb) override;
53 Return<void> getValidFrequenciesForBand(
Ahmed ElArabawyfd809fc2019-11-15 18:19:15 -080054 V1_0::WifiBand band,
55 getValidFrequenciesForBand_cb hidl_status_cb) override;
Patrik Fimmlc919f962019-09-11 14:31:56 +020056 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;
lesl420c4fc2020-11-23 19:33:04 +080060 Return<void> resetToFactoryMacAddress(
61 resetToFactoryMacAddress_cb hidl_status_cb) override;
Roshan Pius3e2d6712016-10-06 13:16:23 -070062
lesl669c9062021-01-22 19:37:47 +080063 Return<void> getBridgedInstances(
64 getBridgedInstances_cb hidl_status_cb) override;
65
Roshan Piusabcf78f2017-10-06 16:30:38 -070066 private:
67 // Corresponding worker functions for the HIDL methods.
68 std::pair<WifiStatus, std::string> getNameInternal();
69 std::pair<WifiStatus, IfaceType> getTypeInternal();
70 WifiStatus setCountryCodeInternal(const std::array<int8_t, 2>& code);
71 std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
Ahmed ElArabawyfd809fc2019-11-15 18:19:15 -080072 getValidFrequenciesForBandInternal(V1_0::WifiBand band);
Patrik Fimmlc919f962019-09-11 14:31:56 +020073 WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac);
lesl420c4fc2020-11-23 19:33:04 +080074 std::pair<WifiStatus, std::array<uint8_t, 6>> getFactoryMacAddressInternal(
75 const std::string& ifaceName);
76 WifiStatus resetToFactoryMacAddressInternal();
lesl669c9062021-01-22 19:37:47 +080077 std::pair<WifiStatus, std::vector<hidl_string>>
78 getBridgedInstancesInternal();
Roshan Pius907d4a22016-10-27 12:48:12 -070079
Roshan Piusabcf78f2017-10-06 16:30:38 -070080 std::string ifname_;
lesl420c4fc2020-11-23 19:33:04 +080081 std::vector<std::string> instances_;
Roshan Piusabcf78f2017-10-06 16:30:38 -070082 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
Roshan Pius99dab382019-02-14 07:57:10 -080083 std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_;
Roshan Piusabcf78f2017-10-06 16:30:38 -070084 bool is_valid_;
Roshan Pius3e2d6712016-10-06 13:16:23 -070085
Roshan Piusabcf78f2017-10-06 16:30:38 -070086 DISALLOW_COPY_AND_ASSIGN(WifiApIface);
Roshan Pius3e2d6712016-10-06 13:16:23 -070087};
88
89} // namespace implementation
Jimmy Chend460df32019-11-29 17:31:22 +020090} // namespace V1_5
Roshan Pius3e2d6712016-10-06 13:16:23 -070091} // namespace wifi
92} // namespace hardware
93} // namespace android
94
95#endif // WIFI_AP_IFACE_H_