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 */
17 #ifndef WIFI_AP_IFACE_H_
18 #define WIFI_AP_IFACE_H_
20 #include <android-base/macros.h>
21 #include <android/hardware/wifi/1.0/IWifiApIface.h>
23 #include "wifi_legacy_hal.h"
25 namespace android {
26 namespace hardware {
27 namespace wifi {
28 namespace V1_2 {
29 namespace implementation {
30 using namespace android::hardware::wifi::V1_0;
32 /**
33 * HIDL interface object used to control a AP Iface instance.
34 */
35 class WifiApIface : public V1_0::IWifiApIface {
36 public:
37 WifiApIface(const std::string& ifname,
38 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
39 // Refer to |WifiChip::invalidate()|.
40 void invalidate();
41 bool isValid();
42 std::string getName();
44 // HIDL methods exposed.
45 Return<void> getName(getName_cb hidl_status_cb) override;
46 Return<void> getType(getType_cb hidl_status_cb) override;
47 Return<void> setCountryCode(const hidl_array<int8_t, 2>& code,
48 setCountryCode_cb hidl_status_cb) override;
49 Return<void> getValidFrequenciesForBand(
50 WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override;
52 private:
53 // Corresponding worker functions for the HIDL methods.
54 std::pair<WifiStatus, std::string> getNameInternal();
55 std::pair<WifiStatus, IfaceType> getTypeInternal();
56 WifiStatus setCountryCodeInternal(const std::array<int8_t, 2>& code);
57 std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
58 getValidFrequenciesForBandInternal(WifiBand band);
60 std::string ifname_;
61 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
62 bool is_valid_;
64 DISALLOW_COPY_AND_ASSIGN(WifiApIface);
65 };
67 } // namespace implementation
68 } // namespace V1_2
69 } // namespace wifi
70 } // namespace hardware
71 } // namespace android
73 #endif // WIFI_AP_IFACE_H_