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

Commit 8efe3759 authored by Les Lee's avatar Les Lee
Browse files

wifi: Supports setVoipMode in HAL

Bug: 295885471
Test: manual test, wifi works normally
Change-Id: I20e1479de84fa892c986929eebc692b33f5607a1
parent efb27b92
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ interface IWifiChip {
  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 @@ interface IWifiChip {
    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 */,
+29 −0
Original line number Diff line number Diff line
@@ -384,6 +384,16 @@ interface IWifiChip {
        NAN_INSTANT_MODE = 1 << 2,
    }

    /**
     * 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
@@ -1173,4 +1183,23 @@ interface IWifiChip {
    @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);
}
+23 −0
Original line number Diff line number Diff line
@@ -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 @@ ndk::ScopedAStatus WifiChip::setMloMode(const ChipMloMode in_mode) {
                           &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 @@ ndk::ScopedAStatus WifiChip::setMloModeInternal(const WifiChip::ChipMloMode in_m
    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
+2 −0
Original line number Diff line number Diff line
@@ -158,6 +158,7 @@ class WifiChip : public BnWifiChip {
            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 @@ class WifiChip : public BnWifiChip {
    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);