blob: 3585975b10c799dd0417bec09e769b1b963535cd [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();
Roshan Piusab5c4712016-10-06 14:37:15 -070038 // Names to use for the different types of iface.
39 std::string getApIfaceName();
40 std::string getNanIfaceName();
41 std::string getP2pIfaceName();
42 std::string getStaIfaceName();
43
Roshan Piusaabe5752016-09-29 09:03:59 -070044 // Initialize the legacy HAL and start the event looper thread.
45 wifi_error start();
46 // Deinitialize the legacy HAL and stop the event looper thread.
47 wifi_error stop(const std::function<void()>& on_complete_callback);
Roshan Pius4b26c832016-10-03 12:49:58 -070048 // Wrappers for all the functions in the legacy HAL function table.
Roshan Piusab5c4712016-10-06 14:37:15 -070049 std::pair<wifi_error, std::string> getDriverVersion();
50 std::pair<wifi_error, std::string> getFirmwareVersion();
51 std::pair<wifi_error, std::vector<char>> requestDriverMemoryDump();
52 std::pair<wifi_error, std::vector<char>> requestFirmwareMemoryDump();
Roshan Piusaabe5752016-09-29 09:03:59 -070053
54 private:
Roshan Pius4b26c832016-10-03 12:49:58 -070055 static const uint32_t kMaxVersionStringLength;
56
Roshan Piusaabe5752016-09-29 09:03:59 -070057 // Retrieve the interface handle to be used for the "wlan" interface.
58 wifi_error retrieveWlanInterfaceHandle();
59 // Run the legacy HAL event loop thread.
60 void runEventLoop();
61
62 // Event loop thread used by legacy HAL.
63 std::thread event_loop_thread_;
64 // Global function table of legacy HAL.
65 wifi_hal_fn global_func_table_;
66 // Opaque handle to be used for all global operations.
67 wifi_handle global_handle_;
68 // Opaque handle to be used for all wlan0 interface specific operations.
69 wifi_interface_handle wlan_interface_handle_;
70 // Flag to indicate if we have initiated the cleanup of legacy HAL.
71 bool awaiting_event_loop_termination_;
72};
73
74} // namespace implementation
75} // namespace V1_0
76} // namespace wifi
77} // namespace hardware
78} // namespace android
79
80#endif // WIFI_LEGACY_WIFI_HAL_H_