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

Commit 6125c01f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "fix: Invalid subscription plan cause NPE" into sc-dev am: d0e38d0a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15171197

Change-Id: I958cd870c52358c70baf7db949d71dd41cf56623
parents 511a1f77 d0e38d0a
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -2159,6 +2159,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
            if (!quotaEnabled) continue;
            if (snapshot.getNetwork() == null) continue;
            final int subId = getSubIdLocked(snapshot.getNetwork());
            if (subId == INVALID_SUBSCRIPTION_ID) continue;
            final SubscriptionPlan plan = getPrimarySubscriptionPlanLocked(subId);
            if (plan == null) continue;

@@ -2181,9 +2182,10 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
                final long startOfDay = ZonedDateTime.ofInstant(now, cycle.getLower().getZone())
                        .truncatedTo(ChronoUnit.DAYS)
                        .toInstant().toEpochMilli();
                final long totalBytes = getTotalBytes(
                        buildTemplateCarrierMetered(snapshot.getSubscriberId()),
                        start, startOfDay);
                final String subscriberId = snapshot.getSubscriberId();
                final long totalBytes = subscriberId == null
                        ? 0 : getTotalBytes(
                                buildTemplateCarrierMetered(subscriberId), start, startOfDay);
                final long remainingBytes = limitBytes - totalBytes;
                // Number of remaining days including current day
                final long remainingDays =
@@ -2706,6 +2708,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
            // write all known subscription plans
            for (int i = 0; i < mSubscriptionPlans.size(); i++) {
                final int subId = mSubscriptionPlans.keyAt(i);
                if (subId == INVALID_SUBSCRIPTION_ID) continue;
                final String ownerPackage = mSubscriptionPlansOwner.get(subId);
                final SubscriptionPlan[] plans = mSubscriptionPlans.valueAt(i);
                if (ArrayUtils.isEmpty(plans)) continue;
@@ -5619,7 +5622,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {

        // Turn carrier/mobile data limit off
        NetworkPolicy[] policies = getNetworkPolicies(mContext.getOpPackageName());
        NetworkTemplate templateCarrier = buildTemplateCarrierMetered(subscriber);
        NetworkTemplate templateCarrier = subscriber != null
                ? buildTemplateCarrierMetered(subscriber) : null;
        NetworkTemplate templateMobile = buildTemplateMobileAll(subscriber);
        for (NetworkPolicy policy : policies) {
            //  All policies loaded from disk will be carrier templates, and setting will also only