blob: 4f3438c298cc0a1ab17bd6dcb419c1f9d4c80907 [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>
Patrik Fimmlc919f962019-09-11 14:31:56 +020021#include <android/hardware/wifi/1.4/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 {
Ahmed ElArabawyf501a982019-07-23 15:02:22 -070029namespace V1_4 {
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 */
Patrik Fimmlc919f962019-09-11 14:31:56 +020036class WifiApIface : public V1_4::IWifiApIface {
Roshan Piusabcf78f2017-10-06 16:30:38 -070037 public:
Patrik Fimml6beae322019-10-09 17:34:01 +020038 WifiApIface(const std::string& ifname,
39 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
40 const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util);
Roshan Piusabcf78f2017-10-06 16:30:38 -070041 // Refer to |WifiChip::invalidate()|.
42 void invalidate();
43 bool isValid();
Roshan Pius675609b2017-10-31 14:24:58 -070044 std::string getName();
Roshan Pius3e2d6712016-10-06 13:16:23 -070045
Roshan Piusabcf78f2017-10-06 16:30:38 -070046 // HIDL methods exposed.
47 Return<void> getName(getName_cb hidl_status_cb) override;
48 Return<void> getType(getType_cb hidl_status_cb) override;
49 Return<void> setCountryCode(const hidl_array<int8_t, 2>& code,
50 setCountryCode_cb hidl_status_cb) override;
51 Return<void> getValidFrequenciesForBand(
52 WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override;
Patrik Fimmlc919f962019-09-11 14:31:56 +020053 Return<void> setMacAddress(const hidl_array<uint8_t, 6>& mac,
54 setMacAddress_cb hidl_status_cb) override;
55 Return<void> getFactoryMacAddress(
56 getFactoryMacAddress_cb hidl_status_cb) override;
Roshan Pius3e2d6712016-10-06 13:16:23 -070057
Roshan Piusabcf78f2017-10-06 16:30:38 -070058 private:
59 // Corresponding worker functions for the HIDL methods.
60 std::pair<WifiStatus, std::string> getNameInternal();
61 std::pair<WifiStatus, IfaceType> getTypeInternal();
62 WifiStatus setCountryCodeInternal(const std::array<int8_t, 2>& code);
63 std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
64 getValidFrequenciesForBandInternal(WifiBand band);
Patrik Fimmlc919f962019-09-11 14:31:56 +020065 WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac);
66 std::pair<WifiStatus, std::array<uint8_t, 6>>
67 getFactoryMacAddressInternal();
Roshan Pius907d4a22016-10-27 12:48:12 -070068
Roshan Piusabcf78f2017-10-06 16:30:38 -070069 std::string ifname_;
70 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
Roshan Pius99dab382019-02-14 07:57:10 -080071 std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_;
Roshan Piusabcf78f2017-10-06 16:30:38 -070072 bool is_valid_;
Roshan Pius3e2d6712016-10-06 13:16:23 -070073
Roshan Piusabcf78f2017-10-06 16:30:38 -070074 DISALLOW_COPY_AND_ASSIGN(WifiApIface);
Roshan Pius3e2d6712016-10-06 13:16:23 -070075};
76
77} // namespace implementation
Ahmed ElArabawyf501a982019-07-23 15:02:22 -070078} // namespace V1_4
Roshan Pius3e2d6712016-10-06 13:16:23 -070079} // namespace wifi
80} // namespace hardware
81} // namespace android
82
83#endif // WIFI_AP_IFACE_H_