Rate-limit on TrafficStats#get*[Bytes|Packets] API calls
This change put a rate-limit on TrafficStats getter APIs to
reduce the need of accessing bpf map. For any caller who calls
this method within 1 second, a stale result will be returned.
One expected outcome is this change would break any test which
relies on immediate change of the result of TrafficStats after
making network traffic. Thus, related tests are fixed in the
counter part CL accordingly.
Test: atest CtsNetTestCases:android.net.cts.TrafficStatsTest --rerun-until-failure 100
Test: atest CtsNetTestCases:android.net.cts.NetworkStatsManagerTest
Test: atest NetworkStackIntegrationTests:android.net.NetworkStatsIntegrationTest
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest
Bug: N/A
Change-Id: Ibd6ae92d7c806481bb8a5124dd231f8f5aa206f2
4 files changed