Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c8855d3 authored by Meng Wang's avatar Meng Wang
Browse files

SubscriptionPlan: remove getNetworkTypesBitMask

To avoid using hidden API TelephonyManager#getBitMaskForNetworkType

Bug: 140908357
Test: make
Change-Id: Ibb04fd43117d4b7cf9f768e6ccf9a8f605a2f5e8
parent 742715cf
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
@@ -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
+16 −4
Original line number Diff line number Diff line
@@ -3106,17 +3106,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();
                }
            }
        }
@@ -3128,6 +3127,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);