diff options
author | Ecco Park <eccopark@google.com> | 2018-01-30 11:18:58 -0800 |
---|---|---|
committer | Ecco Park <eccopark@google.com> | 2018-02-21 17:48:25 -0800 |
commit | e4334721104f3fa6df8886f5f46e43e0317a8dd2 (patch) | |
tree | 5215ed6cfed5c2e7aeab945cc7404d98180451d6 /service | |
parent | 122f5a7c7ca66a716b4cfa6744ed1377f7c27e5c (diff) |
WifiTrafficPoller: Implement Unit test
Bug: 72549299
Test: All the tests are passed
./frameworks/opt/net/wifi/tests/wifitests/runtests.sh -e class
com.android.server.wifi.WifiTrafficPollerTest
OK (4 tests)
Change-Id: Icc4a5688ecc7dfb6fc1de9210cb25a71000ba59b
Signed-off-by: Ecco Park <eccopark@google.com>
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiNative.java | 21 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiTrafficPoller.java | 8 |
2 files changed, 25 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index 56a57348d..dd1fb4492 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -21,6 +21,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.net.InterfaceConfiguration; import android.net.MacAddress; +import android.net.TrafficStats; import android.net.apf.ApfCapabilities; import android.net.wifi.RttManager; import android.net.wifi.RttManager.ResponderConfig; @@ -2477,6 +2478,26 @@ public class WifiNative { } /** + * Get the tx packet counts for the interface. + * + * @param ifaceName Name of the interface. + * @return tx packet counts + */ + public long getTxPackets(@NonNull String ifaceName) { + return TrafficStats.getTxPackets(ifaceName); + } + + /** + * Get the rx packet counts for the interface. + * + * @param ifaceName Name of the interface + * @return rx packet counts + */ + public long getRxPackets(@NonNull String ifaceName) { + return TrafficStats.getRxPackets(ifaceName); + } + + /** * Start sending the specified keep alive packets periodically. * * @param ifaceName Name of the interface. diff --git a/service/java/com/android/server/wifi/WifiTrafficPoller.java b/service/java/com/android/server/wifi/WifiTrafficPoller.java index cd6c72d57..bcb625ed6 100644 --- a/service/java/com/android/server/wifi/WifiTrafficPoller.java +++ b/service/java/com/android/server/wifi/WifiTrafficPoller.java @@ -24,7 +24,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.net.NetworkInfo; -import android.net.TrafficStats; import android.net.wifi.WifiManager; import android.os.Handler; import android.os.Looper; @@ -75,7 +74,8 @@ public class WifiTrafficPoller { private boolean mVerboseLoggingEnabled = false; - WifiTrafficPoller(Context context, Looper looper, WifiNative wifiNative) { + WifiTrafficPoller(@NonNull Context context, @NonNull Looper looper, + @NonNull WifiNative wifiNative) { mTrafficHandler = new TrafficHandler(looper); mWifiNative = wifiNative; @@ -195,8 +195,8 @@ public class WifiTrafficPoller { long preTxPkts = mTxPkts, preRxPkts = mRxPkts; int dataActivity = WifiManager.DATA_ACTIVITY_NONE; - mTxPkts = TrafficStats.getTxPackets(ifaceName); - mRxPkts = TrafficStats.getRxPackets(ifaceName); + mTxPkts = mWifiNative.getTxPackets(ifaceName); + mRxPkts = mWifiNative.getRxPackets(ifaceName); if (DBG) { Log.d(TAG, " packet count Tx=" |