wifi: Supports setVoipMode in HAL
Bug: 295885471
Test: manual test, wifi works normally
Change-Id: I20e1479de84fa892c986929eebc692b33f5607a1
diff --git a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/IWifiChip.aidl b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/IWifiChip.aidl
index 2d7fe03..db82a6e 100644
--- a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/IWifiChip.aidl
+++ b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/IWifiChip.aidl
@@ -84,6 +84,7 @@
void enableStaChannelForPeerNetwork(in int channelCategoryEnableFlag);
void setMloMode(in android.hardware.wifi.IWifiChip.ChipMloMode mode);
@PropagateAllowBlocking android.hardware.wifi.IWifiApIface createApOrBridgedApIface(in android.hardware.wifi.IfaceConcurrencyType iface, in android.hardware.wifi.common.OuiKeyedData[] vendorData);
+ void setVoipMode(in android.hardware.wifi.IWifiChip.VoipMode mode);
const int NO_POWER_CAP_CONSTANT = 0x7FFFFFFF;
@Backing(type="int") @VintfStability
enum FeatureSetMask {
@@ -162,6 +163,11 @@
NAN_INSTANT_MODE = (1 << 2) /* 4 */,
}
@Backing(type="int") @VintfStability
+ enum VoipMode {
+ OFF = 0,
+ VOICE = 1,
+ }
+ @Backing(type="int") @VintfStability
enum ChannelCategoryMask {
INDOOR_CHANNEL = (1 << 0) /* 1 */,
DFS_CHANNEL = (1 << 1) /* 2 */,
diff --git a/wifi/aidl/android/hardware/wifi/IWifiChip.aidl b/wifi/aidl/android/hardware/wifi/IWifiChip.aidl
index 733ff62..cf4c884 100644
--- a/wifi/aidl/android/hardware/wifi/IWifiChip.aidl
+++ b/wifi/aidl/android/hardware/wifi/IWifiChip.aidl
@@ -385,6 +385,16 @@
}
/**
+ * This enum represents the different VoIP mode that can be set through |setVoipMode|.
+ */
+ @VintfStability
+ @Backing(type="int")
+ enum VoipMode {
+ OFF = 0,
+ VOICE = 1,
+ }
+
+ /**
* Configure the Chip.
* This may NOT be called to reconfigure a chip due to an internal
* limitation. Calling this when chip is already configured in a different
@@ -1173,4 +1183,23 @@
@PropagateAllowBlocking
IWifiApIface createApOrBridgedApIface(
in IfaceConcurrencyType iface, in OuiKeyedData[] vendorData);
+
+ /**
+ * API to set the wifi VoIP mode.
+ *
+ * The VoIP mode is a hint to the HAL to enable or disable Wi-Fi VoIP
+ * optimization. The optimization should be enabled if the mode is NOT set to |OFF|.
+ * Furthermore, HAL should implement relevant optimization techniques based on the
+ * current operational mode.
+ *
+ * Note: Wi-Fi VoIP optimization may trade-off power against Wi-Fi
+ * performance but it provides better voice quility.
+ *
+ * @param mode Voip mode as defined by the enum |VoipMode|
+ * @throws ServiceSpecificException with one of the following values:
+ * |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|,
+ * |WifiStatusCode.ERROR_INVALID_ARGS|,
+ * |WifiStatusCode.ERROR_UNKNOWN|
+ */
+ void setVoipMode(in VoipMode mode);
}
diff --git a/wifi/aidl/default/wifi_chip.cpp b/wifi/aidl/default/wifi_chip.cpp
index d72775c..2db3b4a 100644
--- a/wifi/aidl/default/wifi_chip.cpp
+++ b/wifi/aidl/default/wifi_chip.cpp
@@ -20,6 +20,7 @@
#include <android-base/unique_fd.h>
#include <cutils/properties.h>
#include <fcntl.h>
+#include <hardware_legacy/wifi_hal.h>
#include <net/if.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
@@ -605,6 +606,11 @@
&WifiChip::setMloModeInternal, in_mode);
}
+ndk::ScopedAStatus WifiChip::setVoipMode(const VoipMode in_mode) {
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::setVoipModeInternal, in_mode);
+}
+
void WifiChip::invalidateAndRemoveAllIfaces() {
invalidateAndClearBridgedApAll();
invalidateAndClearAll(ap_ifaces_);
@@ -1913,6 +1919,23 @@
return createWifiStatusFromLegacyError(legacy_hal_.lock()->setMloMode(mode));
}
+ndk::ScopedAStatus WifiChip::setVoipModeInternal(const WifiChip::VoipMode in_mode) {
+ const auto ifname = getFirstActiveWlanIfaceName();
+ wifi_voip_mode mode;
+ switch (in_mode) {
+ case WifiChip::VoipMode::VOICE:
+ mode = wifi_voip_mode::WIFI_VOIP_MODE_ON;
+ break;
+ case WifiChip::VoipMode::OFF:
+ mode = wifi_voip_mode::WIFI_VOIP_MODE_OFF;
+ break;
+ default:
+ PLOG(ERROR) << "Error: invalid mode: " << toString(in_mode);
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ return createWifiStatusFromLegacyError(legacy_hal_.lock()->setVoipMode(ifname, mode));
+}
+
} // namespace wifi
} // namespace hardware
} // namespace android
diff --git a/wifi/aidl/default/wifi_chip.h b/wifi/aidl/default/wifi_chip.h
index c6517db..ffd507f 100644
--- a/wifi/aidl/default/wifi_chip.h
+++ b/wifi/aidl/default/wifi_chip.h
@@ -158,6 +158,7 @@
int32_t in_channelCategoryEnableFlag) override;
binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;
ndk::ScopedAStatus setMloMode(const ChipMloMode in_mode) override;
+ ndk::ScopedAStatus setVoipMode(const VoipMode in_mode) override;
private:
void invalidateAndRemoveAllIfaces();
@@ -269,6 +270,7 @@
getSupportedRadioCombinationsInternal();
std::pair<WifiChipCapabilities, ndk::ScopedAStatus> getWifiChipCapabilitiesInternal();
ndk::ScopedAStatus setMloModeInternal(const ChipMloMode in_mode);
+ ndk::ScopedAStatus setVoipModeInternal(const VoipMode in_mode);
void retrieveDynamicIfaceCombination();
void setWeakPtr(std::weak_ptr<WifiChip> ptr);