From ab70a83b053f00834e12ccfb14b572f2c1cf55c4 Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Mon, 14 Dec 2020 13:01:32 -0800 Subject: [PATCH] [WifiCoex] Add enum for wifi coex restrictions Add custom enum for wifi coex restrictions since IfaceType is not suitable for use as a bitmask flag since it does not represent bit positions. Bug: 153651001 Test: build Change-Id: I15575ea12784a778a3b358eea1b05b75319aa95b --- wifi/1.5/IWifiChip.hal | 20 +++++++++++++------- wifi/1.5/default/wifi_chip.cpp | 14 ++++++++++++-- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/wifi/1.5/IWifiChip.hal b/wifi/1.5/IWifiChip.hal index e9caa3deb5..80f2ca448c 100644 --- a/wifi/1.5/IWifiChip.hal +++ b/wifi/1.5/IWifiChip.hal @@ -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 unsafeChannels, bitfield restrictions) + vec unsafeChannels, bitfield restrictions) generates (WifiStatus status); }; diff --git a/wifi/1.5/default/wifi_chip.cpp b/wifi/1.5/default/wifi_chip.cpp index 1b0353b353..44cd5cf61f 100644 --- a/wifi/1.5/default/wifi_chip.cpp +++ b/wifi/1.5/default/wifi_chip.cpp @@ -724,7 +724,7 @@ Return WifiChip::setMultiStaUseCase( Return WifiChip::setCoexUnsafeChannels( const hidl_vec& unsafeChannels, - hidl_bitfield restrictions, + hidl_bitfield 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); }