[SP04] add unit test for NetworkStatsProvider

Test: atest NetworkStatsServiceTest
Bug: 130855321
Change-Id: I0c19d8bedcb9398da3f464efe01e775fde9f8a78
This commit is contained in:
junyulai
2019-11-22 22:27:21 +08:00
parent 258eb3b9e5
commit a97b5c3bb3

View File

@@ -182,7 +182,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
* This avoids firing the global alert too often on devices with high transfer speeds and * This avoids firing the global alert too often on devices with high transfer speeds and
* high quota. * high quota.
*/ */
private static final int PERFORM_POLL_DELAY_MS = 1000; private static final int DEFAULT_PERFORM_POLL_DELAY_MS = 1000;
private static final String TAG_NETSTATS_ERROR = "netstats_error"; private static final String TAG_NETSTATS_ERROR = "netstats_error";
@@ -226,6 +226,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
*/ */
public interface NetworkStatsSettings { public interface NetworkStatsSettings {
public long getPollInterval(); public long getPollInterval();
public long getPollDelay();
public boolean getSampleEnabled(); public boolean getSampleEnabled();
public boolean getAugmentEnabled(); public boolean getAugmentEnabled();
@@ -1116,7 +1117,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
// such a call pending; UID stats are handled during normal polling interval. // such a call pending; UID stats are handled during normal polling interval.
if (!mHandler.hasMessages(MSG_PERFORM_POLL_REGISTER_ALERT)) { if (!mHandler.hasMessages(MSG_PERFORM_POLL_REGISTER_ALERT)) {
mHandler.sendEmptyMessageDelayed(MSG_PERFORM_POLL_REGISTER_ALERT, mHandler.sendEmptyMessageDelayed(MSG_PERFORM_POLL_REGISTER_ALERT,
PERFORM_POLL_DELAY_MS); mSettings.getPollDelay());
} }
} }
} }
@@ -1995,6 +1996,10 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
return getGlobalLong(NETSTATS_POLL_INTERVAL, 30 * MINUTE_IN_MILLIS); return getGlobalLong(NETSTATS_POLL_INTERVAL, 30 * MINUTE_IN_MILLIS);
} }
@Override @Override
public long getPollDelay() {
return DEFAULT_PERFORM_POLL_DELAY_MS;
}
@Override
public long getGlobalAlertBytes(long def) { public long getGlobalAlertBytes(long def) {
return getGlobalLong(NETSTATS_GLOBAL_ALERT_BYTES, def); return getGlobalLong(NETSTATS_GLOBAL_ALERT_BYTES, def);
} }