Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ba0a90c authored by Roshan Pius's avatar Roshan Pius
Browse files

Use additional interface for the WiFi Aware Discovery operations.

NAN operations are currently done on the STA interface.This resulted
in the NAN sessions getting terminated in all the instances where the
STA interface is restarted (IFF DOWN/UP), due to connected MAC
randomization.
Hence, remove the dependency of NAN over STA interface. This change
expects the driver to create a dedicated interface for the
NAN operations. The iface name needs to be set in "wifi.aware.interface"
property.

Bug: 1636219
Test: HAL unit tests
Test: Device boots up and connects to wifi network.
Change-Id: I1b6d64eb94334172a8cd621d0b15ed8c8dc87f91
parent 432974a6
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -156,6 +156,11 @@ LOCAL_SRC_FILES := \
LOCAL_STATIC_LIBRARIES := \
    libgmock \
    libgtest \
    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.0-service-lib
LOCAL_SHARED_LIBRARIES := \
    libbase \
@@ -165,10 +170,5 @@ LOCAL_SHARED_LIBRARIES := \
    libnl \
    libutils \
    libwifi-hal \
    libwifi-system-iface \
    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
    libwifi-system-iface
include $(BUILD_NATIVE_TEST)
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ class MockWifiIfaceUtil : public WifiIfaceUtil {
    MOCK_METHOD2(registerIfaceEventHandlers,
                 void(const std::string&, IfaceEventHandlers));
    MOCK_METHOD1(unregisterIfaceEventHandlers, void(const std::string&));
    MOCK_METHOD2(setUpState, bool(const std::string&, bool));
};
}  // namespace iface_util
}  // namespace implementation
+4 −0
Original line number Diff line number Diff line
@@ -57,6 +57,10 @@ class MockWifiLegacyHal : public WifiLegacyHal {
    MOCK_METHOD3(nanDataInterfaceDelete,
                 wifi_error(const std::string&, transaction_id,
                            const std::string&));
    MOCK_METHOD2(createVirtualInterface,
                 wifi_error(const std::string& ifname,
                            wifi_interface_type iftype));
    MOCK_METHOD1(deleteVirtualInterface, wifi_error(const std::string& ifname));
};
}  // namespace legacy_hal
}  // namespace implementation
+23 −0
Original line number Diff line number Diff line
@@ -292,6 +292,7 @@ class WifiChipTest : public Test {
        // mock).
        property_set("wifi.interface", "wlan0");
        property_set("wifi.concurrent.interface", "wlan1");
        property_set("wifi.aware.interface", nullptr);
    }
};

@@ -773,6 +774,28 @@ TEST_F(WifiChipV2_AwareIfaceCombinationTest,
        });
}

TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateNanWithSharedNanIface) {
    property_set("wifi.aware.interface", nullptr);
    findModeAndConfigureForIfaceType(IfaceType::STA);
    ASSERT_EQ(createIface(IfaceType::STA), "wlan0");
    ASSERT_EQ(createIface(IfaceType::NAN), "wlan0");
    removeIface(IfaceType::NAN, "wlan0");
    EXPECT_CALL(*iface_util_, setUpState(testing::_, testing::_)).Times(0);
}

TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateNanWithDedicatedNanIface) {
    property_set("wifi.aware.interface", "aware0");
    findModeAndConfigureForIfaceType(IfaceType::STA);
    ASSERT_EQ(createIface(IfaceType::STA), "wlan0");
    EXPECT_CALL(*iface_util_, setUpState("aware0", true))
        .WillOnce(testing::Return(true));
    ASSERT_EQ(createIface(IfaceType::NAN), "aware0");

    EXPECT_CALL(*iface_util_, setUpState("aware0", false))
        .WillOnce(testing::Return(true));
    removeIface(IfaceType::NAN, "aware0");
}

////////// V1 Iface Combinations when AP creation is disabled //////////
class WifiChipV1_AwareDisabledApIfaceCombinationTest : public WifiChipTest {
   public:
+1 −1
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ TEST_F(WifiNanIfaceTest, IfacEventHandlers_OnStateToggleOffOn) {
            bind(CaptureIfaceEventHandlers, std::placeholders::_1,
                 std::placeholders::_2, &captured_iface_event_handlers)));
    sp<WifiNanIface> nan_iface =
        new WifiNanIface(kIfaceName, legacy_hal_, iface_util_);
        new WifiNanIface(kIfaceName, false, legacy_hal_, iface_util_);

    // Register a mock nan event callback.
    sp<NiceMock<MockNanIfaceEventCallback>> mock_event_callback{
Loading