Loading wifi/1.4/default/Android.mk +0 −1 Original line number Diff line number Diff line Loading @@ -150,7 +150,6 @@ LOCAL_SRC_FILES := \ tests/mock_wifi_legacy_hal.cpp \ tests/mock_wifi_mode_controller.cpp \ tests/ringbuffer_unit_tests.cpp \ tests/wifi_ap_iface_unit_tests.cpp \ tests/wifi_nan_iface_unit_tests.cpp \ tests/wifi_chip_unit_tests.cpp \ tests/wifi_iface_util_unit_tests.cpp Loading wifi/1.4/default/tests/wifi_ap_iface_unit_tests.cppdeleted 100644 → 0 +0 −79 Original line number Diff line number Diff line /* * Copyright (C) 2019, 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. */ #include <android-base/logging.h> #include <android-base/macros.h> #include <cutils/properties.h> #include <gmock/gmock.h> #undef NAN // This is weird, NAN is defined in bionic/libc/include/math.h:38 #include "wifi_ap_iface.h" #include "mock_interface_tool.h" #include "mock_wifi_feature_flags.h" #include "mock_wifi_iface_util.h" #include "mock_wifi_legacy_hal.h" using testing::NiceMock; using testing::Return; using testing::Test; namespace { constexpr char kIfaceName[] = "mockWlan0"; } // namespace namespace android { namespace hardware { namespace wifi { namespace V1_4 { namespace implementation { class WifiApIfaceTest : public Test { protected: std::shared_ptr<NiceMock<wifi_system::MockInterfaceTool>> iface_tool_{ new NiceMock<wifi_system::MockInterfaceTool>}; std::shared_ptr<NiceMock<legacy_hal::MockWifiLegacyHal>> legacy_hal_{ new NiceMock<legacy_hal::MockWifiLegacyHal>(iface_tool_)}; std::shared_ptr<NiceMock<iface_util::MockWifiIfaceUtil>> iface_util_{ new NiceMock<iface_util::MockWifiIfaceUtil>(iface_tool_)}; std::shared_ptr<NiceMock<feature_flags::MockWifiFeatureFlags>> feature_flags_{new NiceMock<feature_flags::MockWifiFeatureFlags>}; }; TEST_F(WifiApIfaceTest, SetRandomMacAddressIfFeatureEnabled) { EXPECT_CALL(*feature_flags_, isApMacRandomizationDisabled()) .WillOnce(testing::Return(false)); EXPECT_CALL(*iface_util_, getOrCreateRandomMacAddress()) .WillOnce(testing::Return(std::array<uint8_t, 6>{0, 0, 0, 0, 0, 0})); EXPECT_CALL(*iface_util_, setMacAddress(testing::_, testing::_)) .WillOnce(testing::Return(true)); sp<WifiApIface> ap_iface = new WifiApIface(kIfaceName, legacy_hal_, iface_util_, feature_flags_); } TEST_F(WifiApIfaceTest, DontSetRandomMacAddressIfFeatureDisabled) { EXPECT_CALL(*feature_flags_, isApMacRandomizationDisabled()) .WillOnce(testing::Return(true)); EXPECT_CALL(*iface_util_, getOrCreateRandomMacAddress()).Times(0); EXPECT_CALL(*iface_util_, setMacAddress(testing::_, testing::_)).Times(0); sp<WifiApIface> ap_iface = new WifiApIface(kIfaceName, legacy_hal_, iface_util_, feature_flags_); } } // namespace implementation } // namespace V1_4 } // namespace wifi } // namespace hardware } // namespace android wifi/1.4/default/wifi_ap_iface.cpp +2 −17 Original line number Diff line number Diff line Loading @@ -31,26 +31,11 @@ using hidl_return_util::validateAndCall; WifiApIface::WifiApIface( const std::string& ifname, const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal, const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util, const std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags) const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util) : ifname_(ifname), legacy_hal_(legacy_hal), iface_util_(iface_util), feature_flags_(feature_flags), is_valid_(true) { if (feature_flags_.lock()->isApMacRandomizationDisabled()) { LOG(INFO) << "AP MAC randomization disabled"; return; } LOG(INFO) << "AP MAC randomization enabled"; // Set random MAC address std::array<uint8_t, 6> randomized_mac = iface_util_.lock()->getOrCreateRandomMacAddress(); bool status = iface_util_.lock()->setMacAddress(ifname_, randomized_mac); if (!status) { LOG(ERROR) << "Failed to set random mac address"; } } is_valid_(true) {} void WifiApIface::invalidate() { legacy_hal_.reset(); Loading wifi/1.4/default/wifi_ap_iface.h +3 −7 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ #include <android-base/macros.h> #include <android/hardware/wifi/1.4/IWifiApIface.h> #include "wifi_feature_flags.h" #include "wifi_iface_util.h" #include "wifi_legacy_hal.h" Loading @@ -36,11 +35,9 @@ using namespace android::hardware::wifi::V1_0; */ class WifiApIface : public V1_4::IWifiApIface { public: WifiApIface( const std::string& ifname, WifiApIface(const std::string& ifname, const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal, const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util, const std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags); const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util); // Refer to |WifiChip::invalidate()|. void invalidate(); bool isValid(); Loading Loading @@ -72,7 +69,6 @@ class WifiApIface : public V1_4::IWifiApIface { std::string ifname_; std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_; std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags_; bool is_valid_; DISALLOW_COPY_AND_ASSIGN(WifiApIface); Loading wifi/1.4/default/wifi_chip.cpp +1 −3 Original line number Diff line number Diff line Loading @@ -321,7 +321,6 @@ WifiChip::WifiChip( legacy_hal_(legacy_hal), mode_controller_(mode_controller), iface_util_(iface_util), feature_flags_(feature_flags), is_valid_(true), current_mode_id_(feature_flags::chip_mode_ids::kInvalid), modes_(feature_flags.lock()->getChipModes()), Loading Loading @@ -806,8 +805,7 @@ std::pair<WifiStatus, sp<IWifiApIface>> WifiChip::createApIfaceInternal() { return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}}; } std::string ifname = allocateApIfaceName(); sp<WifiApIface> iface = new WifiApIface(ifname, legacy_hal_, iface_util_, feature_flags_); sp<WifiApIface> iface = new WifiApIface(ifname, legacy_hal_, iface_util_); ap_ifaces_.push_back(iface); for (const auto& callback : event_cb_handler_.getCallbacks()) { if (!callback->onIfaceAdded(IfaceType::AP, ifname).isOk()) { Loading Loading
wifi/1.4/default/Android.mk +0 −1 Original line number Diff line number Diff line Loading @@ -150,7 +150,6 @@ LOCAL_SRC_FILES := \ tests/mock_wifi_legacy_hal.cpp \ tests/mock_wifi_mode_controller.cpp \ tests/ringbuffer_unit_tests.cpp \ tests/wifi_ap_iface_unit_tests.cpp \ tests/wifi_nan_iface_unit_tests.cpp \ tests/wifi_chip_unit_tests.cpp \ tests/wifi_iface_util_unit_tests.cpp Loading
wifi/1.4/default/tests/wifi_ap_iface_unit_tests.cppdeleted 100644 → 0 +0 −79 Original line number Diff line number Diff line /* * Copyright (C) 2019, 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. */ #include <android-base/logging.h> #include <android-base/macros.h> #include <cutils/properties.h> #include <gmock/gmock.h> #undef NAN // This is weird, NAN is defined in bionic/libc/include/math.h:38 #include "wifi_ap_iface.h" #include "mock_interface_tool.h" #include "mock_wifi_feature_flags.h" #include "mock_wifi_iface_util.h" #include "mock_wifi_legacy_hal.h" using testing::NiceMock; using testing::Return; using testing::Test; namespace { constexpr char kIfaceName[] = "mockWlan0"; } // namespace namespace android { namespace hardware { namespace wifi { namespace V1_4 { namespace implementation { class WifiApIfaceTest : public Test { protected: std::shared_ptr<NiceMock<wifi_system::MockInterfaceTool>> iface_tool_{ new NiceMock<wifi_system::MockInterfaceTool>}; std::shared_ptr<NiceMock<legacy_hal::MockWifiLegacyHal>> legacy_hal_{ new NiceMock<legacy_hal::MockWifiLegacyHal>(iface_tool_)}; std::shared_ptr<NiceMock<iface_util::MockWifiIfaceUtil>> iface_util_{ new NiceMock<iface_util::MockWifiIfaceUtil>(iface_tool_)}; std::shared_ptr<NiceMock<feature_flags::MockWifiFeatureFlags>> feature_flags_{new NiceMock<feature_flags::MockWifiFeatureFlags>}; }; TEST_F(WifiApIfaceTest, SetRandomMacAddressIfFeatureEnabled) { EXPECT_CALL(*feature_flags_, isApMacRandomizationDisabled()) .WillOnce(testing::Return(false)); EXPECT_CALL(*iface_util_, getOrCreateRandomMacAddress()) .WillOnce(testing::Return(std::array<uint8_t, 6>{0, 0, 0, 0, 0, 0})); EXPECT_CALL(*iface_util_, setMacAddress(testing::_, testing::_)) .WillOnce(testing::Return(true)); sp<WifiApIface> ap_iface = new WifiApIface(kIfaceName, legacy_hal_, iface_util_, feature_flags_); } TEST_F(WifiApIfaceTest, DontSetRandomMacAddressIfFeatureDisabled) { EXPECT_CALL(*feature_flags_, isApMacRandomizationDisabled()) .WillOnce(testing::Return(true)); EXPECT_CALL(*iface_util_, getOrCreateRandomMacAddress()).Times(0); EXPECT_CALL(*iface_util_, setMacAddress(testing::_, testing::_)).Times(0); sp<WifiApIface> ap_iface = new WifiApIface(kIfaceName, legacy_hal_, iface_util_, feature_flags_); } } // namespace implementation } // namespace V1_4 } // namespace wifi } // namespace hardware } // namespace android
wifi/1.4/default/wifi_ap_iface.cpp +2 −17 Original line number Diff line number Diff line Loading @@ -31,26 +31,11 @@ using hidl_return_util::validateAndCall; WifiApIface::WifiApIface( const std::string& ifname, const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal, const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util, const std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags) const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util) : ifname_(ifname), legacy_hal_(legacy_hal), iface_util_(iface_util), feature_flags_(feature_flags), is_valid_(true) { if (feature_flags_.lock()->isApMacRandomizationDisabled()) { LOG(INFO) << "AP MAC randomization disabled"; return; } LOG(INFO) << "AP MAC randomization enabled"; // Set random MAC address std::array<uint8_t, 6> randomized_mac = iface_util_.lock()->getOrCreateRandomMacAddress(); bool status = iface_util_.lock()->setMacAddress(ifname_, randomized_mac); if (!status) { LOG(ERROR) << "Failed to set random mac address"; } } is_valid_(true) {} void WifiApIface::invalidate() { legacy_hal_.reset(); Loading
wifi/1.4/default/wifi_ap_iface.h +3 −7 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ #include <android-base/macros.h> #include <android/hardware/wifi/1.4/IWifiApIface.h> #include "wifi_feature_flags.h" #include "wifi_iface_util.h" #include "wifi_legacy_hal.h" Loading @@ -36,11 +35,9 @@ using namespace android::hardware::wifi::V1_0; */ class WifiApIface : public V1_4::IWifiApIface { public: WifiApIface( const std::string& ifname, WifiApIface(const std::string& ifname, const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal, const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util, const std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags); const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util); // Refer to |WifiChip::invalidate()|. void invalidate(); bool isValid(); Loading Loading @@ -72,7 +69,6 @@ class WifiApIface : public V1_4::IWifiApIface { std::string ifname_; std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_; std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags_; bool is_valid_; DISALLOW_COPY_AND_ASSIGN(WifiApIface); Loading
wifi/1.4/default/wifi_chip.cpp +1 −3 Original line number Diff line number Diff line Loading @@ -321,7 +321,6 @@ WifiChip::WifiChip( legacy_hal_(legacy_hal), mode_controller_(mode_controller), iface_util_(iface_util), feature_flags_(feature_flags), is_valid_(true), current_mode_id_(feature_flags::chip_mode_ids::kInvalid), modes_(feature_flags.lock()->getChipModes()), Loading Loading @@ -806,8 +805,7 @@ std::pair<WifiStatus, sp<IWifiApIface>> WifiChip::createApIfaceInternal() { return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}}; } std::string ifname = allocateApIfaceName(); sp<WifiApIface> iface = new WifiApIface(ifname, legacy_hal_, iface_util_, feature_flags_); sp<WifiApIface> iface = new WifiApIface(ifname, legacy_hal_, iface_util_); ap_ifaces_.push_back(iface); for (const auto& callback : event_cb_handler_.getCallbacks()) { if (!callback->onIfaceAdded(IfaceType::AP, ifname).isOk()) { Loading