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

Commit 99378445 authored by Nate Jiang's avatar Nate Jiang Committed by Automerger Merge Worker
Browse files

Merge "Fix NAN validate interface existence" into rvc-dev am: 8fce7985 am: 9f1854e2

Change-Id: Ifaf2424b7f0ab61ca5f363f202c813153f1200a2
parents babbcc86 9f1854e2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ class MockWifiIfaceUtil : public WifiIfaceUtil {
                 void(const std::string&, IfaceEventHandlers));
    MOCK_METHOD1(unregisterIfaceEventHandlers, void(const std::string&));
    MOCK_METHOD2(setUpState, bool(const std::string&, bool));
    MOCK_METHOD1(ifNameToIndex, unsigned(const std::string&));
};
}  // namespace iface_util
}  // namespace implementation
+2 −0
Original line number Diff line number Diff line
@@ -787,6 +787,8 @@ TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateNanWithDedicatedNanIface) {
    property_set("wifi.aware.interface", "aware0");
    findModeAndConfigureForIfaceType(IfaceType::STA);
    ASSERT_EQ(createIface(IfaceType::STA), "wlan0");
    EXPECT_CALL(*iface_util_, ifNameToIndex("aware0"))
        .WillOnce(testing::Return(4));
    EXPECT_CALL(*iface_util_, setUpState("aware0", true))
        .WillOnce(testing::Return(true));
    ASSERT_EQ(createIface(IfaceType::NAN), "aware0");
+1 −2
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@
#include <android-base/logging.h>
#include <android-base/unique_fd.h>
#include <cutils/properties.h>
#include <net/if.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>

@@ -886,7 +885,7 @@ std::pair<WifiStatus, sp<IWifiNanIface>> WifiChip::createNanIfaceInternal() {
    }
    bool is_dedicated_iface = true;
    std::string ifname = getNanIfaceName();
    if (ifname.empty() || if_nametoindex(ifname.c_str())) {
    if (ifname.empty() || !iface_util_.lock()->ifNameToIndex(ifname)) {
        // Use the first shared STA iface (wlan0) if a dedicated aware iface is
        // not defined.
        ifname = getFirstActiveWlanIfaceName();
+5 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
 * limitations under the License.
 */

#include <net/if.h>
#include <cstddef>
#include <iostream>
#include <limits>
@@ -122,6 +123,10 @@ bool WifiIfaceUtil::setUpState(const std::string& iface_name, bool request_up) {
    }
    return true;
}

unsigned WifiIfaceUtil::ifNameToIndex(const std::string& iface_name) {
    return if_nametoindex(iface_name.c_str());
}
}  // namespace iface_util
}  // namespace implementation
}  // namespace V1_4
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ class WifiIfaceUtil {
                                            IfaceEventHandlers handlers);
    virtual void unregisterIfaceEventHandlers(const std::string& iface_name);
    virtual bool setUpState(const std::string& iface_name, bool request_up);
    virtual unsigned ifNameToIndex(const std::string& iface_name);

   private:
    std::array<uint8_t, 6> createRandomMacAddress();