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

Commit 51a770bf authored by Benedict Wong's avatar Benedict Wong
Browse files

Inline readNetworkStatsDetailInternal, make mUseBpfStats final

This change inlines the logic from readNetworkStatsDetailInternal, and
reduces reundant checks in mUseBpfStats

Bug: 113122541
Test: atest FrameworksNetTests run, passing
Merged-In: If2ef8d8f038f32c8cf974aa02cfc1dc7e44dbad3
Change-Id: If7d41052115ed145da8a610d676f6ed33c8d5e63
(cherry picked from commit 8c9d8c5e)
parent 8cdd41eb
Loading
Loading
Loading
Loading
+12 −19
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public class NetworkStatsFactory {
    /** Path to {@code /proc/net/xt_qtaguid/stats}. */
    private final File mStatsXtUid;

    private boolean mUseBpfStats;
    private final boolean mUseBpfStats;

    private INetd mNetdService;

@@ -302,34 +302,27 @@ public class NetworkStatsFactory {
        return readNetworkStatsDetail(UID_ALL, INTERFACES_ALL, TAG_ALL);
    }

    /**
     * Reads the detailed UID stats based on the provided parameters
     *
     * @param limitUid the UID to limit this query to
     * @param limitIfaces the interfaces to limit this query to. Use {@link
     *     NetworkStats.INTERFACES_ALL} to select all interfaces
     * @param limitTag the tags to limit this query to
     * @return the NetworkStats instance containing network statistics at the present time.
     */
    public NetworkStats readNetworkStatsDetail(
            int limitUid, @Nullable String[] limitIfaces, int limitTag) throws IOException {
        return readNetworkStatsDetailInternal(limitUid, limitIfaces, limitTag);
    }

    @GuardedBy("sPersistentDataLock")
    private void requestSwapActiveStatsMapLocked() throws RemoteException {
        // Ask netd to do a active map stats swap. When the binder call successfully returns,
        // the system server should be able to safely read and clean the inactive map
        // without race problem.
        if (mUseBpfStats) {
        if (mNetdService == null) {
            mNetdService = NetdService.getInstance();
        }
        mNetdService.trafficSwapActiveStatsMap();
    }
    }

    private NetworkStats readNetworkStatsDetailInternal(
    /**
     * Reads the detailed UID stats based on the provided parameters
     *
     * @param limitUid the UID to limit this query to
     * @param limitIfaces the interfaces to limit this query to. Use {@link
     *     NetworkStats.INTERFACES_ALL} to select all interfaces
     * @param limitTag the tags to limit this query to
     * @return the NetworkStats instance containing network statistics at the present time.
     */
    public NetworkStats readNetworkStatsDetail(
            int limitUid, String[] limitIfaces, int limitTag) throws IOException {
        // In order to prevent deadlocks, anything protected by this lock MUST NOT call out to other
        // code that will acquire other locks within the system server. See b/134244752.