Register for kernel global data usage alerts.
Instead of polling every 15 minutes, register for alerts that trigger when system-wide traffic passes a threshold. Still mixed with polling to persist UID stats, but relaxed to 30 minutes. Currently watches for every 512kB. Make persistence decision separately for network versus UID, and use total delta bytes when making decision. Use light bootstrap during systemReady() instead of heavy poll, which had been force-loading all UID data unnecessarily. Bug: 5023631 Change-Id: I04b723d6c4bf872fb1028071122dba66a8e1b576
This commit is contained in:
@@ -312,6 +312,22 @@ public class NetworkStats implements Parcelable {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return total bytes represented by this snapshot object, usually used when
|
||||
* checking if a {@link #subtract(NetworkStats)} delta passes a threshold.
|
||||
*/
|
||||
public long getTotalBytes() {
|
||||
long totalBytes = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
// skip specific tags, since already counted in TAG_NONE
|
||||
if (tag[i] != TAG_NONE) continue;
|
||||
|
||||
totalBytes += rxBytes[i];
|
||||
totalBytes += txBytes[i];
|
||||
}
|
||||
return totalBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract the given {@link NetworkStats}, effectively leaving the delta
|
||||
* between two snapshots in time. Assumes that statistics rows collect over
|
||||
|
||||
Reference in New Issue
Block a user