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

Commit e8987208 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "fixCoexRestrictions"

* changes:
  Add VTS test for IWifiChip::setCoexUnsafeChannels
  [WifiCoex] Add enum for wifi coex restrictions
parents 65020a8e 26cd1567
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.hardware.wifi@1.5;

import @1.0::WifiStatus;
import @1.0::IfaceType;
import @1.5::IWifiApIface;
import @1.0::IWifiIface;
import @1.3::IWifiChip;
@@ -187,6 +186,12 @@ interface IWifiChip extends @1.4::IWifiChip {
        NO_POWER_CAP = 0x7FFFFFFF,
    };

    enum CoexRestriction : uint32_t {
        WIFI_DIRECT = 1 << 0,
        SOFTAP = 1 << 1,
        WIFI_AWARE = 1 << 2
    };

    /**
     * Invoked to indicate that the provided |CoexUnsafeChannels| should be avoided with the
     * specified restrictions.
@@ -194,13 +199,14 @@ interface IWifiChip extends @1.4::IWifiChip {
     * Channel avoidance is a suggestion and should be done on a best-effort approach. If a provided
     * channel is used, then the specified power cap should be applied.
     *
     * In addition, hard restrictions on the Wifi modes may be indicated by |IfaceType| bits
     * (STA, AP, P2P, NAN, etc) in the |restrictions| bitfield. If a hard restriction is provided,
     * then the channels should be completely avoided for the provided Wifi modes instead of by
     * best-effort.
     * In addition, hard restrictions on the Wifi modes may be indicated by |CoexRestriction| bits
     * (WIFI_DIRECT, SOFTAP, WIFI_AWARE) in the |restrictions| bitfield. If a hard restriction is
     * provided, then the channels should be completely avoided for the provided Wifi modes instead
     * of by best-effort.
     *
     * @param unsafeChannels List of |CoexUnsafeChannels| to avoid.
     * @param restrictions Bitset of |IfaceType| values indicating Wifi modes to completely avoid.
     * @param restrictions Bitset of |CoexRestriction| values indicating Wifi interfaces to
     *         completely avoid.
     * @return status WifiStatus of the operation.
     *         Possible status codes:
     *         |WifiStatusCode.SUCCESS|,
@@ -208,6 +214,6 @@ interface IWifiChip extends @1.4::IWifiChip {
     *         |WifiStatusCode.ERROR_INVALID_ARGS|,
     */
    setCoexUnsafeChannels(
        vec<CoexUnsafeChannel> unsafeChannels, bitfield<IfaceType> restrictions)
        vec<CoexUnsafeChannel> unsafeChannels, bitfield<CoexRestriction> restrictions)
            generates (WifiStatus status);
};
+12 −2
Original line number Diff line number Diff line
@@ -724,7 +724,7 @@ Return<void> WifiChip::setMultiStaUseCase(

Return<void> WifiChip::setCoexUnsafeChannels(
    const hidl_vec<CoexUnsafeChannel>& unsafeChannels,
    hidl_bitfield<IfaceType> restrictions,
    hidl_bitfield<CoexRestriction> restrictions,
    setCoexUnsafeChannels_cb hidl_status_cb) {
    return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
                           &WifiChip::setCoexUnsafeChannelsInternal,
@@ -1463,8 +1463,18 @@ WifiStatus WifiChip::setCoexUnsafeChannelsInternal(
            unsafe_channels, &legacy_unsafe_channels)) {
        return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
    }
    uint32_t legacy_restrictions = 0;
    if (restrictions & CoexRestriction::WIFI_DIRECT) {
        legacy_restrictions |= legacy_hal::wifi_coex_restriction::WIFI_DIRECT;
    }
    if (restrictions & CoexRestriction::SOFTAP) {
        legacy_restrictions |= legacy_hal::wifi_coex_restriction::SOFTAP;
    }
    if (restrictions & CoexRestriction::WIFI_AWARE) {
        legacy_restrictions |= legacy_hal::wifi_coex_restriction::WIFI_AWARE;
    }
    auto legacy_status = legacy_hal_.lock()->setCoexUnsafeChannels(
        legacy_unsafe_channels, restrictions);
        legacy_unsafe_channels, legacy_restrictions);
    return createWifiStatusFromLegacyError(legacy_status);
}

+32 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ using ::android::hardware::wifi::V1_0::WifiStatus;
using ::android::hardware::wifi::V1_0::WifiStatusCode;
using ::android::hardware::wifi::V1_4::IWifiChipEventCallback;
using ::android::hardware::wifi::V1_5::IWifiChip;
using ::android::hardware::wifi::V1_5::WifiBand;

/**
 * Fixture to use for all Wifi chip HIDL interface tests.
@@ -141,6 +142,37 @@ TEST_P(WifiChipHidlTest, setMultiStaUseCase) {
    }
}

/*
 * setCoexUnsafeChannels
 */
TEST_P(WifiChipHidlTest, setCoexUnsafeChannels) {
    // Test with empty vector of CoexUnsafeChannels
    std::vector<IWifiChip::CoexUnsafeChannel> vec;
    const auto& statusEmpty =
        HIDL_INVOKE(wifi_chip_, setCoexUnsafeChannels, vec, 0);
    if (statusEmpty.code != WifiStatusCode::SUCCESS) {
        EXPECT_EQ(WifiStatusCode::ERROR_NOT_SUPPORTED, statusEmpty.code);
    }

    // Test with non-empty vector of CoexUnsafeChannels
    IWifiChip::CoexUnsafeChannel unsafeChannel24Ghz;
    unsafeChannel24Ghz.band = WifiBand::BAND_24GHZ;
    unsafeChannel24Ghz.channel = 6;
    vec.push_back(unsafeChannel24Ghz);
    IWifiChip::CoexUnsafeChannel unsafeChannel5Ghz;
    unsafeChannel5Ghz.band = WifiBand::BAND_5GHZ;
    unsafeChannel5Ghz.channel = 36;
    vec.push_back(unsafeChannel5Ghz);
    uint32_t restrictions = IWifiChip::CoexRestriction::WIFI_AWARE |
                            IWifiChip::CoexRestriction::SOFTAP |
                            IWifiChip::CoexRestriction::WIFI_DIRECT;
    const auto& statusNonEmpty =
        HIDL_INVOKE(wifi_chip_, setCoexUnsafeChannels, vec, restrictions);
    if (statusNonEmpty.code != WifiStatusCode::SUCCESS) {
        EXPECT_EQ(WifiStatusCode::ERROR_NOT_SUPPORTED, statusNonEmpty.code);
    }
}

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(WifiChipHidlTest);
INSTANTIATE_TEST_SUITE_P(
    PerInstance, WifiChipHidlTest,