blob: 21acb92621b01e8b67683252e9724575a30bd780 [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>
Roshan Pius734fea02016-10-11 08:30:28 -070022#include <vector>
Roshan Piusaabe5752016-09-29 09:03:59 -070023
24#include <hardware_legacy/wifi_hal.h>
25
26namespace android {
27namespace hardware {
28namespace wifi {
29namespace V1_0 {
30namespace implementation {
31
32/**
33 * Class that encapsulates all legacy HAL interactions.
34 * This class manages the lifetime of the event loop thread used by legacy HAL.
35 */
36class WifiLegacyHal {
37 public:
38 WifiLegacyHal();
Roshan Piusab5c4712016-10-06 14:37:15 -070039 // Names to use for the different types of iface.
40 std::string getApIfaceName();
41 std::string getNanIfaceName();
42 std::string getP2pIfaceName();
43 std::string getStaIfaceName();
44
Roshan Piusaabe5752016-09-29 09:03:59 -070045 // Initialize the legacy HAL and start the event looper thread.
46 wifi_error start();
47 // Deinitialize the legacy HAL and stop the event looper thread.
48 wifi_error stop(const std::function<void()>& on_complete_callback);
Roshan Pius4b26c832016-10-03 12:49:58 -070049 // Wrappers for all the functions in the legacy HAL function table.
Roshan Piusab5c4712016-10-06 14:37:15 -070050 std::pair<wifi_error, std::string> getDriverVersion();
51 std::pair<wifi_error, std::string> getFirmwareVersion();
Roshan Pius3c868522016-10-27 12:43:49 -070052 std::pair<wifi_error, std::vector<uint8_t>> requestDriverMemoryDump();
53 std::pair<wifi_error, std::vector<uint8_t>> requestFirmwareMemoryDump();
Roshan Piusaabe5752016-09-29 09:03:59 -070054
55 private:
Roshan Pius4b26c832016-10-03 12:49:58 -070056 static const uint32_t kMaxVersionStringLength;
57
Roshan Piusaabe5752016-09-29 09:03:59 -070058 // Retrieve the interface handle to be used for the "wlan" interface.
59 wifi_error retrieveWlanInterfaceHandle();
60 // Run the legacy HAL event loop thread.
61 void runEventLoop();
62
63 // Event loop thread used by legacy HAL.
64 std::thread event_loop_thread_;
65 // Global function table of legacy HAL.
66 wifi_hal_fn global_func_table_;
67 // Opaque handle to be used for all global operations.
68 wifi_handle global_handle_;
69 // Opaque handle to be used for all wlan0 interface specific operations.
70 wifi_interface_handle wlan_interface_handle_;
71 // Flag to indicate if we have initiated the cleanup of legacy HAL.
72 bool awaiting_event_loop_termination_;
73};
74
75} // namespace implementation
76} // namespace V1_0
77} // namespace wifi
78} // namespace hardware
79} // namespace android
80
81#endif // WIFI_LEGACY_WIFI_HAL_H_