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.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) {
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ import android.provider.Settings;
|
|||||||
import android.provider.Settings.Global;
|
import android.provider.Settings.Global;
|
||||||
import android.service.NetworkInterfaceProto;
|
import android.service.NetworkInterfaceProto;
|
||||||
import android.service.NetworkStatsServiceDumpProto;
|
import android.service.NetworkStatsServiceDumpProto;
|
||||||
import android.telephony.SubscriptionManager;
|
|
||||||
import android.telephony.SubscriptionPlan;
|
import android.telephony.SubscriptionPlan;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
@@ -545,7 +544,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);
|
||||||
@@ -679,22 +679,12 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
private SubscriptionPlan resolveSubscriptionPlan(NetworkTemplate template, int flags) {
|
private SubscriptionPlan resolveSubscriptionPlan(NetworkTemplate template, int flags) {
|
||||||
SubscriptionPlan plan = null;
|
SubscriptionPlan plan = null;
|
||||||
if ((flags & NetworkStatsManager.FLAG_AUGMENT_WITH_SUBSCRIPTION_PLAN) != 0
|
if ((flags & NetworkStatsManager.FLAG_AUGMENT_WITH_SUBSCRIPTION_PLAN) != 0
|
||||||
&& (template.getMatchRule() == NetworkTemplate.MATCH_MOBILE)
|
|
||||||
&& mSettings.getAugmentEnabled()) {
|
&& mSettings.getAugmentEnabled()) {
|
||||||
if (LOGD) Slog.d(TAG, "Resolving plan for " + template);
|
if (LOGD) Slog.d(TAG, "Resolving plan for " + template);
|
||||||
final long token = Binder.clearCallingIdentity();
|
final long token = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
final SubscriptionManager sm = mContext.getSystemService(SubscriptionManager.class);
|
plan = LocalServices.getService(NetworkPolicyManagerInternal.class)
|
||||||
final TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
|
.getSubscriptionPlan(template);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(token);
|
Binder.restoreCallingIdentity(token);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user