Loading core/java/android/telephony/SubscriptionPlan.java +0 −18 Original line number Original line Diff line number Diff line Loading @@ -227,24 +227,6 @@ public final class SubscriptionPlan implements Parcelable { return networkTypes; 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 * Return an iterator that will return all valid data usage cycles based on * any recurrence rules. The iterator starts from the currently active cycle * any recurrence rules. The iterator starts from the currently active cycle Loading services/core/java/com/android/server/net/NetworkPolicyManagerService.java +16 −4 Original line number Original line Diff line number Diff line Loading @@ -3105,17 +3105,16 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { return; return; } } long applicableNetworkTypes = 0; final ArraySet<Integer> applicableNetworkTypes = new ArraySet<Integer>(); boolean allNetworks = false; boolean allNetworks = false; for (SubscriptionPlan plan : plans) { for (SubscriptionPlan plan : plans) { if (plan.getNetworkTypes() == null) { if (plan.getNetworkTypes() == null) { allNetworks = true; allNetworks = true; } else { } else { if ((applicableNetworkTypes & plan.getNetworkTypesBitMask()) != 0) { final int[] networkTypes = plan.getNetworkTypes(); if (!addAll(applicableNetworkTypes, networkTypes)) { throw new IllegalArgumentException( throw new IllegalArgumentException( "Multiple subscription plans defined for a single network type."); "Multiple subscription plans defined for a single network type."); } else { applicableNetworkTypes |= plan.getNetworkTypesBitMask(); } } } } } } Loading @@ -3127,6 +3126,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 @Override public SubscriptionPlan[] getSubscriptionPlans(int subId, String callingPackage) { public SubscriptionPlan[] getSubscriptionPlans(int subId, String callingPackage) { enforceSubscriptionPlanAccess(subId, Binder.getCallingUid(), callingPackage); enforceSubscriptionPlanAccess(subId, Binder.getCallingUid(), callingPackage); Loading Loading
core/java/android/telephony/SubscriptionPlan.java +0 −18 Original line number Original line Diff line number Diff line Loading @@ -227,24 +227,6 @@ public final class SubscriptionPlan implements Parcelable { return networkTypes; 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 * Return an iterator that will return all valid data usage cycles based on * any recurrence rules. The iterator starts from the currently active cycle * any recurrence rules. The iterator starts from the currently active cycle Loading
services/core/java/com/android/server/net/NetworkPolicyManagerService.java +16 −4 Original line number Original line Diff line number Diff line Loading @@ -3105,17 +3105,16 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { return; return; } } long applicableNetworkTypes = 0; final ArraySet<Integer> applicableNetworkTypes = new ArraySet<Integer>(); boolean allNetworks = false; boolean allNetworks = false; for (SubscriptionPlan plan : plans) { for (SubscriptionPlan plan : plans) { if (plan.getNetworkTypes() == null) { if (plan.getNetworkTypes() == null) { allNetworks = true; allNetworks = true; } else { } else { if ((applicableNetworkTypes & plan.getNetworkTypesBitMask()) != 0) { final int[] networkTypes = plan.getNetworkTypes(); if (!addAll(applicableNetworkTypes, networkTypes)) { throw new IllegalArgumentException( throw new IllegalArgumentException( "Multiple subscription plans defined for a single network type."); "Multiple subscription plans defined for a single network type."); } else { applicableNetworkTypes |= plan.getNetworkTypesBitMask(); } } } } } } Loading @@ -3127,6 +3126,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 @Override public SubscriptionPlan[] getSubscriptionPlans(int subId, String callingPackage) { public SubscriptionPlan[] getSubscriptionPlans(int subId, String callingPackage) { enforceSubscriptionPlanAccess(subId, Binder.getCallingUid(), callingPackage); enforceSubscriptionPlanAccess(subId, Binder.getCallingUid(), callingPackage); Loading