Augment network stats based on SubscriptionPlan.
When a carrier provides an "anchor" of data usage at a specific moment in time, augment the network statistics used by warning/limit thresholds and Settings UI. For example, if the OS measured 500MB of usage, but the carrier says only 400MB has been used, we "squish" down the OS measured usage to match that anchor. Callers using the hidden API will have their data augmented by default, and the public API offers a way to opt-into augmentation. Thorough testing to verify behavior. Test: bit FrameworksNetTests:android.net.,com.android.server.net. Test: cts-tradefed run commandAndExit cts-dev -m CtsUsageStatsTestCases -t android.app.usage.cts.NetworkUsageStatsTest Bug: 64534190 Change-Id: Id3d4d7625bbf04f57643e51dbf376e3fa0ea8eca
This commit is contained in:
@@ -485,6 +485,21 @@ public class NetworkStatsHistoryTest extends AndroidTestCase {
|
||||
assertTrue(stats.intersects(Long.MIN_VALUE, TEST_START + 1));
|
||||
}
|
||||
|
||||
public void testSetValues() throws Exception {
|
||||
stats = new NetworkStatsHistory(HOUR_IN_MILLIS);
|
||||
stats.recordData(TEST_START, TEST_START + 1,
|
||||
new NetworkStats.Entry(1024L, 10L, 2048L, 20L, 2L));
|
||||
|
||||
assertEquals(1024L + 2048L, stats.getTotalBytes());
|
||||
|
||||
final NetworkStatsHistory.Entry entry = stats.getValues(0, null);
|
||||
entry.rxBytes /= 2;
|
||||
entry.txBytes *= 2;
|
||||
stats.setValues(0, entry);
|
||||
|
||||
assertEquals(512L + 4096L, stats.getTotalBytes());
|
||||
}
|
||||
|
||||
private static void assertIndexBeforeAfter(
|
||||
NetworkStatsHistory stats, int before, int after, long time) {
|
||||
assertEquals("unexpected before", before, stats.getIndexBefore(time));
|
||||
|
||||
Reference in New Issue
Block a user