OSDN Git Service

1af9f1a2f64aaba0f2da23abc4a968f8954b42dc
[android-x86/hardware-interfaces.git] / wifi / 1.0 / default / wifi_legacy_hal.h
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_LEGACY_WIFI_HAL_H_
18 #define WIFI_LEGACY_WIFI_HAL_H_
19
20 #include <functional>
21 #include <thread>
22
23 #include <hardware_legacy/wifi_hal.h>
24
25 namespace android {
26 namespace hardware {
27 namespace wifi {
28 namespace V1_0 {
29 namespace implementation {
30
31 /**
32  * Class that encapsulates all legacy HAL interactions.
33  * This class manages the lifetime of the event loop thread used by legacy HAL.
34  */
35 class WifiLegacyHal {
36  public:
37   WifiLegacyHal();
38   // Initialize the legacy HAL and start the event looper thread.
39   wifi_error start();
40   // Deinitialize the legacy HAL and stop the event looper thread.
41   wifi_error stop(const std::function<void()>& on_complete_callback);
42
43  private:
44   // Retrieve the interface handle to be used for the "wlan" interface.
45   wifi_error retrieveWlanInterfaceHandle();
46   // Run the legacy HAL event loop thread.
47   void runEventLoop();
48
49   // Event loop thread used by legacy HAL.
50   std::thread event_loop_thread_;
51   // Global function table of legacy HAL.
52   wifi_hal_fn global_func_table_;
53   // Opaque handle to be used for all global operations.
54   wifi_handle global_handle_;
55   // Opaque handle to be used for all wlan0 interface specific operations.
56   wifi_interface_handle wlan_interface_handle_;
57   // Flag to indicate if we have initiated the cleanup of legacy HAL.
58   bool awaiting_event_loop_termination_;
59 };
60
61 }  // namespace implementation
62 }  // namespace V1_0
63 }  // namespace wifi
64 }  // namespace hardware
65 }  // namespace android
66
67 #endif  // WIFI_LEGACY_WIFI_HAL_H_