From 68328303fa28c9a7f8f89085cee5182661ccbc20 Mon Sep 17 00:00:00 2001 From: Ahmed ElArabawy Date: Sun, 10 Nov 2019 00:03:26 -0800 Subject: Remove SAR sensor handling This commit removes the handling of SAR sensors from framework code. Bug: 141275843 Test: atest com.android.server.wifi Change-Id: I284c7e344ffe767ce27f0bc795fde0666c7f61de --- .../src/com/android/server/wifi/SarInfoTest.java | 115 ----- .../com/android/server/wifi/SarManagerTest.java | 524 +-------------------- .../com/android/server/wifi/WifiMetricsTest.java | 7 - .../com/android/server/wifi/WifiVendorHalTest.java | 253 +--------- 4 files changed, 43 insertions(+), 856 deletions(-) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/SarInfoTest.java b/tests/wifitests/src/com/android/server/wifi/SarInfoTest.java index 72f48ffa4..96b6f99ea 100644 --- a/tests/wifitests/src/com/android/server/wifi/SarInfoTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SarInfoTest.java @@ -146,79 +146,8 @@ public class SarInfoTest extends WifiBaseTest { assertTrue(mSarInfo.shouldReport()); } - /** - * Test that setting sensor (with wifi disabled), shouldReport returns false. - */ - @Test - public void testSarInfo_check_sensor_wifi_disabled() throws Exception { - mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD; - assertFalse(mSarInfo.shouldReport()); - } - - /** - * Test that setting sensor (with some wifi mode enabled), shouldReport returns true. - */ - @Test - public void testSarInfo_check_sensor_wifi_enabled() throws Exception { - mSarInfo.isWifiSapEnabled = true; - assertTrue(mSarInfo.shouldReport()); - mSarInfo.reportingSuccessful(); - - mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD; - assertTrue(mSarInfo.shouldReport()); - } - - /** - * Test that setting sensor (with some wifi mode enabled), shouldReport returns true - * only the first time, following attempts should return false (since sensor state - * did not change) - */ - @Test - public void testSarInfo_check_sensor_multiple_wifi_enabled() throws Exception { - mSarInfo.isWifiScanOnlyEnabled = true; - mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD; - assertTrue(mSarInfo.shouldReport()); - mSarInfo.reportingSuccessful(); - - assertFalse(mSarInfo.shouldReport()); - } - - /** - * Test that setting sensor with different values (with wifi enabled), - * shouldReport returns true every time. - */ - @Test - public void testSarInfo_check_sensor_multiple_values_wifi_enabled() throws Exception { - mSarInfo.isWifiClientEnabled = true; - mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD; - assertTrue(mSarInfo.shouldReport()); - mSarInfo.reportingSuccessful(); - - mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_BODY; - assertTrue(mSarInfo.shouldReport()); - mSarInfo.reportingSuccessful(); - - mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD; - assertTrue(mSarInfo.shouldReport()); - } - - /** - * Test setting sensor while wifi is disabled, then enable wifi. - */ - @Test - public void testSarInfo_change_sensors_while_wifi_disabled() throws Exception { - mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD; - assertFalse(mSarInfo.shouldReport()); - - mSarInfo.isWifiClientEnabled = true; - assertTrue(mSarInfo.shouldReport()); - mSarInfo.reportingSuccessful(); - } - /** * Test having a voice call, shouldReport should return true - * Note: will need to report once before starting the call to remove - * the effect of sensor state change. */ @Test public void testSarInfo_voice_call_wifi_enabled() throws Exception { @@ -232,8 +161,6 @@ public class SarInfoTest extends WifiBaseTest { /** * Test a change in earpiece status, shouldReport should return true - * Note: will need to report once before making the change to remove - * the effect of sensor state change. */ @Test public void testSarInfo_earpiece_wifi_enabled() throws Exception { @@ -247,8 +174,6 @@ public class SarInfoTest extends WifiBaseTest { /** * Test starting SAP, shouldReport should return true - * Note: will need to report once before starting SAP to remove - * the effect of sensor state change. */ @Test public void testSarInfo_sap_wifi_enabled() throws Exception { @@ -259,44 +184,4 @@ public class SarInfoTest extends WifiBaseTest { mSarInfo.isWifiSapEnabled = true; assertTrue(mSarInfo.shouldReport()); } - - /** - * Test that setting sensor (with wifi enabled), reporting not successful - * Then, we should expect that shouldReport returns true evne if we have - * no further changes until reporting is successful. - */ - @Test - public void testSarInfo_check_sensor_reporting_no_success_reporting() throws Exception { - mSarInfo.isWifiClientEnabled = true; - mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD; - assertTrue(mSarInfo.shouldReport()); - - /* No call to reportingSuccessful() will be done */ - assertTrue(mSarInfo.shouldReport()); - - /* Now call reportingSuccessful() */ - mSarInfo.reportingSuccessful(); - assertFalse(mSarInfo.shouldReport()); - } - - /** - * Test that setting sensor (with wifi enabled), reporting successful - * Then, changing the sensor state with no successful reporting. - * Followed by reverting to the previous state. - */ - @Test - public void testSarInfo_check_sensor_reporting_no_success_reporting_revert() throws Exception { - mSarInfo.isWifiClientEnabled = true; - mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD; - assertTrue(mSarInfo.shouldReport()); - mSarInfo.reportingSuccessful(); - - /* Changing the sensor state and fail to report */ - mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_BODY; - assertTrue(mSarInfo.shouldReport()); - - /* Changing the sensor back to the same value as last reported */ - 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 85eecbc0c..f6db3dd3f 100644 --- a/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java @@ -19,19 +19,13 @@ package com.android.server.wifi; import static android.telephony.TelephonyManager.CALL_STATE_IDLE; import static android.telephony.TelephonyManager.CALL_STATE_OFFHOOK; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import static org.mockito.Mockito.*; import android.content.Context; import android.content.pm.ApplicationInfo; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SystemSensorManager; import android.net.wifi.WifiManager; import android.os.Build; import android.os.test.TestLooper; @@ -50,11 +44,6 @@ import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; - /** * unit tests for {@link com.android.server.wifi.SarManager}. */ @@ -62,12 +51,6 @@ import java.util.List; public class SarManagerTest extends WifiBaseTest { private static final String TAG = "WifiSarManagerTest"; private static final String OP_PACKAGE_NAME = "com.xxx"; - private static final String SAR_SENSOR_NAME = "com.google.sensor.sar"; - - private static final int SAR_SENSOR_EVENT_FREE_SPACE = 1; - private static final int SAR_SENSOR_EVENT_HAND = 2; - private static final int SAR_SENSOR_EVENT_HEAD = 3; - private static final int SAR_SENSOR_EVENT_BODY = 4; private void enableDebugLogs() { mSarMgr.enableVerboseLogging(1); @@ -82,17 +65,12 @@ public class SarManagerTest extends WifiBaseTest { private TestLooper mLooper; private MockResources mResources; private PhoneStateListener mPhoneStateListener; - private List mSensorList; - private Sensor mSensor; private SarInfo mSarInfo; @Mock private Context mContext; - @Mock SensorEventListener mSensorEventListener; - @Mock SystemSensorManager mSensorManager; @Mock TelephonyManager mTelephonyManager; @Mock private ApplicationInfo mMockApplInfo; @Mock WifiNative mWifiNative; - @Mock WifiMetrics mWifiMetrics; @Before public void setUp() throws Exception { @@ -124,79 +102,26 @@ public class SarManagerTest extends WifiBaseTest { * Helper function to capture SarInfo object */ private void captureSarInfo(WifiNative wifiNative) { - /* Capture the SensorEventListener */ + /* Capture the SarInfo */ ArgumentCaptor sarInfoCaptor = ArgumentCaptor.forClass(SarInfo.class); verify(wifiNative).selectTxPowerScenario(sarInfoCaptor.capture()); mSarInfo = sarInfoCaptor.getValue(); assertNotNull(mSarInfo); } - /** - * Helper function to create and prepare sensor info - */ - private void prepareSensorInfo(boolean registerReturn) { - /* Create a sensor object (note, this can not be mocked since it is a final class) */ - Constructor constructor = - (Constructor) Sensor.class.getDeclaredConstructors()[0]; - constructor.setAccessible(true); - - try { - mSensor = constructor.newInstance(); - } catch (Exception e) { - fail("Failed to create a sensor object"); - } - - /* Now set the mStringType field with the proper field */ - Field declaredField = null; - try { - declaredField = Sensor.class.getDeclaredField("mStringType"); - declaredField.setAccessible(true); - declaredField.set(mSensor, SAR_SENSOR_NAME); - } catch (Exception e) { - fail("Could not set sensor string type"); - } - - /* Prepare the sensor list */ - mSensorList = new ArrayList(); - mSensorList.add(mSensor); - when(mSensorManager.getSensorList(Sensor.TYPE_ALL)).thenReturn(mSensorList); - when(mSensorManager.registerListener(any(SensorEventListener.class), any(Sensor.class), - anyInt())).thenReturn(registerReturn); - } - /** * Helper function to set configuration for SAR and create the SAR Manager * */ - private void createSarManager(boolean isSarEnabled, boolean isSarSapEnabled, - boolean isSarSensorEnabled) { + private void createSarManager(boolean isSarEnabled, boolean isSarSapEnabled) { 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); - - /* Set the event id configs */ - mResources.setInteger(R.integer.config_wifi_framework_sar_free_space_event_id, - SAR_SENSOR_EVENT_FREE_SPACE); - mResources.setInteger(R.integer.config_wifi_framework_sar_near_hand_event_id, - SAR_SENSOR_EVENT_HAND); - mResources.setInteger(R.integer.config_wifi_framework_sar_near_head_event_id, - SAR_SENSOR_EVENT_HEAD); - mResources.setInteger(R.integer.config_wifi_framework_sar_near_body_event_id, - SAR_SENSOR_EVENT_BODY); - - /* Prepare sensor info only if SarSensorEnabled */ - if (isSarSensorEnabled) { - prepareSensorInfo(true); - } mSarMgr = new SarManager(mContext, mTelephonyManager, mLooper.getLooper(), - mWifiNative, mSensorManager, mWifiMetrics); + mWifiNative); if (isSarEnabled) { /* Capture the PhoneStateListener */ @@ -208,89 +133,17 @@ public class SarManagerTest extends WifiBaseTest { assertNotNull(mPhoneStateListener); } - if (isSarSensorEnabled) { - /* Capture the SensorEventListener */ - ArgumentCaptor sensorEventListenerCaptor = - ArgumentCaptor.forClass(SensorEventListener.class); - verify(mSensorManager).registerListener(sensorEventListenerCaptor.capture(), - any(Sensor.class), anyInt()); - mSensorEventListener = sensorEventListenerCaptor.getValue(); - assertNotNull(mSensorEventListener); - } - - verify(mWifiMetrics, never()).incrementNumSarSensorRegistrationFailures(); - - /* Enable logs from SarManager */ - enableDebugLogs(); - } - - /** - * Helper function to create SarManager with some error cases for sensor handling - */ - private void createSarManagerSensorNegTest(String configSensorName, boolean addToConfigs, - boolean sensorRegisterReturn) { - 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); - } - - /* Set the event id configs */ - mResources.setInteger(R.integer.config_wifi_framework_sar_free_space_event_id, - SAR_SENSOR_EVENT_FREE_SPACE); - mResources.setInteger(R.integer.config_wifi_framework_sar_near_hand_event_id, - SAR_SENSOR_EVENT_HAND); - mResources.setInteger(R.integer.config_wifi_framework_sar_near_head_event_id, - SAR_SENSOR_EVENT_HEAD); - mResources.setInteger(R.integer.config_wifi_framework_sar_near_body_event_id, - SAR_SENSOR_EVENT_BODY); - - prepareSensorInfo(sensorRegisterReturn); - - mSarMgr = new SarManager(mContext, mTelephonyManager, mLooper.getLooper(), - mWifiNative, mSensorManager, mWifiMetrics); - - /* Capture the PhoneStateListener */ - ArgumentCaptor phoneStateListenerCaptor = - ArgumentCaptor.forClass(PhoneStateListener.class); - verify(mTelephonyManager).listen(phoneStateListenerCaptor.capture(), - eq(PhoneStateListener.LISTEN_CALL_STATE)); - mPhoneStateListener = phoneStateListenerCaptor.getValue(); - assertNotNull(mPhoneStateListener); - /* Enable logs from SarManager */ enableDebugLogs(); } - /** - * Helper function to create and pass a sensor event - */ - private void sendSensorEvent(int eventId) { - SensorEvent event; - Constructor constructor = - (Constructor) SensorEvent.class.getDeclaredConstructors()[0]; - constructor.setAccessible(true); - - try { - event = constructor.newInstance(1); - event.values[0] = (float) eventId; - mSensorEventListener.onSensorChanged(event); - } catch (Exception e) { - fail("Failed to create a Sensor Event"); - } - } - /** * Test that we do register the telephony call state listener on devices which do support * setting/resetting Tx power limit. */ @Test public void testSarMgr_enabledTxPowerScenario_registerPhone() throws Exception { - createSarManager(true, false, false); + createSarManager(true, false); verify(mTelephonyManager).listen(any(), eq(PhoneStateListener.LISTEN_CALL_STATE)); } @@ -300,7 +153,7 @@ public class SarManagerTest extends WifiBaseTest { */ @Test public void testSarMgr_disabledTxPowerScenario_registerPhone() throws Exception { - createSarManager(false, false, false); + createSarManager(false, false); verify(mTelephonyManager, never()).listen(any(), anyInt()); } @@ -312,7 +165,7 @@ public class SarManagerTest extends WifiBaseTest { */ @Test public void testSarMgr_enabledTxPowerScenario_wifiOn_offHook() throws Exception { - createSarManager(true, false, false); + createSarManager(true, false); InOrder inOrder = inOrder(mWifiNative); @@ -337,7 +190,7 @@ public class SarManagerTest extends WifiBaseTest { */ @Test public void testSarMgr_enabledTxPowerScenario_offHook_wifiOn() throws Exception { - createSarManager(true, false, false); + createSarManager(true, false); InOrder inOrder = inOrder(mWifiNative); @@ -359,7 +212,7 @@ public class SarManagerTest extends WifiBaseTest { */ @Test public void testSarMgr_enabledTxPowerScenario_wifiOn_offHook_onHook() throws Exception { - createSarManager(true, false, false); + createSarManager(true, false); InOrder inOrder = inOrder(mWifiNative); @@ -397,7 +250,7 @@ public class SarManagerTest extends WifiBaseTest { */ @Test public void testSarMgr_enabledTxPowerScenario_wifiOff_offHook_onHook() throws Exception { - createSarManager(true, false, false); + createSarManager(true, false); InOrder inOrder = inOrder(mWifiNative); @@ -421,7 +274,7 @@ public class SarManagerTest extends WifiBaseTest { */ @Test public void testSarMgr_enabledSar_wifiOn_offHook_wifiOff_onHook() throws Exception { - createSarManager(true, false, false); + createSarManager(true, false); InOrder inOrder = inOrder(mWifiNative); @@ -458,7 +311,7 @@ public class SarManagerTest extends WifiBaseTest { */ @Test public void testSarMgr_enabledSar_wifiOff_offHook_onHook_wifiOn() throws Exception { - createSarManager(true, false, false); + createSarManager(true, false); InOrder inOrder = inOrder(mWifiNative); @@ -484,7 +337,7 @@ public class SarManagerTest extends WifiBaseTest { */ @Test public void testSarMgr_enabledSar_offHook_wifiOnOff_onHook() throws Exception { - createSarManager(true, false, false); + createSarManager(true, false); InOrder inOrder = inOrder(mWifiNative); @@ -515,7 +368,7 @@ public class SarManagerTest extends WifiBaseTest { */ @Test public void testSarMgr_enabledSar_error_wifiOn_offOnHook() throws Exception { - createSarManager(true, false, false); + createSarManager(true, false); when(mWifiNative.selectTxPowerScenario(any(SarInfo.class))).thenReturn(false); InOrder inOrder = inOrder(mWifiNative); @@ -539,275 +392,13 @@ public class SarManagerTest extends WifiBaseTest { assertFalse(mSarInfo.isVoiceCall); } - /** - * Test that for a device that has SAR enabled, with sar sensor enabled, - * wifi enabled, Then Tx power scenarios follow events from sensor for body/hand/head/none - */ - @Test - public void testSarMgr_sarSensorOn_WifiOn_sensorEventsTriggered() throws Exception { - createSarManager(true, true, true); - - InOrder inOrder = inOrder(mWifiNative); - - /* Enable Wifi Client */ - mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_ENABLED); - captureSarInfo(mWifiNative); - - inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo)); - 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.sensorState); - assertFalse(mSarInfo.isVoiceCall); - - /* Sensor event */ - sendSensorEvent(SAR_SENSOR_EVENT_HEAD); - inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo)); - 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.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.sensorState); - assertFalse(mSarInfo.isVoiceCall); - } - - /** - * Test that for a device that has SAR enabled, with sar sensor enabled, - * wifi enabled, cellOn, - * then Tx power scenarios follow events from sensor for body/hand/head/none - */ - @Test - public void testSarMgr_sarSensorOn_wifiOn_cellOn_sensorEventsTriggered() throws Exception { - createSarManager(true, true, true); - - InOrder inOrder = inOrder(mWifiNative); - - /* Enable Wifi Client */ - mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_ENABLED); - captureSarInfo(mWifiNative); - - /* Should get the an event with no calls */ - inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo)); - 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.sensorState); - assertTrue(mSarInfo.isVoiceCall); - - /* Sensor event */ - sendSensorEvent(SAR_SENSOR_EVENT_BODY); - inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo)); - 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.sensorState); - assertTrue(mSarInfo.isVoiceCall); - - /* Sensor event */ - sendSensorEvent(SAR_SENSOR_EVENT_HAND); - inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo)); - 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.sensorState); - assertTrue(mSarInfo.isVoiceCall); - } - - /** - * Test that for a device that has SAR enabled, with sar sensor enabled, - * wifi enabled, device next to user head, a call has started and stopped, - * then Tx power scenarios should adjust properly - */ - @Test - public void testSarMgr_sarSensorOn_wifiOn_onHead_cellOnOff() throws Exception { - createSarManager(true, true, true); - - InOrder inOrder = inOrder(mWifiNative); - - /* Enable Wifi Client */ - mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_ENABLED); - captureSarInfo(mWifiNative); - - inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo)); - 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.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.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.sensorState); - assertFalse(mSarInfo.isVoiceCall); - } - - /** - * Test that for a device that has SAR enabled, with sar sensor enabled, - * all wifi states disabled, when a sensor event is triggered no setting of Tx power scenario - * is initiated. - * Then when Wifi is enabled, Tx power setting will be initiated to reflect the sensor event. - */ - @Test - public void testSarMgr_sarSensorOn_WifiOffOn_sensorEventTriggered() throws Exception { - createSarManager(true, true, true); - - InOrder inOrder = inOrder(mWifiNative); - - /* Sensor event */ - sendSensorEvent(SAR_SENSOR_EVENT_BODY); - inOrder.verify(mWifiNative, never()).selectTxPowerScenario(any(SarInfo.class)); - - /* Enable Wifi Client */ - mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_ENABLED); - captureSarInfo(mWifiNative); - - inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo)); - assertEquals(SarInfo.SAR_SENSOR_NEAR_BODY, mSarInfo.sensorState); - assertFalse(mSarInfo.isVoiceCall); - } - - /** - * Test the error case when SAR sensor name does not exist in configuration. - * In this case, SarManager should assume operation near head all the time. - */ - @Test - public void testSarMgr_error_sar_name_does_not_exist() throws Exception { - createSarManagerSensorNegTest(SAR_SENSOR_NAME, false, true); - - InOrder inOrder = inOrder(mWifiNative); - - verify(mSensorManager, never()).registerListener(any(SensorEventListener.class), - any(Sensor.class), anyInt()); - verify(mWifiMetrics).incrementNumSarSensorRegistrationFailures(); - - /* Enable WiFi Client */ - mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_ENABLED); - captureSarInfo(mWifiNative); - - inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo)); - 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.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.sensorState); - assertFalse(mSarInfo.isVoiceCall); - } - - /** - * Test the error case when SarManager uses the wrong sensor name in configuration. - * In this case, SarManager should assume operation near head all the time. - */ - @Test - public void testSarMgr_error_sar_name_mismatch() throws Exception { - createSarManagerSensorNegTest("wrong.sensor.name", true, true); - - InOrder inOrder = inOrder(mWifiNative); - - verify(mSensorManager, never()).registerListener(any(SensorEventListener.class), - any(Sensor.class), anyInt()); - verify(mWifiMetrics).incrementNumSarSensorRegistrationFailures(); - - /* Enable WiFi Client */ - mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_ENABLED); - captureSarInfo(mWifiNative); - - inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo)); - 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.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.sensorState); - assertFalse(mSarInfo.isVoiceCall); - } - - /** - * Test the error case when SarManager fails to register as a SensorEventListener. - * In this case, SarManager should assume operation near head all the time. - */ - @Test - public void testSarMgr_error_sar_register_failure() throws Exception { - createSarManagerSensorNegTest(SAR_SENSOR_NAME, true, false); - - verify(mSensorManager).registerListener(any(SensorEventListener.class), - any(Sensor.class), anyInt()); - verify(mWifiMetrics).incrementNumSarSensorRegistrationFailures(); - - InOrder inOrder = inOrder(mWifiNative); - - /* Enable WiFi Client */ - mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_ENABLED); - captureSarInfo(mWifiNative); - - inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo)); - 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.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.sensorState); - assertFalse(mSarInfo.isVoiceCall); - } - /** * Test that Start of SoftAP for a device that does not have SAR enabled does not result in * setting the Tx power scenario */ @Test public void testSarMgr_disabledTxPowerScenario_sapOn() throws Exception { - createSarManager(false, false, false); + createSarManager(false, false); /* Enable WiFi SoftAP State */ mSarMgr.setSapWifiState(WifiManager.WIFI_AP_STATE_ENABLED); @@ -816,11 +407,11 @@ public class SarManagerTest extends WifiBaseTest { } /** - * Test that Start of SoftAP for a device that has SAR enabled, SAR sensor disabled. + * Test that Start of SoftAP for a device that has SAR enabled. */ @Test public void testSarMgr_enabledTxPowerScenario_sapOn() throws Exception { - createSarManager(true, false, false); + createSarManager(true, false); InOrder inOrder = inOrder(mWifiNative); @@ -834,84 +425,13 @@ public class SarManagerTest extends WifiBaseTest { assertFalse(mSarInfo.isWifiScanOnlyEnabled); } - /** - * Test that for a device that has SAR enabled, SAR sensor enabled, near head, and when - * wifi sta is enabled, turning on sap then turning it off. - */ - @Test - public void testSarMgr_enabledTxPowerScenario_staOn_sapOnOff() throws Exception { - createSarManager(true, true, true); - - InOrder inOrder = inOrder(mWifiNative); - - /* Sensor event */ - sendSensorEvent(SAR_SENSOR_EVENT_HEAD); - inOrder.verify(mWifiNative, never()).selectTxPowerScenario(any(SarInfo.class)); - - /* Enable WiFi Client State */ - mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_ENABLED); - captureSarInfo(mWifiNative); - - inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo)); - 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.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.sensorState); - assertFalse(mSarInfo.isWifiSapEnabled); - } - - /** - * Test that for a device that has SAR enabled, SAR sensor enabled, Near body, and when - * disabling wifi softAP while Wifi Sta is also disabled, no update to the HAL for Tx - * power scenario is issued. - * Then, when wifi client is enabled, the Tx Power scenario is set. - * This is to verify that no call to update tx power when all wifi modes are disabled. - */ - @Test - public void testSarMgr_enabledTxPowerScenario_sapOnOff_staOffOn() throws Exception { - createSarManager(true, true, true); - - InOrder inOrder = inOrder(mWifiNative); - - /* Sensor event */ - sendSensorEvent(SAR_SENSOR_EVENT_BODY); - inOrder.verify(mWifiNative, never()).selectTxPowerScenario(any(SarInfo.class)); - - /* Enable WiFi softAP State */ - mSarMgr.setSapWifiState(WifiManager.WIFI_AP_STATE_ENABLED); - captureSarInfo(mWifiNative); - - inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo)); - assertEquals(SarInfo.SAR_SENSOR_NEAR_BODY, mSarInfo.sensorState); - assertTrue(mSarInfo.isWifiSapEnabled); - - /* Disable Wifi SoftAP state */ - mSarMgr.setSapWifiState(WifiManager.WIFI_AP_STATE_DISABLED); - inOrder.verify(mWifiNative, never()).selectTxPowerScenario(any(SarInfo.class)); - - /* Enable WiFi Clinet State */ - mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_ENABLED); - inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo)); - assertEquals(SarInfo.SAR_SENSOR_NEAR_BODY, mSarInfo.sensorState); - assertFalse(mSarInfo.isWifiSapEnabled); - } - /** * Test that for a device that has SAR enabled, when scan-only state is enabled with both SoftAP * and Client states disabled, the SarInfo is reported with proper values. */ @Test public void testSarMgr_enabledTxPowerScenario_staOff_sapOff_scanOnlyOn() throws Exception { - createSarManager(true, false, false); + createSarManager(true, false); /* Enable Wifi ScanOnly State */ mSarMgr.setScanOnlyWifiState(WifiManager.WIFI_STATE_ENABLED); @@ -928,7 +448,7 @@ public class SarManagerTest extends WifiBaseTest { */ @Test public void testSarMgr_enabledTxPowerScenario_staOn_sapOff_scanOnlyOn() throws Exception { - createSarManager(true, false, false); + createSarManager(true, false); InOrder inOrder = inOrder(mWifiNative); @@ -946,7 +466,7 @@ public class SarManagerTest extends WifiBaseTest { } /** - * Test the success case for for devices supporting SAR, with no SAR sensor support, + * Test the success case for for devices supporting SAR, * Wifi enabled, SoftAP enabled, wifi disabled, scan-only enabled, SoftAP disabled. * * SarManager should report these changes as they occur(only when changes occur to @@ -954,7 +474,7 @@ public class SarManagerTest extends WifiBaseTest { */ @Test public void testSarMgr_enabledTxPowerScenario_wifi_sap_scanOnly() throws Exception { - createSarManager(true, false, false); + createSarManager(true, false); InOrder inOrder = inOrder(mWifiNative); @@ -991,13 +511,13 @@ public class SarManagerTest extends WifiBaseTest { } /** - * Test the error case for devices supporting SAR, with no SAR sensor support, + * Test the error case for devices supporting SAR, * Wifi enabled, SoftAP enabled, wifi disabled, scan-only enabled, SoftAP disabled * Throughout this test case, calls to the hal return with error. */ @Test public void testSarMgr_enabledTxPowerScenario_error_wifi_sap_scanOnly() throws Exception { - createSarManager(true, false, false); + createSarManager(true, false); when(mWifiNative.selectTxPowerScenario(any(SarInfo.class))).thenReturn(false); InOrder inOrder = inOrder(mWifiNative); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index 27094b240..7ba3dbf95 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -400,7 +400,6 @@ public class WifiMetricsTest extends WifiBaseTest { private static final boolean LINK_SPEED_COUNTS_LOGGING_SETTING = true; private static final int DATA_STALL_MIN_TX_BAD_SETTING = 5; private static final int DATA_STALL_MIN_TX_SUCCESS_WITHOUT_RX_SETTING = 75; - private static final int NUM_SAR_SENSOR_LISTENER_REGISTRATION_FAILURES = 5; private static final int NUM_ONESHOT_SCAN_REQUESTS_WITH_DFS_CHANNELS = 4; private static final int NUM_ADD_OR_UPDATE_NETWORK_CALLS = 5; private static final int NUM_ENABLE_NETWORK_CALLS = 6; @@ -854,9 +853,6 @@ public class WifiMetricsTest extends WifiBaseTest { for (int i = 0; i < NUM_WPS_CANCELLATION; i++) { mWifiMetrics.incrementWpsCancellationCount(); } - for (int i = 0; i < NUM_SAR_SENSOR_LISTENER_REGISTRATION_FAILURES; i++) { - mWifiMetrics.incrementNumSarSensorRegistrationFailures(); - } for (int i = 0; i < NUM_ONESHOT_SCAN_REQUESTS_WITH_DFS_CHANNELS; i++) { mWifiMetrics.incrementOneshotScanWithDfsCount(); } @@ -1200,9 +1196,6 @@ public class WifiMetricsTest extends WifiBaseTest { mDecodedProto.experimentValues.wifiDataStallMinTxBad); assertEquals(DATA_STALL_MIN_TX_SUCCESS_WITHOUT_RX_SETTING, mDecodedProto.experimentValues.wifiDataStallMinTxSuccessWithoutRx); - - assertEquals(NUM_SAR_SENSOR_LISTENER_REGISTRATION_FAILURES, - mDecodedProto.numSarSensorRegistrationFailures); assertEquals(NUM_ONESHOT_SCAN_REQUESTS_WITH_DFS_CHANNELS, mDecodedProto.numOneshotHasDfsChannelScans); assertEquals(NUM_ADD_OR_UPDATE_NETWORK_CALLS, mDecodedProto.numAddOrUpdateNetworkCalls); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java index 561902e86..d44d63d1e 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java @@ -123,7 +123,6 @@ public class WifiVendorHalTest extends WifiBaseTest { private static final String TEST_IFACE_NAME = "wlan0"; private static final String TEST_IFACE_NAME_1 = "wlan1"; private static final MacAddress TEST_MAC_ADDRESS = MacAddress.fromString("ee:33:a2:94:10:92"); - private static final int SAR_SENSOR_INVALID_STATE = -6; private static final int[] TEST_FREQUENCIES = {2412, 2417, 2422, 2427, 2432, 2437}; @@ -2352,7 +2351,7 @@ public class WifiVendorHalTest extends WifiBaseTest { */ @Test public void testSelectTxPowerScenario_1_0() throws RemoteException { - // Create a SAR info record (no sensor support) + // Create a SAR info record SarInfo sarInfo = new SarInfo(); sarInfo.isVoiceCall = true; @@ -2369,11 +2368,10 @@ public class WifiVendorHalTest extends WifiBaseTest { */ @Test public void testSelectTxPowerScenario_1_1() throws RemoteException { - // Create a SAR info record (no sensor support) + // Create a SAR info record SarInfo sarInfo = new SarInfo(); sarInfo.sarVoiceCallSupported = true; sarInfo.sarSapSupported = false; - sarInfo.sarSensorSupported = false; sarInfo.isVoiceCall = true; @@ -2395,11 +2393,10 @@ public class WifiVendorHalTest extends WifiBaseTest { */ @Test public void testSelectTxPowerScenario_1_2() throws RemoteException { - // Create a SAR info record (no sensor support) + // Create a SAR info record SarInfo sarInfo = new SarInfo(); sarInfo.sarVoiceCallSupported = true; sarInfo.sarSapSupported = false; - sarInfo.sarSensorSupported = false; sarInfo.isVoiceCall = true; @@ -2421,7 +2418,7 @@ public class WifiVendorHalTest extends WifiBaseTest { */ @Test public void testResetTxPowerScenario_1_0() throws RemoteException { - // Create a SAR info record (no sensor support) + // Create a SAR info record SarInfo sarInfo = new SarInfo(); assertTrue(mWifiVendorHal.startVendorHalSta()); @@ -2437,11 +2434,10 @@ public class WifiVendorHalTest extends WifiBaseTest { */ @Test public void testResetTxPowerScenario_1_1() throws RemoteException { - // Create a SAR info record (no sensor support) + // Create a SAR info record SarInfo sarInfo = new SarInfo(); sarInfo.sarVoiceCallSupported = true; sarInfo.sarSapSupported = false; - sarInfo.sarSensorSupported = false; // Now expose the 1.1 IWifiChip. mWifiVendorHal = new WifiVendorHalSpyV1_1(mHalDeviceManager, mHandler); @@ -2463,11 +2459,10 @@ public class WifiVendorHalTest extends WifiBaseTest { public void testResetTxPowerScenario_not_needed_1_1() throws RemoteException { InOrder inOrder = inOrder(mIWifiChipV11); - // Create a SAR info record (no sensor or SAP support) + // Create a SAR info record (no 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, mHandler); @@ -2495,11 +2490,10 @@ public class WifiVendorHalTest extends WifiBaseTest { */ @Test public void testResetTxPowerScenario_1_2() throws RemoteException { - // Create a SAR info record (no sensor or SAP support) + // Create a SAR info record (no 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, mHandler); @@ -2521,11 +2515,10 @@ public class WifiVendorHalTest extends WifiBaseTest { public void testResetTxPowerScenario_not_needed_1_2() throws RemoteException { InOrder inOrder = inOrder(mIWifiChipV12); - // Create a SAR info record (no sensor or SAP support) + // Create a SAR info record (no 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, mHandler); @@ -2548,19 +2541,16 @@ public class WifiVendorHalTest extends WifiBaseTest { } /** - * Test the selectTxPowerScenario HIDL method invocation with no sensor support, but with - * SAP and voice call support. + * Test the selectTxPowerScenario HIDL method invocation 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) + // Create a SAR info record (with SAP support) SarInfo sarInfo = new SarInfo(); sarInfo.sarVoiceCallSupported = true; sarInfo.sarSapSupported = true; - sarInfo.sarSensorSupported = false; - sarInfo.isWifiSapEnabled = true; // Expose the 1.2 IWifiChip. @@ -2577,18 +2567,16 @@ public class WifiVendorHalTest extends WifiBaseTest { } /** - * Test the selectTxPowerScenario HIDL method invocation with no sensor support, but with - * SAP and voice call support. + * Test the selectTxPowerScenario HIDL method invocation 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) + // Create a SAR info record (with SAP support) SarInfo sarInfo = new SarInfo(); sarInfo.sarVoiceCallSupported = true; sarInfo.sarSapSupported = true; - sarInfo.sarSensorSupported = false; sarInfo.isVoiceCall = true; @@ -2606,18 +2594,16 @@ public class WifiVendorHalTest extends WifiBaseTest { } /** - * Test the selectTxPowerScenario HIDL method invocation with no sensor support, but with - * SAP and voice call support. + * Test the selectTxPowerScenario HIDL method invocation with SAP and voice call support. * When earpiece is active, should result in cell with near head scenario * Using IWifiChip 1.2 interface */ @Test public void testEarPieceScenarios_SelectTxPowerV1_2() throws RemoteException { - // Create a SAR info record (with sensor and SAP support) + // Create a SAR info record (with SAP support) SarInfo sarInfo = new SarInfo(); sarInfo.sarVoiceCallSupported = true; sarInfo.sarSapSupported = true; - sarInfo.sarSensorSupported = false; sarInfo.isEarPieceActive = true; @@ -2634,33 +2620,6 @@ public class WifiVendorHalTest extends WifiBaseTest { 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 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, mHandler); - when(mIWifiChipV12.selectTxPowerScenario_1_2(anyInt())).thenReturn(mWifiStatusSuccess); - - // ON_HEAD_CELL_OFF - assertTrue(mWifiVendorHal.startVendorHalSta()); - assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo)); - verify(mIWifiChipV12).selectTxPowerScenario_1_2( - eq(android.hardware.wifi.V1_2.IWifiChip.TxPowerScenario.ON_HEAD_CELL_OFF)); - verify(mIWifiChipV12, never()).resetTxPowerScenario(); - mWifiVendorHal.stopVendorHal(); - } - /** * Test setting SAR scenario when not needed, should return true without invoking * the HAL method. @@ -2670,25 +2629,20 @@ public class WifiVendorHalTest extends WifiBaseTest { public void testSetTxPowerScenario_not_needed_1_2() throws RemoteException { InOrder inOrder = inOrder(mIWifiChipV12); - // Create a SAR info record (no sensor and SAP support) + // Create a SAR info record (no 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, mHandler); - when(mIWifiChipV12.selectTxPowerScenario_1_2(anyInt())).thenReturn(mWifiStatusSuccess); + when(mIWifiChipV12.resetTxPowerScenario()).thenReturn(mWifiStatusSuccess); assertTrue(mWifiVendorHal.startVendorHalSta()); /* Calling set once */ assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo)); - inOrder.verify(mIWifiChipV12).selectTxPowerScenario_1_2( - eq(android.hardware.wifi.V1_2.IWifiChip.TxPowerScenario.ON_HEAD_CELL_OFF)); - inOrder.verify(mIWifiChipV12, never()).resetTxPowerScenario(); + inOrder.verify(mIWifiChipV12).resetTxPowerScenario(); sarInfo.reportingSuccessful(); /* Calling set second time */ @@ -2699,118 +2653,19 @@ public class WifiVendorHalTest extends WifiBaseTest { mWifiVendorHal.stopVendorHal(); } - /** - * Test the selectTxPowerScenairo HIDL method invocation with sensor events for - * IWifiChip 1.2 interface (Near hand event) along with a voice call. - * This should be reverted to BODY events (First with CELL_OFF followed by CELL_ON). - */ - @Test - public void testHandSensorScenarios_SelectTxPowerV1_2() throws RemoteException { - // 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, mHandler); - when(mIWifiChipV12.selectTxPowerScenario_1_2(anyInt())).thenReturn(mWifiStatusSuccess); - - assertTrue(mWifiVendorHal.startVendorHalSta()); - - // First select a scenario with cell off - assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo)); - verify(mIWifiChipV12).selectTxPowerScenario_1_2( - eq(android.hardware.wifi.V1_2.IWifiChip.TxPowerScenario.ON_BODY_CELL_OFF)); - - // Then select a scenario with cell on - sarInfo.isVoiceCall = true; - assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo)); - verify(mIWifiChipV12).selectTxPowerScenario_1_2( - eq(android.hardware.wifi.V1_2.IWifiChip.TxPowerScenario.ON_BODY_CELL_ON)); - - mWifiVendorHal.stopVendorHal(); - } - - /** - * Test the selectTxPowerScenario HIDL method invocation with a sensor info to IWifiChip - * 1.1 interface. - * Sensor mode should be ignored, and act only based on Cell on/off. - */ - @Test - public void testOnHeadCellOffOn_SelectTxPowerScenarioV1_1() throws RemoteException { - // 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, mHandler); - when(mIWifiChipV11.selectTxPowerScenario(anyInt())).thenReturn(mWifiStatusSuccess); - when(mIWifiChipV11.resetTxPowerScenario()).thenReturn(mWifiStatusSuccess); - - assertTrue(mWifiVendorHal.startVendorHalSta()); - - // First select a scenario with cell off - assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo)); - verify(mIWifiChipV11).resetTxPowerScenario(); - - // Then select a scenario with cell on - sarInfo.isVoiceCall = true; - assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo)); - verify(mIWifiChipV11).selectTxPowerScenario( - eq(android.hardware.wifi.V1_1.IWifiChip.TxPowerScenario.VOICE_CALL)); - - mWifiVendorHal.stopVendorHal(); - } - - /** - * Test the new selectTxPowerScenario HIDL method invocation with a bad input. - * This should not result into any calls to the HAL. - * Use IWifiChip 1.2 interface - */ - @Test - public void testInvalidSelectTxPowerScenario_1_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 = true; - - sarInfo.sensorState = SAR_SENSOR_INVALID_STATE; - - // Expose the 1.2 IWifiChip. - mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mHandler); - - assertTrue(mWifiVendorHal.startVendorHalSta()); - assertFalse(mWifiVendorHal.selectTxPowerScenario(sarInfo)); - verify(mIWifiChipV12, never()).selectTxPowerScenario(anyInt()); - verify(mIWifiChipV12, never()).resetTxPowerScenario(); - mWifiVendorHal.stopVendorHal(); - } - /** * Test the selectTxPowerScenario HIDL method invocation with IWifiChip 1.2 interface. * The following inputs: - * - Sensor support is enabled - * - Sensor state is NEAR_HEAD * - SAP is enabled * - No voice call */ @Test - public void testSelectTxPowerScenario_1_2_head_sap() throws RemoteException { - // Create a SAR info record (with sensor and SAP support) + public void testSelectTxPowerScenario_1_2_sap() throws RemoteException { + // Create a SAR info record (with 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; @@ -2821,7 +2676,7 @@ public class WifiVendorHalTest extends WifiBaseTest { assertTrue(mWifiVendorHal.startVendorHalSta()); assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo)); verify(mIWifiChipV12).selectTxPowerScenario_1_2( - eq(android.hardware.wifi.V1_2.IWifiChip.TxPowerScenario.ON_HEAD_CELL_ON)); + eq(android.hardware.wifi.V1_2.IWifiChip.TxPowerScenario.ON_BODY_CELL_ON)); mWifiVendorHal.stopVendorHal(); } @@ -2829,20 +2684,16 @@ public class WifiVendorHalTest extends WifiBaseTest { /** * Test the selectTxPowerScenario HIDL method invocation with IWifiChip 1.2 interface. * The following inputs: - * - Sensor support is enabled - * - Sensor state is NEAR_HEAD * - SAP is enabled * - voice call is enabled */ @Test public void testSelectTxPowerScenario_1_2_head_sap_call() throws RemoteException { - // Create a SAR info record (with sensor and SAP support) + // Create a SAR info record (with 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; @@ -2858,68 +2709,6 @@ public class WifiVendorHalTest extends WifiBaseTest { mWifiVendorHal.stopVendorHal(); } - /** - * Test the selectTxPowerScenario HIDL method invocation with IWifiChip 1.2 interface. - * The following inputs: - * - Sensor support is enabled - * - Sensor state is FREE_SPACE - * - SAP is enabled - * - No voice call - */ - @Test - public void testSelectTxPowerScenario_1_2_freespace_sap() throws RemoteException { - // 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, mHandler); - when(mIWifiChipV12.resetTxPowerScenario()).thenReturn(mWifiStatusSuccess); - - assertTrue(mWifiVendorHal.startVendorHalSta()); - assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo)); - - verify(mIWifiChipV12).resetTxPowerScenario(); - verify(mIWifiChipV12, never()).selectTxPowerScenario_1_2(anyInt()); - mWifiVendorHal.stopVendorHal(); - } - - /** - * Test the selectTxPowerScenario HIDL method invocation with IWifiChip 1.2 interface. - * The following inputs: - * - Sensor support is disabled - * - SAP is enabled - * - No voice call - */ - @Test - public void testSelectTxPowerScenario_1_2_no_sensors_sap() throws RemoteException { - // Create a SAR info record (with no sensor support) - 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, mHandler); - when(mIWifiChipV12.resetTxPowerScenario()).thenReturn(mWifiStatusSuccess); - - assertTrue(mWifiVendorHal.startVendorHalSta()); - assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo)); - - verify(mIWifiChipV12).resetTxPowerScenario(); - verify(mIWifiChipV12, never()).selectTxPowerScenario_1_2(anyInt()); - mWifiVendorHal.stopVendorHal(); - } - /** * Test the setLowLatencyMode HIDL method invocation with IWifiChip 1.2 interface. * Function should return false -- cgit v1.2.3