summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorAhmed ElArabawy <arabawy@google.com>2018-07-12 13:48:55 -0700
committerAhmed ElArabawy <arabawy@google.com>2018-07-18 12:33:25 -0700
commit8392e5dc1ec0c0e5e9ac5d40dac2a38a47b6b63d (patch)
treec551c6a884be8308e188bb1b3fb703e01b86a97b /service
parenta52e9108f44a2770dc7b0ce00bfb4493c3f8e65e (diff)
SAR: Add conditional support for SAP/voice call
In current implementation, SAR support for sensors assume automatically that SoftAP is supported. This CL introduces a separate configurations for support of voice calls and softAP independent of SAR sensor support. Bug: 65174506 Test: Unit test Change-Id: I92eb15142888054b5c8070c2c9c73862f0e5fcdc Merged-In: I92eb15142888054b5c8070c2c9c73862f0e5fcdc
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/SarInfo.java51
-rw-r--r--service/java/com/android/server/wifi/SarManager.java89
-rw-r--r--service/java/com/android/server/wifi/WifiVendorHal.java68
3 files changed, 128 insertions, 80 deletions
diff --git a/service/java/com/android/server/wifi/SarInfo.java b/service/java/com/android/server/wifi/SarInfo.java
index 6eb777c65..514f15e10 100644
--- a/service/java/com/android/server/wifi/SarInfo.java
+++ b/service/java/com/android/server/wifi/SarInfo.java
@@ -23,7 +23,7 @@ import java.io.PrintWriter;
* This class represents the list of SAR inputs that will be used to select the proper
* power profile.
* This includes:
- * - SAR body sensor status
+ * - SAR sensor status
* - Is there an ongoing voice call
* - Is SoftAP active
* It also contains info about state of the other Wifi modes
@@ -64,14 +64,17 @@ public class SarInfo {
/* For Logging */
private static final String TAG = "WifiSarInfo";
- public boolean mSarSensorEnabled;
+ /* SAR support configs */
+ public boolean sarVoiceCallSupported;
+ public boolean sarSapSupported;
+ public boolean sarSensorSupported;
- public int mSensorState = SAR_SENSOR_FREE_SPACE;
- public boolean mIsWifiClientEnabled = false;
- public boolean mIsWifiSapEnabled = false;
- public boolean mIsWifiScanOnlyEnabled = false;
- public boolean mIsVoiceCall = false;
- public int mAttemptedSarScenario = RESET_SAR_SCENARIO;
+ public int sensorState = SAR_SENSOR_FREE_SPACE;
+ public boolean isWifiClientEnabled = false;
+ public boolean isWifiSapEnabled = false;
+ public boolean isWifiScanOnlyEnabled = false;
+ public boolean isVoiceCall = false;
+ public int attemptedSarScenario = RESET_SAR_SCENARIO;
private boolean mAllWifiDisabled = true;
@@ -81,10 +84,6 @@ public class SarInfo {
private boolean mLastReportedIsVoiceCall = false;
private int mLastReportedScenario = INITIAL_SAR_SCENARIO;
- SarInfo(boolean sarSensorEnabled) {
- mSarSensorEnabled = sarSensorEnabled;
- }
-
/**
* shouldReport()
* This method returns false in the following cases:
@@ -100,7 +99,7 @@ public class SarInfo {
*/
public boolean shouldReport() {
/* Check if all Wifi modes are disabled */
- if (!mIsWifiClientEnabled && !mIsWifiSapEnabled && !mIsWifiScanOnlyEnabled) {
+ if (!isWifiClientEnabled && !isWifiSapEnabled && !isWifiScanOnlyEnabled) {
mAllWifiDisabled = true;
return false;
}
@@ -111,9 +110,9 @@ public class SarInfo {
}
/* Check if some change happened since last successful reporting */
- if ((mSensorState != mLastReportedSensorState)
- || (mIsWifiSapEnabled != mLastReportedIsWifiSapEnabled)
- || (mIsVoiceCall != mLastReportedIsVoiceCall)) {
+ if ((sensorState != mLastReportedSensorState)
+ || (isWifiSapEnabled != mLastReportedIsWifiSapEnabled)
+ || (isVoiceCall != mLastReportedIsVoiceCall)) {
return true;
} else {
return false;
@@ -126,10 +125,10 @@ public class SarInfo {
* This results in caching the last reported inputs for future comparison.
*/
public void reportingSuccessful() {
- mLastReportedSensorState = mSensorState;
- mLastReportedIsWifiSapEnabled = mIsWifiSapEnabled;
- mLastReportedIsVoiceCall = mIsVoiceCall;
- mLastReportedScenario = mAttemptedSarScenario;
+ mLastReportedSensorState = sensorState;
+ mLastReportedIsWifiSapEnabled = isWifiSapEnabled;
+ mLastReportedIsVoiceCall = isVoiceCall;
+ mLastReportedScenario = attemptedSarScenario;
mAllWifiDisabled = false;
}
@@ -152,7 +151,7 @@ public class SarInfo {
* another call to set the SAR scenario to the same value would be redundant.
*/
public boolean setSarScenarioNeeded(int scenario) {
- mAttemptedSarScenario = scenario;
+ attemptedSarScenario = scenario;
return (mLastReportedScenario != scenario);
}
@@ -163,11 +162,11 @@ public class SarInfo {
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println("*** WiFi SAR Info Dump ***");
pw.println("Current values:");
- pw.println(" Sensor state is: " + sensorStateToString(mSensorState));
- pw.println(" Voice Call state is: " + mIsVoiceCall);
- pw.println(" Wifi Client state is: " + mIsWifiClientEnabled);
- pw.println(" Wifi Soft AP state is: " + mIsWifiSapEnabled);
- pw.println(" Wifi ScanOnly state is: " + mIsWifiScanOnlyEnabled);
+ pw.println(" Sensor state is: " + sensorStateToString(sensorState));
+ pw.println(" Voice Call state is: " + isVoiceCall);
+ pw.println(" Wifi Client state is: " + isWifiClientEnabled);
+ pw.println(" Wifi Soft AP state is: " + isWifiSapEnabled);
+ pw.println(" Wifi ScanOnly state is: " + isWifiScanOnlyEnabled);
pw.println("Last reported values:");
pw.println(" Sensor state is: " + sensorStateToString(mLastReportedSensorState));
pw.println(" Soft AP state is: " + mLastReportedIsWifiSapEnabled);
diff --git a/service/java/com/android/server/wifi/SarManager.java b/service/java/com/android/server/wifi/SarManager.java
index d38eab981..89da7012b 100644
--- a/service/java/com/android/server/wifi/SarManager.java
+++ b/service/java/com/android/server/wifi/SarManager.java
@@ -55,9 +55,11 @@ public class SarManager {
private SarInfo mSarInfo;
- /* Configuration for SAR */
- private boolean mEnableSarTxPowerLimit;
- private boolean mEnableSarBodyProximity;
+ /* Configuration for SAR support */
+ private boolean mSupportSarTxPowerLimit;
+ private boolean mSupportSarVoiceCall;
+ private boolean mSupportSarSoftAp;
+ private boolean mSupportSarSensor;
/* Sensor event definitions */
private int mSarSensorEventFreeSpace;
private int mSarSensorEventNearBody;
@@ -92,27 +94,36 @@ public class SarManager {
mSensorListener = new SarSensorEventListener();
readSarConfigs();
- if (mEnableSarTxPowerLimit) {
- mSarInfo = new SarInfo(mEnableSarBodyProximity);
+ if (mSupportSarTxPowerLimit) {
+ mSarInfo = new SarInfo();
+ setSarConfigsInInfo();
registerListeners();
}
}
private void readSarConfigs() {
- mEnableSarTxPowerLimit = mContext.getResources().getBoolean(
+ mSupportSarTxPowerLimit = mContext.getResources().getBoolean(
R.bool.config_wifi_framework_enable_sar_tx_power_limit);
/* In case SAR is disabled,
- then SAR sensor is automatically disabled as well (irrespective of the config) */
- if (!mEnableSarTxPowerLimit) {
- mEnableSarBodyProximity = false;
+ then all SAR inputs are automatically disabled as well (irrespective of the config) */
+ if (!mSupportSarTxPowerLimit) {
+ mSupportSarVoiceCall = false;
+ mSupportSarSoftAp = false;
+ mSupportSarSensor = false;
return;
}
- mEnableSarBodyProximity = mContext.getResources().getBoolean(
+ /* Voice calls are supported when SAR is supported */
+ mSupportSarVoiceCall = true;
+
+ mSupportSarSoftAp = mContext.getResources().getBoolean(
+ R.bool.config_wifi_framework_enable_soft_ap_sar_tx_power_limit);
+
+ mSupportSarSensor = mContext.getResources().getBoolean(
R.bool.config_wifi_framework_enable_body_proximity_sar_tx_power_limit);
/* Read the sar sensor event Ids */
- if (mEnableSarBodyProximity) {
+ if (mSupportSarSensor) {
mSarSensorEventFreeSpace = mContext.getResources().getInteger(
R.integer.config_wifi_framework_sar_free_space_event_id);
mSarSensorEventNearBody = mContext.getResources().getInteger(
@@ -124,18 +135,26 @@ public class SarManager {
}
}
+ private void setSarConfigsInInfo() {
+ mSarInfo.sarVoiceCallSupported = mSupportSarVoiceCall;
+ mSarInfo.sarSapSupported = mSupportSarSoftAp;
+ mSarInfo.sarSensorSupported = mSupportSarSensor;
+ }
+
private void registerListeners() {
- /* Listen for Phone State changes */
- registerPhoneStateListener();
+ if (mSupportSarVoiceCall) {
+ /* Listen for Phone State changes */
+ registerPhoneStateListener();
+ }
/* Only listen for SAR sensor if supported */
- if (mEnableSarBodyProximity) {
+ if (mSupportSarSensor) {
/* Register the SAR sensor listener.
* If this fails, we will assume worst case (near head) */
if (!registerSensorListener()) {
Log.e(TAG, "Failed to register sensor listener, setting Sensor to NearHead");
/*TODO Need to add a metric to determine how often this happens */
- mSarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
+ mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
}
}
}
@@ -162,8 +181,8 @@ public class SarManager {
*/
public void setClientWifiState(int state) {
boolean newIsEnabled;
- /* No action is taken if SAR is not enabled */
- if (!mEnableSarTxPowerLimit) {
+ /* No action is taken if SAR is not supported */
+ if (!mSupportSarTxPowerLimit) {
return;
}
@@ -177,8 +196,8 @@ public class SarManager {
}
/* Report change to HAL if needed */
- if (mSarInfo.mIsWifiClientEnabled != newIsEnabled) {
- mSarInfo.mIsWifiClientEnabled = newIsEnabled;
+ if (mSarInfo.isWifiClientEnabled != newIsEnabled) {
+ mSarInfo.isWifiClientEnabled = newIsEnabled;
updateSarScenario();
}
}
@@ -188,8 +207,8 @@ public class SarManager {
*/
public void setSapWifiState(int state) {
boolean newIsEnabled;
- /* No action is taken if SAR is not enabled */
- if (!mEnableSarTxPowerLimit) {
+ /* No action is taken if SAR is not supported */
+ if (!mSupportSarTxPowerLimit) {
return;
}
@@ -203,8 +222,8 @@ public class SarManager {
}
/* Report change to HAL if needed */
- if (mSarInfo.mIsWifiSapEnabled != newIsEnabled) {
- mSarInfo.mIsWifiSapEnabled = newIsEnabled;
+ if (mSarInfo.isWifiSapEnabled != newIsEnabled) {
+ mSarInfo.isWifiSapEnabled = newIsEnabled;
updateSarScenario();
}
}
@@ -214,8 +233,8 @@ public class SarManager {
*/
public void setScanOnlyWifiState(int state) {
boolean newIsEnabled;
- /* No action is taken if SAR is not enabled */
- if (!mEnableSarTxPowerLimit) {
+ /* No action is taken if SAR is not supported */
+ if (!mSupportSarTxPowerLimit) {
return;
}
@@ -229,8 +248,8 @@ public class SarManager {
}
/* Report change to HAL if needed */
- if (mSarInfo.mIsWifiScanOnlyEnabled != newIsEnabled) {
- mSarInfo.mIsWifiScanOnlyEnabled = newIsEnabled;
+ if (mSarInfo.isWifiScanOnlyEnabled != newIsEnabled) {
+ mSarInfo.isWifiScanOnlyEnabled = newIsEnabled;
updateSarScenario();
}
}
@@ -256,8 +275,8 @@ public class SarManager {
}
/* Report change to HAL if needed */
- if (mSarInfo.mIsVoiceCall != newIsVoiceCall) {
- mSarInfo.mIsVoiceCall = newIsVoiceCall;
+ if (mSarInfo.isVoiceCall != newIsVoiceCall) {
+ mSarInfo.isVoiceCall = newIsVoiceCall;
updateSarScenario();
}
}
@@ -281,9 +300,9 @@ public class SarManager {
}
/* Report change to HAL if needed */
- if (mSarInfo.mSensorState != newSensorState) {
+ if (mSarInfo.sensorState != newSensorState) {
Log.d(TAG, "Setting Sensor state to " + SarInfo.sensorStateToString(newSensorState));
- mSarInfo.mSensorState = newSensorState;
+ mSarInfo.sensorState = newSensorState;
updateSarScenario();
}
}
@@ -305,8 +324,10 @@ public class SarManager {
*/
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println("*** WiFi SAR Manager Dump ***");
- pw.println("isSarEnabled: " + mEnableSarTxPowerLimit);
- pw.println("isSarSensorEnabled: " + mEnableSarBodyProximity);
+ pw.println("isSarSupported: " + mSupportSarTxPowerLimit);
+ pw.println("isSarVoiceCallSupported: " + mSupportSarVoiceCall);
+ pw.println("isSarSoftApSupported: " + mSupportSarSoftAp);
+ pw.println("isSarSensorSupported: " + mSupportSarSensor);
pw.println("");
mSarInfo.dump(fd, pw, args);
}
@@ -330,7 +351,7 @@ public class SarManager {
Log.d(TAG, "Received Phone State Change: " + state);
/* In case of an unsolicited event */
- if (!mEnableSarTxPowerLimit) {
+ if (!mSupportSarTxPowerLimit || !mSupportSarVoiceCall) {
return;
}
onCellStateChangeEvent(state);
diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java
index 2517ba62a..fad90d140 100644
--- a/service/java/com/android/server/wifi/WifiVendorHal.java
+++ b/service/java/com/android/server/wifi/WifiVendorHal.java
@@ -2661,22 +2661,28 @@ public class WifiVendorHal {
* a voice call is ongoing.
*/
private boolean sarPowerBackoffRequired_1_1(SarInfo sarInfo) {
- /* As long as no voice call is active, no backoff is needed */
- return sarInfo.mIsVoiceCall;
+ /* As long as no voice call is active (in case voice call is supported),
+ * no backoff is needed */
+ if (sarInfo.sarVoiceCallSupported) {
+ return sarInfo.isVoiceCall;
+ } else {
+ return false;
+ }
}
/**
* frameworkToHalTxPowerScenario_1_1()
* This method maps the information inside the SarInfo instance into a SAR scenario
* when device is running the V1_1 version of WifiChip HAL.
- * In this HAL version, only one scenario is defined which is for VOICE_CALL
- * otherwise, an exception is thrown.
+ * In this HAL version, only one scenario is defined which is for VOICE_CALL (if voice call is
+ * supported).
+ * Otherwise, an exception is thrown.
*/
private int frameworkToHalTxPowerScenario_1_1(SarInfo sarInfo) {
- if (sarInfo.mIsVoiceCall) {
+ if (sarInfo.sarVoiceCallSupported && sarInfo.isVoiceCall) {
return android.hardware.wifi.V1_1.IWifiChip.TxPowerScenario.VOICE_CALL;
} else {
- throw new IllegalArgumentException("bad scenario: voice call not active");
+ throw new IllegalArgumentException("bad scenario: voice call not active/supported");
}
}
@@ -2690,11 +2696,17 @@ public class WifiVendorHal {
* a voice call is ongoing.
*/
private boolean sarPowerBackoffRequired_1_2(SarInfo sarInfo) {
- if (sarInfo.mSarSensorEnabled) {
- return (sarInfo.mSensorState != SarInfo.SAR_SENSOR_FREE_SPACE);
- } else {
- return sarInfo.mIsVoiceCall;
+ /* If SAR sensor is supported, output only dependent on device proximity */
+ if (sarInfo.sarSensorSupported) {
+ return (sarInfo.sensorState != SarInfo.SAR_SENSOR_FREE_SPACE);
}
+ if (sarInfo.sarSapSupported && sarInfo.isWifiSapEnabled) {
+ return true;
+ }
+ if (sarInfo.sarVoiceCallSupported && sarInfo.isVoiceCall) {
+ return true;
+ }
+ return false;
}
/**
@@ -2707,15 +2719,19 @@ public class WifiVendorHal {
* near the user body.
* - Running in softAP mode can be treated the same way as running a voice call from tx power
* backoff perspective.
- * If SAR sensor input is not considered in this device, then we should revert to the V1_1 HAL
+ * If SAR sensor input is not supported in this device, but SoftAP is,
+ * we make these assumptions:
+ * - All voice calls are treated as if device is near the head.
+ * - SoftAP scenario is treated as if device is near the body.
+ * In case neither SAR sensor, nor SoftAP is supported, then we should revert to the V1_1 HAL
* behavior, and the only valid scenario would be when a voice call is ongoing.
*/
private int frameworkToHalTxPowerScenario_1_2(SarInfo sarInfo) {
- if (sarInfo.mSarSensorEnabled) {
- switch(sarInfo.mSensorState) {
+ if (sarInfo.sarSensorSupported) {
+ switch(sarInfo.sensorState) {
case SarInfo.SAR_SENSOR_NEAR_BODY:
case SarInfo.SAR_SENSOR_NEAR_HAND:
- if (sarInfo.mIsVoiceCall || sarInfo.mIsWifiSapEnabled) {
+ if (sarInfo.isVoiceCall || sarInfo.isWifiSapEnabled) {
return android.hardware.wifi.V1_2.IWifiChip
.TxPowerScenario.ON_BODY_CELL_ON;
} else {
@@ -2724,7 +2740,7 @@ public class WifiVendorHal {
}
case SarInfo.SAR_SENSOR_NEAR_HEAD:
- if (sarInfo.mIsVoiceCall || sarInfo.mIsWifiSapEnabled) {
+ if (sarInfo.isVoiceCall || sarInfo.isWifiSapEnabled) {
return android.hardware.wifi.V1_2.IWifiChip
.TxPowerScenario.ON_HEAD_CELL_ON;
} else {
@@ -2735,13 +2751,25 @@ public class WifiVendorHal {
default:
throw new IllegalArgumentException("bad scenario: Invalid sensor state");
}
- } else {
- /* SAR Sensors not enabled, act like V1_1 */
- if (sarInfo.mIsVoiceCall) {
+ } else if (sarInfo.sarSapSupported && sarInfo.sarVoiceCallSupported) {
+ if (sarInfo.isVoiceCall) {
+ return android.hardware.wifi.V1_2.IWifiChip
+ .TxPowerScenario.ON_HEAD_CELL_ON;
+ } else if (sarInfo.isWifiSapEnabled) {
+ return android.hardware.wifi.V1_2.IWifiChip
+ .TxPowerScenario.ON_BODY_CELL_ON;
+ } else {
+ throw new IllegalArgumentException("bad scenario: no voice call/softAP active");
+ }
+ } else if (sarInfo.sarVoiceCallSupported) {
+ /* SAR Sensors and SoftAP not supported, act like V1_1 */
+ if (sarInfo.isVoiceCall) {
return android.hardware.wifi.V1_1.IWifiChip.TxPowerScenario.VOICE_CALL;
} else {
throw new IllegalArgumentException("bad scenario: voice call not active");
}
+ } else {
+ throw new IllegalArgumentException("Invalid case: voice call not supported");
}
}
@@ -2791,7 +2819,7 @@ public class WifiVendorHal {
if (sarInfo.setSarScenarioNeeded(halScenario)) {
status = iWifiChip.selectTxPowerScenario(halScenario);
if (ok(status)) {
- mLog.e("Setting SAR scenario to " + halScenario);
+ mLog.d("Setting SAR scenario to " + halScenario);
return true;
} else {
mLog.e("Failed to set SAR scenario to " + halScenario);
@@ -2839,7 +2867,7 @@ public class WifiVendorHal {
if (sarInfo.setSarScenarioNeeded(halScenario)) {
status = iWifiChip.selectTxPowerScenario_1_2(halScenario);
if (ok(status)) {
- mLog.e("Setting SAR scenario to " + halScenario);
+ mLog.d("Setting SAR scenario to " + halScenario);
return true;
} else {
mLog.e("Failed to set SAR scenario to " + halScenario);