Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 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> |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 22 | #include <vector> |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 23 | |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 24 | namespace android { |
| 25 | namespace hardware { |
| 26 | namespace wifi { |
| 27 | namespace V1_0 { |
| 28 | namespace implementation { |
Roshan Pius | 955542e | 2016-10-28 09:42:44 -0700 | [diff] [blame^] | 29 | // This is in a separate namespace to prevent typename conflicts between |
| 30 | // the legacy HAL types and the HIDL interface types. |
| 31 | namespace legacy_hal { |
| 32 | // Wrap all the types defined inside the legacy HAL header files inside this |
| 33 | // namespace. |
| 34 | #include <hardware_legacy/wifi_hal.h> |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Class that encapsulates all legacy HAL interactions. |
| 38 | * This class manages the lifetime of the event loop thread used by legacy HAL. |
| 39 | */ |
| 40 | class WifiLegacyHal { |
| 41 | public: |
| 42 | WifiLegacyHal(); |
Roshan Pius | ab5c471 | 2016-10-06 14:37:15 -0700 | [diff] [blame] | 43 | // Names to use for the different types of iface. |
| 44 | std::string getApIfaceName(); |
| 45 | std::string getNanIfaceName(); |
| 46 | std::string getP2pIfaceName(); |
| 47 | std::string getStaIfaceName(); |
| 48 | |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 49 | // Initialize the legacy HAL and start the event looper thread. |
| 50 | wifi_error start(); |
| 51 | // Deinitialize the legacy HAL and stop the event looper thread. |
| 52 | wifi_error stop(const std::function<void()>& on_complete_callback); |
Roshan Pius | 4b26c83 | 2016-10-03 12:49:58 -0700 | [diff] [blame] | 53 | // Wrappers for all the functions in the legacy HAL function table. |
Roshan Pius | ab5c471 | 2016-10-06 14:37:15 -0700 | [diff] [blame] | 54 | std::pair<wifi_error, std::string> getDriverVersion(); |
| 55 | std::pair<wifi_error, std::string> getFirmwareVersion(); |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 56 | std::pair<wifi_error, std::vector<uint8_t>> requestDriverMemoryDump(); |
| 57 | std::pair<wifi_error, std::vector<uint8_t>> requestFirmwareMemoryDump(); |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 58 | |
| 59 | private: |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 60 | // Retrieve the interface handle to be used for the "wlan" interface. |
| 61 | wifi_error retrieveWlanInterfaceHandle(); |
| 62 | // Run the legacy HAL event loop thread. |
| 63 | void runEventLoop(); |
Roshan Pius | 511cc49 | 2016-10-28 09:54:26 -0700 | [diff] [blame] | 64 | void invalidate(); |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 65 | |
| 66 | // Event loop thread used by legacy HAL. |
| 67 | std::thread event_loop_thread_; |
| 68 | // Global function table of legacy HAL. |
| 69 | wifi_hal_fn global_func_table_; |
| 70 | // Opaque handle to be used for all global operations. |
| 71 | wifi_handle global_handle_; |
| 72 | // Opaque handle to be used for all wlan0 interface specific operations. |
| 73 | wifi_interface_handle wlan_interface_handle_; |
| 74 | // Flag to indicate if we have initiated the cleanup of legacy HAL. |
| 75 | bool awaiting_event_loop_termination_; |
| 76 | }; |
| 77 | |
Roshan Pius | 955542e | 2016-10-28 09:42:44 -0700 | [diff] [blame^] | 78 | } // namespace legacy_hal |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 79 | } // namespace implementation |
| 80 | } // namespace V1_0 |
| 81 | } // namespace wifi |
| 82 | } // namespace hardware |
| 83 | } // namespace android |
| 84 | |
| 85 | #endif // WIFI_LEGACY_WIFI_HAL_H_ |