blob: f691b9ba5c76e6feedf1bb93ea8642956d49fde2 [file] [log] [blame]
Roshan Piusaabe5752016-09-29 09:03:59 -07001/*
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
25namespace android {
26namespace hardware {
27namespace wifi {
28namespace V1_0 {
29namespace 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 */
35class 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);
Roshan Pius4b26c832016-10-03 12:49:58 -070042 // Wrappers for all the functions in the legacy HAL function table.
43 std::pair<wifi_error, std::string> getWlanDriverVersion();
44 std::pair<wifi_error, std::string> getWlanFirmwareVersion();
Roshan Piuscdb77f32016-10-03 14:09:57 -070045 std::pair<wifi_error, std::vector<char>> requestWlanDriverMemoryDump();
46 std::pair<wifi_error, std::vector<char>> requestWlanFirmwareMemoryDump();
Roshan Piusaabe5752016-09-29 09:03:59 -070047
48 private:
Roshan Pius4b26c832016-10-03 12:49:58 -070049 static const uint32_t kMaxVersionStringLength;
50
Roshan Piusaabe5752016-09-29 09:03:59 -070051 // Retrieve the interface handle to be used for the "wlan" interface.
52 wifi_error retrieveWlanInterfaceHandle();
53 // Run the legacy HAL event loop thread.
54 void runEventLoop();
55
56 // Event loop thread used by legacy HAL.
57 std::thread event_loop_thread_;
58 // Global function table of legacy HAL.
59 wifi_hal_fn global_func_table_;
60 // Opaque handle to be used for all global operations.
61 wifi_handle global_handle_;
62 // Opaque handle to be used for all wlan0 interface specific operations.
63 wifi_interface_handle wlan_interface_handle_;
64 // Flag to indicate if we have initiated the cleanup of legacy HAL.
65 bool awaiting_event_loop_termination_;
66};
67
68} // namespace implementation
69} // namespace V1_0
70} // namespace wifi
71} // namespace hardware
72} // namespace android
73
74#endif // WIFI_LEGACY_WIFI_HAL_H_