summaryrefslogtreecommitdiffstats
path: root/services/tests
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2011-04-26 16:25:36 -0700
committerJeff Sharkey <jsharkey@android.com>2011-05-04 16:07:21 -0700
commit9a13f36cddaad01350bdb5f000167811a1d753c9 (patch)
tree024269b4f6c6ab8fb284156955ecace0578eaba2 /services/tests
parent588f280fe099dc5b18f15124ffb035fc1f5ef2f1 (diff)
downloadframeworks_base-9a13f36cddaad01350bdb5f000167811a1d753c9.zip
frameworks_base-9a13f36cddaad01350bdb5f000167811a1d753c9.tar.gz
frameworks_base-9a13f36cddaad01350bdb5f000167811a1d753c9.tar.bz2
Return NetworkStats bundle from NM service.
Introduce NetworkStats which is a collection of network statistics, which should match the structure communicated by kernel module through netd. Will introduce tags and fg/bg stats later. Kept entirely in a flat data structure to optimize parcel speed. Initial pass at returning NetworkStats from NetworkManagementService, both summary and details. Will eventually pull data from kernel module over netd connection. Change-Id: I92d9f61678ec8c22e2ce26775fb035a0cf32413f
Diffstat (limited to 'services/tests')
-rw-r--r--services/tests/servicestests/src/com/android/server/ThrottleServiceTest.java28
1 files changed, 24 insertions, 4 deletions
diff --git a/services/tests/servicestests/src/com/android/server/ThrottleServiceTest.java b/services/tests/servicestests/src/com/android/server/ThrottleServiceTest.java
index 6f55f46..f20d5e5 100644
--- a/services/tests/servicestests/src/com/android/server/ThrottleServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/ThrottleServiceTest.java
@@ -34,11 +34,17 @@ import android.content.ContextWrapper;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.INetworkManagementEventObserver;
+import android.net.NetworkStats;
import android.net.ThrottleManager;
+import android.os.IBinder;
import android.os.INetworkManagementService;
+import android.os.ServiceManager;
+import android.os.SystemClock;
import android.provider.Settings;
import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.Suppress;
import android.text.format.DateUtils;
+import android.util.Log;
import android.util.TrustedTime;
import java.util.Iterator;
@@ -222,6 +228,16 @@ public class ThrottleServiceTest extends AndroidTestCase {
verify(mMockTime, mMockNMService);
}
+ @Suppress
+ public void testReturnStats() throws Exception {
+ final IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE);
+ final INetworkManagementService nmService = INetworkManagementService.Stub.asInterface(b);
+
+ // test is currently no-op, just exercises stats apis
+ Log.d(TAG, nmService.getNetworkStatsSummary().toString());
+ Log.d(TAG, nmService.getNetworkStatsDetail().toString());
+ }
+
/**
* Persist the given {@link ThrottleService} policy into {@link Settings}.
*/
@@ -272,12 +288,16 @@ public class ThrottleServiceTest extends AndroidTestCase {
}
/**
- * Expect {@link NetworkManagementService#getInterfaceRxCounter} mock calls,
- * responding with the given counter values.
+ * Expect {@link NetworkManagementService#getNetworkStatsSummary()} mock
+ * calls, responding with the given counter values.
*/
public void expectGetInterfaceCounter(long rx, long tx) throws Exception {
- expect(mMockNMService.getInterfaceRxCounter(isA(String.class))).andReturn(rx).atLeastOnce();
- expect(mMockNMService.getInterfaceTxCounter(isA(String.class))).andReturn(tx).atLeastOnce();
+ // TODO: provide elapsedRealtime mock to match TimeAuthority
+ final NetworkStats.Builder stats = new NetworkStats.Builder(
+ SystemClock.elapsedRealtime(), 1);
+ stats.addEntry(TEST_IFACE, NetworkStats.UID_ALL, rx, tx);
+
+ expect(mMockNMService.getNetworkStatsSummary()).andReturn(stats.build()).atLeastOnce();
}
/**