Fix spamming of network stats updated intent

While the reason of triggering frequently polls is still unknown
(b/343844995), this commit prevents the spamming of network stats
update intents by sending broadcast messages at intervals of at
least one second. It also ensures that update requests experience
a delay of no more than one second. This is safe since
NETWORK_STATS_UPDATED intent is only use for signaling updated
of NetworkStats, which is stateless and not very time sensitive.
A kill-switch flag is included for rollback if needed.

However, while the intent was not be able to deprecated, all
callers should migrate to use registerDataUsageCallback
with proper threshold instead.

Test: atest FrameworksNetTests:android.net.connectivity.com.android.\
	server.net.NetworkStatsServiceTest\
	#testNetworkStatsUpdatedIntentSpam_rateLimitOn
Test: atest FrameworksNetTests:android.net.connectivity.com.android.\
	server.net.NetworkStatsServiceTest\
	#testNetworkStatsUpdatedIntentSpam_rateLimitOff
Bug: 343844995
Change-Id: I972f0778b823ed0dc1f35b1b011f1ad225ca020c
1 file changed