use of android.net.NetworkTemplate in project android_frameworks_base by ParanoidAndroid.
the class NetworkStatsService method openSession.
@Override
public INetworkStatsSession openSession() {
mContext.enforceCallingOrSelfPermission(READ_NETWORK_USAGE_HISTORY, TAG);
assertBandwidthControlEnabled();
return new INetworkStatsSession.Stub() {
private NetworkStatsCollection mUidComplete;
private NetworkStatsCollection mUidTagComplete;
private NetworkStatsCollection getUidComplete() {
if (mUidComplete == null) {
synchronized (mStatsLock) {
mUidComplete = mUidRecorder.getOrLoadCompleteLocked();
}
}
return mUidComplete;
}
private NetworkStatsCollection getUidTagComplete() {
if (mUidTagComplete == null) {
synchronized (mStatsLock) {
mUidTagComplete = mUidTagRecorder.getOrLoadCompleteLocked();
}
}
return mUidTagComplete;
}
@Override
public NetworkStats getSummaryForNetwork(NetworkTemplate template, long start, long end) {
return internalGetSummaryForNetwork(template, start, end);
}
@Override
public NetworkStatsHistory getHistoryForNetwork(NetworkTemplate template, int fields) {
return internalGetHistoryForNetwork(template, fields);
}
@Override
public NetworkStats getSummaryForAllUid(NetworkTemplate template, long start, long end, boolean includeTags) {
final NetworkStats stats = getUidComplete().getSummary(template, start, end);
if (includeTags) {
final NetworkStats tagStats = getUidTagComplete().getSummary(template, start, end);
stats.combineAllValues(tagStats);
}
return stats;
}
@Override
public NetworkStatsHistory getHistoryForUid(NetworkTemplate template, int uid, int set, int tag, int fields) {
if (tag == TAG_NONE) {
return getUidComplete().getHistory(template, uid, set, tag, fields);
} else {
return getUidTagComplete().getHistory(template, uid, set, tag, fields);
}
}
@Override
public void close() {
mUidComplete = null;
mUidTagComplete = null;
}
};
}
use of android.net.NetworkTemplate in project android_frameworks_base by ParanoidAndroid.
the class NetworkStatsService method performSampleLocked.
/**
* Sample recent statistics summary into {@link EventLog}.
*/
private void performSampleLocked() {
// TODO: migrate trustedtime fixes to separate binary log events
final long trustedTime = mTime.hasCache() ? mTime.currentTimeMillis() : -1;
NetworkTemplate template;
NetworkStats.Entry devTotal;
NetworkStats.Entry xtTotal;
NetworkStats.Entry uidTotal;
// collect mobile sample
template = buildTemplateMobileWildcard();
devTotal = mDevRecorder.getTotalSinceBootLocked(template);
xtTotal = mXtRecorder.getTotalSinceBootLocked(template);
uidTotal = mUidRecorder.getTotalSinceBootLocked(template);
EventLogTags.writeNetstatsMobileSample(devTotal.rxBytes, devTotal.rxPackets, devTotal.txBytes, devTotal.txPackets, xtTotal.rxBytes, xtTotal.rxPackets, xtTotal.txBytes, xtTotal.txPackets, uidTotal.rxBytes, uidTotal.rxPackets, uidTotal.txBytes, uidTotal.txPackets, trustedTime);
// collect wifi sample
template = buildTemplateWifiWildcard();
devTotal = mDevRecorder.getTotalSinceBootLocked(template);
xtTotal = mXtRecorder.getTotalSinceBootLocked(template);
uidTotal = mUidRecorder.getTotalSinceBootLocked(template);
EventLogTags.writeNetstatsWifiSample(devTotal.rxBytes, devTotal.rxPackets, devTotal.txBytes, devTotal.txPackets, xtTotal.rxBytes, xtTotal.rxPackets, xtTotal.txBytes, xtTotal.txPackets, uidTotal.rxBytes, uidTotal.rxPackets, uidTotal.txBytes, uidTotal.txPackets, trustedTime);
}
use of android.net.NetworkTemplate in project android_frameworks_base by ParanoidAndroid.
the class DataIdleTest method testMobile.
/**
* Test that dumps all the data usage metrics for all mobile to instrumentation out.
*/
public void testMobile() {
String subscriberId = mTelephonyManager.getSubscriberId();
NetworkTemplate template = NetworkTemplate.buildTemplateMobileAll(subscriberId);
fetchStats(template);
}
use of android.net.NetworkTemplate in project android_frameworks_base by ParanoidAndroid.
the class DataIdleTest method testWifiIdle.
/**
* Test that dumps all the data usage metrics for wifi to instrumentation out.
*/
public void testWifiIdle() {
NetworkTemplate template = NetworkTemplate.buildTemplateWifiWildcard();
fetchStats(template);
}
use of android.net.NetworkTemplate in project android_frameworks_base by ResurrectionRemix.
the class DataIdleTest method testMobile.
/**
* Test that dumps all the data usage metrics for all mobile to instrumentation out.
*/
public void testMobile() {
String subscriberId = mTelephonyManager.getSubscriberId();
NetworkTemplate template = NetworkTemplate.buildTemplateMobileAll(subscriberId);
fetchStats(template);
}
Aggregations