SubscriptionPlan: remove getNetworkTypesBitMask am: ba66f0f761
Change-Id: Ibe234465d3318b6f2a2dfe79d784c0d2fc85d987
This commit is contained in:
@@ -227,24 +227,6 @@ public final class SubscriptionPlan implements Parcelable {
|
||||
return networkTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the networkTypes array converted to a {@link TelephonyManager.NetworkTypeBitMask}
|
||||
* @hide
|
||||
*/
|
||||
public long getNetworkTypesBitMask() {
|
||||
// calculate bitmask the first time and save for future calls
|
||||
if (networkTypesBitMask == 0) {
|
||||
if (networkTypes == null) {
|
||||
networkTypesBitMask = ~0;
|
||||
} else {
|
||||
for (int networkType : networkTypes) {
|
||||
networkTypesBitMask |= TelephonyManager.getBitMaskForNetworkType(networkType);
|
||||
}
|
||||
}
|
||||
}
|
||||
return networkTypesBitMask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an iterator that will return all valid data usage cycles based on
|
||||
* any recurrence rules. The iterator starts from the currently active cycle
|
||||
|
||||
@@ -3094,17 +3094,16 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
||||
return;
|
||||
}
|
||||
|
||||
long applicableNetworkTypes = 0;
|
||||
final ArraySet<Integer> applicableNetworkTypes = new ArraySet<Integer>();
|
||||
boolean allNetworks = false;
|
||||
for (SubscriptionPlan plan : plans) {
|
||||
if (plan.getNetworkTypes() == null) {
|
||||
allNetworks = true;
|
||||
} else {
|
||||
if ((applicableNetworkTypes & plan.getNetworkTypesBitMask()) != 0) {
|
||||
final int[] networkTypes = plan.getNetworkTypes();
|
||||
if (!addAll(applicableNetworkTypes, networkTypes)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Multiple subscription plans defined for a single network type.");
|
||||
} else {
|
||||
applicableNetworkTypes |= plan.getNetworkTypesBitMask();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3116,6 +3115,19 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all of the {@code elements} to the {@code set}.
|
||||
*
|
||||
* @return {@code false} if any element is not added because the set already have the value.
|
||||
*/
|
||||
private static boolean addAll(@NonNull Set<Integer> set, @NonNull int... elements) {
|
||||
boolean result = true;
|
||||
for (int element : elements) {
|
||||
result &= set.add(element);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubscriptionPlan[] getSubscriptionPlans(int subId, String callingPackage) {
|
||||
enforceSubscriptionPlanAccess(subId, Binder.getCallingUid(), callingPackage);
|
||||
|
||||
Reference in New Issue
Block a user