summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Benedict Wong <benedictwong@google.com> 2019-06-11 18:21:30 -0700
committer Benedict Wong <benedictwong@google.com> 2019-06-21 01:12:10 +0000
commit5cc3e6ae06c33306ca0c9dd60e005722a85b6a9d (patch)
tree8b197b1c99f2dff77098ac6b389a2e4cab8746cc
parentedcd5ad555ac3503bb374d4b264b07a0d23592cb (diff)
Remove unused lastStats parameter
This change removes an unused parameter that is always null in getNetworkStatsUidDetail Bug: 113122541 Bug: 134244752 Test: FrameworksNetTest passing Merged-In: I995b108ef30e1fbd6190131ed4db40a3d9327eb5 Change-Id: I575a7e4fa145f2c93537f33a2bfe952aeafd0e69 (cherry picked from commit 5823e8d3c69b10ad2a458e491c146631457ca86d)
-rw-r--r--services/core/java/com/android/server/NetworkManagementService.java5
-rw-r--r--services/core/java/com/android/server/net/NetworkStatsFactory.java33
2 files changed, 20 insertions, 18 deletions
diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java
index 8d76634b7018..e5fb5062541e 100644
--- a/services/core/java/com/android/server/NetworkManagementService.java
+++ b/services/core/java/com/android/server/NetworkManagementService.java
@@ -36,7 +36,6 @@ import static android.net.NetworkStats.SET_DEFAULT;
import static android.net.NetworkStats.STATS_PER_UID;
import static android.net.NetworkStats.TAG_ALL;
import static android.net.NetworkStats.TAG_NONE;
-import static android.net.NetworkStats.UID_ALL;
import static android.net.TrafficStats.UID_TETHERING;
import static com.android.server.NetworkManagementSocketTagger.PROP_QTAGUID_ENABLED;
@@ -1236,7 +1235,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
public NetworkStats getNetworkStatsDetail() {
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
try {
- return mStatsFactory.readNetworkStatsDetail(UID_ALL, null, TAG_ALL, null);
+ return mStatsFactory.readNetworkStatsDetail();
} catch (IOException e) {
throw new IllegalStateException(e);
}
@@ -1545,7 +1544,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
public NetworkStats getNetworkStatsUidDetail(int uid, String[] ifaces) {
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
try {
- return mStatsFactory.readNetworkStatsDetail(uid, ifaces, TAG_ALL, null);
+ return mStatsFactory.readNetworkStatsDetail(uid, ifaces, TAG_ALL);
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/services/core/java/com/android/server/net/NetworkStatsFactory.java b/services/core/java/com/android/server/net/NetworkStatsFactory.java
index 69efd02dea9c..c118bda88c2e 100644
--- a/services/core/java/com/android/server/net/NetworkStatsFactory.java
+++ b/services/core/java/com/android/server/net/NetworkStatsFactory.java
@@ -16,6 +16,7 @@
package com.android.server.net;
+import static android.net.NetworkStats.INTERFACES_ALL;
import static android.net.NetworkStats.SET_ALL;
import static android.net.NetworkStats.TAG_ALL;
import static android.net.NetworkStats.TAG_NONE;
@@ -264,13 +265,21 @@ public class NetworkStatsFactory {
}
public NetworkStats readNetworkStatsDetail() throws IOException {
- return readNetworkStatsDetail(UID_ALL, null, TAG_ALL, null);
+ return readNetworkStatsDetail(UID_ALL, INTERFACES_ALL, TAG_ALL);
}
- public NetworkStats readNetworkStatsDetail(int limitUid, String[] limitIfaces, int limitTag,
- NetworkStats lastStats) throws IOException {
- final NetworkStats stats =
- readNetworkStatsDetailInternal(limitUid, limitIfaces, limitTag, lastStats);
+ /**
+ * 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 {
+ final NetworkStats stats = readNetworkStatsDetailInternal(limitUid, limitIfaces, limitTag);
// No locking here: apply464xlatAdjustments behaves fine with an add-only ConcurrentHashMap.
// TODO: remove this and only apply adjustments in NetworkStatsService.
@@ -292,17 +301,11 @@ public class NetworkStatsFactory {
}
}
- // TODO: delete the lastStats parameter
- private NetworkStats readNetworkStatsDetailInternal(int limitUid, String[] limitIfaces,
- int limitTag, NetworkStats lastStats) throws IOException {
+ private NetworkStats readNetworkStatsDetailInternal(
+ int limitUid, String[] limitIfaces, int limitTag) throws IOException {
if (USE_NATIVE_PARSING) {
- final NetworkStats stats;
- if (lastStats != null) {
- stats = lastStats;
- stats.setElapsedRealtime(SystemClock.elapsedRealtime());
- } else {
- stats = new NetworkStats(SystemClock.elapsedRealtime(), -1);
- }
+ final NetworkStats stats =
+ new NetworkStats(SystemClock.elapsedRealtime(), 0 /* initialSize */);
if (mUseBpfStats) {
synchronized (mPersistSnapshot) {
try {