• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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_LEGACY_HAL_FACTORY_H_
18 #define WIFI_LEGACY_HAL_FACTORY_H_
19 
20 #include <wifi_system/interface_tool.h>
21 
22 #include "wifi_legacy_hal.h"
23 
24 namespace android {
25 namespace hardware {
26 namespace wifi {
27 namespace V1_6 {
28 namespace implementation {
29 // This is in a separate namespace to prevent typename conflicts between
30 // the legacy HAL types and the HIDL interface types.
31 namespace legacy_hal {
32 /**
33  * Class that creates WifiLegacyHal objects for vendor HALs in the system.
34  */
35 class WifiLegacyHalFactory {
36   public:
37     WifiLegacyHalFactory(const std::weak_ptr<wifi_system::InterfaceTool> iface_tool);
38     virtual ~WifiLegacyHalFactory() = default;
39 
40     std::vector<std::shared_ptr<WifiLegacyHal>> getHals();
41 
42   private:
43     typedef struct {
44         wifi_hal_fn fn;
45         bool primary;
46         void* handle;
47     } wifi_hal_lib_desc;
48 
49     bool initVendorHalDescriptorFromLinked();
50     void initVendorHalsDescriptorList();
51     bool initLinkedHalFunctionTable(wifi_hal_fn* hal_fn);
52     bool loadVendorHalLib(const std::string& path, wifi_hal_lib_desc& desc);
53 
54     std::weak_ptr<wifi_system::InterfaceTool> iface_tool_;
55     std::vector<wifi_hal_lib_desc> descs_;
56     std::vector<std::shared_ptr<WifiLegacyHal>> legacy_hals_;
57 };
58 
59 }  // namespace legacy_hal
60 }  // namespace implementation
61 }  // namespace V1_6
62 }  // namespace wifi
63 }  // namespace hardware
64 }  // namespace android
65 
66 #endif  // WIFI_LEGACY_HAL_FACTORY_H_
67