Search in sources :

Example 6 with NetworkStatsHistory

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;
}
Also used : NetworkStatsHistory(android.net.NetworkStatsHistory)

Example 7 with NetworkStatsHistory

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);
}
Also used : NetworkStatsHistory(android.net.NetworkStatsHistory)

Example 8 with NetworkStatsHistory

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);
}
Also used : NetworkStatsHistory(android.net.NetworkStatsHistory)

Example 9 with NetworkStatsHistory

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);
}
Also used : NetworkStats(android.net.NetworkStats) NetworkStatsHistory(android.net.NetworkStatsHistory)

Example 10 with NetworkStatsHistory

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();
}
Also used : IntArray(android.util.IntArray) NetworkStatsHistory(android.net.NetworkStatsHistory) RemoteException(android.os.RemoteException)

Aggregations

NetworkStatsHistory (android.net.NetworkStatsHistory)109 NetworkStats (android.net.NetworkStats)21 ProtocolException (java.net.ProtocolException)18 AtomicFile (android.util.AtomicFile)12 BufferedInputStream (java.io.BufferedInputStream)12 DataInputStream (java.io.DataInputStream)12 FileNotFoundException (java.io.FileNotFoundException)12 RemoteException (android.os.RemoteException)10 ArrayList (java.util.ArrayList)6 INetworkStatsSession (android.net.INetworkStatsSession)5 NetworkPolicy (android.net.NetworkPolicy)5 Time (android.text.format.Time)5 ArrayMap (android.util.ArrayMap)5 IntArray (android.util.IntArray)5 Date (java.util.Date)5 Suppress (android.test.suitebuilder.annotation.Suppress)4 HashMap (java.util.HashMap)2 Map (java.util.Map)2 PendingIntent (android.app.PendingIntent)1 Context (android.content.Context)1