summaryrefslogtreecommitdiffstats
path: root/tests/DataIdleTest
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2012-04-06 11:12:08 -0700
committerJeff Sharkey <jsharkey@android.com>2012-04-06 13:38:29 -0700
commitb52e3e55098c4a6e3dbfe19885895411cfb38911 (patch)
tree2b40b88a64184c36d5a3794b8dab7450cc9d99eb /tests/DataIdleTest
parent5713c9cfa9a0ed7625c8a48925a5c33b2c070460 (diff)
downloadframeworks_base-b52e3e55098c4a6e3dbfe19885895411cfb38911.zip
frameworks_base-b52e3e55098c4a6e3dbfe19885895411cfb38911.tar.gz
frameworks_base-b52e3e55098c4a6e3dbfe19885895411cfb38911.tar.bz2
INetworkStatsSession with lifecycle for caching.
Users outside system_server now explicitly communicate their lifecycle, which keeps a strong-reference chain to any fully loaded NetworkStatsCollection histories. Bug: 6236498 Change-Id: I8e22739b6e89a626b676967a736d7117fd000778
Diffstat (limited to 'tests/DataIdleTest')
-rw-r--r--tests/DataIdleTest/src/com/android/tests/dataidle/DataIdleTest.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/DataIdleTest/src/com/android/tests/dataidle/DataIdleTest.java b/tests/DataIdleTest/src/com/android/tests/dataidle/DataIdleTest.java
index b7e80d4..919e2b3 100644
--- a/tests/DataIdleTest/src/com/android/tests/dataidle/DataIdleTest.java
+++ b/tests/DataIdleTest/src/com/android/tests/dataidle/DataIdleTest.java
@@ -17,15 +17,16 @@ package com.android.tests.dataidle;
import android.content.Context;
import android.net.INetworkStatsService;
+import android.net.INetworkStatsSession;
+import android.net.NetworkStats;
import android.net.NetworkStats.Entry;
import android.net.NetworkTemplate;
-import android.net.NetworkStats;
+import android.net.TrafficStats;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.telephony.TelephonyManager;
import android.test.InstrumentationTestCase;
-import android.test.InstrumentationTestRunner;
import android.util.Log;
/**
@@ -71,13 +72,17 @@ public class DataIdleTest extends InstrumentationTestCase {
* @param template {link {@link NetworkTemplate} to match.
*/
private void fetchStats(NetworkTemplate template) {
+ INetworkStatsSession session = null;
try {
mStatsService.forceUpdate();
- NetworkStats stats = mStatsService.getSummaryForAllUid(template, Long.MIN_VALUE,
- Long.MAX_VALUE, false);
+ 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);
}
}