use of android.net.NetworkStatsHistory in project android_frameworks_base by ParanoidAndroid.
the class NetworkStatsService method internalGetHistoryForNetwork.
/**
* Return network history, splicing between {@link #mDevStatsCached}
* and {@link #mXtStatsCached} when appropriate.
*/
private NetworkStatsHistory internalGetHistoryForNetwork(NetworkTemplate template, int fields) {
if (!mSettings.getReportXtOverDev()) {
// shortcut when XT reporting disabled
return mDevStatsCached.getHistory(template, UID_ALL, SET_ALL, TAG_NONE, fields);
}
// splice stats between DEV and XT, switching over from DEV to XT at
// first atomic bucket.
final long firstAtomicBucket = mXtStatsCached.getFirstAtomicBucketMillis();
final NetworkStatsHistory dev = mDevStatsCached.getHistory(template, UID_ALL, SET_ALL, TAG_NONE, fields, Long.MIN_VALUE, firstAtomicBucket);
final NetworkStatsHistory xt = mXtStatsCached.getHistory(template, UID_ALL, SET_ALL, TAG_NONE, fields, firstAtomicBucket, Long.MAX_VALUE);
xt.recordEntireHistory(dev);
return xt;
}
use of android.net.NetworkStatsHistory in project android_frameworks_base by ParanoidAndroid.
the class NetworkStatsCollection method recordData.
/**
* Record given {@link android.net.NetworkStats.Entry} into this collection.
*/
public void recordData(NetworkIdentitySet ident, int uid, int set, int tag, long start, long end, NetworkStats.Entry entry) {
final NetworkStatsHistory history = findOrCreateHistory(ident, uid, set, tag);
history.recordData(start, end, entry);
noteRecordedHistory(history.getStart(), history.getEnd(), entry.rxBytes + entry.txBytes);
}
use of android.net.NetworkStatsHistory in project android_frameworks_base by ParanoidAndroid.
the class NetworkStatsCollection method recordHistory.
/**
* Record given {@link NetworkStatsHistory} into this collection.
*/
private void recordHistory(Key key, NetworkStatsHistory history) {
if (history.size() == 0)
return;
noteRecordedHistory(history.getStart(), history.getEnd(), history.getTotalBytes());
NetworkStatsHistory target = mStats.get(key);
if (target == null) {
target = new NetworkStatsHistory(history.getBucketDuration());
mStats.put(key, target);
}
target.recordEntireHistory(history);
}
use of android.net.NetworkStatsHistory in project android_frameworks_base by ParanoidAndroid.
the class NetworkStatsServiceTest method assertNetworkTotal.
private void assertNetworkTotal(NetworkTemplate template, long start, long end, long rxBytes, long rxPackets, long txBytes, long txPackets, int operations) throws Exception {
// verify history API
final NetworkStatsHistory history = mSession.getHistoryForNetwork(template, FIELD_ALL);
assertValues(history, start, end, rxBytes, rxPackets, txBytes, txPackets, operations);
// verify summary API
final NetworkStats stats = mSession.getSummaryForNetwork(template, start, end);
assertValues(stats, IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, rxBytes, rxPackets, txBytes, txPackets, operations);
}
use of android.net.NetworkStatsHistory in project platform_frameworks_base by android.
the class NetworkStats method startUserUidEnumeration.
/**
* Starts uid enumeration for current user.
* @throws RemoteException
*/
void startUserUidEnumeration() throws RemoteException {
// TODO: getRelevantUids should be sensitive to time interval. When that's done,
// the filtering logic below can be removed.
int[] uids = mSession.getRelevantUids();
// Filtering of uids with empty history.
IntArray filteredUids = new IntArray(uids.length);
for (int uid : uids) {
try {
NetworkStatsHistory history = mSession.getHistoryIntervalForUid(mTemplate, uid, android.net.NetworkStats.SET_ALL, android.net.NetworkStats.TAG_NONE, NetworkStatsHistory.FIELD_ALL, mStartTimeStamp, mEndTimeStamp);
if (history != null && history.size() > 0) {
filteredUids.add(uid);
}
} catch (RemoteException e) {
Log.w(TAG, "Error while getting history of uid " + uid, e);
}
}
mUids = filteredUids.toArray();
mUidOrUidIndex = -1;
stepHistory();
}
Aggregations