diff options
author | David Su <dysu@google.com> | 2019-04-02 17:48:52 -0700 |
---|---|---|
committer | David Su <dysu@google.com> | 2019-04-04 18:42:06 +0000 |
commit | a97544483c791cad7c5e46b9aaa85b40da7587dd (patch) | |
tree | 648fe02b8d72c823fec2dddeb601b7993e22a100 | |
parent | 89bce6ef926ea42e0b77b9098e8bb41b6568c4da (diff) |
WifiMetrics: Add link probe event to StaEvent
Add link probe event type to StaEvent in order to correlate link probe
success/failure with other StaEvents (e.g. disconnection, score breach).
Bug: 112029045
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: Ice7a4f3f775cf399c74586e913d9db6dc5c806e3
3 files changed, 92 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index 5220cb201..0ca2ac284 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -3284,7 +3284,7 @@ public class WifiMetrics { } } - private static int linkProbeFailureReasonToProto(int reason) { + private static int linkProbeFailureReasonToProto(@WifiNative.SendMgmtFrameError int reason) { switch (reason) { case WifiNative.SEND_MGMT_FRAME_ERROR_MCS_UNSUPPORTED: return LinkProbeStats.LINK_PROBE_FAILURE_REASON_MCS_UNSUPPORTED; @@ -3800,6 +3800,16 @@ public class WifiMetrics { case StaEvent.TYPE_WIFI_USABILITY_SCORE_BREACH: sb.append("WIFI_USABILITY_SCORE_BREACH"); break; + case StaEvent.TYPE_LINK_PROBE: + sb.append("LINK_PROBE"); + sb.append(" linkProbeWasSuccess=").append(event.linkProbeWasSuccess); + if (event.linkProbeWasSuccess) { + sb.append(" linkProbeSuccessElapsedTimeMs=") + .append(event.linkProbeSuccessElapsedTimeMs); + } else { + sb.append(" linkProbeFailureReason=").append(event.linkProbeFailureReason); + } + break; default: sb.append("UNKNOWN " + event.type + ":"); break; @@ -4629,6 +4639,13 @@ public class WifiMetrics { mLinkProbeSuccessRssiCounts.increment(rssi); mLinkProbeSuccessLinkSpeedCounts.increment(linkSpeed); mLinkProbeSuccessElapsedTimeMsHistogram.increment(elapsedTimeMs); + + StaEvent event = new StaEvent(); + event.type = StaEvent.TYPE_LINK_PROBE; + event.linkProbeWasSuccess = true; + event.linkProbeSuccessElapsedTimeMs = elapsedTimeMs; + // TODO(129958996): Cap number of link probe StaEvents + addStaEvent(event); } } @@ -4655,6 +4672,13 @@ public class WifiMetrics { mLinkProbeFailureRssiCounts.increment(rssi); mLinkProbeFailureLinkSpeedCounts.increment(linkSpeed); mLinkProbeFailureReasonCounts.increment(reason); + + StaEvent event = new StaEvent(); + event.type = StaEvent.TYPE_LINK_PROBE; + event.linkProbeWasSuccess = false; + event.linkProbeFailureReason = linkProbeFailureReasonToProto(reason); + // TODO(129958996): Cap number of link probe StaEvents + addStaEvent(event); } } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index 5dbde31f6..85a759961 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -24,10 +24,13 @@ import static com.android.server.wifi.WifiMetricsTestUtil.assertDeviceMobilitySt import static com.android.server.wifi.WifiMetricsTestUtil.assertHistogramBucketsEqual; import static com.android.server.wifi.WifiMetricsTestUtil.assertKeyCountsEqual; import static com.android.server.wifi.WifiMetricsTestUtil.assertLinkProbeFailureReasonCountsEqual; +import static com.android.server.wifi.WifiMetricsTestUtil.assertLinkProbeStaEventsEqual; import static com.android.server.wifi.WifiMetricsTestUtil.buildDeviceMobilityStatePnoScanStats; import static com.android.server.wifi.WifiMetricsTestUtil.buildHistogramBucketInt32; import static com.android.server.wifi.WifiMetricsTestUtil.buildInt32Count; import static com.android.server.wifi.WifiMetricsTestUtil.buildLinkProbeFailureReasonCount; +import static com.android.server.wifi.WifiMetricsTestUtil.buildLinkProbeFailureStaEvent; +import static com.android.server.wifi.WifiMetricsTestUtil.buildLinkProbeSuccessStaEvent; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -3344,6 +3347,17 @@ public class WifiMetricsTest { WifiNative.SEND_MGMT_FRAME_ERROR_TIMEOUT); dumpProtoAndDeserialize(); + + StaEvent[] expected = { + buildLinkProbeSuccessStaEvent(5), + buildLinkProbeFailureStaEvent(LinkProbeStats.LINK_PROBE_FAILURE_REASON_NO_ACK), + buildLinkProbeSuccessStaEvent(12), + buildLinkProbeFailureStaEvent(LinkProbeStats.LINK_PROBE_FAILURE_REASON_NO_ACK), + buildLinkProbeSuccessStaEvent(10), + buildLinkProbeFailureStaEvent(LinkProbeStats.LINK_PROBE_FAILURE_REASON_TIMEOUT) + }; + assertLinkProbeStaEventsEqual(expected, mDecodedProto.staEventList); + LinkProbeStats linkProbeStats = mDecodedProto.linkProbeStats; Int32Count[] expectedSuccessRssiHistogram = { diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTestUtil.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTestUtil.java index 84ec37ce0..407d20932 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTestUtil.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTestUtil.java @@ -24,6 +24,7 @@ import com.android.server.wifi.nano.WifiMetricsProto.DeviceMobilityStatePnoScanS import com.android.server.wifi.nano.WifiMetricsProto.HistogramBucketInt32; import com.android.server.wifi.nano.WifiMetricsProto.Int32Count; import com.android.server.wifi.nano.WifiMetricsProto.LinkProbeStats.LinkProbeFailureReasonCount; +import com.android.server.wifi.nano.WifiMetricsProto.StaEvent; import java.util.Arrays; import java.util.Comparator; @@ -174,4 +175,56 @@ public class WifiMetricsTestUtil { expectedStats.pnoDurationMs, actualStats.pnoDurationMs); } } + + /** + * Creates a StaEvent of type TYPE_LINK_PROBE that was successful. + */ + public static StaEvent buildLinkProbeSuccessStaEvent(int elapsedTimeMs) { + StaEvent probe = new StaEvent(); + probe.type = StaEvent.TYPE_LINK_PROBE; + probe.linkProbeWasSuccess = true; + probe.linkProbeSuccessElapsedTimeMs = elapsedTimeMs; + return probe; + } + + /** + * Creates a StaEvent of type TYPE_LINK_PROBE that failed. + */ + public static StaEvent buildLinkProbeFailureStaEvent(int reason) { + StaEvent probe = new StaEvent(); + probe.type = StaEvent.TYPE_LINK_PROBE; + probe.linkProbeWasSuccess = false; + probe.linkProbeFailureReason = reason; + return probe; + } + + /** + * Asserts that the two arrays are equal, reporting any difference between them. + * Note that the order must match. + */ + public static void assertLinkProbeStaEventsEqual(StaEvent[] expected, StaEvent[] actual) { + assertEquals("Number of StaEvents do not match!", expected.length, actual.length); + + for (int i = 0; i < expected.length; i++) { + StaEvent expectedEvent = expected[i]; + StaEvent actualEvent = actual[i]; + + assertEquals(String.format("expected StaEvent[%d].type != TYPE_LINK_PROBE", i), + StaEvent.TYPE_LINK_PROBE, expectedEvent.type); + assertEquals(String.format("actual StaEvent[%d].type != TYPE_LINK_PROBE", i), + StaEvent.TYPE_LINK_PROBE, actualEvent.type); + assertEquals(String.format("StaEvent[%d].linkProbeWasSuccess does not match!", i), + expectedEvent.linkProbeWasSuccess, actualEvent.linkProbeWasSuccess); + if (expectedEvent.linkProbeWasSuccess) { + assertEquals(String.format( + "StaEvent[%d].linkProbeSuccessElapsedTimeMs does not match!", i), + expectedEvent.linkProbeSuccessElapsedTimeMs, + actualEvent.linkProbeSuccessElapsedTimeMs); + } else { + assertEquals(String.format( + "StaEvent[%d].linkProbeFailureReason does not match!", i), + expectedEvent.linkProbeFailureReason, actualEvent.linkProbeFailureReason); + } + } + } } |