summaryrefslogtreecommitdiff
path: root/wifi/aidl/default
diff options
context:
space:
mode:
Diffstat (limited to 'wifi/aidl/default')
-rw-r--r--wifi/aidl/default/Android.bp218
-rw-r--r--wifi/aidl/default/tests/README.md14
-rwxr-xr-xwifi/aidl/default/tests/runtests.sh3
-rw-r--r--wifi/aidl/default/tests/wifi_chip_unit_tests.cpp2
-rw-r--r--wifi/aidl/default/wifi.cpp2
-rw-r--r--wifi/aidl/default/wifi_chip.cpp43
-rw-r--r--wifi/aidl/default/wifi_chip.h8
7 files changed, 267 insertions, 23 deletions
diff --git a/wifi/aidl/default/Android.bp b/wifi/aidl/default/Android.bp
new file mode 100644
index 0000000000..91d609ddc7
--- /dev/null
+++ b/wifi/aidl/default/Android.bp
@@ -0,0 +1,218 @@
+// Copyright (C) 2022 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.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package {
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+soong_config_module_type {
+ name: "wifi_hal_cc_defaults",
+ module_type: "cc_defaults",
+ config_namespace: "wifi",
+ bool_variables: [
+ "hidl_feature_aware", // WIFI_HIDL_FEATURE_AWARE
+ "hidl_feature_dual_interface", // WIFI_HIDL_FEATURE_DUAL_INTERFACE
+ "hidl_feature_disable_ap", // WIFI_HIDL_FEATURE_DISABLE_AP
+ "hidl_feature_disable_ap_mac_randomization", // WIFI_HIDL_FEATURE_DISABLE_AP_MAC_RANDOMIZATION
+ "avoid_iface_reset_mac_change", // WIFI_AVOID_IFACE_RESET_MAC_CHANGE
+ "wifi_skip_state_toggle_off_on_for_nan", // WIFI_SKIP_STATE_TOGGLE_OFF_ON_FOR_NAN
+ ],
+ value_variables: [
+ "hal_interface_combinations", // WIFI_HAL_INTERFACE_COMBINATIONS
+ ],
+ properties: [
+ "cppflags",
+ ],
+}
+
+wifi_hal_cc_defaults {
+ name: "android.hardware.wifi-service-cppflags-defaults",
+ soong_config_variables: {
+ hidl_feature_aware: {
+ cppflags: ["-DWIFI_HIDL_FEATURE_AWARE"],
+ },
+ hidl_feature_dual_interface: {
+ cppflags: ["-DWIFI_HIDL_FEATURE_DUAL_INTERFACE"],
+ },
+ hidl_feature_disable_ap: {
+ cppflags: ["-DWIFI_HIDL_FEATURE_DISABLE_AP"],
+ },
+ hidl_feature_disable_ap_mac_randomization: {
+ cppflags: ["-DWIFI_HIDL_FEATURE_DISABLE_AP_MAC_RANDOMIZATION"],
+ },
+ avoid_iface_reset_mac_change: {
+ cppflags: ["-DWIFI_AVOID_IFACE_RESET_MAC_CHANGE"],
+ },
+ wifi_skip_state_toggle_off_on_for_nan: {
+ cppflags: ["-DWIFI_SKIP_STATE_TOGGLE_OFF_ON_FOR_NAN"],
+ },
+ hal_interface_combinations: {
+ cppflags: ["-DWIFI_HAL_INTERFACE_COMBINATIONS=%s"],
+ },
+ },
+}
+
+cc_library_static {
+ name: "android.hardware.wifi-service-lib",
+ defaults: ["android.hardware.wifi-service-cppflags-defaults"],
+ proprietary: true,
+ compile_multilib: "first",
+ cppflags: [
+ "-Wall",
+ "-Werror",
+ "-Wextra",
+ ],
+ // 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",
+ "ringbuffer.cpp",
+ "wifi.cpp",
+ "wifi_ap_iface.cpp",
+ "wifi_chip.cpp",
+ "wifi_feature_flags.cpp",
+ "wifi_iface_util.cpp",
+ "wifi_legacy_hal.cpp",
+ "wifi_legacy_hal_factory.cpp",
+ "wifi_legacy_hal_stubs.cpp",
+ "wifi_mode_controller.cpp",
+ "wifi_nan_iface.cpp",
+ "wifi_p2p_iface.cpp",
+ "wifi_rtt_controller.cpp",
+ "wifi_sta_iface.cpp",
+ "wifi_status_util.cpp",
+ ],
+
+ shared_libs: [
+ "libbase",
+ "libbinder_ndk",
+ "libcutils",
+ "liblog",
+ "libnl",
+ "libutils",
+ "libwifi-hal",
+ "libwifi-system-iface",
+ "libxml2",
+ "android.hardware.wifi-V1-ndk",
+ ],
+
+ export_include_dirs: ["."],
+}
+
+cc_binary {
+ name: "android.hardware.wifi-service",
+ vintf_fragments: ["android.hardware.wifi-service.xml"],
+ relative_install_path: "hw",
+ proprietary: true,
+ cppflags: [
+ "-Wall",
+ "-Werror",
+ "-Wextra",
+ ],
+ srcs: ["service.cpp"],
+ shared_libs: [
+ "libbase",
+ "libbinder_ndk",
+ "libcutils",
+ "liblog",
+ "libnl",
+ "libutils",
+ "libwifi-hal",
+ "libwifi-system-iface",
+ "libxml2",
+ "android.hardware.wifi-V1-ndk",
+ ],
+ static_libs: ["android.hardware.wifi-service-lib"],
+ init_rc: ["android.hardware.wifi-service.rc"],
+}
+
+cc_binary {
+ name: "android.hardware.wifi-service-lazy",
+ vintf_fragments: ["android.hardware.wifi-service.xml"],
+ overrides: ["android.hardware.wifi-service"],
+ cflags: ["-DLAZY_SERVICE"],
+ relative_install_path: "hw",
+ proprietary: true,
+ cppflags: [
+ "-Wall",
+ "-Werror",
+ "-Wextra",
+ ],
+ srcs: ["service.cpp"],
+ shared_libs: [
+ "libbase",
+ "libbinder_ndk",
+ "libcutils",
+ "liblog",
+ "libnl",
+ "libutils",
+ "libwifi-hal",
+ "libwifi-system-iface",
+ "libxml2",
+ "android.hardware.wifi-V1-ndk",
+ ],
+ static_libs: ["android.hardware.wifi-service-lib"],
+ init_rc: ["android.hardware.wifi-service-lazy.rc"],
+}
+
+cc_test {
+ name: "android.hardware.wifi-service-tests",
+ proprietary: true,
+ compile_multilib: "first",
+ cppflags: [
+ "-Wall",
+ "-Werror",
+ "-Wextra",
+ ],
+ srcs: [
+ "tests/aidl_struct_util_unit_tests.cpp",
+ "tests/main.cpp",
+ "tests/mock_interface_tool.cpp",
+ "tests/mock_wifi_feature_flags.cpp",
+ "tests/mock_wifi_iface_util.cpp",
+ "tests/mock_wifi_legacy_hal.cpp",
+ "tests/mock_wifi_mode_controller.cpp",
+ "tests/ringbuffer_unit_tests.cpp",
+ "tests/wifi_nan_iface_unit_tests.cpp",
+ "tests/wifi_chip_unit_tests.cpp",
+ "tests/wifi_iface_util_unit_tests.cpp",
+ ],
+ static_libs: [
+ "libgmock",
+ "libgtest",
+ "android.hardware.wifi-V1-ndk",
+ "android.hardware.wifi-service-lib",
+ ],
+ shared_libs: [
+ "libbase",
+ "libbinder_ndk",
+ "libcutils",
+ "liblog",
+ "libnl",
+ "libutils",
+ "libwifi-hal",
+ "libwifi-system-iface",
+ ],
+}
+
+filegroup {
+ name: "default-android.hardware.wifi-service.rc",
+ srcs: ["android.hardware.wifi-service.rc"],
+}
+
+filegroup {
+ name: "default-android.hardware.wifi-service.xml",
+ srcs: ["android.hardware.wifi-service.xml"],
+}
diff --git a/wifi/aidl/default/tests/README.md b/wifi/aidl/default/tests/README.md
new file mode 100644
index 0000000000..fc0a98ad92
--- /dev/null
+++ b/wifi/aidl/default/tests/README.md
@@ -0,0 +1,14 @@
+# Vendor HAL gTest Suite
+
+## Overview
+Rather than testing an active instance of the service like the VTS tests,
+this test suite will test individual files from the Vendor HAL.
+This is especially useful for testing conversion methods (see `aidl_struct_util_unit_tests.cpp`),
+but can also be used to test things like `wifi_chip`.
+
+## Usage
+Run the test script with a device connected:
+
+```
+./runtests.sh
+```
diff --git a/wifi/aidl/default/tests/runtests.sh b/wifi/aidl/default/tests/runtests.sh
index 1f53ab8e05..228c82b950 100755
--- a/wifi/aidl/default/tests/runtests.sh
+++ b/wifi/aidl/default/tests/runtests.sh
@@ -20,7 +20,8 @@ if [ -z $ANDROID_BUILD_TOP ]; then
fi
set -e
-$ANDROID_BUILD_TOP/build/soong/soong_ui.bash --make-mode android.hardware.wifi-service-tests
adb root
+adb wait-for-device
+$ANDROID_BUILD_TOP/build/soong/soong_ui.bash --make-mode android.hardware.wifi-service-tests
adb sync data
adb shell /data/nativetest64/vendor/android.hardware.wifi-service-tests/android.hardware.wifi-service-tests
diff --git a/wifi/aidl/default/tests/wifi_chip_unit_tests.cpp b/wifi/aidl/default/tests/wifi_chip_unit_tests.cpp
index e66b650ded..f9afb4b462 100644
--- a/wifi/aidl/default/tests/wifi_chip_unit_tests.cpp
+++ b/wifi/aidl/default/tests/wifi_chip_unit_tests.cpp
@@ -282,7 +282,7 @@ class WifiChipTest : public Test {
public:
void SetUp() override {
chip_ = WifiChip::create(chip_id_, true, legacy_hal_, mode_controller_, iface_util_,
- feature_flags_, subsystemRestartHandler);
+ feature_flags_, subsystemRestartHandler, true);
EXPECT_CALL(*mode_controller_, changeFirmwareMode(testing::_))
.WillRepeatedly(testing::Return(true));
diff --git a/wifi/aidl/default/wifi.cpp b/wifi/aidl/default/wifi.cpp
index d6a85da198..34a7f35d4d 100644
--- a/wifi/aidl/default/wifi.cpp
+++ b/wifi/aidl/default/wifi.cpp
@@ -133,7 +133,7 @@ ndk::ScopedAStatus Wifi::startInternal() {
chips_.push_back(
WifiChip::create(chipId, chipId == kPrimaryChipId, hal, mode_controller_,
std::make_shared<iface_util::WifiIfaceUtil>(iface_tool_, hal),
- feature_flags_, on_subsystem_restart_callback));
+ feature_flags_, on_subsystem_restart_callback, false));
chipId++;
}
run_state_ = RunState::STARTED;
diff --git a/wifi/aidl/default/wifi_chip.cpp b/wifi/aidl/default/wifi_chip.cpp
index f9f55285df..6dd9156414 100644
--- a/wifi/aidl/default/wifi_chip.cpp
+++ b/wifi/aidl/default/wifi_chip.cpp
@@ -366,7 +366,8 @@ WifiChip::WifiChip(int32_t chip_id, bool is_primary,
const std::weak_ptr<mode_controller::WifiModeController> mode_controller,
const std::shared_ptr<iface_util::WifiIfaceUtil> iface_util,
const std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags,
- const std::function<void(const std::string&)>& handler)
+ const std::function<void(const std::string&)>& handler,
+ bool using_dynamic_iface_combination)
: chip_id_(chip_id),
legacy_hal_(legacy_hal),
mode_controller_(mode_controller),
@@ -375,9 +376,9 @@ WifiChip::WifiChip(int32_t chip_id, bool is_primary,
current_mode_id_(feature_flags::chip_mode_ids::kInvalid),
modes_(feature_flags.lock()->getChipModes(is_primary)),
debug_ring_buffer_cb_registered_(false),
+ using_dynamic_iface_combination_(using_dynamic_iface_combination),
subsystemCallbackHandler_(handler) {
setActiveWlanIfaceNameProperty(kNoActiveWlanIfaceNamePropertyValue);
- using_dynamic_iface_combination_ = false;
}
void WifiChip::retrieveDynamicIfaceCombination() {
@@ -413,9 +414,11 @@ std::shared_ptr<WifiChip> WifiChip::create(
const std::weak_ptr<mode_controller::WifiModeController> mode_controller,
const std::shared_ptr<iface_util::WifiIfaceUtil> iface_util,
const std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags,
- const std::function<void(const std::string&)>& handler) {
+ const std::function<void(const std::string&)>& handler,
+ bool using_dynamic_iface_combination) {
std::shared_ptr<WifiChip> ptr = ndk::SharedRefBase::make<WifiChip>(
- chip_id, is_primary, legacy_hal, mode_controller, iface_util, feature_flags, handler);
+ chip_id, is_primary, legacy_hal, mode_controller, iface_util, feature_flags, handler,
+ using_dynamic_iface_combination);
std::weak_ptr<WifiChip> weak_ptr_this(ptr);
ptr->setWeakPtr(weak_ptr_this);
return ptr;
@@ -975,14 +978,14 @@ WifiChip::createBridgedApIfaceInternal() {
br_ifaces_ap_instances_[br_ifname] = ap_instances;
if (!iface_util_->createBridge(br_ifname)) {
LOG(ERROR) << "Failed createBridge - br_name=" << br_ifname.c_str();
- invalidateAndClearBridgedAp(br_ifname);
+ deleteApIface(br_ifname);
return {nullptr, createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE)};
}
for (auto const& instance : ap_instances) {
// Bind ap instance interface to AP bridge
if (!iface_util_->addIfaceToBridge(br_ifname, instance)) {
LOG(ERROR) << "Failed add if to Bridge - if_name=" << instance.c_str();
- invalidateAndClearBridgedAp(br_ifname);
+ deleteApIface(br_ifname);
return {nullptr, createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE)};
}
}
@@ -1016,8 +1019,7 @@ ndk::ScopedAStatus WifiChip::removeApIfaceInternal(const std::string& ifname) {
// nan/rtt objects over AP iface. But, there is no harm to do it
// here and not make that assumption all over the place.
invalidateAndRemoveDependencies(ifname);
- // Clear the bridge interface and the iface instance.
- invalidateAndClearBridgedAp(ifname);
+ deleteApIface(ifname);
invalidateAndClear(ap_ifaces_, iface);
for (const auto& callback : event_cb_handler_.getCallbacks()) {
if (!callback->onIfaceRemoved(IfaceType::AP, ifname).isOk()) {
@@ -1960,21 +1962,28 @@ void WifiChip::invalidateAndClearBridgedApAll() {
br_ifaces_ap_instances_.clear();
}
-void WifiChip::invalidateAndClearBridgedAp(const std::string& br_name) {
- if (br_name.empty()) return;
- // delete managed interfaces
+void WifiChip::deleteApIface(const std::string& if_name) {
+ if (if_name.empty()) return;
+ // delete bridged interfaces if any
for (auto const& it : br_ifaces_ap_instances_) {
- if (it.first == br_name) {
+ if (it.first == if_name) {
for (auto const& iface : it.second) {
- iface_util_->removeIfaceFromBridge(br_name, iface);
+ iface_util_->removeIfaceFromBridge(if_name, iface);
legacy_hal_.lock()->deleteVirtualInterface(iface);
}
- iface_util_->deleteBridge(br_name);
- br_ifaces_ap_instances_.erase(br_name);
- break;
+ iface_util_->deleteBridge(if_name);
+ br_ifaces_ap_instances_.erase(if_name);
+ // ifname is bridged AP, return here.
+ return;
}
}
- return;
+
+ // No bridged AP case, delete AP iface
+ legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->deleteVirtualInterface(if_name);
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ LOG(ERROR) << "Failed to remove interface: " << if_name << " "
+ << legacyErrorToString(legacy_status);
+ }
}
bool WifiChip::findUsingNameFromBridgedApInstances(const std::string& name) {
diff --git a/wifi/aidl/default/wifi_chip.h b/wifi/aidl/default/wifi_chip.h
index 4ddee92867..1a360320c9 100644
--- a/wifi/aidl/default/wifi_chip.h
+++ b/wifi/aidl/default/wifi_chip.h
@@ -53,7 +53,8 @@ class WifiChip : public BnWifiChip {
const std::weak_ptr<mode_controller::WifiModeController> mode_controller,
const std::shared_ptr<iface_util::WifiIfaceUtil> iface_util,
const std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags,
- const std::function<void(const std::string&)>& subsystemCallbackHandler);
+ const std::function<void(const std::string&)>& subsystemCallbackHandler,
+ bool using_dynamic_iface_combination);
// Factory method - use instead of default constructor.
static std::shared_ptr<WifiChip> create(
@@ -62,7 +63,8 @@ class WifiChip : public BnWifiChip {
const std::weak_ptr<mode_controller::WifiModeController> mode_controller,
const std::shared_ptr<iface_util::WifiIfaceUtil> iface_util,
const std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags,
- const std::function<void(const std::string&)>& subsystemCallbackHandler);
+ const std::function<void(const std::string&)>& subsystemCallbackHandler,
+ bool using_dynamic_iface_combination);
// AIDL does not provide a built-in mechanism to let the server invalidate
// an AIDL interface object after creation. If any client process holds onto
@@ -253,7 +255,7 @@ class WifiChip : public BnWifiChip {
bool writeRingbufferFilesInternal();
std::string getWlanIfaceNameWithType(IfaceType type, unsigned idx);
void invalidateAndClearBridgedApAll();
- void invalidateAndClearBridgedAp(const std::string& br_name);
+ void deleteApIface(const std::string& if_name);
bool findUsingNameFromBridgedApInstances(const std::string& name);
ndk::ScopedAStatus triggerSubsystemRestartInternal();
std::pair<std::vector<WifiRadioCombination>, ndk::ScopedAStatus>