Search in sources :

Example 11 with INetworkStatsSession

use of android.net.INetworkStatsSession in project android_frameworks_base by crdroidandroid.

the class DataIdleTest method fetchStats.

/**
     * Helper method that fetches all the network stats available and reports it
     * to instrumentation out.
     * @param template {@link NetworkTemplate} to match.
     */
private void fetchStats(NetworkTemplate template) {
    INetworkStatsSession session = null;
    try {
        mStatsService.forceUpdate();
        session = mStatsService.openSession();
        final NetworkStats stats = session.getSummaryForAllUid(template, Long.MIN_VALUE, Long.MAX_VALUE, false);
        reportStats(stats);
    } catch (RemoteException e) {
        Log.w(LOG_TAG, "Failed to fetch network stats.");
    } finally {
        TrafficStats.closeQuietly(session);
    }
}
Also used : INetworkStatsSession(android.net.INetworkStatsSession) NetworkStats(android.net.NetworkStats) RemoteException(android.os.RemoteException)

Aggregations

INetworkStatsSession (android.net.INetworkStatsSession)11 RemoteException (android.os.RemoteException)11 NetworkPolicy (android.net.NetworkPolicy)5 NetworkStats (android.net.NetworkStats)5 NetworkStatsHistory (android.net.NetworkStatsHistory)5 Time (android.text.format.Time)5 Date (java.util.Date)5 ConnectivityManager (android.net.ConnectivityManager)1