Snap for 4736748 from e71fb69ec9551029959ae2cc75ca2de2a2be3652 to pi-release
Change-Id: I079ed104b35b4d57aa5393980595e3827bf01939
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) {
|
||||
|
||||
@@ -116,7 +116,6 @@ import android.provider.Settings;
|
||||
import android.provider.Settings.Global;
|
||||
import android.service.NetworkInterfaceProto;
|
||||
import android.service.NetworkStatsServiceDumpProto;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.SubscriptionPlan;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.format.DateUtils;
|
||||
@@ -545,7 +544,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
||||
final int usedFlags = isRateLimitedForPoll(callingUid)
|
||||
? flags & (~NetworkStatsManager.FLAG_POLL_ON_OPEN)
|
||||
: 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();
|
||||
try {
|
||||
performPoll(FLAG_PERSIST_ALL);
|
||||
@@ -679,22 +679,12 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
||||
private SubscriptionPlan resolveSubscriptionPlan(NetworkTemplate template, int flags) {
|
||||
SubscriptionPlan plan = null;
|
||||
if ((flags & NetworkStatsManager.FLAG_AUGMENT_WITH_SUBSCRIPTION_PLAN) != 0
|
||||
&& (template.getMatchRule() == NetworkTemplate.MATCH_MOBILE)
|
||||
&& mSettings.getAugmentEnabled()) {
|
||||
if (LOGD) Slog.d(TAG, "Resolving plan for " + template);
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
final SubscriptionManager sm = mContext.getSystemService(SubscriptionManager.class);
|
||||
final TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
|
||||
for (int subId : sm.getActiveSubscriptionIdList()) {
|
||||
if (template.matchesSubscriberId(tm.getSubscriberId(subId))) {
|
||||
if (LOGD) Slog.d(TAG, "Found active matching subId " + subId);
|
||||
final List<SubscriptionPlan> plans = sm.getSubscriptionPlans(subId);
|
||||
if (!plans.isEmpty()) {
|
||||
plan = plans.get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
plan = LocalServices.getService(NetworkPolicyManagerInternal.class)
|
||||
.getSubscriptionPlan(template);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user