summaryrefslogtreecommitdiffstats
path: root/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
diff options
context:
space:
mode:
authorAhmed ElArabawy <arabawy@google.com>2018-05-22 22:55:16 -0700
committerAhmed ElArabawy <arabawy@google.com>2018-06-08 09:11:52 -0700
commit2e6fdb80cbcd264d774c6e13dd350c2665d21bb1 (patch)
treeb029fb58fcc1bf61057c261b251678823e602f33 /tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
parentdc3d066444208c13ed4caf69bebee6b68e7488f3 (diff)
downloadandroid_frameworks_opt_net_wifi-2e6fdb80cbcd264d774c6e13dd350c2665d21bb1.tar.gz
android_frameworks_opt_net_wifi-2e6fdb80cbcd264d774c6e13dd350c2665d21bb1.tar.bz2
android_frameworks_opt_net_wifi-2e6fdb80cbcd264d774c6e13dd350c2665d21bb1.zip
WiFi: SAR Support: Use SarInfo in WifiVendorHal
In a previous commit, the class SarInfo was introduced. This commit utilizes this class to pass SAR related inputs to WifiVendorHal to select the SAR scenario. Note that the functionality introduced in this commit is not called yet during operation. Hence the legacy code is left in place until the new functionality is fully utilized. Bug: 65174506 Test: Run Wifi unit test suite Test: ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh Change-Id: Idb00f2c265d64ea4e8fc3a6e2ed7fc9bc08539fb Signed-off-by: Ahmed ElArabawy <arabawy@google.com>
Diffstat (limited to 'tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java449
1 files changed, 446 insertions, 3 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
index 0f8f56f66..60b5f81ad 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
@@ -32,6 +32,7 @@ import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
@@ -99,6 +100,7 @@ import com.android.server.wifi.util.NativeUtil;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
+import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.stubbing.Answer;
@@ -119,6 +121,7 @@ public class WifiVendorHalTest {
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;
WifiVendorHal mWifiVendorHal;
private WifiStatus mWifiStatusSuccess;
@@ -1997,11 +2000,14 @@ public class WifiVendorHalTest {
}
/**
+ * TODO: This test will be removed in a following change
+ * It is going to be replaced by another test using the new structure
+ *
* Test the new selectTxPowerScenario HIDL method invocation. This should return failure if the
* HAL service is exposing the 1.0 interface.
*/
@Test
- public void testSelectTxPowerScenario() throws RemoteException {
+ public void testSelectTxPowerScenario_old() throws RemoteException {
assertTrue(mWifiVendorHal.startVendorHalSta());
// Should fail because we exposed the 1.0 IWifiChip.
assertFalse(
@@ -2023,11 +2029,14 @@ public class WifiVendorHalTest {
}
/**
+ * TODO: This test will be removed in a following change
+ * It is going to be replaced by another test using the new structure
+ *
* Test the new resetTxPowerScenario HIDL method invocation. This should return failure if the
* HAL service is exposing the 1.0 interface.
*/
@Test
- public void testResetTxPowerScenario() throws RemoteException {
+ public void testResetTxPowerScenario_old() throws RemoteException {
assertTrue(mWifiVendorHal.startVendorHalSta());
// Should fail because we exposed the 1.0 IWifiChip.
assertFalse(mWifiVendorHal.selectTxPowerScenario(WifiNative.TX_POWER_SCENARIO_NORMAL));
@@ -2046,10 +2055,13 @@ public class WifiVendorHalTest {
}
/**
+ * TODO: This test will be removed in a following change
+ * It is going to be replaced by another test using the new structure
+ *
* Test the new selectTxPowerScenario HIDL method invocation with a bad scenario index.
*/
@Test
- public void testInvalidSelectTxPowerScenario() throws RemoteException {
+ public void testInvalidSelectTxPowerScenario_old() throws RemoteException {
// Expose the 1.1 IWifiChip.
mWifiVendorHal = new WifiVendorHalSpyV1_1(mHalDeviceManager, mLooper.getLooper());
when(mIWifiChipV11.selectTxPowerScenario(anyInt())).thenReturn(mWifiStatusSuccess);
@@ -2062,6 +2074,437 @@ public class WifiVendorHalTest {
}
/**
+ * Test the selectTxPowerScenario HIDL method invocation for 1.0 interface.
+ * This should return failure since SAR is not supported for this interface version.
+ */
+ @Test
+ public void testSelectTxPowerScenario_1_0() throws RemoteException {
+ // Create a SAR info record (no sensor support)
+ SarInfo sarInfo = new SarInfo(false);
+ sarInfo.mIsVoiceCall = true;
+
+ assertTrue(mWifiVendorHal.startVendorHalSta());
+ // Should fail because we exposed the 1.0 IWifiChip.
+ assertFalse(mWifiVendorHal.selectTxPowerScenario(sarInfo));
+ verify(mIWifiChipV11, never()).selectTxPowerScenario(anyInt());
+ mWifiVendorHal.stopVendorHal();
+ }
+
+ /**
+ * Test the selectTxPowerScenario HIDL method invocation for 1.1 interface.
+ * This should return success.
+ */
+ @Test
+ public void testSelectTxPowerScenario_1_1() throws RemoteException {
+ // Create a SAR info record (no sensor support)
+ SarInfo sarInfo = new SarInfo(false);
+ sarInfo.mIsVoiceCall = true;
+
+ // Now expose the 1.1 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_1(mHalDeviceManager, mLooper.getLooper());
+ when(mIWifiChipV11.selectTxPowerScenario(anyInt())).thenReturn(mWifiStatusSuccess);
+
+ assertTrue(mWifiVendorHal.startVendorHalSta());
+ assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo));
+ verify(mIWifiChipV11).selectTxPowerScenario(
+ eq(android.hardware.wifi.V1_1.IWifiChip.TxPowerScenario.VOICE_CALL));
+ verify(mIWifiChipV11, never()).resetTxPowerScenario();
+ mWifiVendorHal.stopVendorHal();
+ }
+
+ /**
+ * Test the selectTxPowerScenario HIDL method invocation for 1.2 interface.
+ * This should return success.
+ */
+ @Test
+ public void testSelectTxPowerScenario_1_2() throws RemoteException {
+ // Create a SAR info record (no sensor support)
+ SarInfo sarInfo = new SarInfo(false);
+ sarInfo.mIsVoiceCall = true;
+
+ // Now expose the 1.2 IWifiChip
+ mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
+ when(mIWifiChipV12.selectTxPowerScenario_1_2(anyInt())).thenReturn(mWifiStatusSuccess);
+
+ assertTrue(mWifiVendorHal.startVendorHalSta());
+ assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo));
+ verify(mIWifiChipV12).selectTxPowerScenario_1_2(
+ eq(android.hardware.wifi.V1_2.IWifiChip.TxPowerScenario.VOICE_CALL));
+ verify(mIWifiChipV12, never()).resetTxPowerScenario();
+ mWifiVendorHal.stopVendorHal();
+ }
+
+ /**
+ * Test the resetTxPowerScenario HIDL method invocation for 1.0 interface.
+ * This should return failure since it does not supprt SAR.
+ */
+ @Test
+ public void testResetTxPowerScenario_1_0() throws RemoteException {
+ // Create a SAR info record (no sensor support)
+ SarInfo sarInfo = new SarInfo(false);
+
+ assertTrue(mWifiVendorHal.startVendorHalSta());
+ // Should fail because we exposed the 1.0 IWifiChip.
+ assertFalse(mWifiVendorHal.selectTxPowerScenario(sarInfo));
+ verify(mIWifiChipV11, never()).resetTxPowerScenario();
+ mWifiVendorHal.stopVendorHal();
+ }
+
+ /**
+ * Test the resetTxPowerScenario HIDL method invocation for 1.1 interface.
+ * This should return success.
+ */
+ @Test
+ public void testResetTxPowerScenario_1_1() throws RemoteException {
+ // Create a SAR info record (no sensor support)
+ SarInfo sarInfo = new SarInfo(false);
+
+ // Now expose the 1.1 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_1(mHalDeviceManager, mLooper.getLooper());
+ when(mIWifiChipV11.resetTxPowerScenario()).thenReturn(mWifiStatusSuccess);
+
+ assertTrue(mWifiVendorHal.startVendorHalSta());
+ assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo));
+ verify(mIWifiChipV11).resetTxPowerScenario();
+ verify(mIWifiChipV11, never()).selectTxPowerScenario(anyInt());
+ mWifiVendorHal.stopVendorHal();
+ }
+
+ /**
+ * Test resetting SAR scenario when not needed, should return true without invoking
+ * the HAL method.
+ * This is using HAL 1.1 interface.
+ */
+ @Test
+ 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);
+
+ // Now expose the 1.1 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_1(mHalDeviceManager, mLooper.getLooper());
+ when(mIWifiChipV11.resetTxPowerScenario()).thenReturn(mWifiStatusSuccess);
+
+ assertTrue(mWifiVendorHal.startVendorHalSta());
+
+ /* Calling reset once */
+ assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo));
+ inOrder.verify(mIWifiChipV11).resetTxPowerScenario();
+ inOrder.verify(mIWifiChipV11, never()).selectTxPowerScenario(anyInt());
+ sarInfo.reportingSuccessful();
+
+ /* Calling reset second time */
+ assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo));
+ inOrder.verify(mIWifiChipV11, never()).resetTxPowerScenario();
+ inOrder.verify(mIWifiChipV11, never()).selectTxPowerScenario(anyInt());
+
+ mWifiVendorHal.stopVendorHal();
+ }
+
+ /**
+ * Test the new resetTxPowerScenario HIDL method invocation for 1.2 interface.
+ * This should return success.
+ */
+ @Test
+ public void testResetTxPowerScenario_1_2() throws RemoteException {
+ // Create a SAR info record (no sensor support)
+ SarInfo sarInfo = new SarInfo(false);
+
+ // Now expose the 1.2 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
+ 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 resetting SAR scenario when not needed, should return true without invoking
+ * the HAL method.
+ * This is using HAL 1.2 interface.
+ */
+ @Test
+ 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);
+
+ // Now expose the 1.2 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
+ when(mIWifiChipV12.resetTxPowerScenario()).thenReturn(mWifiStatusSuccess);
+
+ assertTrue(mWifiVendorHal.startVendorHalSta());
+
+ /* Calling reset once */
+ assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo));
+ inOrder.verify(mIWifiChipV12).resetTxPowerScenario();
+ inOrder.verify(mIWifiChipV12, never()).selectTxPowerScenario(anyInt());
+ sarInfo.reportingSuccessful();
+
+ /* Calling reset second time */
+ assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo));
+ inOrder.verify(mIWifiChipV12, never()).resetTxPowerScenario();
+ inOrder.verify(mIWifiChipV12, never()).selectTxPowerScenario(anyInt());
+
+ 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;
+
+ // Expose the 1.2 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
+ 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.
+ * This is using HAL 1.2 interface.
+ */
+ @Test
+ 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;
+
+ // Now expose the 1.2 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
+ when(mIWifiChipV12.selectTxPowerScenario_1_2(anyInt())).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();
+ sarInfo.reportingSuccessful();
+
+ /* Calling set second time */
+ assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo));
+ inOrder.verify(mIWifiChipV12, never()).resetTxPowerScenario();
+ inOrder.verify(mIWifiChipV12, never()).selectTxPowerScenario(anyInt());
+
+ 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 support)
+ SarInfo sarInfo = new SarInfo(true);
+ sarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HAND;
+
+ // Expose the 1.2 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
+ 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.mIsVoiceCall = 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 support)
+ SarInfo sarInfo = new SarInfo(true);
+ sarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
+
+ // Expose the 1.1 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_1(mHalDeviceManager, mLooper.getLooper());
+ 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.mIsVoiceCall = 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 support)
+ SarInfo sarInfo = new SarInfo(true);
+ sarInfo.mSensorState = SAR_SENSOR_INVALID_STATE;
+
+ // Expose the 1.2 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
+
+ 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 support)
+ SarInfo sarInfo = new SarInfo(true);
+ sarInfo.mSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD;
+ sarInfo.mIsWifiSapEnabled = true;
+ sarInfo.mIsVoiceCall = false;
+
+ // Expose the 1.2 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
+ when(mIWifiChipV12.selectTxPowerScenario_1_2(anyInt())).thenReturn(mWifiStatusSuccess);
+
+ assertTrue(mWifiVendorHal.startVendorHalSta());
+ assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo));
+ verify(mIWifiChipV12).selectTxPowerScenario_1_2(
+ eq(android.hardware.wifi.V1_2.IWifiChip.TxPowerScenario.ON_HEAD_CELL_ON));
+
+ 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
+ * - voice call is enabled
+ */
+ @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;
+
+ // Expose the 1.2 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
+ when(mIWifiChipV12.selectTxPowerScenario_1_2(anyInt())).thenReturn(mWifiStatusSuccess);
+
+ assertTrue(mWifiVendorHal.startVendorHalSta());
+ assertTrue(mWifiVendorHal.selectTxPowerScenario(sarInfo));
+ verify(mIWifiChipV12).selectTxPowerScenario_1_2(
+ eq(android.hardware.wifi.V1_2.IWifiChip.TxPowerScenario.ON_HEAD_CELL_ON));
+
+ 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 support)
+ SarInfo sarInfo = new SarInfo(true);
+ sarInfo.mSensorState = SarInfo.SAR_SENSOR_FREE_SPACE;
+ sarInfo.mIsWifiSapEnabled = true;
+ sarInfo.mIsVoiceCall = false;
+
+ // Expose the 1.2 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
+ 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(false);
+ sarInfo.mIsWifiSapEnabled = true;
+ sarInfo.mIsVoiceCall = false;
+
+ // Expose the 1.2 IWifiChip.
+ mWifiVendorHal = new WifiVendorHalSpyV1_2(mHalDeviceManager, mLooper.getLooper());
+ 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 STA Iface creation failure due to iface name retrieval failure.
*/
@Test