Wifi: Add Support for Body Proximity for SAR

This commit extends the SAR support to include scenarios for near
head/body and voice calls
These features are only applicale for a certain device capability
(defined in capability mask)

Bug: 3489513
Test: Manual

Change-Id: Ie99978df3c19e04fdd3d7862240f6d3c62eac539
Signed-off-by: Ahmed ElArabawy <arabawy@google.com>
This commit is contained in:
Ahmed ElArabawy
2018-01-23 10:57:29 -08:00
parent e210c3cddf
commit 6a1accf8ba
5 changed files with 97 additions and 12 deletions

View File

@@ -26,6 +26,50 @@ import IWifiChipEventCallback;
* to perform operations like NAN, RTT, etc.
*/
interface IWifiChip extends @1.1::IWifiChip {
/**
* Capabilities exposed by this chip.
*/
enum ChipCapabilityMask : @1.1::IWifiChip.ChipCapabilityMask {
/**
* Set/Reset Tx Power limits.
*/
USE_BODY_HEAD_SAR = 1 << 11
};
/**
* List of preset wifi radio TX power levels for different scenarios.
* The actual power values (typically varies based on the channel,
* 802.11 connection type, number of MIMO streams, etc) for each scenario
* is defined by the OEM as a BDF file since it varies for each wifi chip
* vendor and device.
*/
enum TxPowerScenario : @1.1::IWifiChip.TxPowerScenario {
ON_HEAD_CELL_OFF = 1,
ON_HEAD_CELL_ON = 2,
ON_BODY_CELL_OFF = 3,
ON_BODY_CELL_ON = 4
};
/**
* API to select one of the preset TX power scenarios.
*
* The framework must invoke this method with the appropriate scenario to let
* the wifi chip change it's transmitting power levels.
* OEM's should define various power profiles for each of the scenarios
* above (defined in |TxPowerScenario|) in a vendor extension.
*
* @param scenario One of the preselected scenarios defined in
* |TxPowerScenario|.
* @return status WifiStatus of the operation.
* Possible status codes:
* |WifiStatusCode.SUCCESS|,
* |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|,
* |WifiStatusCode.ERROR_NOT_SUPPORTED|,
* |WifiStatusCode.NOT_AVAILABLE|,
* |WifiStatusCode.UNKNOWN|
*/
selectTxPowerScenario_1_2(TxPowerScenario scenario) generates (WifiStatus status);
/**
* Requests notifications of significant events on this chip. Multiple calls
* to this must register multiple callbacks each of which must receive all

View File

@@ -66,12 +66,14 @@ convertLegacyLoggerFeatureToHidlStaIfaceCapability(uint32_t feature) {
return {};
}
V1_1::IWifiChip::ChipCapabilityMask convertLegacyFeatureToHidlChipCapability(
IWifiChip::ChipCapabilityMask convertLegacyFeatureToHidlChipCapability(
uint32_t feature) {
using HidlChipCaps = V1_1::IWifiChip::ChipCapabilityMask;
using HidlChipCaps = IWifiChip::ChipCapabilityMask;
switch (feature) {
case WIFI_FEATURE_SET_TX_POWER_LIMIT:
return HidlChipCaps::SET_TX_POWER_LIMIT;
case WIFI_FEATURE_USE_BODY_HEAD_SAR:
return HidlChipCaps::USE_BODY_HEAD_SAR;
case WIFI_FEATURE_D2D_RTT:
return HidlChipCaps::D2D_RTT;
case WIFI_FEATURE_D2AP_RTT:
@@ -135,6 +137,7 @@ bool convertLegacyFeaturesToHidlChipCapabilities(
}
}
for (const auto feature : {WIFI_FEATURE_SET_TX_POWER_LIMIT,
WIFI_FEATURE_USE_BODY_HEAD_SAR,
WIFI_FEATURE_D2D_RTT, WIFI_FEATURE_D2AP_RTT}) {
if (feature & legacy_feature_set) {
*hidl_caps |= convertLegacyFeatureToHidlChipCapability(feature);
@@ -260,12 +263,32 @@ bool convertLegacyWakeReasonStatsToHidl(
legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy(
V1_1::IWifiChip::TxPowerScenario hidl_scenario) {
switch (hidl_scenario) {
case V1_1::IWifiChip::TxPowerScenario::VOICE_CALL:
// This is the only supported scenario for V1_1
case V1_1::IWifiChip::TxPowerScenario::VOICE_CALL:
return legacy_hal::WIFI_POWER_SCENARIO_VOICE_CALL;
};
CHECK(false);
}
legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy_1_2(
IWifiChip::TxPowerScenario hidl_scenario) {
switch (hidl_scenario) {
// This is the only supported scenario for V1_1
case IWifiChip::TxPowerScenario::VOICE_CALL:
return legacy_hal::WIFI_POWER_SCENARIO_VOICE_CALL;
// Those are the supported scenarios for V1_2
case IWifiChip::TxPowerScenario::ON_HEAD_CELL_OFF:
return legacy_hal::WIFI_POWER_SCENARIO_ON_HEAD_CELL_OFF;
case IWifiChip::TxPowerScenario::ON_HEAD_CELL_ON:
return legacy_hal::WIFI_POWER_SCENARIO_ON_HEAD_CELL_ON;
case IWifiChip::TxPowerScenario::ON_BODY_CELL_OFF:
return legacy_hal::WIFI_POWER_SCENARIO_ON_BODY_CELL_OFF;
case IWifiChip::TxPowerScenario::ON_BODY_CELL_ON:
return legacy_hal::WIFI_POWER_SCENARIO_ON_BODY_CELL_ON;
};
CHECK(false);
}
bool convertLegacyWifiMacInfoToHidl(
const legacy_hal::WifiMacInfo& legacy_mac_info,
IWifiChipEventCallback::RadioModeInfo* hidl_radio_mode_info) {

View File

@@ -21,7 +21,7 @@
#include <android/hardware/wifi/1.0/IWifiChip.h>
#include <android/hardware/wifi/1.0/types.h>
#include <android/hardware/wifi/1.1/IWifiChip.h>
#include <android/hardware/wifi/1.2/IWifiChip.h>
#include <android/hardware/wifi/1.2/IWifiChipEventCallback.h>
#include <android/hardware/wifi/1.2/types.h>
@@ -56,6 +56,8 @@ bool convertLegacyWakeReasonStatsToHidl(
WifiDebugHostWakeReasonStats* hidl_stats);
legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy(
V1_1::IWifiChip::TxPowerScenario hidl_scenario);
legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy_1_2(
IWifiChip::TxPowerScenario hidl_scenario);
bool convertLegacyWifiMacInfosToHidl(
const std::vector<legacy_hal::WifiMacInfo>& legacy_mac_infos,
std::vector<IWifiChipEventCallback::RadioModeInfo>* hidl_radio_mode_infos);

View File

@@ -507,7 +507,7 @@ Return<void> WifiChip::enableDebugErrorAlerts(
}
Return<void> WifiChip::selectTxPowerScenario(
TxPowerScenario scenario, selectTxPowerScenario_cb hidl_status_cb) {
V1_1::IWifiChip::TxPowerScenario scenario, selectTxPowerScenario_cb hidl_status_cb) {
return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
&WifiChip::selectTxPowerScenarioInternal,
hidl_status_cb, scenario);
@@ -528,6 +528,12 @@ Return<void> WifiChip::registerEventCallback_1_2(
hidl_status_cb, event_callback);
}
Return<void> WifiChip::selectTxPowerScenario_1_2(
TxPowerScenario scenario, selectTxPowerScenario_cb hidl_status_cb) {
return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
&WifiChip::selectTxPowerScenarioInternal_1_2, hidl_status_cb, scenario);
}
Return<void> WifiChip::debug(const hidl_handle& handle,
const hidl_vec<hidl_string>&) {
if (handle != nullptr && handle->numFds >= 1) {
@@ -990,7 +996,8 @@ WifiStatus WifiChip::enableDebugErrorAlertsInternal(bool enable) {
return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiChip::selectTxPowerScenarioInternal(TxPowerScenario scenario) {
WifiStatus WifiChip::selectTxPowerScenarioInternal(
V1_1::IWifiChip::TxPowerScenario scenario) {
auto legacy_status = legacy_hal_.lock()->selectTxPowerScenario(
getWlan0IfaceName(),
hidl_struct_util::convertHidlTxPowerScenarioToLegacy(scenario));
@@ -1011,6 +1018,13 @@ WifiStatus WifiChip::registerEventCallbackInternal_1_2(
return createWifiStatus(WifiStatusCode::SUCCESS);
}
WifiStatus WifiChip::selectTxPowerScenarioInternal_1_2(TxPowerScenario scenario) {
auto legacy_status = legacy_hal_.lock()->selectTxPowerScenario(
getWlan0IfaceName(),
hidl_struct_util::convertHidlTxPowerScenarioToLegacy_1_2(scenario));
return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiChip::handleChipConfiguration(
/* NONNULL */ std::unique_lock<std::recursive_mutex>* lock,
ChipModeId mode_id) {

View File

@@ -132,16 +132,18 @@ class WifiChip : public V1_2::IWifiChip {
Return<void> enableDebugErrorAlerts(
bool enable, enableDebugErrorAlerts_cb hidl_status_cb) override;
Return<void> selectTxPowerScenario(
TxPowerScenario scenario,
V1_1::IWifiChip::TxPowerScenario scenario,
selectTxPowerScenario_cb hidl_status_cb) override;
Return<void> resetTxPowerScenario(
resetTxPowerScenario_cb hidl_status_cb) override;
Return<void> debug(const hidl_handle& handle,
const hidl_vec<hidl_string>& options) override;
Return<void> registerEventCallback_1_2(
const sp<IWifiChipEventCallback>& event_callback,
registerEventCallback_1_2_cb hidl_status_cb) override;
Return<void> selectTxPowerScenario_1_2(
TxPowerScenario scenario,
selectTxPowerScenario_cb hidl_status_cb) override;
Return<void> debug(const hidl_handle& handle,
const hidl_vec<hidl_string>& options) override;
private:
void invalidateAndRemoveAllIfaces();
@@ -193,11 +195,11 @@ class WifiChip : public V1_2::IWifiChip {
std::pair<WifiStatus, WifiDebugHostWakeReasonStats>
getDebugHostWakeReasonStatsInternal();
WifiStatus enableDebugErrorAlertsInternal(bool enable);
WifiStatus selectTxPowerScenarioInternal(TxPowerScenario scenario);
WifiStatus selectTxPowerScenarioInternal(V1_1::IWifiChip::TxPowerScenario scenario);
WifiStatus resetTxPowerScenarioInternal();
WifiStatus registerEventCallbackInternal_1_2(
const sp<IWifiChipEventCallback>& event_callback);
WifiStatus selectTxPowerScenarioInternal_1_2(TxPowerScenario scenario);
WifiStatus handleChipConfiguration(
std::unique_lock<std::recursive_mutex>* lock, ChipModeId mode_id);
WifiStatus registerDebugRingBufferCallback();