Loading wifi/aidl/default/Android.bp→wifi/1.6/default/Android.bp +54 −30 Original line number Diff line number Diff line // Copyright (C) 2022 The Android Open Source Project // Copyright (C) 2021 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. Loading Loading @@ -36,7 +36,7 @@ soong_config_module_type { } wifi_hal_cc_defaults { name: "android.hardware.wifi-service-cppflags-defaults", name: "android.hardware.wifi@1.0-service-cppflags-defaults", soong_config_variables: { hidl_feature_aware: { cppflags: ["-DWIFI_HIDL_FEATURE_AWARE"], Loading @@ -60,8 +60,8 @@ wifi_hal_cc_defaults { } cc_library_static { name: "android.hardware.wifi-service-lib", defaults: ["android.hardware.wifi-service-cppflags-defaults"], name: "android.hardware.wifi@1.0-service-lib", defaults: ["android.hardware.wifi@1.0-service-cppflags-defaults"], proprietary: true, compile_multilib: "first", cppflags: [ Loading @@ -72,8 +72,8 @@ cc_library_static { // Allow implicit fallthroughs in wifi_legacy_hal.cpp until they are fixed. cflags: ["-Wno-error=implicit-fallthrough"], srcs: [ "aidl_struct_util.cpp", "aidl_sync_util.cpp", "hidl_struct_util.cpp", "hidl_sync_util.cpp", "ringbuffer.cpp", "wifi.cpp", "wifi_ap_iface.cpp", Loading @@ -93,23 +93,29 @@ cc_library_static { shared_libs: [ "libbase", "libbinder_ndk", "libcutils", "libhidlbase", "liblog", "libnl", "libutils", "libwifi-hal", "libwifi-system-iface", "libxml2", "android.hardware.wifi-V1-ndk", "android.hardware.wifi@1.0", "android.hardware.wifi@1.1", "android.hardware.wifi@1.2", "android.hardware.wifi@1.3", "android.hardware.wifi@1.4", "android.hardware.wifi@1.5", "android.hardware.wifi@1.6", ], export_include_dirs: ["."], } cc_binary { name: "android.hardware.wifi-service", vintf_fragments: ["android.hardware.wifi-service.xml"], name: "android.hardware.wifi@1.0-service", vintf_fragments: ["android.hardware.wifi@1.0-service.xml"], relative_install_path: "hw", proprietary: true, cppflags: [ Loading @@ -120,24 +126,30 @@ cc_binary { srcs: ["service.cpp"], shared_libs: [ "libbase", "libbinder_ndk", "libcutils", "libhidlbase", "liblog", "libnl", "libutils", "libwifi-hal", "libwifi-system-iface", "libxml2", "android.hardware.wifi-V1-ndk", "android.hardware.wifi@1.0", "android.hardware.wifi@1.1", "android.hardware.wifi@1.2", "android.hardware.wifi@1.3", "android.hardware.wifi@1.4", "android.hardware.wifi@1.5", "android.hardware.wifi@1.6", ], static_libs: ["android.hardware.wifi-service-lib"], init_rc: ["android.hardware.wifi-service.rc"], static_libs: ["android.hardware.wifi@1.0-service-lib"], init_rc: ["android.hardware.wifi@1.0-service.rc"], } cc_binary { name: "android.hardware.wifi-service-lazy", vintf_fragments: ["android.hardware.wifi-service.xml"], overrides: ["android.hardware.wifi-service"], name: "android.hardware.wifi@1.0-service-lazy", vintf_fragments: ["android.hardware.wifi@1.0-service.xml"], overrides: ["android.hardware.wifi@1.0-service"], cflags: ["-DLAZY_SERVICE"], relative_install_path: "hw", proprietary: true, Loading @@ -149,22 +161,28 @@ cc_binary { srcs: ["service.cpp"], shared_libs: [ "libbase", "libbinder_ndk", "libcutils", "libhidlbase", "liblog", "libnl", "libutils", "libwifi-hal", "libwifi-system-iface", "libxml2", "android.hardware.wifi-V1-ndk", "android.hardware.wifi@1.0", "android.hardware.wifi@1.1", "android.hardware.wifi@1.2", "android.hardware.wifi@1.3", "android.hardware.wifi@1.4", "android.hardware.wifi@1.5", "android.hardware.wifi@1.6", ], static_libs: ["android.hardware.wifi-service-lib"], init_rc: ["android.hardware.wifi-service-lazy.rc"], static_libs: ["android.hardware.wifi@1.0-service-lib"], init_rc: ["android.hardware.wifi@1.0-service-lazy.rc"], } cc_test { name: "android.hardware.wifi-service-tests", name: "android.hardware.wifi@1.0-service-tests", proprietary: true, compile_multilib: "first", cppflags: [ Loading @@ -173,7 +191,7 @@ cc_test { "-Wextra", ], srcs: [ "tests/aidl_struct_util_unit_tests.cpp", "tests/hidl_struct_util_unit_tests.cpp", "tests/main.cpp", "tests/mock_interface_tool.cpp", "tests/mock_wifi_feature_flags.cpp", Loading @@ -188,13 +206,19 @@ cc_test { static_libs: [ "libgmock", "libgtest", "android.hardware.wifi-V1-ndk", "android.hardware.wifi-service-lib", "android.hardware.wifi@1.0", "android.hardware.wifi@1.1", "android.hardware.wifi@1.2", "android.hardware.wifi@1.3", "android.hardware.wifi@1.4", "android.hardware.wifi@1.5", "android.hardware.wifi@1.6", "android.hardware.wifi@1.0-service-lib", ], shared_libs: [ "libbase", "libbinder_ndk", "libcutils", "libhidlbase", "liblog", "libnl", "libutils", Loading @@ -204,11 +228,11 @@ cc_test { } filegroup { name: "default-android.hardware.wifi-service.rc", srcs: ["android.hardware.wifi-service.rc"], name: "default-android.hardware.wifi@1.0-service.rc", srcs: ["android.hardware.wifi@1.0-service.rc"], } filegroup { name: "default-android.hardware.wifi-service.xml", srcs: ["android.hardware.wifi-service.xml"], name: "default-android.hardware.wifi@1.0-service.xml", srcs: ["android.hardware.wifi@1.0-service.xml"], } wifi/aidl/default/THREADING.README→wifi/1.6/default/THREADING.README +6 −6 Original line number Diff line number Diff line Vendor HAL Threading Model ========================== The vendor HAL service has two threads: 1. AIDL thread: This is the main thread which processes all the incoming AIDL 1. HIDL thread: This is the main thread which processes all the incoming HIDL RPC's. 2. Legacy HAL event loop thread: This is the thread forked off for processing the legacy HAL event loop (wifi_event_loop()). This thread is used to process Loading @@ -11,9 +11,9 @@ callbacks passed to the legacy HAL API's are invoked on this thread. Synchronization Concerns ======================== wifi_legacy_hal.cpp has a bunch of global "C" style functions to handle the legacy callbacks. Each of these "C" style functions invokes a corresponding legacy callbacks. Each of these "C" style function invokes a corresponding "std::function" version of the callback which does the actual processing. The variables holding these "std::function" callbacks are reset from the AIDL The variables holding these "std::function" callbacks are reset from the HIDL thread when they are no longer used. For example: stopGscan() will reset the corresponding "on_gscan_*" callback variables which were set when startGscan() was invoked. This is not thread safe since these callback variables are Loading @@ -24,12 +24,12 @@ Synchronization Solution Adding a global lock seems to be the most trivial solution to the problem. a) All of the asynchronous "C" style callbacks will acquire the global lock before invoking the corresponding "std::function" callback variables. b) All of the AIDL methods will also acquire the global lock before processing (in aidl_return_util::validateAndCall()). b) All of the HIDL methods will also acquire the global lock before processing (in hidl_return_util::validateAndCall()). Note: It's important that we only acquire the global lock for asynchronous callbacks, because there is no guarantee (or documentation to clarify) that the synchronous callbacks are invoked on the same invocation thread. If that is not the case in some implementation, we will end up deadlocking the system since the AIDL thread would have acquired the global lock which is needed by the HIDL thread would have acquired the global lock which is needed by the synchronous callback executed on the legacy hal event loop thread. wifi/aidl/default/android.hardware.wifi-service-lazy.rc→wifi/1.6/default/android.hardware.wifi@1.0-service-lazy.rc +14 −0 Original line number Diff line number Diff line service vendor.wifi_hal_legacy /vendor/bin/hw/android.hardware.wifi-service-lazy interface aidl android.hardware.wifi.IWifi/default service vendor.wifi_hal_legacy /vendor/bin/hw/android.hardware.wifi@1.0-service-lazy interface android.hardware.wifi@1.0::IWifi default interface android.hardware.wifi@1.1::IWifi default interface android.hardware.wifi@1.2::IWifi default interface android.hardware.wifi@1.3::IWifi default interface android.hardware.wifi@1.4::IWifi default interface android.hardware.wifi@1.5::IWifi default interface android.hardware.wifi@1.6::IWifi default oneshot disabled class hal Loading wifi/1.6/default/android.hardware.wifi@1.0-service.rc 0 → 100644 +12 −0 Original line number Diff line number Diff line service vendor.wifi_hal_legacy /vendor/bin/hw/android.hardware.wifi@1.0-service interface android.hardware.wifi@1.0::IWifi default interface android.hardware.wifi@1.1::IWifi default interface android.hardware.wifi@1.2::IWifi default interface android.hardware.wifi@1.3::IWifi default interface android.hardware.wifi@1.4::IWifi default interface android.hardware.wifi@1.5::IWifi default interface android.hardware.wifi@1.6::IWifi default class hal capabilities NET_ADMIN NET_RAW SYS_MODULE user wifi group wifi gps wifi/1.6/default/android.hardware.wifi@1.0-service.xml 0 → 100644 +11 −0 Original line number Diff line number Diff line <manifest version="1.0" type="device"> <hal format="hidl"> <name>android.hardware.wifi</name> <transport>hwbinder</transport> <version>1.6</version> <interface> <name>IWifi</name> <instance>default</instance> </interface> </hal> </manifest> Loading
wifi/aidl/default/Android.bp→wifi/1.6/default/Android.bp +54 −30 Original line number Diff line number Diff line // Copyright (C) 2022 The Android Open Source Project // Copyright (C) 2021 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. Loading Loading @@ -36,7 +36,7 @@ soong_config_module_type { } wifi_hal_cc_defaults { name: "android.hardware.wifi-service-cppflags-defaults", name: "android.hardware.wifi@1.0-service-cppflags-defaults", soong_config_variables: { hidl_feature_aware: { cppflags: ["-DWIFI_HIDL_FEATURE_AWARE"], Loading @@ -60,8 +60,8 @@ wifi_hal_cc_defaults { } cc_library_static { name: "android.hardware.wifi-service-lib", defaults: ["android.hardware.wifi-service-cppflags-defaults"], name: "android.hardware.wifi@1.0-service-lib", defaults: ["android.hardware.wifi@1.0-service-cppflags-defaults"], proprietary: true, compile_multilib: "first", cppflags: [ Loading @@ -72,8 +72,8 @@ cc_library_static { // Allow implicit fallthroughs in wifi_legacy_hal.cpp until they are fixed. cflags: ["-Wno-error=implicit-fallthrough"], srcs: [ "aidl_struct_util.cpp", "aidl_sync_util.cpp", "hidl_struct_util.cpp", "hidl_sync_util.cpp", "ringbuffer.cpp", "wifi.cpp", "wifi_ap_iface.cpp", Loading @@ -93,23 +93,29 @@ cc_library_static { shared_libs: [ "libbase", "libbinder_ndk", "libcutils", "libhidlbase", "liblog", "libnl", "libutils", "libwifi-hal", "libwifi-system-iface", "libxml2", "android.hardware.wifi-V1-ndk", "android.hardware.wifi@1.0", "android.hardware.wifi@1.1", "android.hardware.wifi@1.2", "android.hardware.wifi@1.3", "android.hardware.wifi@1.4", "android.hardware.wifi@1.5", "android.hardware.wifi@1.6", ], export_include_dirs: ["."], } cc_binary { name: "android.hardware.wifi-service", vintf_fragments: ["android.hardware.wifi-service.xml"], name: "android.hardware.wifi@1.0-service", vintf_fragments: ["android.hardware.wifi@1.0-service.xml"], relative_install_path: "hw", proprietary: true, cppflags: [ Loading @@ -120,24 +126,30 @@ cc_binary { srcs: ["service.cpp"], shared_libs: [ "libbase", "libbinder_ndk", "libcutils", "libhidlbase", "liblog", "libnl", "libutils", "libwifi-hal", "libwifi-system-iface", "libxml2", "android.hardware.wifi-V1-ndk", "android.hardware.wifi@1.0", "android.hardware.wifi@1.1", "android.hardware.wifi@1.2", "android.hardware.wifi@1.3", "android.hardware.wifi@1.4", "android.hardware.wifi@1.5", "android.hardware.wifi@1.6", ], static_libs: ["android.hardware.wifi-service-lib"], init_rc: ["android.hardware.wifi-service.rc"], static_libs: ["android.hardware.wifi@1.0-service-lib"], init_rc: ["android.hardware.wifi@1.0-service.rc"], } cc_binary { name: "android.hardware.wifi-service-lazy", vintf_fragments: ["android.hardware.wifi-service.xml"], overrides: ["android.hardware.wifi-service"], name: "android.hardware.wifi@1.0-service-lazy", vintf_fragments: ["android.hardware.wifi@1.0-service.xml"], overrides: ["android.hardware.wifi@1.0-service"], cflags: ["-DLAZY_SERVICE"], relative_install_path: "hw", proprietary: true, Loading @@ -149,22 +161,28 @@ cc_binary { srcs: ["service.cpp"], shared_libs: [ "libbase", "libbinder_ndk", "libcutils", "libhidlbase", "liblog", "libnl", "libutils", "libwifi-hal", "libwifi-system-iface", "libxml2", "android.hardware.wifi-V1-ndk", "android.hardware.wifi@1.0", "android.hardware.wifi@1.1", "android.hardware.wifi@1.2", "android.hardware.wifi@1.3", "android.hardware.wifi@1.4", "android.hardware.wifi@1.5", "android.hardware.wifi@1.6", ], static_libs: ["android.hardware.wifi-service-lib"], init_rc: ["android.hardware.wifi-service-lazy.rc"], static_libs: ["android.hardware.wifi@1.0-service-lib"], init_rc: ["android.hardware.wifi@1.0-service-lazy.rc"], } cc_test { name: "android.hardware.wifi-service-tests", name: "android.hardware.wifi@1.0-service-tests", proprietary: true, compile_multilib: "first", cppflags: [ Loading @@ -173,7 +191,7 @@ cc_test { "-Wextra", ], srcs: [ "tests/aidl_struct_util_unit_tests.cpp", "tests/hidl_struct_util_unit_tests.cpp", "tests/main.cpp", "tests/mock_interface_tool.cpp", "tests/mock_wifi_feature_flags.cpp", Loading @@ -188,13 +206,19 @@ cc_test { static_libs: [ "libgmock", "libgtest", "android.hardware.wifi-V1-ndk", "android.hardware.wifi-service-lib", "android.hardware.wifi@1.0", "android.hardware.wifi@1.1", "android.hardware.wifi@1.2", "android.hardware.wifi@1.3", "android.hardware.wifi@1.4", "android.hardware.wifi@1.5", "android.hardware.wifi@1.6", "android.hardware.wifi@1.0-service-lib", ], shared_libs: [ "libbase", "libbinder_ndk", "libcutils", "libhidlbase", "liblog", "libnl", "libutils", Loading @@ -204,11 +228,11 @@ cc_test { } filegroup { name: "default-android.hardware.wifi-service.rc", srcs: ["android.hardware.wifi-service.rc"], name: "default-android.hardware.wifi@1.0-service.rc", srcs: ["android.hardware.wifi@1.0-service.rc"], } filegroup { name: "default-android.hardware.wifi-service.xml", srcs: ["android.hardware.wifi-service.xml"], name: "default-android.hardware.wifi@1.0-service.xml", srcs: ["android.hardware.wifi@1.0-service.xml"], }
wifi/aidl/default/THREADING.README→wifi/1.6/default/THREADING.README +6 −6 Original line number Diff line number Diff line Vendor HAL Threading Model ========================== The vendor HAL service has two threads: 1. AIDL thread: This is the main thread which processes all the incoming AIDL 1. HIDL thread: This is the main thread which processes all the incoming HIDL RPC's. 2. Legacy HAL event loop thread: This is the thread forked off for processing the legacy HAL event loop (wifi_event_loop()). This thread is used to process Loading @@ -11,9 +11,9 @@ callbacks passed to the legacy HAL API's are invoked on this thread. Synchronization Concerns ======================== wifi_legacy_hal.cpp has a bunch of global "C" style functions to handle the legacy callbacks. Each of these "C" style functions invokes a corresponding legacy callbacks. Each of these "C" style function invokes a corresponding "std::function" version of the callback which does the actual processing. The variables holding these "std::function" callbacks are reset from the AIDL The variables holding these "std::function" callbacks are reset from the HIDL thread when they are no longer used. For example: stopGscan() will reset the corresponding "on_gscan_*" callback variables which were set when startGscan() was invoked. This is not thread safe since these callback variables are Loading @@ -24,12 +24,12 @@ Synchronization Solution Adding a global lock seems to be the most trivial solution to the problem. a) All of the asynchronous "C" style callbacks will acquire the global lock before invoking the corresponding "std::function" callback variables. b) All of the AIDL methods will also acquire the global lock before processing (in aidl_return_util::validateAndCall()). b) All of the HIDL methods will also acquire the global lock before processing (in hidl_return_util::validateAndCall()). Note: It's important that we only acquire the global lock for asynchronous callbacks, because there is no guarantee (or documentation to clarify) that the synchronous callbacks are invoked on the same invocation thread. If that is not the case in some implementation, we will end up deadlocking the system since the AIDL thread would have acquired the global lock which is needed by the HIDL thread would have acquired the global lock which is needed by the synchronous callback executed on the legacy hal event loop thread.
wifi/aidl/default/android.hardware.wifi-service-lazy.rc→wifi/1.6/default/android.hardware.wifi@1.0-service-lazy.rc +14 −0 Original line number Diff line number Diff line service vendor.wifi_hal_legacy /vendor/bin/hw/android.hardware.wifi-service-lazy interface aidl android.hardware.wifi.IWifi/default service vendor.wifi_hal_legacy /vendor/bin/hw/android.hardware.wifi@1.0-service-lazy interface android.hardware.wifi@1.0::IWifi default interface android.hardware.wifi@1.1::IWifi default interface android.hardware.wifi@1.2::IWifi default interface android.hardware.wifi@1.3::IWifi default interface android.hardware.wifi@1.4::IWifi default interface android.hardware.wifi@1.5::IWifi default interface android.hardware.wifi@1.6::IWifi default oneshot disabled class hal Loading
wifi/1.6/default/android.hardware.wifi@1.0-service.rc 0 → 100644 +12 −0 Original line number Diff line number Diff line service vendor.wifi_hal_legacy /vendor/bin/hw/android.hardware.wifi@1.0-service interface android.hardware.wifi@1.0::IWifi default interface android.hardware.wifi@1.1::IWifi default interface android.hardware.wifi@1.2::IWifi default interface android.hardware.wifi@1.3::IWifi default interface android.hardware.wifi@1.4::IWifi default interface android.hardware.wifi@1.5::IWifi default interface android.hardware.wifi@1.6::IWifi default class hal capabilities NET_ADMIN NET_RAW SYS_MODULE user wifi group wifi gps
wifi/1.6/default/android.hardware.wifi@1.0-service.xml 0 → 100644 +11 −0 Original line number Diff line number Diff line <manifest version="1.0" type="device"> <hal format="hidl"> <name>android.hardware.wifi</name> <transport>hwbinder</transport> <version>1.6</version> <interface> <name>IWifi</name> <instance>default</instance> </interface> </hal> </manifest>