diff options
-rw-r--r-- | service/java/com/android/server/wifi/SarInfo.java | 44 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/SarManager.java | 144 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiInjector.java | 4 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiMetrics.java | 9 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiVendorHal.java | 48 | ||||
-rw-r--r-- | service/proto/src/metrics.proto | 4 | ||||
-rw-r--r-- | service/res/values/config.xml | 19 | ||||
-rw-r--r-- | service/res/values/overlayable.xml | 6 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/SarInfoTest.java | 115 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/SarManagerTest.java | 524 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java | 7 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java | 253 |
12 files changed, 53 insertions, 1124 deletions
diff --git a/service/java/com/android/server/wifi/SarInfo.java b/service/java/com/android/server/wifi/SarInfo.java index a88c4ecb3..5a2178d0c 100644 --- a/service/java/com/android/server/wifi/SarInfo.java +++ b/service/java/com/android/server/wifi/SarInfo.java @@ -23,7 +23,6 @@ import java.io.PrintWriter; * This class represents the list of SAR inputs that will be used to select the proper * power profile. * This includes: - * - SAR sensor status * - Is there an ongoing voice call * - Is SoftAP active * It also contains info about state of the other Wifi modes @@ -51,25 +50,13 @@ public class SarInfo { */ public static final int RESET_SAR_SCENARIO = -1; - private static final String SAR_SENSOR_FREE_SPACE_STR = "SAR_SENSOR_FREE_SPACE"; - private static final String SAR_SENSOR_NEAR_BODY_STR = "SAR_SENSOR_NEAR_BODY"; - private static final String SAR_SENSOR_NEAR_HAND_STR = "SAR_SENSOR_NEAR_HAND"; - private static final String SAR_SENSOR_NEAR_HEAD_STR = "SAR_SENSOR_NEAR_HEAD"; - - public static final int SAR_SENSOR_FREE_SPACE = 1; - public static final int SAR_SENSOR_NEAR_HAND = 2; - public static final int SAR_SENSOR_NEAR_HEAD = 3; - public static final int SAR_SENSOR_NEAR_BODY = 4; - /* For Logging */ private static final String TAG = "WifiSarInfo"; /* SAR support configs */ public boolean sarVoiceCallSupported; public boolean sarSapSupported; - public boolean sarSensorSupported; - public int sensorState = SAR_SENSOR_FREE_SPACE; public boolean isWifiClientEnabled = false; public boolean isWifiSapEnabled = false; public boolean isWifiScanOnlyEnabled = false; @@ -80,7 +67,6 @@ public class SarInfo { private boolean mAllWifiDisabled = true; /* Variables representing the last successfully reported values to hal */ - private int mLastReportedSensorState = SAR_SENSOR_FREE_SPACE; private boolean mLastReportedIsWifiSapEnabled = false; private boolean mLastReportedIsVoiceCall = false; private boolean mLastReportedIsEarPieceActive = false; @@ -113,14 +99,9 @@ public class SarInfo { } /* Check if some change happened since last successful reporting */ - if ((sensorState != mLastReportedSensorState) - || (isWifiSapEnabled != mLastReportedIsWifiSapEnabled) + return ((isWifiSapEnabled != mLastReportedIsWifiSapEnabled) || (isVoiceCall != mLastReportedIsVoiceCall) - || (isEarPieceActive != mLastReportedIsEarPieceActive)) { - return true; - } else { - return false; - } + || (isEarPieceActive != mLastReportedIsEarPieceActive)); } /** @@ -129,7 +110,6 @@ public class SarInfo { * This results in caching the last reported inputs for future comparison. */ public void reportingSuccessful() { - mLastReportedSensorState = sensorState; mLastReportedIsWifiSapEnabled = isWifiSapEnabled; mLastReportedIsVoiceCall = isVoiceCall; mLastReportedIsEarPieceActive = isEarPieceActive; @@ -175,14 +155,12 @@ public class SarInfo { public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("Dump of SarInfo"); pw.println("Current values:"); - pw.println(" Sensor state is: " + sensorStateToString(sensorState)); pw.println(" Voice Call state is: " + isVoiceCall); pw.println(" Wifi Client state is: " + isWifiClientEnabled); pw.println(" Wifi Soft AP state is: " + isWifiSapEnabled); pw.println(" Wifi ScanOnly state is: " + isWifiScanOnlyEnabled); pw.println(" Earpiece state is : " + isEarPieceActive); pw.println("Last reported values:"); - pw.println(" Sensor state is: " + sensorStateToString(mLastReportedSensorState)); pw.println(" Soft AP state is: " + mLastReportedIsWifiSapEnabled); pw.println(" Voice Call state is: " + mLastReportedIsVoiceCall); pw.println(" Earpiece state is: " + mLastReportedIsEarPieceActive); @@ -190,22 +168,4 @@ public class SarInfo { pw.println("Reported " + (System.currentTimeMillis() - mLastReportedScenarioTs) / 1000 + " seconds ago"); } - - /** - * Convert SAR sensor state to string - */ - public static String sensorStateToString(int sensorState) { - switch(sensorState) { - case SAR_SENSOR_FREE_SPACE: - return SAR_SENSOR_FREE_SPACE_STR; - case SAR_SENSOR_NEAR_BODY: - return SAR_SENSOR_NEAR_BODY_STR; - case SAR_SENSOR_NEAR_HAND: - return SAR_SENSOR_NEAR_HAND_STR; - case SAR_SENSOR_NEAR_HEAD: - return SAR_SENSOR_NEAR_HEAD_STR; - default: - return "Invalid SAR sensor state"; - } - } } diff --git a/service/java/com/android/server/wifi/SarManager.java b/service/java/com/android/server/wifi/SarManager.java index be25123d6..eaba1b9bb 100644 --- a/service/java/com/android/server/wifi/SarManager.java +++ b/service/java/com/android/server/wifi/SarManager.java @@ -24,10 +24,6 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; import android.media.AudioManager; import android.media.AudioSystem; import android.net.wifi.WifiManager; @@ -36,7 +32,6 @@ import android.os.HandlerExecutor; import android.os.Looper; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; -import android.text.TextUtils; import android.util.Log; import com.android.server.wifi.util.WifiHandler; @@ -44,7 +39,6 @@ import com.android.wifi.R; import java.io.FileDescriptor; import java.io.PrintWriter; -import java.util.List; /** * This class provides the Support for SAR to control WiFi TX power limits. @@ -53,7 +47,6 @@ import java.util.List; * - Tracking the SAP state through calls from SoftApManager * - Tracking the Scan-Only state through ScanOnlyModeManager * - Tracking the state of the Cellular calls or data. - * - Tracking the sensor indicating proximity to user head/hand/body. * - It constructs the sar info and send it towards the HAL */ public class SarManager { @@ -69,12 +62,6 @@ public class SarManager { private boolean mSupportSarTxPowerLimit; private boolean mSupportSarVoiceCall; private boolean mSupportSarSoftAp; - private boolean mSupportSarSensor; - /* Sensor event definitions */ - private int mSarSensorEventFreeSpace; - private int mSarSensorEventNearBody; - private int mSarSensorEventNearHand; - private int mSarSensorEventNearHead; // Device starts with screen on private boolean mScreenOn = false; @@ -87,11 +74,8 @@ public class SarManager { private final TelephonyManager mTelephonyManager; private final WifiPhoneStateListener mPhoneStateListener; private final WifiNative mWifiNative; - private final SarSensorEventListener mSensorListener; - private final SensorManager mSensorManager; private final Handler mHandler; private final Looper mLooper; - private final WifiMetrics mWifiMetrics; /** * Create new instance of SarManager. @@ -99,18 +83,13 @@ public class SarManager { SarManager(Context context, TelephonyManager telephonyManager, Looper looper, - WifiNative wifiNative, - SensorManager sensorManager, - WifiMetrics wifiMetrics) { + WifiNative wifiNative) { mContext = context; mTelephonyManager = telephonyManager; mWifiNative = wifiNative; mLooper = looper; mHandler = new WifiHandler(TAG, looper); - mSensorManager = sensorManager; - mWifiMetrics = wifiMetrics; mPhoneStateListener = new WifiPhoneStateListener(looper); - mSensorListener = new SarSensorEventListener(); readSarConfigs(); if (mSupportSarTxPowerLimit) { @@ -202,7 +181,6 @@ public class SarManager { if (!mSupportSarTxPowerLimit) { mSupportSarVoiceCall = false; mSupportSarSoftAp = false; - mSupportSarSensor = false; return; } @@ -211,27 +189,11 @@ public class SarManager { mSupportSarSoftAp = mContext.getResources().getBoolean( R.bool.config_wifi_framework_enable_soft_ap_sar_tx_power_limit); - - mSupportSarSensor = mContext.getResources().getBoolean( - R.bool.config_wifi_framework_enable_body_proximity_sar_tx_power_limit); - - /* Read the sar sensor event Ids */ - if (mSupportSarSensor) { - mSarSensorEventFreeSpace = mContext.getResources().getInteger( - R.integer.config_wifi_framework_sar_free_space_event_id); - mSarSensorEventNearBody = mContext.getResources().getInteger( - R.integer.config_wifi_framework_sar_near_body_event_id); - mSarSensorEventNearHand = mContext.getResources().getInteger( - R.integer.config_wifi_framework_sar_near_hand_event_id); - mSarSensorEventNearHead = mContext.getResources().getInteger( - R.integer.config_wifi_framework_sar_near_head_event_id); - } } private void setSarConfigsInInfo() { mSarInfo.sarVoiceCallSupported = mSupportSarVoiceCall; mSarInfo.sarSapSupported = mSupportSarSoftAp; - mSarInfo.sarSensorSupported = mSupportSarSensor; } private void registerListeners() { @@ -240,17 +202,6 @@ public class SarManager { registerPhoneStateListener(); registerVoiceStreamListener(); } - - /* Only listen for SAR sensor if supported */ - if (mSupportSarSensor) { - /* Register the SAR sensor listener. - * If this fails, we will assume worst case (near head) */ - if (!registerSensorListener()) { - Log.e(TAG, "Failed to register sensor listener, setting Sensor to NearHead"); - mSarInfo.sensorState = SarInfo.SAR_SENSOR_NEAR_HEAD; - mWifiMetrics.incrementNumSarSensorRegistrationFailures(); - } - } } private void registerVoiceStreamListener() { @@ -313,14 +264,6 @@ public class SarManager { } /** - * Register the body/hand/head proximity sensor. - */ - private boolean registerSensorListener() { - Log.i(TAG, "Registering for Sensor notification Listener"); - return mSensorListener.register(); - } - - /** * Update Wifi Client State */ public void setClientWifiState(int state) { @@ -430,32 +373,6 @@ public class SarManager { } /** - * Report an event from the SAR sensor - */ - private void onSarSensorEvent(int sarSensorEvent) { - int newSensorState; - if (sarSensorEvent == mSarSensorEventFreeSpace) { - newSensorState = SarInfo.SAR_SENSOR_FREE_SPACE; - } else if (sarSensorEvent == mSarSensorEventNearBody) { - newSensorState = SarInfo.SAR_SENSOR_NEAR_BODY; - } else if (sarSensorEvent == mSarSensorEventNearHand) { - newSensorState = SarInfo.SAR_SENSOR_NEAR_HAND; - } else if (sarSensorEvent == mSarSensorEventNearHead) { - newSensorState = SarInfo.SAR_SENSOR_NEAR_HEAD; - } else { - Log.e(TAG, "Invalid SAR sensor event id: " + sarSensorEvent); - return; - } - - /* Report change to HAL if needed */ - if (mSarInfo.sensorState != newSensorState) { - Log.d(TAG, "Setting Sensor state to " + SarInfo.sensorStateToString(newSensorState)); - mSarInfo.sensorState = newSensorState; - updateSarScenario(); - } - } - - /** * Enable/disable verbose logging. */ public void enableVerboseLogging(int verbose) { @@ -475,7 +392,6 @@ public class SarManager { pw.println("isSarSupported: " + mSupportSarTxPowerLimit); pw.println("isSarVoiceCallSupported: " + mSupportSarVoiceCall); pw.println("isSarSoftApSupported: " + mSupportSarSoftAp); - pw.println("isSarSensorSupported: " + mSupportSarSensor); pw.println(""); if (mSarInfo != null) { mSarInfo.dump(fd, pw, args); @@ -492,7 +408,7 @@ public class SarManager { /** * onCallStateChanged() - * This callback is called when a SAR sensor event is received + * This callback is called when a call state event is received * Note that this runs in the WifiCoreHandlerThread * since the corresponding Looper was passed to the WifiPhoneStateListener constructor. */ @@ -508,62 +424,6 @@ public class SarManager { } } - private class SarSensorEventListener implements SensorEventListener { - - private Sensor mSensor; - - /** - * Register the SAR listener to get SAR sensor events - */ - private boolean register() { - /* Get the sensor type from configuration */ - String sensorType = mContext.getResources().getString( - R.string.config_wifi_sar_sensor_type); - if (TextUtils.isEmpty(sensorType)) { - Log.e(TAG, "Empty SAR sensor type"); - return false; - } - - /* Get the sensor object */ - Sensor sensor = null; - List<Sensor> sensorList = mSensorManager.getSensorList(Sensor.TYPE_ALL); - for (Sensor s : sensorList) { - if (sensorType.equals(s.getStringType())) { - sensor = s; - break; - } - } - if (sensor == null) { - Log.e(TAG, "Failed to Find the SAR Sensor"); - return false; - } - - /* Now register the listener */ - if (!mSensorManager.registerListener(this, sensor, - SensorManager.SENSOR_DELAY_NORMAL)) { - Log.e(TAG, "Failed to register SAR Sensor Listener"); - return false; - } - - return true; - } - - /** - * onSensorChanged() - * This callback is called when a SAR sensor event is received - * Note that this runs in the WifiCoreHandlerThread - * since, the corresponding Looper was passed to the SensorManager instance. - */ - @Override - public void onSensorChanged(SensorEvent event) { - onSarSensorEvent((int) event.values[0]); - } - - @Override - public void onAccuracyChanged(Sensor sensor, int accuracy) { - } - } - /** * updateSarScenario() * Update HAL with the new SAR scenario if needed. diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java index d972fbc5f..7103b0444 100644 --- a/service/java/com/android/server/wifi/WifiInjector.java +++ b/service/java/com/android/server/wifi/WifiInjector.java @@ -21,7 +21,6 @@ import android.app.ActivityManager; import android.app.AlarmManager; import android.app.AppOpsManager; import android.content.Context; -import android.hardware.SystemSensorManager; import android.net.IpMemoryStore; import android.net.NetworkCapabilities; import android.net.NetworkKey; @@ -300,8 +299,7 @@ public class WifiInjector { this, mWifiConfigManager, mWifiPermissionsUtil, mWifiMetrics, mClock, mFrameworkFacade, wifiHandler); mSarManager = new SarManager(mContext, makeTelephonyManager(), wifiLooper, - mWifiNative, new SystemSensorManager(mContext, wifiLooper), - mWifiMetrics); + mWifiNative); mWifiDiagnostics = new WifiDiagnostics( mContext, this, mWifiNative, mBuildProperties, new LastMileLogger(this), mClock); diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index c34becf75..321958485 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -2096,13 +2096,6 @@ public class WifiMetrics { } } - /** Increment the failure count of SAR sensor listener registration */ - public void incrementNumSarSensorRegistrationFailures() { - synchronized (mLock) { - mWifiLogProto.numSarSensorRegistrationFailures++; - } - } - /** * Increment N-Way network selection decision histograms: * Counts the size of various sets of scanDetails within a scan, and increment the occurrence @@ -2577,8 +2570,6 @@ public class WifiMetrics { + mWifiLogProto.numSetupSoftApInterfaceFailureDueToWificond); pw.println("mWifiLogProto.numSetupSoftApInterfaceFailureDueToHostapd=" + mWifiLogProto.numSetupSoftApInterfaceFailureDueToHostapd); - pw.println("mWifiLogProto.numSarSensorRegistrationFailures=" - + mWifiLogProto.numSarSensorRegistrationFailures); pw.println("StaEventList:"); for (StaEventWithTime event : mStaEventList) { pw.println(event); diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java index ea8c7688f..eca80bdb9 100644 --- a/service/java/com/android/server/wifi/WifiVendorHal.java +++ b/service/java/com/android/server/wifi/WifiVendorHal.java @@ -2370,16 +2370,8 @@ public class WifiVendorHal { * sarPowerBackoffRequired_1_2() * This method checks if we need to backoff wifi Tx power due to SAR requirements. * It handles the case when the device is running the V1_2 version of WifiChip HAL - * In that HAL version, behavior depends on if SAR sensor input is considered in this device. - * If it is, then whenever the device is near the user body/hand/head, back-off is required. - * Otherwise, we should revert to the V1_1 HAL behavior which is only to perform backoff when - * a voice call is ongoing. */ private boolean sarPowerBackoffRequired_1_2(SarInfo sarInfo) { - /* If SAR sensor is supported, output only dependent on device proximity */ - if (sarInfo.sarSensorSupported) { - return (sarInfo.sensorState != SarInfo.SAR_SENSOR_FREE_SPACE); - } if (sarInfo.sarSapSupported && sarInfo.isWifiSapEnabled) { return true; } @@ -2393,45 +2385,15 @@ public class WifiVendorHal { * frameworkToHalTxPowerScenario_1_2() * This method maps the information inside the SarInfo instance into a SAR scenario * when device is running the V1_2 version of WifiChip HAL. - * In this HAL version, behavior depends on if SAR sensor input is considered in this device. - * If it is, then based on regulatory compliance requirements, - * - There is no need to treat NEAR_HAND different from NEAR_BODY, both can be considered - * near the user body. - * - Running in softAP mode can be treated the same way as running a voice call from tx power - * backoff perspective. - * If SAR sensor input is not supported in this device, but SoftAP is, + * If SAR SoftAP input is supported, * we make these assumptions: * - All voice calls are treated as if device is near the head. * - SoftAP scenario is treated as if device is near the body. - * In case neither SAR sensor, nor SoftAP is supported, then we should revert to the V1_1 HAL + * In case SoftAP is not supported, then we should revert to the V1_1 HAL * behavior, and the only valid scenario would be when a voice call is ongoing. */ private int frameworkToHalTxPowerScenario_1_2(SarInfo sarInfo) { - if (sarInfo.sarSensorSupported) { - switch(sarInfo.sensorState) { - case SarInfo.SAR_SENSOR_NEAR_BODY: - case SarInfo.SAR_SENSOR_NEAR_HAND: - if (sarInfo.isVoiceCall || sarInfo.isWifiSapEnabled) { - return android.hardware.wifi.V1_2.IWifiChip - .TxPowerScenario.ON_BODY_CELL_ON; - } else { - return android.hardware.wifi.V1_2.IWifiChip - .TxPowerScenario.ON_BODY_CELL_OFF; - } - - case SarInfo.SAR_SENSOR_NEAR_HEAD: - if (sarInfo.isVoiceCall || sarInfo.isWifiSapEnabled) { - return android.hardware.wifi.V1_2.IWifiChip - .TxPowerScenario.ON_HEAD_CELL_ON; - } else { - return android.hardware.wifi.V1_2.IWifiChip - .TxPowerScenario.ON_HEAD_CELL_OFF; - } - - default: - throw new IllegalArgumentException("bad scenario: Invalid sensor state"); - } - } else if (sarInfo.sarSapSupported && sarInfo.sarVoiceCallSupported) { + if (sarInfo.sarSapSupported && sarInfo.sarVoiceCallSupported) { if (sarInfo.isVoiceCall || sarInfo.isEarPieceActive) { return android.hardware.wifi.V1_2.IWifiChip .TxPowerScenario.ON_HEAD_CELL_ON; @@ -2442,7 +2404,7 @@ public class WifiVendorHal { throw new IllegalArgumentException("bad scenario: no voice call/softAP active"); } } else if (sarInfo.sarVoiceCallSupported) { - /* SAR Sensors and SoftAP not supported, act like V1_1 */ + /* SAR SoftAP input not supported, act like V1_1 */ if (sarInfo.isVoiceCall || sarInfo.isEarPieceActive) { return android.hardware.wifi.V1_1.IWifiChip.TxPowerScenario.VOICE_CALL; } else { @@ -2463,8 +2425,6 @@ public class WifiVendorHal { * in that case, we should not call the hal unless there is a change in scenario. * Note: It is assumed that this method is only called if SAR is enabled. The logic of whether * to call it or not resides in SarManager class. - * Note: This method is called whether SAR sensor is supported or not. The passed SarInfo object - * contains a flag to indicate the SAR sensor support. * * @param sarInfo The collection of inputs to select the SAR scenario. * @return true for success; false for failure or if the HAL version does not support this API. diff --git a/service/proto/src/metrics.proto b/service/proto/src/metrics.proto index abd70d654..ee7d92dcc 100644 --- a/service/proto/src/metrics.proto +++ b/service/proto/src/metrics.proto @@ -23,6 +23,7 @@ option java_outer_classname = "WifiMetricsProto"; // The information about the Wifi events. message WifiLog { + reserved 122; // Session information that gets logged for every Wifi connection. repeated ConnectionEvent connection_event = 1; @@ -471,9 +472,6 @@ message WifiLog { // with rssi (dBm) and rssi^2 sums (dBm^2) repeated LinkSpeedCount link_speed_counts = 121; - // Number of times the SarManager failed to register SAR sensor listener - optional int32 num_sar_sensor_registration_failures = 122; - // Hardware revision (EVT, DVT, PVT etc.) optional string hardware_revision = 124; diff --git a/service/res/values/config.xml b/service/res/values/config.xml index 928c847e2..bc7ef3bb2 100644 --- a/service/res/values/config.xml +++ b/service/res/values/config.xml @@ -172,25 +172,6 @@ power limit for meeting SAR requirements --> <bool translatable="false" name="config_wifi_framework_enable_soft_ap_sar_tx_power_limit">false</bool> - <!-- Boolean indicating whether framework needs to use body proximity to set the tx power limit - for meeting SAR requirements --> - <bool translatable="false" name="config_wifi_framework_enable_body_proximity_sar_tx_power_limit">false</bool> - - <!-- String for the sensor type for body/head proximity for SAR --> - <string translatable="false" name="config_wifi_sar_sensor_type"></string> - - <!-- Integer indicating event id by sar sensor for free space --> - <integer translatable="false" name="config_wifi_framework_sar_free_space_event_id">1</integer> - - <!-- Integer indicating event id by sar sensor for near hand --> - <integer translatable="false" name="config_wifi_framework_sar_near_hand_event_id">2</integer> - - <!-- Integer indicating event id by sar sensor for near head --> - <integer translatable="false" name="config_wifi_framework_sar_near_head_event_id">3</integer> - - <!-- Integer indicating event id by sar sensor for near body --> - <integer translatable="false" name="config_wifi_framework_sar_near_body_event_id">4</integer> - <!-- Wifi driver supports batched scan --> <bool translatable="false" name="config_wifi_batched_scan_supported">false</bool> diff --git a/service/res/values/overlayable.xml b/service/res/values/overlayable.xml index 093aa8f14..f49e3df3a 100644 --- a/service/res/values/overlayable.xml +++ b/service/res/values/overlayable.xml @@ -81,12 +81,6 @@ <item type="bool" name="config_wifi_only_link_same_credential_configurations" /> <item type="bool" name="config_wifi_framework_enable_sar_tx_power_limit" /> <item type="bool" name="config_wifi_framework_enable_soft_ap_sar_tx_power_limit" /> - <item type="bool" name="config_wifi_framework_enable_body_proximity_sar_tx_power_limit" /> - <item type="string" name="config_wifi_sar_sensor_type" /> - <item type="integer" name="config_wifi_framework_sar_free_space_event_id" /> - <item type="integer" name="config_wifi_framework_sar_near_hand_event_id" /> - <item type="integer" name="config_wifi_framework_sar_near_head_event_id" /> - <item type="integer" name="config_wifi_framework_sar_near_body_event_id" /> <item type="bool" name="config_wifi_batched_scan_supported" /> <item type="bool" name="config_wifi_softap_acs_supported" /> <item type="string" name="config_wifi_softap_acs_supported_channel_list" /> 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 @@ -147,78 +147,7 @@ public class SarInfoTest extends WifiBaseTest { } /** - * 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<Sensor> 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,7 +102,7 @@ public class SarManagerTest extends WifiBaseTest { * Helper function to capture SarInfo object */ private void captureSarInfo(WifiNative wifiNative) { - /* Capture the SensorEventListener */ + /* Capture the SarInfo */ ArgumentCaptor<SarInfo> sarInfoCaptor = ArgumentCaptor.forClass(SarInfo.class); verify(wifiNative).selectTxPowerScenario(sarInfoCaptor.capture()); mSarInfo = sarInfoCaptor.getValue(); @@ -132,71 +110,18 @@ public class SarManagerTest extends WifiBaseTest { } /** - * 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<Sensor> constructor = - (Constructor<Sensor>) 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<Sensor>(); - 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<SensorEventListener> 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<PhoneStateListener> 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<SensorEvent> constructor = - (Constructor<SensorEvent>) 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); @@ -540,274 +393,12 @@ public class SarManagerTest extends WifiBaseTest { } /** - * 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); @@ -835,83 +426,12 @@ public class SarManagerTest extends WifiBaseTest { } /** - * 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; @@ -2635,33 +2621,6 @@ public class WifiVendorHalTest extends WifiBaseTest { } /** - * 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. * This is using HAL 1.2 interface. @@ -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 */ @@ -2700,117 +2654,18 @@ public class WifiVendorHalTest extends WifiBaseTest { } /** - * 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; @@ -2859,68 +2710,6 @@ 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 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 */ |