diff options
author | Ahmed ElArabawy <arabawy@google.com> | 2018-07-12 13:48:55 -0700 |
---|---|---|
committer | Ahmed ElArabawy <arabawy@google.com> | 2018-07-18 12:33:25 -0700 |
commit | 8392e5dc1ec0c0e5e9ac5d40dac2a38a47b6b63d (patch) | |
tree | c551c6a884be8308e188bb1b3fb703e01b86a97b /tests | |
parent | a52e9108f44a2770dc7b0ce00bfb4493c3f8e65e (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 'tests')
4 files changed, 325 insertions, 204 deletions
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()); |