Merge "Give CTS a way to force-poll network stats." into pi-dev
am: 46e58e1b40 Change-Id: Id2252b803a33ddadfef71618b3b9106c93c5be2a
This commit is contained in:
@@ -20,6 +20,7 @@ import static com.android.internal.util.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.SystemService;
|
import android.annotation.SystemService;
|
||||||
|
import android.annotation.TestApi;
|
||||||
import android.app.usage.NetworkStats.Bucket;
|
import android.app.usage.NetworkStats.Bucket;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
@@ -111,7 +112,9 @@ public class NetworkStatsManager {
|
|||||||
/** @hide */
|
/** @hide */
|
||||||
public static final int FLAG_POLL_ON_OPEN = 1 << 0;
|
public static final int FLAG_POLL_ON_OPEN = 1 << 0;
|
||||||
/** @hide */
|
/** @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;
|
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 */
|
/** @hide */
|
||||||
public void setAugmentWithSubscriptionPlan(boolean augmentWithSubscriptionPlan) {
|
public void setAugmentWithSubscriptionPlan(boolean augmentWithSubscriptionPlan) {
|
||||||
if (augmentWithSubscriptionPlan) {
|
if (augmentWithSubscriptionPlan) {
|
||||||
|
|||||||
@@ -543,7 +543,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
final int usedFlags = isRateLimitedForPoll(callingUid)
|
final int usedFlags = isRateLimitedForPoll(callingUid)
|
||||||
? flags & (~NetworkStatsManager.FLAG_POLL_ON_OPEN)
|
? flags & (~NetworkStatsManager.FLAG_POLL_ON_OPEN)
|
||||||
: flags;
|
: flags;
|
||||||
if ((usedFlags & NetworkStatsManager.FLAG_POLL_ON_OPEN) != 0) {
|
if ((usedFlags & (NetworkStatsManager.FLAG_POLL_ON_OPEN
|
||||||
|
| NetworkStatsManager.FLAG_POLL_FORCE)) != 0) {
|
||||||
final long ident = Binder.clearCallingIdentity();
|
final long ident = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
performPoll(FLAG_PERSIST_ALL);
|
performPoll(FLAG_PERSIST_ALL);
|
||||||
|
|||||||
Reference in New Issue
Block a user