summaryrefslogtreecommitdiff
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
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
-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
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SarInfoTest.java46
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SarManagerTest.java267
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java4
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java212
7 files changed, 453 insertions, 284 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);
diff --git a/tests/wifitests/src/com/android/server/wifi/SarInfoTest.java b/tests/wifitests/src/com/android/server/wifi/SarInfoTest.java
index 1f0e44c8a..2bf1f3ee4 100644
--- a/tests/wifitests/src/com/android/server/wifi/SarInfoTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SarInfoTest.java
@@ -39,7 +39,7 @@ public class SarInfoTest {
@Before
public void setUp() throws Exception {
- mSarInfo = new SarInfo(true);
+ mSarInfo = new SarInfo();
}
@After
@@ -142,7 +142,7 @@ public class SarInfoTest {
*/
@Test
public void testSarInfo_shouldReport_wifi_enabled() throws Exception {
- mSarInfo.mIsWifiClientEnabled = true;
+ mSarInfo.isWifiClientEnabled = true;
assertTrue(mSarInfo.shouldReport());
}
@@ -151,7 +151,7 @@ public class SarInfoTest {
*/
@Test
public void testSarInfo_check_sensor_wifi_disabled() throws Exception {
- mSarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
+ mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
assertFalse(mSarInfo.shouldReport());
}
@@ -160,11 +160,11 @@ public class SarInfoTest {
*/
@Test
public void testSarInfo_check_sensor_wifi_enabled() throws Exception {
- mSarInfo.mIsWifiSapEnabled = true;
+ mSarInfo.isWifiSapEnabled = true;
assertTrue(mSarInfo.shouldReport());
mSarInfo.reportingSuccessful();
- mSarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
+ mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
assertTrue(mSarInfo.shouldReport());
}
@@ -175,8 +175,8 @@ public class SarInfoTest {
*/
@Test
public void testSarInfo_check_sensor_multiple_wifi_enabled() throws Exception {
- mSarInfo.mIsWifiScanOnlyEnabled = true;
- mSarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
+ mSarInfo.isWifiScanOnlyEnabled = true;
+ mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
assertTrue(mSarInfo.shouldReport());
mSarInfo.reportingSuccessful();
@@ -189,16 +189,16 @@ public class SarInfoTest {
*/
@Test
public void testSarInfo_check_sensor_multiple_values_wifi_enabled() throws Exception {
- mSarInfo.mIsWifiClientEnabled = true;
- mSarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
+ mSarInfo.isWifiClientEnabled = true;
+ mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
assertTrue(mSarInfo.shouldReport());
mSarInfo.reportingSuccessful();
- mSarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_BODY;
+ mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_BODY;
assertTrue(mSarInfo.shouldReport());
mSarInfo.reportingSuccessful();
- mSarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
+ mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
assertTrue(mSarInfo.shouldReport());
}
@@ -207,10 +207,10 @@ public class SarInfoTest {
*/
@Test
public void testSarInfo_change_sensors_while_wifi_disabled() throws Exception {
- mSarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
+ mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
assertFalse(mSarInfo.shouldReport());
- mSarInfo.mIsWifiClientEnabled = true;
+ mSarInfo.isWifiClientEnabled = true;
assertTrue(mSarInfo.shouldReport());
mSarInfo.reportingSuccessful();
}
@@ -222,11 +222,11 @@ public class SarInfoTest {
*/
@Test
public void testSarInfo_voice_call_wifi_enabled() throws Exception {
- mSarInfo.mIsWifiClientEnabled = true;
+ mSarInfo.isWifiClientEnabled = true;
assertTrue(mSarInfo.shouldReport());
mSarInfo.reportingSuccessful();
- mSarInfo.mIsVoiceCall = true;
+ mSarInfo.isVoiceCall = true;
assertTrue(mSarInfo.shouldReport());
}
@@ -237,11 +237,11 @@ public class SarInfoTest {
*/
@Test
public void testSarInfo_sap_wifi_enabled() throws Exception {
- mSarInfo.mIsWifiClientEnabled = true;
+ mSarInfo.isWifiClientEnabled = true;
assertTrue(mSarInfo.shouldReport());
mSarInfo.reportingSuccessful();
- mSarInfo.mIsWifiSapEnabled = true;
+ mSarInfo.isWifiSapEnabled = true;
assertTrue(mSarInfo.shouldReport());
}
@@ -252,8 +252,8 @@ public class SarInfoTest {
*/
@Test
public void testSarInfo_check_sensor_reporting_no_success_reporting() throws Exception {
- mSarInfo.mIsWifiClientEnabled = true;
- mSarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
+ mSarInfo.isWifiClientEnabled = true;
+ mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
assertTrue(mSarInfo.shouldReport());
/* No call to reportingSuccessful() will be done */
@@ -271,17 +271,17 @@ public class SarInfoTest {
*/
@Test
public void testSarInfo_check_sensor_reporting_no_success_reporting_revert() throws Exception {
- mSarInfo.mIsWifiClientEnabled = true;
- mSarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
+ mSarInfo.isWifiClientEnabled = true;
+ mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
assertTrue(mSarInfo.shouldReport());
mSarInfo.reportingSuccessful();
/* Changing the sensor state and fail to report */
- mSarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_BODY;
+ mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_BODY;
assertTrue(mSarInfo.shouldReport());
/* Changing the sensor back to the same value as last reported */
- mSarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
+ mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
assertFalse(mSarInfo.shouldReport());
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java
index 369dcba33..0cf9dd3f2 100644
--- a/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java
@@ -166,10 +166,14 @@ public class SarManagerTest {
* Helper function to set configuration for SAR and create the SAR Manager
*
*/
- private void createSarManager(boolean isSarEnabled, boolean isSarSensorEnabled) {
+ private void createSarManager(boolean isSarEnabled, boolean isSarSapEnabled,
+ boolean isSarSensorEnabled) {
mResources.setBoolean(
R.bool.config_wifi_framework_enable_sar_tx_power_limit, isSarEnabled);
mResources.setBoolean(
+ R.bool.config_wifi_framework_enable_soft_ap_sar_tx_power_limit,
+ isSarSapEnabled);
+ mResources.setBoolean(
R.bool.config_wifi_framework_enable_body_proximity_sar_tx_power_limit,
isSarSensorEnabled);
mResources.setString(R.string.config_wifi_sar_sensor_type, SAR_SENSOR_NAME);
@@ -224,6 +228,8 @@ public class SarManagerTest {
mResources.setBoolean(
R.bool.config_wifi_framework_enable_sar_tx_power_limit, true);
mResources.setBoolean(
+ R.bool.config_wifi_framework_enable_soft_ap_sar_tx_power_limit, true);
+ mResources.setBoolean(
R.bool.config_wifi_framework_enable_body_proximity_sar_tx_power_limit, true);
if (addToConfigs) {
mResources.setString(R.string.config_wifi_sar_sensor_type, configSensorName);
@@ -280,7 +286,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_enabledTxPowerScenario_registerPhone() throws Exception {
- createSarManager(true, false);
+ createSarManager(true, false, false);
verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_CALL_STATE));
}
@@ -290,7 +296,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_disabledTxPowerScenario_registerPhone() throws Exception {
- createSarManager(false, false);
+ createSarManager(false, false, false);
verify(mTelephonyManager, never()).listen(any(), anyInt());
}
@@ -302,7 +308,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_enabledTxPowerScenario_wifiOn_offHook() throws Exception {
- createSarManager(true, false);
+ createSarManager(true, false, false);
InOrder inOrder = inOrder(mWifiNative);
@@ -311,12 +317,12 @@ public class SarManagerTest {
captureSarInfo(mWifiNative);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertFalse(mSarInfo.isVoiceCall);
/* Set phone state to OFFHOOK */
mPhoneStateListener.onCallStateChanged(CALL_STATE_OFFHOOK, "");
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertTrue(mSarInfo.mIsVoiceCall);
+ assertTrue(mSarInfo.isVoiceCall);
}
/**
@@ -327,7 +333,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_enabledTxPowerScenario_offHook_wifiOn() throws Exception {
- createSarManager(true, false);
+ createSarManager(true, false, false);
InOrder inOrder = inOrder(mWifiNative);
@@ -339,7 +345,7 @@ public class SarManagerTest {
captureSarInfo(mWifiNative);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertTrue(mSarInfo.mIsVoiceCall);
+ assertTrue(mSarInfo.isVoiceCall);
}
/**
@@ -349,7 +355,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_enabledTxPowerScenario_wifiOn_offHook_onHook() throws Exception {
- createSarManager(true, false);
+ createSarManager(true, false, false);
InOrder inOrder = inOrder(mWifiNative);
@@ -359,21 +365,21 @@ public class SarManagerTest {
/* Now device should set tx power scenario to NORMAL */
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertFalse(mSarInfo.isVoiceCall);
/* Set phone state to OFFHOOK */
mPhoneStateListener.onCallStateChanged(CALL_STATE_OFFHOOK, "");
/* Device should set tx power scenario to Voice call */
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertTrue(mSarInfo.mIsVoiceCall);
+ assertTrue(mSarInfo.isVoiceCall);
/* Set state back to ONHOOK */
mPhoneStateListener.onCallStateChanged(CALL_STATE_IDLE, "");
/* Device should set tx power scenario to NORMAL again */
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertFalse(mSarInfo.isVoiceCall);
/* Disable WiFi State */
mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_DISABLED);
@@ -387,7 +393,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_enabledTxPowerScenario_wifiOff_offHook_onHook() throws Exception {
- createSarManager(true, false);
+ createSarManager(true, false, false);
InOrder inOrder = inOrder(mWifiNative);
@@ -411,7 +417,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_enabledSar_wifiOn_offHook_wifiOff_onHook() throws Exception {
- createSarManager(true, false);
+ createSarManager(true, false, false);
InOrder inOrder = inOrder(mWifiNative);
@@ -421,12 +427,12 @@ public class SarManagerTest {
/* Now device should set tx power scenario to NORMAL */
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertFalse(mSarInfo.isVoiceCall);
/* Set phone state to OFFHOOK */
mPhoneStateListener.onCallStateChanged(CALL_STATE_OFFHOOK, "");
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertTrue(mSarInfo.mIsVoiceCall);
+ assertTrue(mSarInfo.isVoiceCall);
/* Disable WiFi State */
mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_DISABLED);
@@ -439,7 +445,7 @@ public class SarManagerTest {
/* Enable WiFi State again */
mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_ENABLED);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertFalse(mSarInfo.isVoiceCall);
}
/**
@@ -448,7 +454,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_enabledSar_wifiOff_offHook_onHook_wifiOn() throws Exception {
- createSarManager(true, false);
+ createSarManager(true, false, false);
InOrder inOrder = inOrder(mWifiNative);
@@ -465,7 +471,7 @@ public class SarManagerTest {
captureSarInfo(mWifiNative);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertFalse(mSarInfo.isVoiceCall);
}
/**
@@ -474,7 +480,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_enabledSar_offHook_wifiOnOff_onHook() throws Exception {
- createSarManager(true, false);
+ createSarManager(true, false, false);
InOrder inOrder = inOrder(mWifiNative);
@@ -488,7 +494,7 @@ public class SarManagerTest {
assertNotNull(mSarInfo);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertTrue(mSarInfo.mIsVoiceCall);
+ assertTrue(mSarInfo.isVoiceCall);
/* Disable WiFi State */
mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_DISABLED);
@@ -505,7 +511,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_enabledSar_error_wifiOn_offOnHook() throws Exception {
- createSarManager(true, false);
+ createSarManager(true, false, false);
when(mWifiNative.selectTxPowerScenario(any(SarInfo.class))).thenReturn(false);
InOrder inOrder = inOrder(mWifiNative);
@@ -516,17 +522,17 @@ public class SarManagerTest {
assertNotNull(mSarInfo);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertFalse(mSarInfo.isVoiceCall);
/* Set phone state to OFFHOOK */
mPhoneStateListener.onCallStateChanged(CALL_STATE_OFFHOOK, "");
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertTrue(mSarInfo.mIsVoiceCall);
+ assertTrue(mSarInfo.isVoiceCall);
/* Set state back to ONHOOK */
mPhoneStateListener.onCallStateChanged(CALL_STATE_IDLE, "");
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertFalse(mSarInfo.isVoiceCall);
}
/**
@@ -535,7 +541,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_sarSensorOn_WifiOn_sensorEventsTriggered() throws Exception {
- createSarManager(true, true);
+ createSarManager(true, true, true);
InOrder inOrder = inOrder(mWifiNative);
@@ -544,31 +550,31 @@ public class SarManagerTest {
captureSarInfo(mWifiNative);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_FREE_SPACE, mSarInfo.mSensorState);
+ assertEquals(SarInfo.SAR_SENSOR_FREE_SPACE, mSarInfo.sensorState);
/* Sensor event */
sendSensorEvent(SAR_SENSOR_EVENT_BODY);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_BODY, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_BODY, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isVoiceCall);
/* Sensor event */
sendSensorEvent(SAR_SENSOR_EVENT_HEAD);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isVoiceCall);
/* Sensor event */
sendSensorEvent(SAR_SENSOR_EVENT_HAND);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HAND, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HAND, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isVoiceCall);
/* Sensor event */
sendSensorEvent(SAR_SENSOR_EVENT_FREE_SPACE);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_FREE_SPACE, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_FREE_SPACE, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isVoiceCall);
}
/**
@@ -578,7 +584,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_sarSensorOn_wifiOn_cellOn_sensorEventsTriggered() throws Exception {
- createSarManager(true, true);
+ createSarManager(true, true, true);
InOrder inOrder = inOrder(mWifiNative);
@@ -588,38 +594,38 @@ public class SarManagerTest {
/* Should get the an event with no calls */
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_FREE_SPACE, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_FREE_SPACE, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isVoiceCall);
/* Start a Cell call */
mPhoneStateListener.onCallStateChanged(CALL_STATE_OFFHOOK, "");
inOrder.verify(mWifiNative).selectTxPowerScenario(any(SarInfo.class));
- assertEquals(SarInfo.SAR_SENSOR_FREE_SPACE, mSarInfo.mSensorState);
- assertTrue(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_FREE_SPACE, mSarInfo.sensorState);
+ assertTrue(mSarInfo.isVoiceCall);
/* Sensor event */
sendSensorEvent(SAR_SENSOR_EVENT_BODY);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_BODY, mSarInfo.mSensorState);
- assertTrue(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_BODY, mSarInfo.sensorState);
+ assertTrue(mSarInfo.isVoiceCall);
/* Sensor event */
sendSensorEvent(SAR_SENSOR_EVENT_HEAD);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.mSensorState);
- assertTrue(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.sensorState);
+ assertTrue(mSarInfo.isVoiceCall);
/* Sensor event */
sendSensorEvent(SAR_SENSOR_EVENT_HAND);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HAND, mSarInfo.mSensorState);
- assertTrue(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HAND, mSarInfo.sensorState);
+ assertTrue(mSarInfo.isVoiceCall);
/* Sensor event */
sendSensorEvent(SAR_SENSOR_EVENT_FREE_SPACE);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_FREE_SPACE, mSarInfo.mSensorState);
- assertTrue(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_FREE_SPACE, mSarInfo.sensorState);
+ assertTrue(mSarInfo.isVoiceCall);
}
/**
@@ -629,7 +635,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_sarSensorOn_wifiOn_onHead_cellOnOff() throws Exception {
- createSarManager(true, true);
+ createSarManager(true, true, true);
InOrder inOrder = inOrder(mWifiNative);
@@ -638,26 +644,27 @@ public class SarManagerTest {
captureSarInfo(mWifiNative);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_FREE_SPACE, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_FREE_SPACE, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isVoiceCall);
/* Sensor event */
sendSensorEvent(SAR_SENSOR_EVENT_HEAD);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isVoiceCall);
+
/* Start a Cell call */
mPhoneStateListener.onCallStateChanged(CALL_STATE_OFFHOOK, "");
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.mSensorState);
- assertTrue(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.sensorState);
+ assertTrue(mSarInfo.isVoiceCall);
/* End a Cell call */
mPhoneStateListener.onCallStateChanged(CALL_STATE_IDLE, "");
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isVoiceCall);
}
/**
@@ -668,7 +675,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_sarSensorOn_WifiOffOn_sensorEventTriggered() throws Exception {
- createSarManager(true, true);
+ createSarManager(true, true, true);
InOrder inOrder = inOrder(mWifiNative);
@@ -681,8 +688,8 @@ public class SarManagerTest {
captureSarInfo(mWifiNative);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_BODY, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_BODY, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isVoiceCall);
}
/**
@@ -703,20 +710,20 @@ public class SarManagerTest {
captureSarInfo(mWifiNative);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isVoiceCall);
/* Start a Cell Call */
mPhoneStateListener.onCallStateChanged(CALL_STATE_OFFHOOK, "");
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.mSensorState);
- assertTrue(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.sensorState);
+ assertTrue(mSarInfo.isVoiceCall);
/* End the call */
mPhoneStateListener.onCallStateChanged(CALL_STATE_IDLE, "");
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isVoiceCall);
}
/**
@@ -737,20 +744,20 @@ public class SarManagerTest {
captureSarInfo(mWifiNative);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isVoiceCall);
/* Start a Cell Call */
mPhoneStateListener.onCallStateChanged(CALL_STATE_OFFHOOK, "");
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.mSensorState);
- assertTrue(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.sensorState);
+ assertTrue(mSarInfo.isVoiceCall);
/* End the call */
mPhoneStateListener.onCallStateChanged(CALL_STATE_IDLE, "");
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isVoiceCall);
}
/**
@@ -771,20 +778,20 @@ public class SarManagerTest {
captureSarInfo(mWifiNative);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isVoiceCall);
/* Start a Cell Call */
mPhoneStateListener.onCallStateChanged(CALL_STATE_OFFHOOK, "");
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.mSensorState);
- assertTrue(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.sensorState);
+ assertTrue(mSarInfo.isVoiceCall);
/* End the call */
mPhoneStateListener.onCallStateChanged(CALL_STATE_IDLE, "");
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsVoiceCall);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isVoiceCall);
}
/**
@@ -793,7 +800,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_disabledTxPowerScenario_sapOn() throws Exception {
- createSarManager(false, false);
+ createSarManager(false, false, false);
/* Enable WiFi SoftAP State */
mSarMgr.setSapWifiState(WifiManager.WIFI_AP_STATE_ENABLED);
@@ -806,7 +813,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_enabledTxPowerScenario_sapOn() throws Exception {
- createSarManager(true, false);
+ createSarManager(true, false, false);
InOrder inOrder = inOrder(mWifiNative);
@@ -815,9 +822,9 @@ public class SarManagerTest {
captureSarInfo(mWifiNative);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsVoiceCall);
- assertTrue(mSarInfo.mIsWifiSapEnabled);
- assertFalse(mSarInfo.mIsWifiScanOnlyEnabled);
+ assertFalse(mSarInfo.isVoiceCall);
+ assertTrue(mSarInfo.isWifiSapEnabled);
+ assertFalse(mSarInfo.isWifiScanOnlyEnabled);
}
/**
@@ -826,7 +833,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_enabledTxPowerScenario_staOn_sapOnOff() throws Exception {
- createSarManager(true, true);
+ createSarManager(true, true, true);
InOrder inOrder = inOrder(mWifiNative);
@@ -839,20 +846,20 @@ public class SarManagerTest {
captureSarInfo(mWifiNative);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsWifiSapEnabled);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isWifiSapEnabled);
/* Enable WiFi SoftAP State */
mSarMgr.setSapWifiState(WifiManager.WIFI_AP_STATE_ENABLED);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.mSensorState);
- assertTrue(mSarInfo.mIsWifiSapEnabled);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.sensorState);
+ assertTrue(mSarInfo.isWifiSapEnabled);
/* Disable Wifi SoftAP state */
mSarMgr.setSapWifiState(WifiManager.WIFI_AP_STATE_DISABLED);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsWifiSapEnabled);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_HEAD, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isWifiSapEnabled);
}
/**
@@ -864,7 +871,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_enabledTxPowerScenario_sapOnOff_staOffOn() throws Exception {
- createSarManager(true, true);
+ createSarManager(true, true, true);
InOrder inOrder = inOrder(mWifiNative);
@@ -877,8 +884,8 @@ public class SarManagerTest {
captureSarInfo(mWifiNative);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_BODY, mSarInfo.mSensorState);
- assertTrue(mSarInfo.mIsWifiSapEnabled);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_BODY, mSarInfo.sensorState);
+ assertTrue(mSarInfo.isWifiSapEnabled);
/* Disable Wifi SoftAP state */
mSarMgr.setSapWifiState(WifiManager.WIFI_AP_STATE_DISABLED);
@@ -887,8 +894,8 @@ public class SarManagerTest {
/* Enable WiFi Clinet State */
mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_ENABLED);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertEquals(SarInfo.SAR_SENSOR_NEAR_BODY, mSarInfo.mSensorState);
- assertFalse(mSarInfo.mIsWifiSapEnabled);
+ assertEquals(SarInfo.SAR_SENSOR_NEAR_BODY, mSarInfo.sensorState);
+ assertFalse(mSarInfo.isWifiSapEnabled);
}
/**
@@ -897,15 +904,15 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_enabledTxPowerScenario_staOff_sapOff_scanOnlyOn() throws Exception {
- createSarManager(true, false);
+ createSarManager(true, false, false);
/* Enable Wifi ScanOnly State */
mSarMgr.setScanOnlyWifiState(WifiManager.WIFI_STATE_ENABLED);
captureSarInfo(mWifiNative);
verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsWifiSapEnabled);
- assertTrue(mSarInfo.mIsWifiScanOnlyEnabled);
+ assertFalse(mSarInfo.isWifiSapEnabled);
+ assertTrue(mSarInfo.isWifiScanOnlyEnabled);
}
/**
@@ -914,7 +921,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_enabledTxPowerScenario_staOn_sapOff_scanOnlyOn() throws Exception {
- createSarManager(true, false);
+ createSarManager(true, false, false);
InOrder inOrder = inOrder(mWifiNative);
@@ -923,8 +930,8 @@ public class SarManagerTest {
captureSarInfo(mWifiNative);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsWifiSapEnabled);
- assertTrue(mSarInfo.mIsWifiScanOnlyEnabled);
+ assertFalse(mSarInfo.isWifiSapEnabled);
+ assertTrue(mSarInfo.isWifiScanOnlyEnabled);
/* Now enable Client state */
mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_ENABLED);
@@ -940,7 +947,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_enabledTxPowerScenario_wifi_sap_scanOnly() throws Exception {
- createSarManager(true, false);
+ createSarManager(true, false, false);
InOrder inOrder = inOrder(mWifiNative);
@@ -949,16 +956,16 @@ public class SarManagerTest {
captureSarInfo(mWifiNative);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsVoiceCall);
- assertFalse(mSarInfo.mIsWifiSapEnabled);
- assertFalse(mSarInfo.mIsWifiScanOnlyEnabled);
+ assertFalse(mSarInfo.isVoiceCall);
+ assertFalse(mSarInfo.isWifiSapEnabled);
+ assertFalse(mSarInfo.isWifiScanOnlyEnabled);
/* Enable SoftAP state */
mSarMgr.setSapWifiState(WifiManager.WIFI_AP_STATE_ENABLED);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsVoiceCall);
- assertTrue(mSarInfo.mIsWifiSapEnabled);
- assertFalse(mSarInfo.mIsWifiScanOnlyEnabled);
+ assertFalse(mSarInfo.isVoiceCall);
+ assertTrue(mSarInfo.isWifiSapEnabled);
+ assertFalse(mSarInfo.isWifiScanOnlyEnabled);
/* Disable WiFi State */
mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_DISABLED);
@@ -971,9 +978,9 @@ public class SarManagerTest {
/* Disable SoftAP state */
mSarMgr.setSapWifiState(WifiManager.WIFI_AP_STATE_DISABLED);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsVoiceCall);
- assertFalse(mSarInfo.mIsWifiSapEnabled);
- assertTrue(mSarInfo.mIsWifiScanOnlyEnabled);
+ assertFalse(mSarInfo.isVoiceCall);
+ assertFalse(mSarInfo.isWifiSapEnabled);
+ assertTrue(mSarInfo.isWifiScanOnlyEnabled);
}
/**
@@ -983,7 +990,7 @@ public class SarManagerTest {
*/
@Test
public void testSarMgr_enabledTxPowerScenario_error_wifi_sap_scanOnly() throws Exception {
- createSarManager(true, false);
+ createSarManager(true, false, false);
when(mWifiNative.selectTxPowerScenario(any(SarInfo.class))).thenReturn(false);
InOrder inOrder = inOrder(mWifiNative);
@@ -993,39 +1000,39 @@ public class SarManagerTest {
captureSarInfo(mWifiNative);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsVoiceCall);
- assertFalse(mSarInfo.mIsWifiSapEnabled);
- assertFalse(mSarInfo.mIsWifiScanOnlyEnabled);
+ assertFalse(mSarInfo.isVoiceCall);
+ assertFalse(mSarInfo.isWifiSapEnabled);
+ assertFalse(mSarInfo.isWifiScanOnlyEnabled);
/* Enable SoftAP state */
mSarMgr.setSapWifiState(WifiManager.WIFI_AP_STATE_ENABLED);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsVoiceCall);
- assertTrue(mSarInfo.mIsWifiSapEnabled);
- assertFalse(mSarInfo.mIsWifiScanOnlyEnabled);
+ assertFalse(mSarInfo.isVoiceCall);
+ assertTrue(mSarInfo.isWifiSapEnabled);
+ assertFalse(mSarInfo.isWifiScanOnlyEnabled);
/* Disable WiFi State, reporting should still happen */
mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_DISABLED);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsVoiceCall);
- assertTrue(mSarInfo.mIsWifiSapEnabled);
- assertFalse(mSarInfo.mIsWifiScanOnlyEnabled);
- assertFalse(mSarInfo.mIsWifiClientEnabled);
+ assertFalse(mSarInfo.isVoiceCall);
+ assertTrue(mSarInfo.isWifiSapEnabled);
+ assertFalse(mSarInfo.isWifiScanOnlyEnabled);
+ assertFalse(mSarInfo.isWifiClientEnabled);
/* Enable ScanOnly state */
mSarMgr.setScanOnlyWifiState(WifiManager.WIFI_STATE_ENABLED);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsVoiceCall);
- assertTrue(mSarInfo.mIsWifiSapEnabled);
- assertTrue(mSarInfo.mIsWifiScanOnlyEnabled);
- assertFalse(mSarInfo.mIsWifiClientEnabled);
+ assertFalse(mSarInfo.isVoiceCall);
+ assertTrue(mSarInfo.isWifiSapEnabled);
+ assertTrue(mSarInfo.isWifiScanOnlyEnabled);
+ assertFalse(mSarInfo.isWifiClientEnabled);
/* Disable SoftAP state */
mSarMgr.setSapWifiState(WifiManager.WIFI_AP_STATE_DISABLED);
inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
- assertFalse(mSarInfo.mIsVoiceCall);
- assertFalse(mSarInfo.mIsWifiSapEnabled);
- assertTrue(mSarInfo.mIsWifiScanOnlyEnabled);
- assertFalse(mSarInfo.mIsWifiClientEnabled);
+ assertFalse(mSarInfo.isVoiceCall);
+ assertFalse(mSarInfo.isWifiSapEnabled);
+ assertTrue(mSarInfo.isWifiScanOnlyEnabled);
+ assertFalse(mSarInfo.isWifiClientEnabled);
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java
index fbdc8f507..abec9dc8b 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java
@@ -593,7 +593,7 @@ public class WifiNativeTest {
@Test
public void testSelectTxPowerScenario_success() throws Exception {
when(mWifiVendorHal.selectTxPowerScenario(any(SarInfo.class))).thenReturn(true);
- SarInfo sarInfo = new SarInfo(true);
+ SarInfo sarInfo = new SarInfo();
assertTrue(mWifiNative.selectTxPowerScenario(sarInfo));
verify(mWifiVendorHal).selectTxPowerScenario(sarInfo);
}
@@ -604,7 +604,7 @@ public class WifiNativeTest {
@Test
public void testSelectTxPowerScenario_failure() throws Exception {
when(mWifiVendorHal.selectTxPowerScenario(any(SarInfo.class))).thenReturn(false);
- SarInfo sarInfo = new SarInfo(true);
+ SarInfo sarInfo = new SarInfo();
assertFalse(mWifiNative.selectTxPowerScenario(sarInfo));
verify(mWifiVendorHal).selectTxPowerScenario(sarInfo);
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
index fc030b83c..f089ebbe7 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
@@ -2006,8 +2006,8 @@ public class WifiVendorHalTest {
@Test
public void testSelectTxPowerScenario_1_0() throws RemoteException {
// Create a SAR info record (no sensor support)
- SarInfo sarInfo = new SarInfo(false);
- sarInfo.mIsVoiceCall = true;
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.isVoiceCall = true;
assertTrue(mWifiVendorHal.startVendorHalSta());
// Should fail because we exposed the 1.0 IWifiChip.
@@ -2023,8 +2023,12 @@ public class WifiVendorHalTest {
@Test
public void testSelectTxPowerScenario_1_1() throws RemoteException {
// Create a SAR info record (no sensor support)
- SarInfo sarInfo = new SarInfo(false);
- sarInfo.mIsVoiceCall = true;
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.sarVoiceCallSupported = true;
+ sarInfo.sarSapSupported = false;
+ sarInfo.sarSensorSupported = false;
+
+ sarInfo.isVoiceCall = true;
// Now expose the 1.1 IWifiChip.
mWifiVendorHal = new WifiVendorHalSpyV1_1(mHalDeviceManager, mLooper.getLooper());
@@ -2045,8 +2049,12 @@ public class WifiVendorHalTest {
@Test
public void testSelectTxPowerScenario_1_2() throws RemoteException {
// Create a SAR info record (no sensor support)
- SarInfo sarInfo = new SarInfo(false);
- sarInfo.mIsVoiceCall = true;
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.sarVoiceCallSupported = true;
+ sarInfo.sarSapSupported = false;
+ sarInfo.sarSensorSupported = false;
+
+ sarInfo.isVoiceCall = true;
// Now expose the 1.2 IWifiChip
mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
@@ -2067,7 +2075,7 @@ public class WifiVendorHalTest {
@Test
public void testResetTxPowerScenario_1_0() throws RemoteException {
// Create a SAR info record (no sensor support)
- SarInfo sarInfo = new SarInfo(false);
+ SarInfo sarInfo = new SarInfo();
assertTrue(mWifiVendorHal.startVendorHalSta());
// Should fail because we exposed the 1.0 IWifiChip.
@@ -2083,7 +2091,10 @@ public class WifiVendorHalTest {
@Test
public void testResetTxPowerScenario_1_1() throws RemoteException {
// Create a SAR info record (no sensor support)
- SarInfo sarInfo = new SarInfo(false);
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.sarVoiceCallSupported = true;
+ sarInfo.sarSapSupported = false;
+ sarInfo.sarSensorSupported = false;
// Now expose the 1.1 IWifiChip.
mWifiVendorHal = new WifiVendorHalSpyV1_1(mHalDeviceManager, mLooper.getLooper());
@@ -2105,8 +2116,11 @@ public class WifiVendorHalTest {
public void testResetTxPowerScenario_not_needed_1_1() throws RemoteException {
InOrder inOrder = inOrder(mIWifiChipV11);
- // Create a SAR info record (no sensor support)
- SarInfo sarInfo = new SarInfo(false);
+ // Create a SAR info record (no sensor or SAP support)
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.sarVoiceCallSupported = true;
+ sarInfo.sarSapSupported = false;
+ sarInfo.sarSensorSupported = false;
// Now expose the 1.1 IWifiChip.
mWifiVendorHal = new WifiVendorHalSpyV1_1(mHalDeviceManager, mLooper.getLooper());
@@ -2134,8 +2148,11 @@ public class WifiVendorHalTest {
*/
@Test
public void testResetTxPowerScenario_1_2() throws RemoteException {
- // Create a SAR info record (no sensor support)
- SarInfo sarInfo = new SarInfo(false);
+ // Create a SAR info record (no sensor or SAP support)
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.sarVoiceCallSupported = true;
+ sarInfo.sarSapSupported = false;
+ sarInfo.sarSensorSupported = false;
// Now expose the 1.2 IWifiChip.
mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
@@ -2157,8 +2174,11 @@ public class WifiVendorHalTest {
public void testResetTxPowerScenario_not_needed_1_2() throws RemoteException {
InOrder inOrder = inOrder(mIWifiChipV12);
- // Create a SAR info record (no sensor support)
- SarInfo sarInfo = new SarInfo(false);
+ // Create a SAR info record (no sensor or SAP support)
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.sarVoiceCallSupported = true;
+ sarInfo.sarSapSupported = false;
+ sarInfo.sarSensorSupported = false;
// Now expose the 1.2 IWifiChip.
mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
@@ -2180,15 +2200,77 @@ public class WifiVendorHalTest {
mWifiVendorHal.stopVendorHal();
}
+ /**
+ * Test the selectTxPowerScenario HIDL method invocation with no sensor support, but with
+ * SAP and voice call support.
+ * When SAP is enabled, should result in SAP with near body scenario
+ * Using IWifiChip 1.2 interface
+ */
+ @Test
+ public void testSapScenarios_SelectTxPowerV1_2() throws RemoteException {
+ // Create a SAR info record (with sensor and SAP support)
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.sarVoiceCallSupported = true;
+ sarInfo.sarSapSupported = true;
+ sarInfo.sarSensorSupported = false;
+
+ sarInfo.isWifiSapEnabled = true;
+
+ // Expose the 1.2 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
+ when(mIWifiChipV12.selectTxPowerScenario_1_2(anyInt())).thenReturn(mWifiStatusSuccess);
+
+ // ON_BODY_CELL_ON
+ assertTrue(mWifiVendorHal.startVendorHalSta());
+ assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo));
+ verify(mIWifiChipV12).selectTxPowerScenario_1_2(
+ eq(android.hardware.wifi.V1_2.IWifiChip.TxPowerScenario.ON_BODY_CELL_ON));
+ verify(mIWifiChipV12, never()).resetTxPowerScenario();
+ mWifiVendorHal.stopVendorHal();
+ }
+
+ /**
+ * Test the selectTxPowerScenario HIDL method invocation with no sensor support, but with
+ * SAP and voice call support.
+ * When a voice call is ongoing, should result in cell with near head scenario
+ * Using IWifiChip 1.2 interface
+ */
+ @Test
+ public void testVoiceCallScenarios_SelectTxPowerV1_2() throws RemoteException {
+ // Create a SAR info record (with sensor and SAP support)
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.sarVoiceCallSupported = true;
+ sarInfo.sarSapSupported = true;
+ sarInfo.sarSensorSupported = false;
+
+ sarInfo.isVoiceCall = true;
+
+ // Expose the 1.2 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
+ when(mIWifiChipV12.selectTxPowerScenario_1_2(anyInt())).thenReturn(mWifiStatusSuccess);
+
+ // ON_HEAD_CELL_ON
+ assertTrue(mWifiVendorHal.startVendorHalSta());
+ assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo));
+ verify(mIWifiChipV12).selectTxPowerScenario_1_2(
+ eq(android.hardware.wifi.V1_2.IWifiChip.TxPowerScenario.ON_HEAD_CELL_ON));
+ verify(mIWifiChipV12, never()).resetTxPowerScenario();
+ mWifiVendorHal.stopVendorHal();
+ }
+
/**
* Test the selectTxPowerScenario HIDL method invocation with sensor related scenarios
* to IWifiChip 1.2 interface
*/
@Test
public void testHeadSensorScenarios_SelectTxPowerV1_2() throws RemoteException {
- // Create a SAR info record (with sensor support)
- SarInfo sarInfo = new SarInfo(true);
- sarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
+ // Create a SAR info record (with sensor and SAP support)
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.sarVoiceCallSupported = true;
+ sarInfo.sarSapSupported = true;
+ sarInfo.sarSensorSupported = true;
+
+ sarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
// Expose the 1.2 IWifiChip.
mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
@@ -2212,9 +2294,13 @@ public class WifiVendorHalTest {
public void testSetTxPowerScenario_not_needed_1_2() throws RemoteException {
InOrder inOrder = inOrder(mIWifiChipV12);
- // Create a SAR info record (no sensor support)
- SarInfo sarInfo = new SarInfo(true);
- sarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
+ // Create a SAR info record (no sensor and SAP support)
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.sarVoiceCallSupported = true;
+ sarInfo.sarSapSupported = true;
+ sarInfo.sarSensorSupported = true;
+
+ sarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
// Now expose the 1.2 IWifiChip.
mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
@@ -2244,9 +2330,13 @@ public class WifiVendorHalTest {
*/
@Test
public void testHandSensorScenarios_SelectTxPowerV1_2() throws RemoteException {
- // Create a SAR info record (with sensor support)
- SarInfo sarInfo = new SarInfo(true);
- sarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HAND;
+ // Create a SAR info record (with sensor and SAR support)
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.sarVoiceCallSupported = true;
+ sarInfo.sarSapSupported = true;
+ sarInfo.sarSensorSupported = true;
+
+ sarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HAND;
// Expose the 1.2 IWifiChip.
mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
@@ -2260,7 +2350,7 @@ public class WifiVendorHalTest {
eq(android.hardware.wifi.V1_2.IWifiChip.TxPowerScenario.ON_BODY_CELL_OFF));
// Then select a scenario with cell on
- sarInfo.mIsVoiceCall = true;
+ sarInfo.isVoiceCall = true;
assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo));
verify(mIWifiChipV12).selectTxPowerScenario_1_2(
eq(android.hardware.wifi.V1_2.IWifiChip.TxPowerScenario.ON_BODY_CELL_ON));
@@ -2275,9 +2365,13 @@ public class WifiVendorHalTest {
*/
@Test
public void testOnHeadCellOffOn_SelectTxPowerScenarioV1_1() throws RemoteException {
- // Create a SAR info record (with sensor support)
- SarInfo sarInfo = new SarInfo(true);
- sarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
+ // Create a SAR info record (with sensor and SAP support)
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.sarVoiceCallSupported = true;
+ sarInfo.sarSapSupported = true;
+ sarInfo.sarSensorSupported = true;
+
+ sarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
// Expose the 1.1 IWifiChip.
mWifiVendorHal = new WifiVendorHalSpyV1_1(mHalDeviceManager, mLooper.getLooper());
@@ -2291,7 +2385,7 @@ public class WifiVendorHalTest {
verify(mIWifiChipV11).resetTxPowerScenario();
// Then select a scenario with cell on
- sarInfo.mIsVoiceCall = true;
+ sarInfo.isVoiceCall = true;
assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo));
verify(mIWifiChipV11).selectTxPowerScenario(
eq(android.hardware.wifi.V1_1.IWifiChip.TxPowerScenario.VOICE_CALL));
@@ -2306,9 +2400,13 @@ public class WifiVendorHalTest {
*/
@Test
public void testInvalidSelectTxPowerScenario_1_2() throws RemoteException {
- // Create a SAR info record (with sensor support)
- SarInfo sarInfo = new SarInfo(true);
- sarInfo.mSensorState = SAR_SENSOR_INVALID_STATE;
+ // Create a SAR info record (with sensor and SAP support)
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.sarVoiceCallSupported = true;
+ sarInfo.sarSapSupported = true;
+ sarInfo.sarSensorSupported = true;
+
+ sarInfo.sensorState = SAR_SENSOR_INVALID_STATE;
// Expose the 1.2 IWifiChip.
mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
@@ -2330,11 +2428,15 @@ public class WifiVendorHalTest {
*/
@Test
public void testSelectTxPowerScenario_1_2_head_sap() throws RemoteException {
- // Create a SAR info record (with sensor support)
- SarInfo sarInfo = new SarInfo(true);
- sarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
- sarInfo.mIsWifiSapEnabled = true;
- sarInfo.mIsVoiceCall = false;
+ // Create a SAR info record (with sensor and SAP support)
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.sarVoiceCallSupported = true;
+ sarInfo.sarSapSupported = true;
+ sarInfo.sarSensorSupported = true;
+
+ sarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
+ sarInfo.isWifiSapEnabled = true;
+ sarInfo.isVoiceCall = false;
// Expose the 1.2 IWifiChip.
mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
@@ -2358,11 +2460,15 @@ public class WifiVendorHalTest {
*/
@Test
public void testSelectTxPowerScenario_1_2_head_sap_call() throws RemoteException {
- // Create a SAR info record (with sensor support)
- SarInfo sarInfo = new SarInfo(true);
- sarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
- sarInfo.mIsWifiSapEnabled = true;
- sarInfo.mIsVoiceCall = true;
+ // Create a SAR info record (with sensor and SAP support)
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.sarVoiceCallSupported = true;
+ sarInfo.sarSapSupported = true;
+ sarInfo.sarSensorSupported = true;
+
+ sarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
+ sarInfo.isWifiSapEnabled = true;
+ sarInfo.isVoiceCall = true;
// Expose the 1.2 IWifiChip.
mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
@@ -2386,11 +2492,15 @@ public class WifiVendorHalTest {
*/
@Test
public void testSelectTxPowerScenario_1_2_freespace_sap() throws RemoteException {
- // Create a SAR info record (with sensor support)
- SarInfo sarInfo = new SarInfo(true);
- sarInfo.mSensorState = SarInfo.SAR_SENSOR_FREE_SPACE;
- sarInfo.mIsWifiSapEnabled = true;
- sarInfo.mIsVoiceCall = false;
+ // Create a SAR info record (with sensor and SAP support)
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.sarVoiceCallSupported = true;
+ sarInfo.sarSapSupported = true;
+ sarInfo.sarSensorSupported = true;
+
+ sarInfo.sensorState = SarInfo.SAR_SENSOR_FREE_SPACE;
+ sarInfo.isWifiSapEnabled = true;
+ sarInfo.isVoiceCall = false;
// Expose the 1.2 IWifiChip.
mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
@@ -2414,9 +2524,13 @@ public class WifiVendorHalTest {
@Test
public void testSelectTxPowerScenario_1_2_no_sensors_sap() throws RemoteException {
// Create a SAR info record (with no sensor support)
- SarInfo sarInfo = new SarInfo(false);
- sarInfo.mIsWifiSapEnabled = true;
- sarInfo.mIsVoiceCall = false;
+ SarInfo sarInfo = new SarInfo();
+ sarInfo.sarVoiceCallSupported = true;
+ sarInfo.sarSapSupported = true;
+ sarInfo.sarSensorSupported = true;
+
+ sarInfo.isWifiSapEnabled = true;
+ sarInfo.isVoiceCall = false;
// Expose the 1.2 IWifiChip.
mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());