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

Commit 41c13c9a authored by junyulai's avatar junyulai
Browse files

Update interface quota limit when network stats updated

In previous design, interface quota limit does not changed
when network stats are updated. However, this is incorrect
today since there are some offloaded traffic that cannot
be seen by kernel. If the limit is not updated, the offloaded
traffic might still be able to use whole quota as if there is
no embedded traffic.

This change also removes the re-arm global alert after
advising persist threshold if not changed, given that it will
cause an additional alert while updating interface quota limit.

Bug: 145792619
Test: 1. atest NetworkStatsServiceTest
      2. atest NetworkPolicyManagerServiceTest
      3. manual test: run speedtest, check dumpsys netd

Change-Id: I8d2203e713730d536430a234b1aa8b2468badee3
parent 8e708ff3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1027,6 +1027,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
            // READ_NETWORK_USAGE_HISTORY permission above.

            synchronized (mNetworkPoliciesSecondLock) {
                updateNetworkRulesNL();
                updateNetworkEnabledNL();
                updateNotificationsNL();
            }
+5 −2
Original line number Diff line number Diff line
@@ -873,6 +873,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
                    + mPersistThreshold);
        }

        final long oldGlobalAlertBytes = mGlobalAlertBytes;

        // update and persist if beyond new thresholds
        final long currentTime = mClock.millis();
        synchronized (mStatsLock) {
@@ -886,9 +888,10 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
            mUidTagRecorder.maybePersistLocked(currentTime);
        }

        // re-arm global alert
        if (oldGlobalAlertBytes != mGlobalAlertBytes) {
            registerGlobalAlert();
        }
    }

    @Override
    public DataUsageRequest registerUsageCallback(String callingPackage,