diff options
author | Jeff Sharkey <jsharkey@android.com> | 2011-05-28 20:56:34 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2011-06-07 23:09:25 -0700 |
commit | d2a458750e5a3d490af09cecb5c28370baf0a913 (patch) | |
tree | 72881850dcc70e3b74c52be52ec4858c96a98a8e /core/tests | |
parent | dd82b85677b3556776dbf023ad4fdc22cf075523 (diff) | |
download | frameworks_base-d2a458750e5a3d490af09cecb5c28370baf0a913.zip frameworks_base-d2a458750e5a3d490af09cecb5c28370baf0a913.tar.gz frameworks_base-d2a458750e5a3d490af09cecb5c28370baf0a913.tar.bz2 |
Map network identity using ConnectivityService.
Instead of deriving network identity based on raw subsystem broadcasts,
listen for updates from ConnectivityService. Added atomic view of all
active NetworkState, and build map from "iface" to NetworkIdentity set
for stats tracking.
To avoid exposing internal complexity, INetworkStatsService calls use
general templates. Added TelephonyManager mapping to classify network
types using broad labels like "3G" or "4G", used to drive templates.
Cleaned up Objects and Preconditions.
Change-Id: I1d4c1403f0503bc3635a59bb378841ba42239a91
Diffstat (limited to 'core/tests')
-rw-r--r-- | core/tests/coretests/src/android/net/NetworkStatsHistoryTest.java | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/core/tests/coretests/src/android/net/NetworkStatsHistoryTest.java b/core/tests/coretests/src/android/net/NetworkStatsHistoryTest.java index eb63c0d..69bbcd7 100644 --- a/core/tests/coretests/src/android/net/NetworkStatsHistoryTest.java +++ b/core/tests/coretests/src/android/net/NetworkStatsHistoryTest.java @@ -16,8 +16,6 @@ package android.net; -import static android.net.ConnectivityManager.TYPE_MOBILE; -import static android.net.NetworkStatsHistory.UID_ALL; import static android.text.format.DateUtils.DAY_IN_MILLIS; import static android.text.format.DateUtils.HOUR_IN_MILLIS; import static android.text.format.DateUtils.MINUTE_IN_MILLIS; @@ -51,7 +49,7 @@ public class NetworkStatsHistoryTest extends TestCase { public void testRecordSingleBucket() throws Exception { final long BUCKET_SIZE = HOUR_IN_MILLIS; - stats = buildStats(BUCKET_SIZE); + stats = new NetworkStatsHistory(BUCKET_SIZE); // record data into narrow window to get single bucket stats.recordData(TEST_START, TEST_START + SECOND_IN_MILLIS, 1024L, 2048L); @@ -62,7 +60,7 @@ public class NetworkStatsHistoryTest extends TestCase { public void testRecordEqualBuckets() throws Exception { final long bucketDuration = HOUR_IN_MILLIS; - stats = buildStats(bucketDuration); + stats = new NetworkStatsHistory(bucketDuration); // split equally across two buckets final long recordStart = TEST_START + (bucketDuration / 2); @@ -75,7 +73,7 @@ public class NetworkStatsHistoryTest extends TestCase { public void testRecordTouchingBuckets() throws Exception { final long BUCKET_SIZE = 15 * MINUTE_IN_MILLIS; - stats = buildStats(BUCKET_SIZE); + stats = new NetworkStatsHistory(BUCKET_SIZE); // split almost completely into middle bucket, but with a few minutes // overlap into neighboring buckets. total record is 20 minutes. @@ -94,7 +92,7 @@ public class NetworkStatsHistoryTest extends TestCase { public void testRecordGapBuckets() throws Exception { final long BUCKET_SIZE = HOUR_IN_MILLIS; - stats = buildStats(BUCKET_SIZE); + stats = new NetworkStatsHistory(BUCKET_SIZE); // record some data today and next week with large gap final long firstStart = TEST_START; @@ -122,7 +120,7 @@ public class NetworkStatsHistoryTest extends TestCase { public void testRecordOverlapBuckets() throws Exception { final long BUCKET_SIZE = HOUR_IN_MILLIS; - stats = buildStats(BUCKET_SIZE); + stats = new NetworkStatsHistory(BUCKET_SIZE); // record some data in one bucket, and another overlapping buckets stats.recordData(TEST_START, TEST_START + SECOND_IN_MILLIS, 256L, 256L); @@ -137,7 +135,7 @@ public class NetworkStatsHistoryTest extends TestCase { public void testRemove() throws Exception { final long BUCKET_SIZE = HOUR_IN_MILLIS; - stats = buildStats(BUCKET_SIZE); + stats = new NetworkStatsHistory(BUCKET_SIZE); // record some data across 24 buckets stats.recordData(TEST_START, TEST_START + DAY_IN_MILLIS, 24L, 24L); @@ -171,7 +169,7 @@ public class NetworkStatsHistoryTest extends TestCase { // fuzzing with random events, looking for crashes final Random r = new Random(); for (int i = 0; i < 500; i++) { - stats = buildStats(r.nextLong()); + stats = new NetworkStatsHistory(r.nextLong()); for (int j = 0; j < 10000; j++) { if (r.nextBoolean()) { // add range @@ -191,10 +189,6 @@ public class NetworkStatsHistoryTest extends TestCase { } } - private static NetworkStatsHistory buildStats(long bucketSize) { - return new NetworkStatsHistory(TYPE_MOBILE, null, UID_ALL, bucketSize); - } - private static void assertConsistent(NetworkStatsHistory stats) { // verify timestamps are monotonic for (int i = 1; i < stats.bucketCount; i++) { |