• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  */
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 
23 #include "wifi_feature_flags.h"
24 #include "wifi_iface_util.h"
25 #include "wifi_legacy_hal.h"
26 
27 namespace android {
28 namespace hardware {
29 namespace wifi {
30 namespace V1_3 {
31 namespace implementation {
32 using namespace android::hardware::wifi::V1_0;
33 
34 /**
35  * HIDL interface object used to control a AP Iface instance.
36  */
37 class WifiApIface : public V1_0::IWifiApIface {
38    public:
39     WifiApIface(
40         const std::string& ifname,
41         const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
42         const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util,
43         const std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags);
44     // Refer to |WifiChip::invalidate()|.
45     void invalidate();
46     bool isValid();
47     std::string getName();
48 
49     // HIDL methods exposed.
50     Return<void> getName(getName_cb hidl_status_cb) override;
51     Return<void> getType(getType_cb hidl_status_cb) override;
52     Return<void> setCountryCode(const hidl_array<int8_t, 2>& code,
53                                 setCountryCode_cb hidl_status_cb) override;
54     Return<void> getValidFrequenciesForBand(
55         WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override;
56 
57    private:
58     // Corresponding worker functions for the HIDL methods.
59     std::pair<WifiStatus, std::string> getNameInternal();
60     std::pair<WifiStatus, IfaceType> getTypeInternal();
61     WifiStatus setCountryCodeInternal(const std::array<int8_t, 2>& code);
62     std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
63     getValidFrequenciesForBandInternal(WifiBand band);
64 
65     std::string ifname_;
66     std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
67     std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_;
68     std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags_;
69     bool is_valid_;
70 
71     DISALLOW_COPY_AND_ASSIGN(WifiApIface);
72 };
73 
74 }  // namespace implementation
75 }  // namespace V1_3
76 }  // namespace wifi
77 }  // namespace hardware
78 }  // namespace android
79 
80 #endif  // WIFI_AP_IFACE_H_
81