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

Commit fce46f46 authored by Veerendranath Jakkam's avatar Veerendranath Jakkam Committed by Sunil Ravi
Browse files

wifi: Avoid doing iface reset when dynamic MAC update supported

Skip doing iface reset(down and up) to change MAC address if driver
indicates support for WIFI_FEATURE_DYNAMIC_SET_MAC.

Bug: 202424223
Test: atest VtsHalWifiV1_5TargetTest
Test: Manual - Connect STA to AP and check random mac is set
Change-Id: I86cf86e20893759a4e926571727943e4ee51d093
parent f763d677
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -56,14 +56,21 @@ std::array<uint8_t, 6> WifiIfaceUtil::getFactoryMacAddress(
bool WifiIfaceUtil::setMacAddress(const std::string& iface_name,
                                  const std::array<uint8_t, 6>& mac) {
#ifndef WIFI_AVOID_IFACE_RESET_MAC_CHANGE
    if (!iface_tool_.lock()->SetUpState(iface_name.c_str(), false)) {
    legacy_hal::wifi_error legacy_status;
    uint64_t legacy_feature_set;
    std::tie(legacy_status, legacy_feature_set) =
        legacy_hal_.lock()->getSupportedFeatureSet(iface_name);

    if (!(legacy_feature_set & WIFI_FEATURE_DYNAMIC_SET_MAC) &&
        !iface_tool_.lock()->SetUpState(iface_name.c_str(), false)) {
        LOG(ERROR) << "SetUpState(false) failed.";
        return false;
    }
#endif
    bool success = iface_tool_.lock()->SetMacAddress(iface_name.c_str(), mac);
#ifndef WIFI_AVOID_IFACE_RESET_MAC_CHANGE
    if (!iface_tool_.lock()->SetUpState(iface_name.c_str(), true)) {
    if (!(legacy_feature_set & WIFI_FEATURE_DYNAMIC_SET_MAC) &&
        !iface_tool_.lock()->SetUpState(iface_name.c_str(), true)) {
        LOG(ERROR) << "SetUpState(true) failed. Wait for driver ready.";
        // Wait for driver ready and try to set iface UP again
        if (legacy_hal_.lock()->waitForDriverReady() !=