Use getAllInterfaceNames to get all interface names
The current design is using hidden API - getStackedLinks() to get LinkProperties then call getInterfaceName() to get the interface name. In fact, this behavior could be replaced by system API - getAllInterfaceNames(). Bug: 182963397 Test: atest FrameworksNetTests Test: atest CtsNetTestCases Change-Id: Id2b19dc5099355af69d23a6d99d2b7e6c0e1e88a
This commit is contained in:
@@ -92,7 +92,6 @@ import android.net.DataUsageRequest;
|
|||||||
import android.net.INetworkManagementEventObserver;
|
import android.net.INetworkManagementEventObserver;
|
||||||
import android.net.INetworkStatsService;
|
import android.net.INetworkStatsService;
|
||||||
import android.net.INetworkStatsSession;
|
import android.net.INetworkStatsSession;
|
||||||
import android.net.LinkProperties;
|
|
||||||
import android.net.Network;
|
import android.net.Network;
|
||||||
import android.net.NetworkCapabilities;
|
import android.net.NetworkCapabilities;
|
||||||
import android.net.NetworkIdentity;
|
import android.net.NetworkIdentity;
|
||||||
@@ -131,6 +130,7 @@ import android.service.NetworkInterfaceProto;
|
|||||||
import android.service.NetworkStatsServiceDumpProto;
|
import android.service.NetworkStatsServiceDumpProto;
|
||||||
import android.telephony.PhoneStateListener;
|
import android.telephony.PhoneStateListener;
|
||||||
import android.telephony.SubscriptionPlan;
|
import android.telephony.SubscriptionPlan;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
@@ -1358,17 +1358,18 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
// (or non eBPF offloaded) TX they would appear on both, however egress interface
|
// (or non eBPF offloaded) TX they would appear on both, however egress interface
|
||||||
// accounting is explicitly bypassed for traffic from the clat uid.
|
// accounting is explicitly bypassed for traffic from the clat uid.
|
||||||
//
|
//
|
||||||
final List<LinkProperties> stackedLinks = snapshot.linkProperties.getStackedLinks();
|
// TODO: This code might be combined to above code.
|
||||||
for (LinkProperties stackedLink : stackedLinks) {
|
for (String iface : snapshot.linkProperties.getAllInterfaceNames()) {
|
||||||
final String stackedIface = stackedLink.getInterfaceName();
|
// baseIface has been handled, so ignore it.
|
||||||
if (stackedIface != null) {
|
if (TextUtils.equals(baseIface, iface)) continue;
|
||||||
findOrCreateNetworkIdentitySet(mActiveIfaces, stackedIface).add(ident);
|
if (iface != null) {
|
||||||
findOrCreateNetworkIdentitySet(mActiveUidIfaces, stackedIface).add(ident);
|
findOrCreateNetworkIdentitySet(mActiveIfaces, iface).add(ident);
|
||||||
|
findOrCreateNetworkIdentitySet(mActiveUidIfaces, iface).add(ident);
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
mobileIfaces.add(stackedIface);
|
mobileIfaces.add(iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
mStatsFactory.noteStackedIface(stackedIface, baseIface);
|
mStatsFactory.noteStackedIface(iface, baseIface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user