blob: 6dbfc18a335e1174b5e603565a12b023d25f21f1 [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>
21#include <android/hardware/wifi/1.0/IWifiApIface.h>
22
Roshan Pius99dab382019-02-14 07:57:10 -080023#include "wifi_iface_util.h"
24
Roshan Pius3e2d6712016-10-06 13:16:23 -070025#include "wifi_legacy_hal.h"
26
27namespace android {
28namespace hardware {
29namespace wifi {
Jong Wook Kimda830c92018-07-23 15:29:38 -070030namespace V1_3 {
Roshan Pius3e2d6712016-10-06 13:16:23 -070031namespace implementation {
Roshan Piusdbd83ef2017-06-20 12:05:40 -070032using namespace android::hardware::wifi::V1_0;
Roshan Pius3e2d6712016-10-06 13:16:23 -070033
34/**
35 * HIDL interface object used to control a AP Iface instance.
36 */
Roshan Piusdbd83ef2017-06-20 12:05:40 -070037class WifiApIface : public V1_0::IWifiApIface {
Roshan Piusabcf78f2017-10-06 16:30:38 -070038 public:
39 WifiApIface(const std::string& ifname,
Roshan Pius99dab382019-02-14 07:57:10 -080040 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();
Roshan Pius3e2d6712016-10-06 13:16:23 -070046
Roshan Piusabcf78f2017-10-06 16:30:38 -070047 // 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(
53 WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override;
Roshan Pius3e2d6712016-10-06 13:16:23 -070054
Roshan Piusabcf78f2017-10-06 16:30:38 -070055 private:
56 // Corresponding worker functions for the HIDL methods.
57 std::pair<WifiStatus, std::string> getNameInternal();
58 std::pair<WifiStatus, IfaceType> getTypeInternal();
59 WifiStatus setCountryCodeInternal(const std::array<int8_t, 2>& code);
60 std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
61 getValidFrequenciesForBandInternal(WifiBand band);
Roshan Pius907d4a22016-10-27 12:48:12 -070062
Roshan Piusabcf78f2017-10-06 16:30:38 -070063 std::string ifname_;
64 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
Roshan Pius99dab382019-02-14 07:57:10 -080065 std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_;
Roshan Piusabcf78f2017-10-06 16:30:38 -070066 bool is_valid_;
Roshan Pius3e2d6712016-10-06 13:16:23 -070067
Roshan Piusabcf78f2017-10-06 16:30:38 -070068 DISALLOW_COPY_AND_ASSIGN(WifiApIface);
Roshan Pius3e2d6712016-10-06 13:16:23 -070069};
70
71} // namespace implementation
Jong Wook Kimda830c92018-07-23 15:29:38 -070072} // namespace V1_3
Roshan Pius3e2d6712016-10-06 13:16:23 -070073} // namespace wifi
74} // namespace hardware
75} // namespace android
76
77#endif // WIFI_AP_IFACE_H_