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