Give CTS a way to force-poll network stats.
Collecting network statistics is pretty heavy, which is why we're throttling callers. However, to keep CTS running fast, we provide a way for tests to force a poll event, instead of making them wait for the throttle timeout. Bug: 77908520 Test: atest cts/tests/tests/app.usage/src/android/app/usage/cts/NetworkUsageStatsTest.java Change-Id: Ia792f0cd495023366ff8c4839df54e7da2ae8331
This commit is contained in:
@@ -20,6 +20,7 @@ import static com.android.internal.util.Preconditions.checkNotNull;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemService;
|
||||
import android.annotation.TestApi;
|
||||
import android.app.usage.NetworkStats.Bucket;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
@@ -111,7 +112,9 @@ public class NetworkStatsManager {
|
||||
/** @hide */
|
||||
public static final int FLAG_POLL_ON_OPEN = 1 << 0;
|
||||
/** @hide */
|
||||
public static final int FLAG_AUGMENT_WITH_SUBSCRIPTION_PLAN = 1 << 1;
|
||||
public static final int FLAG_POLL_FORCE = 1 << 1;
|
||||
/** @hide */
|
||||
public static final int FLAG_AUGMENT_WITH_SUBSCRIPTION_PLAN = 1 << 2;
|
||||
|
||||
private int mFlags;
|
||||
|
||||
@@ -140,6 +143,16 @@ public class NetworkStatsManager {
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@TestApi
|
||||
public void setPollForce(boolean pollForce) {
|
||||
if (pollForce) {
|
||||
mFlags |= FLAG_POLL_FORCE;
|
||||
} else {
|
||||
mFlags &= ~FLAG_POLL_FORCE;
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void setAugmentWithSubscriptionPlan(boolean augmentWithSubscriptionPlan) {
|
||||
if (augmentWithSubscriptionPlan) {
|
||||
|
||||
Reference in New Issue
Block a user