blob: 7378f98acfcf16735667a85a76c27b3f9f2649a8 [file] [log] [blame]
Gabriel Birenf3262f92022-07-15 23:25:39 +00001/*
2 * Copyright (C) 2022 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 <aidl/android/hardware/wifi/BnWifiApIface.h>
21#include <android-base/macros.h>
22
23#include "wifi_iface_util.h"
24#include "wifi_legacy_hal.h"
25
26namespace aidl {
27namespace android {
28namespace hardware {
29namespace wifi {
30
31/**
32 * AIDL interface object used to control an AP Iface instance.
33 */
34class WifiApIface : public BnWifiApIface {
35 public:
36 WifiApIface(const std::string& ifname, const std::vector<std::string>& instances,
37 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
38 const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util);
39 // Refer to |WifiChip::invalidate()|.
40 void invalidate();
41 bool isValid();
42 std::string getName();
43 void removeInstance(std::string instance);
44
45 // AIDL methods exposed.
46 ndk::ScopedAStatus getName(std::string* _aidl_return) override;
47 ndk::ScopedAStatus setCountryCode(const std::array<uint8_t, 2>& in_code) override;
Gabriel Birenf3262f92022-07-15 23:25:39 +000048 ndk::ScopedAStatus setMacAddress(const std::array<uint8_t, 6>& in_mac) override;
49 ndk::ScopedAStatus getFactoryMacAddress(std::array<uint8_t, 6>* _aidl_return) override;
50 ndk::ScopedAStatus resetToFactoryMacAddress() override;
51 ndk::ScopedAStatus getBridgedInstances(std::vector<std::string>* _aidl_return) override;
52
53 private:
54 // Corresponding worker functions for the AIDL methods.
55 std::pair<std::string, ndk::ScopedAStatus> getNameInternal();
56 ndk::ScopedAStatus setCountryCodeInternal(const std::array<uint8_t, 2>& code);
Gabriel Birenf3262f92022-07-15 23:25:39 +000057 ndk::ScopedAStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac);
58 std::pair<std::array<uint8_t, 6>, ndk::ScopedAStatus> getFactoryMacAddressInternal(
59 const std::string& ifaceName);
60 ndk::ScopedAStatus resetToFactoryMacAddressInternal();
61 std::pair<std::vector<std::string>, ndk::ScopedAStatus> getBridgedInstancesInternal();
62
63 std::string ifname_;
64 std::vector<std::string> instances_;
65 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
66 std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_;
67 bool is_valid_;
68
69 DISALLOW_COPY_AND_ASSIGN(WifiApIface);
70};
71
72} // namespace wifi
73} // namespace hardware
74} // namespace android
75} // namespace aidl
76
77#endif // WIFI_AP_IFACE_H_