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

Commit f09e68d2 authored by Annie Meng's avatar Annie Meng Committed by android-build-merger
Browse files

Merge "Fix NPE in restoring network policies" into pi-dev am: a1b34a43

am: 8fcff1e0

Change-Id: Idb49cf9b4c2be5772e0bb12e4177abafadcc232c
parents 98be3b29 8fcff1e0
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2706,6 +2706,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
    private void normalizePoliciesNL(NetworkPolicy[] policies) {
        mNetworkPolicy.clear();
        for (NetworkPolicy policy : policies) {
            if (policy == null) {
                continue;
            }
            // When two normalized templates conflict, prefer the most
            // restrictive policy
            policy.template = NetworkTemplate.normalize(policy.template, mMergedSubscriberIds);
+14 −0
Original line number Diff line number Diff line
@@ -1628,6 +1628,20 @@ public class NetworkPolicyManagerServiceTest {
        }
    }

    /**
     * Test that policy set of {null, NetworkPolicy, null} does not crash and restores the valid
     * NetworkPolicy.
     */
    @Test
    public void testSetNetworkPolicies_withNullPolicies_doesNotThrow() {
        NetworkPolicy[] policies = new NetworkPolicy[3];
        policies[1] = buildDefaultFakeMobilePolicy();
        setNetworkPolicies(policies);

        assertNetworkPolicyEquals(DEFAULT_CYCLE_DAY, mDefaultWarningBytes, mDefaultLimitBytes,
                true);
    }

    private SubscriptionPlan buildMonthlyDataPlan(ZonedDateTime start, long limitBytes) {
        return SubscriptionPlan.Builder
                .createRecurringMonthly(start)