From bed0885e92c77d5d033eb7b19838b3a090706b20 Mon Sep 17 00:00:00 2001 From: Mingguang Xu Date: Thu, 24 Jan 2019 23:00:10 -0800 Subject: [PATCH] Wifi usability: Add link probe results and rx link speed into usability stats As title indicates. Bug: 113262380 Test: frameworks/base/wifi/tests/runtests.sh Change-Id: Idfa70d314f2938ea42a8b308c7d74e274af7c3cb Signed-off-by: Mingguang Xu --- api/system-current.txt | 8 ++++ proto/src/wifi.proto | 27 +++++++++++ .../net/wifi/WifiUsabilityStatsEntry.java | 45 ++++++++++++++++++- .../net/wifi/WifiUsabilityStatsEntryTest.java | 7 ++- 4 files changed, 84 insertions(+), 3 deletions(-) diff --git a/api/system-current.txt b/api/system-current.txt index e0af359c999bd..e81cb7cf78a14 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4924,8 +4924,16 @@ package android.net.wifi { method public int describeContents(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; + field public static final int PROBE_STATUS_FAILURE = 3; // 0x3 + field public static final int PROBE_STATUS_NO_PROBE = 1; // 0x1 + field public static final int PROBE_STATUS_SUCCESS = 2; // 0x2 + field public static final int PROBE_STATUS_UNKNOWN = 0; // 0x0 field public final int linkSpeedMbps; + field public final int probeElapsedTimeMsSinceLastUpdate; + field public final int probeMcsRateSinceLastUpdate; + field public final int probeStatusSinceLastUpdate; field public final int rssi; + field public final int rxLinkSpeedMbps; field public final long timeStampMs; field public final long totalBackgroundScanTimeMs; field public final long totalBeaconRx; diff --git a/proto/src/wifi.proto b/proto/src/wifi.proto index c063e82766edf..f3d8062f4f7d6 100644 --- a/proto/src/wifi.proto +++ b/proto/src/wifi.proto @@ -1754,6 +1754,21 @@ message WifiLinkLayerUsageStats { } message WifiUsabilityStatsEntry { + // Status codes for link probe status + enum LinkProbeStatus { + // Link probe status is unknown + PROBE_STATUS_UNKNOWN = 0; + + // Link probe is not triggered + PROBE_STATUS_NO_PROBE = 1; + + // Link probe is triggered and the result is success + PROBE_STATUS_SUCCESS = 2; + + // Link probe is triggered and the result is failure + PROBE_STATUS_FAILURE = 3; + } + // Absolute milliseconds from device boot when these stats were sampled optional int64 time_stamp_ms = 1; @@ -1826,6 +1841,18 @@ message WifiUsabilityStatsEntry { // Prediction horizon (in second) of Wifi usability score provided by external // system app optional int32 prediction_horizon_sec = 23; + + // The link probe status since last stats update + optional LinkProbeStatus probe_status_since_last_update = 24; + + // The elapsed time of the most recent link probe since last stats update; + optional int32 probe_elapsed_time_ms_since_last_update = 25; + + // The MCS rate of the most recent link probe since last stats update + optional int32 probe_mcs_rate_since_last_update = 26; + + // Rx link speed at the sample time in Mbps + optional int32 rx_link_speed_mbps = 27; } message WifiUsabilityStats { diff --git a/wifi/java/android/net/wifi/WifiUsabilityStatsEntry.java b/wifi/java/android/net/wifi/WifiUsabilityStatsEntry.java index c796e29e4e1a3..c43818da359c4 100644 --- a/wifi/java/android/net/wifi/WifiUsabilityStatsEntry.java +++ b/wifi/java/android/net/wifi/WifiUsabilityStatsEntry.java @@ -16,10 +16,14 @@ package android.net.wifi; +import android.annotation.IntDef; import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + /** * This class makes a subset of * com.android.server.wifi.nano.WifiMetricsProto.WifiUsabilityStatsEntry parcelable. @@ -28,6 +32,24 @@ import android.os.Parcelable; */ @SystemApi public final class WifiUsabilityStatsEntry implements Parcelable { + /** {@hide} */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(prefix = {"PROBE_STATUS_"}, value = { + PROBE_STATUS_UNKNOWN, + PROBE_STATUS_NO_PROBE, + PROBE_STATUS_SUCCESS, + PROBE_STATUS_FAILURE}) + public @interface ProbeStatus {} + + /** Link probe status is unknown */ + public static final int PROBE_STATUS_UNKNOWN = 0; + /** Link probe is not triggered */ + public static final int PROBE_STATUS_NO_PROBE = 1; + /** Link probe is triggered and the result is success */ + public static final int PROBE_STATUS_SUCCESS = 2; + /** Link probe is triggered and the result is failure */ + public static final int PROBE_STATUS_FAILURE = 3; + /** Absolute milliseconds from device boot when these stats were sampled */ public final long timeStampMs; /** The RSSI (in dBm) at the sample time */ @@ -68,6 +90,14 @@ public final class WifiUsabilityStatsEntry implements Parcelable { public final long totalRadioOnFreqTimeMs; /** The total number of beacons received from the last radio chip reset */ public final long totalBeaconRx; + /** The status of link probe since last stats update */ + public final int probeStatusSinceLastUpdate; + /** The elapsed time of the most recent link probe since last stats update */ + public final int probeElapsedTimeMsSinceLastUpdate; + /** The MCS rate of the most recent link probe since last stats update */ + public final int probeMcsRateSinceLastUpdate; + /** Rx link speed at the sample time in Mbps */ + public final int rxLinkSpeedMbps; /** Constructor function {@hide} */ public WifiUsabilityStatsEntry(long timeStampMs, int rssi, @@ -76,7 +106,9 @@ public final class WifiUsabilityStatsEntry implements Parcelable { long totalRadioTxTimeMs, long totalRadioRxTimeMs, long totalScanTimeMs, long totalNanScanTimeMs, long totalBackgroundScanTimeMs, long totalRoamScanTimeMs, long totalPnoScanTimeMs, long totalHotspot2ScanTimeMs, long totalCcaBusyFreqTimeMs, - long totalRadioOnFreqTimeMs, long totalBeaconRx) { + long totalRadioOnFreqTimeMs, long totalBeaconRx, + @ProbeStatus int probeStatusSinceLastUpdate, int probeElapsedTimeMsSinceLastUpdate, + int probeMcsRateSinceLastUpdate, int rxLinkSpeedMbps) { this.timeStampMs = timeStampMs; this.rssi = rssi; this.linkSpeedMbps = linkSpeedMbps; @@ -96,6 +128,10 @@ public final class WifiUsabilityStatsEntry implements Parcelable { this.totalCcaBusyFreqTimeMs = totalCcaBusyFreqTimeMs; this.totalRadioOnFreqTimeMs = totalRadioOnFreqTimeMs; this.totalBeaconRx = totalBeaconRx; + this.probeStatusSinceLastUpdate = probeStatusSinceLastUpdate; + this.probeElapsedTimeMsSinceLastUpdate = probeElapsedTimeMsSinceLastUpdate; + this.probeMcsRateSinceLastUpdate = probeMcsRateSinceLastUpdate; + this.rxLinkSpeedMbps = rxLinkSpeedMbps; } /** Implement the Parcelable interface */ @@ -124,6 +160,10 @@ public final class WifiUsabilityStatsEntry implements Parcelable { dest.writeLong(totalCcaBusyFreqTimeMs); dest.writeLong(totalRadioOnFreqTimeMs); dest.writeLong(totalBeaconRx); + dest.writeInt(probeStatusSinceLastUpdate); + dest.writeInt(probeElapsedTimeMsSinceLastUpdate); + dest.writeInt(probeMcsRateSinceLastUpdate); + dest.writeInt(rxLinkSpeedMbps); } /** Implement the Parcelable interface */ @@ -137,7 +177,8 @@ public final class WifiUsabilityStatsEntry implements Parcelable { in.readLong(), in.readLong(), in.readLong(), in.readLong(), in.readLong(), in.readLong(), in.readLong(), in.readLong(), in.readLong(), - in.readLong(), in.readLong() + in.readLong(), in.readLong(), in.readInt(), + in.readInt(), in.readInt(), in.readInt() ); } diff --git a/wifi/tests/src/android/net/wifi/WifiUsabilityStatsEntryTest.java b/wifi/tests/src/android/net/wifi/WifiUsabilityStatsEntryTest.java index a947b5568a16d..a22f8ce853bf3 100644 --- a/wifi/tests/src/android/net/wifi/WifiUsabilityStatsEntryTest.java +++ b/wifi/tests/src/android/net/wifi/WifiUsabilityStatsEntryTest.java @@ -74,7 +74,7 @@ public class WifiUsabilityStatsEntryTest { private static WifiUsabilityStatsEntry createResult() { return new WifiUsabilityStatsEntry( - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 ); } @@ -100,5 +100,10 @@ public class WifiUsabilityStatsEntryTest { assertEquals(expected.totalCcaBusyFreqTimeMs, actual.totalCcaBusyFreqTimeMs); assertEquals(expected.totalRadioOnFreqTimeMs, actual.totalRadioOnFreqTimeMs); assertEquals(expected.totalBeaconRx, actual.totalBeaconRx); + assertEquals(expected.probeStatusSinceLastUpdate, actual.probeStatusSinceLastUpdate); + assertEquals(expected.probeElapsedTimeMsSinceLastUpdate, + actual.probeElapsedTimeMsSinceLastUpdate); + assertEquals(expected.probeMcsRateSinceLastUpdate, actual.probeMcsRateSinceLastUpdate); + assertEquals(expected.rxLinkSpeedMbps, actual.rxLinkSpeedMbps); } }