Remove VPN info arrays from NetworkStats(Observer|Recorder)
This change removes the now-unused VPN arrays in the network stats observer and recorder classes. These are always null values in every call site. Bug: 113122541 Bug: 120145746 Bug: 129264869 Bug: 134244752 Test: FrameworksNetTest passing Test: Manual tests show data usage fixes maintained. Merged-In: Ieb8645acc400fdaeb0df7092c5369b96f9f35af9 Change-Id: I66f263d7e12bce7668901306c0c2ecdda634abaf (cherry picked from commit 833603caabb1a850a63a970fc285b4c8ed7401f8)
This commit is contained in:
@@ -39,7 +39,6 @@ import android.util.Slog;
|
|||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.net.VpnInfo;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
@@ -104,9 +103,9 @@ class NetworkStatsObservers {
|
|||||||
public void updateStats(NetworkStats xtSnapshot, NetworkStats uidSnapshot,
|
public void updateStats(NetworkStats xtSnapshot, NetworkStats uidSnapshot,
|
||||||
ArrayMap<String, NetworkIdentitySet> activeIfaces,
|
ArrayMap<String, NetworkIdentitySet> activeIfaces,
|
||||||
ArrayMap<String, NetworkIdentitySet> activeUidIfaces,
|
ArrayMap<String, NetworkIdentitySet> activeUidIfaces,
|
||||||
VpnInfo[] vpnArray, long currentTime) {
|
long currentTime) {
|
||||||
StatsContext statsContext = new StatsContext(xtSnapshot, uidSnapshot, activeIfaces,
|
StatsContext statsContext = new StatsContext(xtSnapshot, uidSnapshot, activeIfaces,
|
||||||
activeUidIfaces, vpnArray, currentTime);
|
activeUidIfaces, currentTime);
|
||||||
getHandler().sendMessage(mHandler.obtainMessage(MSG_UPDATE_STATS, statsContext));
|
getHandler().sendMessage(mHandler.obtainMessage(MSG_UPDATE_STATS, statsContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,7 +353,7 @@ class NetworkStatsObservers {
|
|||||||
// thread will update it. We pass a null VPN array because usage is aggregated by uid
|
// thread will update it. We pass a null VPN array because usage is aggregated by uid
|
||||||
// for this snapshot, so VPN traffic can't be reattributed to responsible apps.
|
// for this snapshot, so VPN traffic can't be reattributed to responsible apps.
|
||||||
mRecorder.recordSnapshotLocked(statsContext.mXtSnapshot, statsContext.mActiveIfaces,
|
mRecorder.recordSnapshotLocked(statsContext.mXtSnapshot, statsContext.mActiveIfaces,
|
||||||
null /* vpnArray */, statsContext.mCurrentTime);
|
statsContext.mCurrentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -396,7 +395,7 @@ class NetworkStatsObservers {
|
|||||||
// thread will update it. We pass the VPN info so VPN traffic is reattributed to
|
// thread will update it. We pass the VPN info so VPN traffic is reattributed to
|
||||||
// responsible apps.
|
// responsible apps.
|
||||||
mRecorder.recordSnapshotLocked(statsContext.mUidSnapshot, statsContext.mActiveUidIfaces,
|
mRecorder.recordSnapshotLocked(statsContext.mUidSnapshot, statsContext.mActiveUidIfaces,
|
||||||
statsContext.mVpnArray, statsContext.mCurrentTime);
|
statsContext.mCurrentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -427,18 +426,16 @@ class NetworkStatsObservers {
|
|||||||
NetworkStats mUidSnapshot;
|
NetworkStats mUidSnapshot;
|
||||||
ArrayMap<String, NetworkIdentitySet> mActiveIfaces;
|
ArrayMap<String, NetworkIdentitySet> mActiveIfaces;
|
||||||
ArrayMap<String, NetworkIdentitySet> mActiveUidIfaces;
|
ArrayMap<String, NetworkIdentitySet> mActiveUidIfaces;
|
||||||
VpnInfo[] mVpnArray;
|
|
||||||
long mCurrentTime;
|
long mCurrentTime;
|
||||||
|
|
||||||
StatsContext(NetworkStats xtSnapshot, NetworkStats uidSnapshot,
|
StatsContext(NetworkStats xtSnapshot, NetworkStats uidSnapshot,
|
||||||
ArrayMap<String, NetworkIdentitySet> activeIfaces,
|
ArrayMap<String, NetworkIdentitySet> activeIfaces,
|
||||||
ArrayMap<String, NetworkIdentitySet> activeUidIfaces,
|
ArrayMap<String, NetworkIdentitySet> activeUidIfaces,
|
||||||
VpnInfo[] vpnArray, long currentTime) {
|
long currentTime) {
|
||||||
mXtSnapshot = xtSnapshot;
|
mXtSnapshot = xtSnapshot;
|
||||||
mUidSnapshot = uidSnapshot;
|
mUidSnapshot = uidSnapshot;
|
||||||
mActiveIfaces = activeIfaces;
|
mActiveIfaces = activeIfaces;
|
||||||
mActiveUidIfaces = activeUidIfaces;
|
mActiveUidIfaces = activeUidIfaces;
|
||||||
mVpnArray = vpnArray;
|
|
||||||
mCurrentTime = currentTime;
|
mCurrentTime = currentTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import static android.text.format.DateUtils.YEAR_IN_MILLIS;
|
|||||||
|
|
||||||
import static com.android.internal.util.Preconditions.checkNotNull;
|
import static com.android.internal.util.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import android.annotation.Nullable;
|
|
||||||
import android.net.NetworkStats;
|
import android.net.NetworkStats;
|
||||||
import android.net.NetworkStats.NonMonotonicObserver;
|
import android.net.NetworkStats.NonMonotonicObserver;
|
||||||
import android.net.NetworkStatsHistory;
|
import android.net.NetworkStatsHistory;
|
||||||
@@ -37,7 +36,6 @@ import android.util.MathUtils;
|
|||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.util.proto.ProtoOutputStream;
|
import android.util.proto.ProtoOutputStream;
|
||||||
|
|
||||||
import com.android.internal.net.VpnInfo;
|
|
||||||
import com.android.internal.util.FileRotator;
|
import com.android.internal.util.FileRotator;
|
||||||
import com.android.internal.util.IndentingPrintWriter;
|
import com.android.internal.util.IndentingPrintWriter;
|
||||||
|
|
||||||
@@ -202,18 +200,12 @@ public class NetworkStatsRecorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Record any delta that occurred since last {@link NetworkStats} snapshot,
|
* Record any delta that occurred since last {@link NetworkStats} snapshot, using the given
|
||||||
* using the given {@link Map} to identify network interfaces. First
|
* {@link Map} to identify network interfaces. First snapshot is considered bootstrap, and is
|
||||||
* snapshot is considered bootstrap, and is not counted as delta.
|
* not counted as delta.
|
||||||
*
|
|
||||||
* @param vpnArray Optional info about the currently active VPN, if any. This is used to
|
|
||||||
* redistribute traffic from the VPN app to the underlying responsible apps.
|
|
||||||
* This should always be set to null if the provided snapshot is aggregated
|
|
||||||
* across all UIDs (e.g. contains UID_ALL buckets), regardless of VPN state.
|
|
||||||
*/
|
*/
|
||||||
public void recordSnapshotLocked(NetworkStats snapshot,
|
public void recordSnapshotLocked(NetworkStats snapshot,
|
||||||
Map<String, NetworkIdentitySet> ifaceIdent, @Nullable VpnInfo[] vpnArray,
|
Map<String, NetworkIdentitySet> ifaceIdent, long currentTimeMillis) {
|
||||||
long currentTimeMillis) {
|
|
||||||
final HashSet<String> unknownIfaces = Sets.newHashSet();
|
final HashSet<String> unknownIfaces = Sets.newHashSet();
|
||||||
|
|
||||||
// skip recording when snapshot missing
|
// skip recording when snapshot missing
|
||||||
@@ -232,12 +224,6 @@ public class NetworkStatsRecorder {
|
|||||||
final long end = currentTimeMillis;
|
final long end = currentTimeMillis;
|
||||||
final long start = end - delta.getElapsedRealtime();
|
final long start = end - delta.getElapsedRealtime();
|
||||||
|
|
||||||
if (vpnArray != null) {
|
|
||||||
for (VpnInfo info : vpnArray) {
|
|
||||||
delta.migrateTun(info.ownerUid, info.vpnIface, info.underlyingIfaces);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkStats.Entry entry = null;
|
NetworkStats.Entry entry = null;
|
||||||
for (int i = 0; i < delta.size(); i++) {
|
for (int i = 0; i < delta.size(); i++) {
|
||||||
entry = delta.getValues(i, entry);
|
entry = delta.getValues(i, entry);
|
||||||
|
|||||||
@@ -1265,28 +1265,24 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
// For xt/dev, we pass a null VPN array because usage is aggregated by UID, so VPN traffic
|
// For xt/dev, we pass a null VPN array because usage is aggregated by UID, so VPN traffic
|
||||||
// can't be reattributed to responsible apps.
|
// can't be reattributed to responsible apps.
|
||||||
Trace.traceBegin(TRACE_TAG_NETWORK, "recordDev");
|
Trace.traceBegin(TRACE_TAG_NETWORK, "recordDev");
|
||||||
mDevRecorder.recordSnapshotLocked(
|
mDevRecorder.recordSnapshotLocked(devSnapshot, mActiveIfaces, currentTime);
|
||||||
devSnapshot, mActiveIfaces, null /* vpnArray */, currentTime);
|
|
||||||
Trace.traceEnd(TRACE_TAG_NETWORK);
|
Trace.traceEnd(TRACE_TAG_NETWORK);
|
||||||
Trace.traceBegin(TRACE_TAG_NETWORK, "recordXt");
|
Trace.traceBegin(TRACE_TAG_NETWORK, "recordXt");
|
||||||
mXtRecorder.recordSnapshotLocked(
|
mXtRecorder.recordSnapshotLocked(xtSnapshot, mActiveIfaces, currentTime);
|
||||||
xtSnapshot, mActiveIfaces, null /* vpnArray */, currentTime);
|
|
||||||
Trace.traceEnd(TRACE_TAG_NETWORK);
|
Trace.traceEnd(TRACE_TAG_NETWORK);
|
||||||
|
|
||||||
// For per-UID stats, pass the VPN info so VPN traffic is reattributed to responsible apps.
|
// For per-UID stats, pass the VPN info so VPN traffic is reattributed to responsible apps.
|
||||||
Trace.traceBegin(TRACE_TAG_NETWORK, "recordUid");
|
Trace.traceBegin(TRACE_TAG_NETWORK, "recordUid");
|
||||||
mUidRecorder.recordSnapshotLocked(
|
mUidRecorder.recordSnapshotLocked(uidSnapshot, mActiveUidIfaces, currentTime);
|
||||||
uidSnapshot, mActiveUidIfaces, null /* vpnArray */, currentTime);
|
|
||||||
Trace.traceEnd(TRACE_TAG_NETWORK);
|
Trace.traceEnd(TRACE_TAG_NETWORK);
|
||||||
Trace.traceBegin(TRACE_TAG_NETWORK, "recordUidTag");
|
Trace.traceBegin(TRACE_TAG_NETWORK, "recordUidTag");
|
||||||
mUidTagRecorder.recordSnapshotLocked(
|
mUidTagRecorder.recordSnapshotLocked(uidSnapshot, mActiveUidIfaces, currentTime);
|
||||||
uidSnapshot, mActiveUidIfaces, null /* vpnArray */, currentTime);
|
|
||||||
Trace.traceEnd(TRACE_TAG_NETWORK);
|
Trace.traceEnd(TRACE_TAG_NETWORK);
|
||||||
|
|
||||||
// We need to make copies of member fields that are sent to the observer to avoid
|
// We need to make copies of member fields that are sent to the observer to avoid
|
||||||
// a race condition between the service handler thread and the observer's
|
// a race condition between the service handler thread and the observer's
|
||||||
mStatsObservers.updateStats(xtSnapshot, uidSnapshot, new ArrayMap<>(mActiveIfaces),
|
mStatsObservers.updateStats(xtSnapshot, uidSnapshot, new ArrayMap<>(mActiveIfaces),
|
||||||
new ArrayMap<>(mActiveUidIfaces), null /* vpnArray */, currentTime);
|
new ArrayMap<>(mActiveUidIfaces), currentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user