Loading packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsFactory.java +7 −9 Original line number Diff line number Diff line Loading @@ -24,11 +24,11 @@ import static android.net.NetworkStats.UID_ALL; import static com.android.server.NetworkManagementSocketTagger.kernelToTag; import android.annotation.NonNull; import android.annotation.Nullable; import android.net.INetd; import android.net.NetworkStats; import android.net.UnderlyingNetworkInfo; import android.net.util.NetdService; import android.os.RemoteException; import android.os.StrictMode; import android.os.SystemClock; Loading Loading @@ -70,7 +70,7 @@ public class NetworkStatsFactory { private final boolean mUseBpfStats; private INetd mNetdService; private final INetd mNetd; /** * Guards persistent data access in this class Loading Loading @@ -158,12 +158,12 @@ public class NetworkStatsFactory { NetworkStats.apply464xlatAdjustments(baseTraffic, stackedTraffic, mStackedIfaces); } public NetworkStatsFactory() { this(new File("/proc/"), true); public NetworkStatsFactory(@NonNull INetd netd) { this(new File("/proc/"), true, netd); } @VisibleForTesting public NetworkStatsFactory(File procRoot, boolean useBpfStats) { public NetworkStatsFactory(File procRoot, boolean useBpfStats, @NonNull INetd netd) { mStatsXtIfaceAll = new File(procRoot, "net/xt_qtaguid/iface_stat_all"); mStatsXtIfaceFmt = new File(procRoot, "net/xt_qtaguid/iface_stat_fmt"); mStatsXtUid = new File(procRoot, "net/xt_qtaguid/stats"); Loading @@ -172,6 +172,7 @@ public class NetworkStatsFactory { mPersistSnapshot = new NetworkStats(SystemClock.elapsedRealtime(), -1); mTunAnd464xlatAdjustedStats = new NetworkStats(SystemClock.elapsedRealtime(), -1); } mNetd = netd; } public NetworkStats readBpfNetworkStatsDev() throws IOException { Loading Loading @@ -298,10 +299,7 @@ public class NetworkStatsFactory { // 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 (mNetdService == null) { mNetdService = NetdService.getInstance(); } mNetdService.trafficSwapActiveStatsMap(); mNetd.trafficSwapActiveStatsMap(); } /** Loading packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java +4 −2 Original line number Diff line number Diff line Loading @@ -89,6 +89,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.database.ContentObserver; import android.net.DataUsageRequest; import android.net.INetd; import android.net.INetworkManagementEventObserver; import android.net.INetworkStatsService; import android.net.INetworkStatsSession; Loading Loading @@ -410,10 +411,11 @@ public class NetworkStatsService extends INetworkStatsService.Stub { PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); final INetd netd = INetd.Stub.asInterface( (IBinder) context.getSystemService(Context.NETD_SERVICE)); final NetworkStatsService service = new NetworkStatsService(context, networkManager, alarmManager, wakeLock, getDefaultClock(), new DefaultNetworkStatsSettings(context), new NetworkStatsFactory(), new DefaultNetworkStatsSettings(context), new NetworkStatsFactory(netd), new NetworkStatsObservers(), getDefaultSystemDir(), getDefaultBaseDir(), new Dependencies()); service.registerLocalService(); Loading Loading
packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsFactory.java +7 −9 Original line number Diff line number Diff line Loading @@ -24,11 +24,11 @@ import static android.net.NetworkStats.UID_ALL; import static com.android.server.NetworkManagementSocketTagger.kernelToTag; import android.annotation.NonNull; import android.annotation.Nullable; import android.net.INetd; import android.net.NetworkStats; import android.net.UnderlyingNetworkInfo; import android.net.util.NetdService; import android.os.RemoteException; import android.os.StrictMode; import android.os.SystemClock; Loading Loading @@ -70,7 +70,7 @@ public class NetworkStatsFactory { private final boolean mUseBpfStats; private INetd mNetdService; private final INetd mNetd; /** * Guards persistent data access in this class Loading Loading @@ -158,12 +158,12 @@ public class NetworkStatsFactory { NetworkStats.apply464xlatAdjustments(baseTraffic, stackedTraffic, mStackedIfaces); } public NetworkStatsFactory() { this(new File("/proc/"), true); public NetworkStatsFactory(@NonNull INetd netd) { this(new File("/proc/"), true, netd); } @VisibleForTesting public NetworkStatsFactory(File procRoot, boolean useBpfStats) { public NetworkStatsFactory(File procRoot, boolean useBpfStats, @NonNull INetd netd) { mStatsXtIfaceAll = new File(procRoot, "net/xt_qtaguid/iface_stat_all"); mStatsXtIfaceFmt = new File(procRoot, "net/xt_qtaguid/iface_stat_fmt"); mStatsXtUid = new File(procRoot, "net/xt_qtaguid/stats"); Loading @@ -172,6 +172,7 @@ public class NetworkStatsFactory { mPersistSnapshot = new NetworkStats(SystemClock.elapsedRealtime(), -1); mTunAnd464xlatAdjustedStats = new NetworkStats(SystemClock.elapsedRealtime(), -1); } mNetd = netd; } public NetworkStats readBpfNetworkStatsDev() throws IOException { Loading Loading @@ -298,10 +299,7 @@ public class NetworkStatsFactory { // 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 (mNetdService == null) { mNetdService = NetdService.getInstance(); } mNetdService.trafficSwapActiveStatsMap(); mNetd.trafficSwapActiveStatsMap(); } /** Loading
packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java +4 −2 Original line number Diff line number Diff line Loading @@ -89,6 +89,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.database.ContentObserver; import android.net.DataUsageRequest; import android.net.INetd; import android.net.INetworkManagementEventObserver; import android.net.INetworkStatsService; import android.net.INetworkStatsSession; Loading Loading @@ -410,10 +411,11 @@ public class NetworkStatsService extends INetworkStatsService.Stub { PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); final INetd netd = INetd.Stub.asInterface( (IBinder) context.getSystemService(Context.NETD_SERVICE)); final NetworkStatsService service = new NetworkStatsService(context, networkManager, alarmManager, wakeLock, getDefaultClock(), new DefaultNetworkStatsSettings(context), new NetworkStatsFactory(), new DefaultNetworkStatsSettings(context), new NetworkStatsFactory(netd), new NetworkStatsObservers(), getDefaultSystemDir(), getDefaultBaseDir(), new Dependencies()); service.registerLocalService(); Loading