summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2018-08-16 12:23:00 -0700
committerxshu <xshu@google.com>2018-09-14 16:19:50 -0700
commit85bd09a1ac7271581330c64be285d139070777c8 (patch)
tree6a67d555019437285522e3267d9936096a70ea86
parent82e4e60fbfc8c5422964d9f4e1dfa705c1ce6f4c (diff)
Plumb some fields up from legacy hal
Creates V1_3 StaLinkLayerStats and StaLinkLayerRadioStats to get more scanning related radio data from the legacy hal. Bug: 77603419 Test: compile, unit tests Test: connect to GoogleGuest and verify that LinkLayer stats are collected correctly through the WifiScoreReport printout. Test: Manually observed that WifiLinkLayerStats.toString() is printing out the expected results including the newly added fields in a local test build. Change-Id: If021b32c38ecfd1a7eda6e920ccb8e8bfb04c9d0
-rw-r--r--service/java/com/android/server/wifi/WifiLinkLayerStats.java39
-rw-r--r--service/java/com/android/server/wifi/WifiVendorHal.java163
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java200
3 files changed, 342 insertions, 60 deletions
diff --git a/service/java/com/android/server/wifi/WifiLinkLayerStats.java b/service/java/com/android/server/wifi/WifiLinkLayerStats.java
index 0c586700d..467ae7709 100644
--- a/service/java/com/android/server/wifi/WifiLinkLayerStats.java
+++ b/service/java/com/android/server/wifi/WifiLinkLayerStats.java
@@ -26,6 +26,11 @@ import java.util.Arrays;
* {@hide}
*/
public class WifiLinkLayerStats {
+ public static final String V1_0 = "V1_0";
+ public static final String V1_3 = "V1_3";
+
+ /** The version of hal StaLinkLayerStats **/
+ public String version;
/** Number of beacons received from our own AP */
public int beacon_rx;
@@ -91,6 +96,27 @@ public class WifiLinkLayerStats {
* Cumulative milliseconds when radio is awake due to scan
*/
public int on_time_scan;
+ /**
+ * Cumulative milliseconds when radio is awake due to nan scan
+ */
+ public int on_time_nan_scan = -1;
+ /**
+ * Cumulative milliseconds when radio is awake due to background scan
+ */
+ public int on_time_background_scan = -1;
+ /**
+ * Cumulative milliseconds when radio is awake due to roam scan
+ */
+ public int on_time_roam_scan = -1;
+ /**
+ * Cumulative milliseconds when radio is awake due to pno scan
+ */
+ public int on_time_pno_scan = -1;
+ /**
+ * Cumulative milliseconds when radio is awake due to hotspot 2.0 scan amd GAS exchange
+ */
+ public int on_time_hs20_scan = -1;
+
/**
* TimeStamp - absolute milliseconds from boot when these stats were sampled.
@@ -102,6 +128,7 @@ public class WifiLinkLayerStats {
StringBuilder sbuf = new StringBuilder();
sbuf.append(" WifiLinkLayerStats: ").append('\n');
+ sbuf.append(" version of StaLinkLayerStats: ").append(version).append('\n');
sbuf.append(" my bss beacon rx: ").append(Integer.toString(this.beacon_rx)).append('\n');
sbuf.append(" RSSI mgmt: ").append(Integer.toString(this.rssi_mgmt)).append('\n');
sbuf.append(" BE : ").append(" rx=").append(Long.toString(this.rxmpdu_be))
@@ -121,9 +148,19 @@ public class WifiLinkLayerStats {
.append(" lost=").append(Long.toString(this.lostmpdu_vo))
.append(" retries=").append(Long.toString(this.retries_vo)).append('\n');
sbuf.append(" on_time : ").append(Integer.toString(this.on_time))
+ .append(" tx_time=").append(Integer.toString(this.tx_time))
.append(" rx_time=").append(Integer.toString(this.rx_time))
.append(" scan_time=").append(Integer.toString(this.on_time_scan)).append('\n')
- .append(" tx_time=").append(Integer.toString(this.tx_time))
+ .append(" nan_scan_time=")
+ .append(Integer.toString(this.on_time_nan_scan)).append('\n')
+ .append(" g_scan_time=")
+ .append(Integer.toString(this.on_time_background_scan)).append('\n')
+ .append(" roam_scan_time=")
+ .append(Integer.toString(this.on_time_roam_scan)).append('\n')
+ .append(" pno_scan_time=")
+ .append(Integer.toString(this.on_time_pno_scan)).append('\n')
+ .append(" hs2.0_scan_time=")
+ .append(Integer.toString(this.on_time_hs20_scan)).append('\n')
.append(" tx_time_per_level=" + Arrays.toString(tx_time_per_level));
sbuf.append(" ts=" + timeStampInMs);
return sbuf.toString();
diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java
index d9279bc57..d95bc751c 100644
--- a/service/java/com/android/server/wifi/WifiVendorHal.java
+++ b/service/java/com/android/server/wifi/WifiVendorHal.java
@@ -34,6 +34,7 @@ import android.hardware.wifi.V1_0.RttType;
import android.hardware.wifi.V1_0.StaBackgroundScanBucketEventReportSchemeMask;
import android.hardware.wifi.V1_0.StaBackgroundScanBucketParameters;
import android.hardware.wifi.V1_0.StaBackgroundScanParameters;
+import android.hardware.wifi.V1_0.StaLinkLayerIfaceStats;
import android.hardware.wifi.V1_0.StaLinkLayerRadioStats;
import android.hardware.wifi.V1_0.StaLinkLayerStats;
import android.hardware.wifi.V1_0.StaRoamingConfig;
@@ -925,6 +926,13 @@ public class WifiVendorHal {
* @return the statistics, or null if unable to do so
*/
public WifiLinkLayerStats getWifiLinkLayerStats(@NonNull String ifaceName) {
+ if (getWifiStaIfaceForV1_3Mockable(ifaceName) != null) {
+ return getWifiLinkLayerStats_1_3_Internal(ifaceName);
+ }
+ return getWifiLinkLayerStats_internal(ifaceName);
+ }
+
+ private WifiLinkLayerStats getWifiLinkLayerStats_internal(@NonNull String ifaceName) {
class AnswerBox {
public StaLinkLayerStats value = null;
}
@@ -946,6 +954,30 @@ public class WifiVendorHal {
return stats;
}
+ private WifiLinkLayerStats getWifiLinkLayerStats_1_3_Internal(@NonNull String ifaceName) {
+ class AnswerBox {
+ public android.hardware.wifi.V1_3.StaLinkLayerStats value = null;
+ }
+ AnswerBox answer = new AnswerBox();
+ synchronized (sLock) {
+ try {
+ android.hardware.wifi.V1_3.IWifiStaIface iface =
+ getWifiStaIfaceForV1_3Mockable(ifaceName);
+ if (iface == null) return null;
+ iface.getLinkLayerStats_1_3((status, stats) -> {
+ if (!ok(status)) return;
+ answer.value = stats;
+ });
+ } catch (RemoteException e) {
+ handleRemoteException(e);
+ return null;
+ }
+ }
+ WifiLinkLayerStats stats = frameworkFromHalLinkLayerStats_1_3(answer.value);
+ return stats;
+ }
+
+
/**
* Makes the framework version of link layer stats from the hal version.
*/
@@ -953,43 +985,96 @@ public class WifiVendorHal {
static WifiLinkLayerStats frameworkFromHalLinkLayerStats(StaLinkLayerStats stats) {
if (stats == null) return null;
WifiLinkLayerStats out = new WifiLinkLayerStats();
- out.beacon_rx = stats.iface.beaconRx;
- out.rssi_mgmt = stats.iface.avgRssiMgmt;
+ setIfaceStats(out, stats.iface);
+ setRadioStats(out, stats.radios);
+ setTimeStamp(out, stats.timeStampInMs);
+ out.version = WifiLinkLayerStats.V1_0;
+ return out;
+ }
+
+ /**
+ * Makes the framework version of link layer stats from the hal version.
+ */
+ @VisibleForTesting
+ static WifiLinkLayerStats frameworkFromHalLinkLayerStats_1_3(
+ android.hardware.wifi.V1_3.StaLinkLayerStats stats) {
+ if (stats == null) return null;
+ WifiLinkLayerStats out = new WifiLinkLayerStats();
+ setIfaceStats(out, stats.iface);
+ setRadioStats_1_3(out, stats.radios);
+ setTimeStamp(out, stats.timeStampInMs);
+ out.version = WifiLinkLayerStats.V1_3;
+ return out;
+ }
+
+ private static void setIfaceStats(WifiLinkLayerStats stats, StaLinkLayerIfaceStats iface) {
+ if (iface == null) return;
+ stats.beacon_rx = iface.beaconRx;
+ stats.rssi_mgmt = iface.avgRssiMgmt;
// Statistics are broken out by Wireless Multimedia Extensions categories
// WME Best Effort Access Category
- out.rxmpdu_be = stats.iface.wmeBePktStats.rxMpdu;
- out.txmpdu_be = stats.iface.wmeBePktStats.txMpdu;
- out.lostmpdu_be = stats.iface.wmeBePktStats.lostMpdu;
- out.retries_be = stats.iface.wmeBePktStats.retries;
+ stats.rxmpdu_be = iface.wmeBePktStats.rxMpdu;
+ stats.txmpdu_be = iface.wmeBePktStats.txMpdu;
+ stats.lostmpdu_be = iface.wmeBePktStats.lostMpdu;
+ stats.retries_be = iface.wmeBePktStats.retries;
// WME Background Access Category
- out.rxmpdu_bk = stats.iface.wmeBkPktStats.rxMpdu;
- out.txmpdu_bk = stats.iface.wmeBkPktStats.txMpdu;
- out.lostmpdu_bk = stats.iface.wmeBkPktStats.lostMpdu;
- out.retries_bk = stats.iface.wmeBkPktStats.retries;
+ stats.rxmpdu_bk = iface.wmeBkPktStats.rxMpdu;
+ stats.txmpdu_bk = iface.wmeBkPktStats.txMpdu;
+ stats.lostmpdu_bk = iface.wmeBkPktStats.lostMpdu;
+ stats.retries_bk = iface.wmeBkPktStats.retries;
// WME Video Access Category
- out.rxmpdu_vi = stats.iface.wmeViPktStats.rxMpdu;
- out.txmpdu_vi = stats.iface.wmeViPktStats.txMpdu;
- out.lostmpdu_vi = stats.iface.wmeViPktStats.lostMpdu;
- out.retries_vi = stats.iface.wmeViPktStats.retries;
+ stats.rxmpdu_vi = iface.wmeViPktStats.rxMpdu;
+ stats.txmpdu_vi = iface.wmeViPktStats.txMpdu;
+ stats.lostmpdu_vi = iface.wmeViPktStats.lostMpdu;
+ stats.retries_vi = iface.wmeViPktStats.retries;
// WME Voice Access Category
- out.rxmpdu_vo = stats.iface.wmeVoPktStats.rxMpdu;
- out.txmpdu_vo = stats.iface.wmeVoPktStats.txMpdu;
- out.lostmpdu_vo = stats.iface.wmeVoPktStats.lostMpdu;
- out.retries_vo = stats.iface.wmeVoPktStats.retries;
- // TODO(b/36176141): Figure out how to coalesce this info for multi radio devices.
- if (stats.radios.size() > 0) {
- StaLinkLayerRadioStats radioStats = stats.radios.get(0);
- out.on_time = radioStats.onTimeInMs;
- out.tx_time = radioStats.txTimeInMs;
- out.tx_time_per_level = new int[radioStats.txTimeInMsPerLevel.size()];
- for (int i = 0; i < out.tx_time_per_level.length; i++) {
- out.tx_time_per_level[i] = radioStats.txTimeInMsPerLevel.get(i);
- }
- out.rx_time = radioStats.rxTimeInMs;
- out.on_time_scan = radioStats.onTimeInMsForScan;
- }
- out.timeStampInMs = stats.timeStampInMs;
- return out;
+ stats.rxmpdu_vo = iface.wmeVoPktStats.rxMpdu;
+ stats.txmpdu_vo = iface.wmeVoPktStats.txMpdu;
+ stats.lostmpdu_vo = iface.wmeVoPktStats.lostMpdu;
+ stats.retries_vo = iface.wmeVoPktStats.retries;
+ }
+
+ private static void setRadioStats(WifiLinkLayerStats stats,
+ List<StaLinkLayerRadioStats> radios) {
+ if (radios == null) return;
+ // NOTE(b/36176141): Figure out how to coalesce this info for multi radio devices.
+ if (radios.size() > 0) {
+ StaLinkLayerRadioStats radioStats = radios.get(0);
+ stats.on_time = radioStats.onTimeInMs;
+ stats.tx_time = radioStats.txTimeInMs;
+ stats.tx_time_per_level = new int[radioStats.txTimeInMsPerLevel.size()];
+ for (int i = 0; i < stats.tx_time_per_level.length; i++) {
+ stats.tx_time_per_level[i] = radioStats.txTimeInMsPerLevel.get(i);
+ }
+ stats.rx_time = radioStats.rxTimeInMs;
+ stats.on_time_scan = radioStats.onTimeInMsForScan;
+ }
+ }
+
+ private static void setRadioStats_1_3(WifiLinkLayerStats stats,
+ List<android.hardware.wifi.V1_3.StaLinkLayerRadioStats> radios) {
+ if (radios == null) return;
+ // NOTE(b/36176141): Figure out how to coalesce this info for multi radio devices.
+ if (radios.size() > 0) {
+ android.hardware.wifi.V1_3.StaLinkLayerRadioStats radioStats = radios.get(0);
+ stats.on_time = radioStats.V1_0.onTimeInMs;
+ stats.tx_time = radioStats.V1_0.txTimeInMs;
+ stats.tx_time_per_level = new int[radioStats.V1_0.txTimeInMsPerLevel.size()];
+ for (int i = 0; i < stats.tx_time_per_level.length; i++) {
+ stats.tx_time_per_level[i] = radioStats.V1_0.txTimeInMsPerLevel.get(i);
+ }
+ stats.rx_time = radioStats.V1_0.rxTimeInMs;
+ stats.on_time_scan = radioStats.V1_0.onTimeInMsForScan;
+ stats.on_time_nan_scan = radioStats.onTimeInMsForNanScan;
+ stats.on_time_background_scan = radioStats.onTimeInMsForBgScan;
+ stats.on_time_roam_scan = radioStats.onTimeInMsForRoamScan;
+ stats.on_time_pno_scan = radioStats.onTimeInMsForPnoScan;
+ stats.on_time_hs20_scan = radioStats.onTimeInMsForHs20Scan;
+ }
+ }
+
+ private static void setTimeStamp(WifiLinkLayerStats stats, long timeStampInMs) {
+ stats.timeStampInMs = timeStampInMs;
}
@VisibleForTesting
@@ -2652,6 +2737,20 @@ public class WifiVendorHal {
}
/**
+ * Method to mock out the V1_3 IWifiStaIface retrieval in unit tests.
+ *
+ * @param ifaceName Name of the interface
+ * @return 1.3 IWifiStaIface object if the device is running the 1.3 wifi hal service, null
+ * otherwise.
+ */
+ protected android.hardware.wifi.V1_3.IWifiStaIface getWifiStaIfaceForV1_3Mockable(
+ @NonNull String ifaceName) {
+ IWifiStaIface iface = getStaIface(ifaceName);
+ if (iface == null) return null;
+ return android.hardware.wifi.V1_3.IWifiStaIface.castFrom(iface);
+ }
+
+ /**
* sarPowerBackoffRequired_1_1()
* 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_1 version of WifiChip HAL
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
index c0a9cf252..d5259c710 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
@@ -61,6 +61,7 @@ import android.hardware.wifi.V1_0.StaApfPacketFilterCapabilities;
import android.hardware.wifi.V1_0.StaBackgroundScanCapabilities;
import android.hardware.wifi.V1_0.StaBackgroundScanParameters;
import android.hardware.wifi.V1_0.StaLinkLayerIfacePacketStats;
+import android.hardware.wifi.V1_0.StaLinkLayerIfaceStats;
import android.hardware.wifi.V1_0.StaLinkLayerRadioStats;
import android.hardware.wifi.V1_0.StaLinkLayerStats;
import android.hardware.wifi.V1_0.StaRoamingCapabilities;
@@ -152,6 +153,8 @@ public class WifiVendorHalTest {
@Mock
private android.hardware.wifi.V1_2.IWifiStaIface mIWifiStaIfaceV12;
@Mock
+ private android.hardware.wifi.V1_3.IWifiStaIface mIWifiStaIfaceV13;
+ @Mock
private IWifiRttController mIWifiRttController;
private IWifiStaIfaceEventCallback mIWifiStaIfaceEventCallback;
private IWifiChipEventCallback mIWifiChipEventCallback;
@@ -185,6 +188,12 @@ public class WifiVendorHalTest {
String ifaceName) {
return null;
}
+
+ @Override
+ protected android.hardware.wifi.V1_3.IWifiStaIface getWifiStaIfaceForV1_3Mockable(
+ String ifaceName) {
+ return null;
+ }
}
/**
@@ -211,6 +220,44 @@ public class WifiVendorHalTest {
String ifaceName) {
return mIWifiStaIfaceV12;
}
+
+ @Override
+ protected android.hardware.wifi.V1_3.IWifiStaIface getWifiStaIfaceForV1_3Mockable(
+ String ifaceName) {
+ return null;
+ }
+ }
+
+ /**
+ * Spy used to return the V1_2 IWifiChip and V1_3 IWifiStaIface mock objects to simulate
+ * the 1.3 HAL running on the device.
+ */
+ private class WifiVendorHalSpyV1_3 extends WifiVendorHal {
+ WifiVendorHalSpyV1_3(HalDeviceManager halDeviceManager, Looper looper) {
+ super(halDeviceManager, looper);
+ }
+
+ @Override
+ protected android.hardware.wifi.V1_1.IWifiChip getWifiChipForV1_1Mockable() {
+ return null;
+ }
+
+ @Override
+ protected android.hardware.wifi.V1_2.IWifiChip getWifiChipForV1_2Mockable() {
+ return mIWifiChipV12;
+ }
+
+ @Override
+ protected android.hardware.wifi.V1_2.IWifiStaIface getWifiStaIfaceForV1_2Mockable(
+ String ifaceName) {
+ return mIWifiStaIfaceV12;
+ }
+
+ @Override
+ protected android.hardware.wifi.V1_3.IWifiStaIface getWifiStaIfaceForV1_3Mockable(
+ String ifaceName) {
+ return mIWifiStaIfaceV13;
+ }
}
/**
@@ -797,6 +844,16 @@ public class WifiVendorHalTest {
}
/**
+ * Test getLinkLayerStats_1_3 gets called when the hal version is V1_3.
+ */
+ @Test
+ public void testLinkLayerStatsCorrectVersionWithHalV1_3() throws Exception {
+ mWifiVendorHal = new WifiVendorHalSpyV1_3(mHalDeviceManager, mLooper.getLooper());
+ mWifiVendorHal.getWifiLinkLayerStats(TEST_IFACE_NAME);
+ verify(mIWifiStaIfaceV13).getLinkLayerStats_1_3(any());
+ }
+
+ /**
* Test that link layer stats are not enabled and harmless in AP mode
*
* Start the HAL in AP mode
@@ -821,11 +878,9 @@ public class WifiVendorHalTest {
/**
* Test that the link layer stats fields are populated correctly.
*
- * This is done by filling with random values and then using toString on the
- * original and converted values, comparing just the numerics in the result.
- * This makes the assumption that the fields are in the same order in both string
- * representations, which is not quite true. So apply some fixups before the final
- * comparison.
+ * This is done by filling Hal LinkLayerStats (V1_0) with random values, converting it to
+ * WifiLinkLayerStats and then asserting the values in the original structure are equal to the
+ * values in the converted structure.
*/
@Test
public void testLinkLayerStatsAssignment() throws Exception {
@@ -836,37 +891,105 @@ public class WifiVendorHalTest {
randomizePacketStats(r, stats.iface.wmeViPktStats);
randomizePacketStats(r, stats.iface.wmeVoPktStats);
randomizeRadioStats(r, stats.radios);
-
stats.timeStampInMs = r.nextLong() & 0xFFFFFFFFFFL;
- String expected = numbersOnly(stats.toString() + " ");
-
WifiLinkLayerStats converted = WifiVendorHal.frameworkFromHalLinkLayerStats(stats);
- String actual = numbersOnly(converted.toString() + " ");
-
- // Do the required fixups to the both expected and actual
- expected = rmValue(expected, stats.radios.get(0).rxTimeInMs);
- expected = rmValue(expected, stats.radios.get(0).onTimeInMsForScan);
+ verifyIFaceStats(stats.iface, converted);
+ verifyRadioStats(stats.radios, converted);
+ assertEquals(stats.timeStampInMs, converted.timeStampInMs);
+ assertEquals(WifiLinkLayerStats.V1_0, converted.version);
+ }
- actual = rmValue(actual, stats.radios.get(0).rxTimeInMs);
- actual = rmValue(actual, stats.radios.get(0).onTimeInMsForScan);
+ /**
+ * Test that the link layer stats V1_3 fields are populated correctly.
+ *
+ * This is done by filling Hal LinkLayerStats (V1_3) with random values, converting it to
+ * WifiLinkLayerStats and then asserting the values in the original structure are equal to the
+ * values in the converted structure.
+ */
+ @Test
+ public void testLinkLayerStatsAssignment_1_3() throws Exception {
+ Random r = new Random(1775968256);
+ android.hardware.wifi.V1_3.StaLinkLayerStats stats =
+ new android.hardware.wifi.V1_3.StaLinkLayerStats();
+ randomizePacketStats(r, stats.iface.wmeBePktStats);
+ randomizePacketStats(r, stats.iface.wmeBkPktStats);
+ randomizePacketStats(r, stats.iface.wmeViPktStats);
+ randomizePacketStats(r, stats.iface.wmeVoPktStats);
+ randomizeRadioStats_1_3(r, stats.radios);
+ stats.timeStampInMs = r.nextLong() & 0xFFFFFFFFFFL;
- // The remaining fields should agree
- assertEquals(expected, actual);
+ WifiLinkLayerStats converted = WifiVendorHal.frameworkFromHalLinkLayerStats_1_3(stats);
+
+ verifyIFaceStats(stats.iface, converted);
+ verifyRadioStats_1_3(stats.radios, converted);
+ assertEquals(stats.timeStampInMs, converted.timeStampInMs);
+ assertEquals(WifiLinkLayerStats.V1_3, converted.version);
+ }
+
+ private void verifyIFaceStats(StaLinkLayerIfaceStats iface,
+ WifiLinkLayerStats wifiLinkLayerStats) {
+ assertEquals(iface.beaconRx, wifiLinkLayerStats.beacon_rx);
+ assertEquals(iface.avgRssiMgmt, wifiLinkLayerStats.rssi_mgmt);
+
+ assertEquals(iface.wmeBePktStats.rxMpdu, wifiLinkLayerStats.rxmpdu_be);
+ assertEquals(iface.wmeBePktStats.txMpdu, wifiLinkLayerStats.txmpdu_be);
+ assertEquals(iface.wmeBePktStats.lostMpdu, wifiLinkLayerStats.lostmpdu_be);
+ assertEquals(iface.wmeBePktStats.retries, wifiLinkLayerStats.retries_be);
+
+ assertEquals(iface.wmeBkPktStats.rxMpdu, wifiLinkLayerStats.rxmpdu_bk);
+ assertEquals(iface.wmeBkPktStats.txMpdu, wifiLinkLayerStats.txmpdu_bk);
+ assertEquals(iface.wmeBkPktStats.lostMpdu, wifiLinkLayerStats.lostmpdu_bk);
+ assertEquals(iface.wmeBkPktStats.retries, wifiLinkLayerStats.retries_bk);
+
+ assertEquals(iface.wmeViPktStats.rxMpdu, wifiLinkLayerStats.rxmpdu_vi);
+ assertEquals(iface.wmeViPktStats.txMpdu, wifiLinkLayerStats.txmpdu_vi);
+ assertEquals(iface.wmeViPktStats.lostMpdu, wifiLinkLayerStats.lostmpdu_vi);
+ assertEquals(iface.wmeViPktStats.retries, wifiLinkLayerStats.retries_vi);
+
+ assertEquals(iface.wmeVoPktStats.rxMpdu, wifiLinkLayerStats.rxmpdu_vo);
+ assertEquals(iface.wmeVoPktStats.txMpdu, wifiLinkLayerStats.txmpdu_vo);
+ assertEquals(iface.wmeVoPktStats.lostMpdu, wifiLinkLayerStats.lostmpdu_vo);
+ assertEquals(iface.wmeVoPktStats.retries, wifiLinkLayerStats.retries_vo);
+ }
+
+ private void verifyRadioStats(List<StaLinkLayerRadioStats> radios,
+ WifiLinkLayerStats wifiLinkLayerStats) {
+ StaLinkLayerRadioStats radio = radios.get(0);
+ assertEquals(radio.onTimeInMs, wifiLinkLayerStats.on_time);
+ assertEquals(radio.txTimeInMs, wifiLinkLayerStats.tx_time);
+ assertEquals(radio.rxTimeInMs, wifiLinkLayerStats.rx_time);
+ assertEquals(radio.onTimeInMsForScan, wifiLinkLayerStats.on_time_scan);
+ assertEquals(radio.txTimeInMsPerLevel.size(),
+ wifiLinkLayerStats.tx_time_per_level.length);
+ for (int i = 0; i < radio.txTimeInMsPerLevel.size(); i++) {
+ assertEquals((int) radio.txTimeInMsPerLevel.get(i),
+ wifiLinkLayerStats.tx_time_per_level[i]);
+ }
}
- /** Just the digits with delimiting spaces, please */
- private static String numbersOnly(String s) {
- return s.replaceAll("[^0-9]+", " ");
+ private void verifyRadioStats_1_3(
+ List<android.hardware.wifi.V1_3.StaLinkLayerRadioStats> radios,
+ WifiLinkLayerStats wifiLinkLayerStats) {
+ android.hardware.wifi.V1_3.StaLinkLayerRadioStats radio = radios.get(0);
+ assertEquals(radio.V1_0.onTimeInMs, wifiLinkLayerStats.on_time);
+ assertEquals(radio.V1_0.txTimeInMs, wifiLinkLayerStats.tx_time);
+ assertEquals(radio.V1_0.rxTimeInMs, wifiLinkLayerStats.rx_time);
+ assertEquals(radio.V1_0.onTimeInMsForScan, wifiLinkLayerStats.on_time_scan);
+ assertEquals(radio.V1_0.txTimeInMsPerLevel.size(),
+ wifiLinkLayerStats.tx_time_per_level.length);
+ for (int i = 0; i < radio.V1_0.txTimeInMsPerLevel.size(); i++) {
+ assertEquals((int) radio.V1_0.txTimeInMsPerLevel.get(i),
+ wifiLinkLayerStats.tx_time_per_level[i]);
+ }
+ assertEquals(radio.onTimeInMsForNanScan, wifiLinkLayerStats.on_time_nan_scan);
+ assertEquals(radio.onTimeInMsForBgScan, wifiLinkLayerStats.on_time_background_scan);
+ assertEquals(radio.onTimeInMsForRoamScan, wifiLinkLayerStats.on_time_roam_scan);
+ assertEquals(radio.onTimeInMsForPnoScan, wifiLinkLayerStats.on_time_pno_scan);
+ assertEquals(radio.onTimeInMsForHs20Scan, wifiLinkLayerStats.on_time_hs20_scan);
}
- /** Remove the given value from the space-delimited string, or die trying. */
- private static String rmValue(String s, long value) throws Exception {
- String ans = s.replaceAll(" " + value + " ", " ");
- assertNotEquals(s, ans);
- return ans;
- }
/**
* Populate packet stats with non-negative random values
@@ -878,7 +1001,7 @@ public class WifiVendorHalTest {
pstats.retries = r.nextLong() & 0xFFFFFFFFFFL;
}
- /**
+ /**
* Populate radio stats with non-negative random values
*/
private static void randomizeRadioStats(Random r, ArrayList<StaLinkLayerRadioStats> rstats) {
@@ -895,6 +1018,29 @@ public class WifiVendorHalTest {
}
/**
+ * Populate radio stats with non-negative random values
+ */
+ private static void randomizeRadioStats_1_3(Random r,
+ ArrayList<android.hardware.wifi.V1_3.StaLinkLayerRadioStats> rstats) {
+ android.hardware.wifi.V1_3.StaLinkLayerRadioStats rstat =
+ new android.hardware.wifi.V1_3.StaLinkLayerRadioStats();
+ rstat.V1_0.onTimeInMs = r.nextInt() & 0xFFFFFF;
+ rstat.V1_0.txTimeInMs = r.nextInt() & 0xFFFFFF;
+ for (int i = 0; i < 4; i++) {
+ Integer v = r.nextInt() & 0xFFFFFF;
+ rstat.V1_0.txTimeInMsPerLevel.add(v);
+ }
+ rstat.V1_0.rxTimeInMs = r.nextInt() & 0xFFFFFF;
+ rstat.V1_0.onTimeInMsForScan = r.nextInt() & 0xFFFFFF;
+ rstat.onTimeInMsForNanScan = r.nextInt() & 0xFFFFFF;
+ rstat.onTimeInMsForBgScan = r.nextInt() & 0xFFFFFF;
+ rstat.onTimeInMsForRoamScan = r.nextInt() & 0xFFFFFF;
+ rstat.onTimeInMsForPnoScan = r.nextInt() & 0xFFFFFF;
+ rstat.onTimeInMsForHs20Scan = r.nextInt() & 0xFFFFFF;
+ rstats.add(rstat);
+ }
+
+ /**
* Test that getFirmwareVersion() and getDriverVersion() work
*
* Calls before the STA is started are expected to return null.