From d69d86e3f06e0f15507a409076596e270190e847 Mon Sep 17 00:00:00 2001 From: Ningyuan Wang Date: Mon, 26 Jun 2017 14:45:27 -0700 Subject: [PATCH 1/2] WifiInfo: Add getters for success tx/rx rate This adds getters to get success tx/rx rate, returning in the unit of 'packets per second'. This also adjusts the constant OUTPUT_SCALE_FACTOR so it can be more informative. Bug: 62428282 Test: compile, unit tests Change-Id: I989defd8fdc14dfc78692385fda86fb20b369b7b --- wifi/java/android/net/wifi/WifiInfo.java | 27 +++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/wifi/java/android/net/wifi/WifiInfo.java b/wifi/java/android/net/wifi/WifiInfo.java index e48f7bdb27ee1..36425c555f53a 100644 --- a/wifi/java/android/net/wifi/WifiInfo.java +++ b/wifi/java/android/net/wifi/WifiInfo.java @@ -142,8 +142,9 @@ public class WifiInfo implements Parcelable { /** * This factor is used to adjust the rate output under the new algorithm * such that the result is comparable to the previous algorithm. + * This actually converts from unit 'packets per second' to 'packets per 5 seconds'. */ - private static final long OUTPUT_SCALE_FACTOR = 5000; + private static final long OUTPUT_SCALE_FACTOR = 5; private long mLastPacketCountUpdateTimeStamp; /** @@ -189,16 +190,16 @@ public class WifiInfo implements Parcelable { double currentSampleWeight = 1.0 - lastSampleWeight; txBadRate = txBadRate * lastSampleWeight - + (txbad - txBad) * OUTPUT_SCALE_FACTOR / timeDelta + + (txbad - txBad) * OUTPUT_SCALE_FACTOR * 1000 / timeDelta * currentSampleWeight; txSuccessRate = txSuccessRate * lastSampleWeight - + (txgood - txSuccess) * OUTPUT_SCALE_FACTOR / timeDelta + + (txgood - txSuccess) * OUTPUT_SCALE_FACTOR * 1000 / timeDelta * currentSampleWeight; rxSuccessRate = rxSuccessRate * lastSampleWeight - + (rxgood - rxSuccess) * OUTPUT_SCALE_FACTOR / timeDelta + + (rxgood - rxSuccess) * OUTPUT_SCALE_FACTOR * 1000 / timeDelta * currentSampleWeight; txRetriesRate = txRetriesRate * lastSampleWeight - + (txretries - txRetries) * OUTPUT_SCALE_FACTOR / timeDelta + + (txretries - txRetries) * OUTPUT_SCALE_FACTOR * 1000/ timeDelta * currentSampleWeight; } else { txBadRate = 0; @@ -437,6 +438,22 @@ public class WifiInfo implements Parcelable { return ScanResult.is5GHz(mFrequency); } + /** + * @hide + * This returns txSuccessRate in packets per second. + */ + public double getTxSuccessRatePps() { + return txSuccessRate / OUTPUT_SCALE_FACTOR; + } + + /** + * @hide + * This returns rxSuccessRate in packets per second. + */ + public double getRxSuccessRatePps() { + return rxSuccessRate / OUTPUT_SCALE_FACTOR; + } + /** * Record the MAC address of the WLAN interface * @param macAddress the MAC address in {@code XX:XX:XX:XX:XX:XX} form From b76708315ad3dbe22f1a454d74f70ec5a609fa13 Mon Sep 17 00:00:00 2001 From: Ningyuan Wang Date: Mon, 26 Jun 2017 16:57:42 -0700 Subject: [PATCH 2/2] Add traffic thresholds to prevent wifi network changes This parameters are used for refraining from changing network when RSSI is good and there is heavy traffic implying streaming. A typical video streaming will move the tx above 20 pps and rx above 40 pps. A typical voice call will move both tx and rx rate above 16 pps. With that being said, this patch sets both thresholds to 16 pps. Bug: 62428282 Test: compile, unit tests, manual test Change-Id: Id2a7546b7ca9a1370c37d3f26f3da28231757c19 --- core/res/res/values/config.xml | 3 +++ core/res/res/values/symbols.xml | 2 ++ 2 files changed, 5 insertions(+) diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index a98738767aac3..b3a7968ce3726 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -485,6 +485,9 @@ 8 16 + + 16 + 16 -82 diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 2f81f43024d6c..6b45c7564cbeb 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -376,6 +376,8 @@ + +