rename InterfaceMapUpdater to InterfaceMapHelper
since it doesn't actually update any more...
Done via:
git grep InterfaceMapUpdater | cut -d: -f1 | sort -u | while read i; do sed -i -r 's@InterfaceMapUpdater@InterfaceMapHelper@g' "$i"; done
git mv ./tests/unit/java/com/android/server/net/BpfInterfaceMapUpdaterTest.java ./tests/unit/java/com/android/server/net/BpfInterfaceMapHelperTest.java
git mv ./service-t/src/com/android/server/net/BpfInterfaceMapUpdater.java ./service-t/src/com/android/server/net/BpfInterfaceMapHelper.java
Test: TreeHugger
atest libnetworkstats_test
atest FrameworksNetTests:android.net.connectivity.com.android.server.net.BpfInterfaceMapHelperTest
atest NetworkStackIntegrationTests:android.net.NetworkStatsIntegrationTest
atest --iterations=100 NetworkStackIntegrationTests:android.net.NetworkStatsIntegrationTest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I07b57158347757f3f8dc4f24803a9bbf30445f7d
diff --git a/service-t/src/com/android/server/net/BpfInterfaceMapUpdater.java b/service-t/src/com/android/server/net/BpfInterfaceMapHelper.java
similarity index 94%
rename from service-t/src/com/android/server/net/BpfInterfaceMapUpdater.java
rename to service-t/src/com/android/server/net/BpfInterfaceMapHelper.java
index 64c3a98..1aa35a4 100644
--- a/service-t/src/com/android/server/net/BpfInterfaceMapUpdater.java
+++ b/service-t/src/com/android/server/net/BpfInterfaceMapHelper.java
@@ -40,19 +40,19 @@
* Monitor interface added (without removed) and right interface name and its index to bpf map.
*/
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
-public class BpfInterfaceMapUpdater {
- private static final String TAG = BpfInterfaceMapUpdater.class.getSimpleName();
+public class BpfInterfaceMapHelper {
+ private static final String TAG = BpfInterfaceMapHelper.class.getSimpleName();
// This is current path but may be changed soon.
private static final String IFACE_INDEX_NAME_MAP_PATH =
"/sys/fs/bpf/netd_shared/map_netd_iface_index_name_map";
private final IBpfMap<S32, InterfaceMapValue> mIndexToIfaceBpfMap;
- public BpfInterfaceMapUpdater() {
+ public BpfInterfaceMapHelper() {
this(new Dependencies());
}
@VisibleForTesting
- public BpfInterfaceMapUpdater(Dependencies deps) {
+ public BpfInterfaceMapHelper(Dependencies deps) {
mIndexToIfaceBpfMap = deps.getInterfaceMap();
}
diff --git a/service-t/src/com/android/server/net/NetworkStatsService.java b/service-t/src/com/android/server/net/NetworkStatsService.java
index 2f546a2..ec10158 100644
--- a/service-t/src/com/android/server/net/NetworkStatsService.java
+++ b/service-t/src/com/android/server/net/NetworkStatsService.java
@@ -476,7 +476,7 @@
private final LocationPermissionChecker mLocationPermissionChecker;
@NonNull
- private final BpfInterfaceMapUpdater mInterfaceMapUpdater;
+ private final BpfInterfaceMapHelper mInterfaceMapHelper;
@Nullable
private final SkDestroyListener mSkDestroyListener;
@@ -628,7 +628,7 @@
mContentObserver = mDeps.makeContentObserver(mHandler, mSettings,
mNetworkStatsSubscriptionsMonitor);
mLocationPermissionChecker = mDeps.makeLocationPermissionChecker(mContext);
- mInterfaceMapUpdater = mDeps.makeBpfInterfaceMapUpdater();
+ mInterfaceMapHelper = mDeps.makeBpfInterfaceMapHelper();
mUidCounterSetMap = mDeps.getUidCounterSetMap();
mCookieTagMap = mDeps.getCookieTagMap();
mStatsMapA = mDeps.getStatsMapA();
@@ -797,10 +797,10 @@
return new LocationPermissionChecker(context);
}
- /** Create BpfInterfaceMapUpdater to update bpf interface map. */
+ /** Create BpfInterfaceMapHelper to update bpf interface map. */
@NonNull
- public BpfInterfaceMapUpdater makeBpfInterfaceMapUpdater() {
- return new BpfInterfaceMapUpdater();
+ public BpfInterfaceMapHelper makeBpfInterfaceMapHelper() {
+ return new BpfInterfaceMapHelper();
}
/** Get counter sets map for each UID. */
@@ -2887,9 +2887,9 @@
}
pw.println();
- pw.println("InterfaceMapUpdater:");
+ pw.println("InterfaceMapHelper:");
pw.increaseIndent();
- mInterfaceMapUpdater.dump(pw);
+ mInterfaceMapHelper.dump(pw);
pw.decreaseIndent();
pw.println();
@@ -3036,7 +3036,7 @@
BpfDump.dumpMap(statsMap, pw, mapName,
"ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets",
(key, value) -> {
- final String ifName = mInterfaceMapUpdater.getIfNameByIndex(key.ifaceIndex);
+ final String ifName = mInterfaceMapHelper.getIfNameByIndex(key.ifaceIndex);
return key.ifaceIndex + " "
+ (ifName != null ? ifName : "unknown") + " "
+ "0x" + Long.toHexString(key.tag) + " "
@@ -3054,7 +3054,7 @@
BpfDump.dumpMap(mIfaceStatsMap, pw, "mIfaceStatsMap",
"ifaceIndex ifaceName rxBytes rxPackets txBytes txPackets",
(key, value) -> {
- final String ifName = mInterfaceMapUpdater.getIfNameByIndex(key.val);
+ final String ifName = mInterfaceMapHelper.getIfNameByIndex(key.val);
return key.val + " "
+ (ifName != null ? ifName : "unknown") + " "
+ value.rxBytes + " "
diff --git a/tests/unit/java/com/android/server/net/BpfInterfaceMapUpdaterTest.java b/tests/unit/java/com/android/server/net/BpfInterfaceMapHelperTest.java
similarity index 94%
rename from tests/unit/java/com/android/server/net/BpfInterfaceMapUpdaterTest.java
rename to tests/unit/java/com/android/server/net/BpfInterfaceMapHelperTest.java
index a7d4802..294e45f 100644
--- a/tests/unit/java/com/android/server/net/BpfInterfaceMapUpdaterTest.java
+++ b/tests/unit/java/com/android/server/net/BpfInterfaceMapHelperTest.java
@@ -60,18 +60,18 @@
@SmallTest
@RunWith(DevSdkIgnoreRunner.class)
@DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.S_V2)
-public final class BpfInterfaceMapUpdaterTest {
+public final class BpfInterfaceMapHelperTest {
private static final int TEST_INDEX = 1;
private static final int TEST_INDEX2 = 2;
private static final String TEST_INTERFACE_NAME = "test1";
private static final String TEST_INTERFACE_NAME2 = "test2";
private BaseNetdUnsolicitedEventListener mListener;
- private BpfInterfaceMapUpdater mUpdater;
+ private BpfInterfaceMapHelper mUpdater;
private IBpfMap<S32, InterfaceMapValue> mBpfMap =
spy(new TestBpfMap<>(S32.class, InterfaceMapValue.class));
- private class TestDependencies extends BpfInterfaceMapUpdater.Dependencies {
+ private class TestDependencies extends BpfInterfaceMapHelper.Dependencies {
@Override
public IBpfMap<S32, InterfaceMapValue> getInterfaceMap() {
return mBpfMap;
@@ -81,7 +81,7 @@
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- mUpdater = new BpfInterfaceMapUpdater(new TestDependencies());
+ mUpdater = new BpfInterfaceMapHelper(new TestDependencies());
}
@Test
diff --git a/tests/unit/java/com/android/server/net/NetworkStatsServiceTest.java b/tests/unit/java/com/android/server/net/NetworkStatsServiceTest.java
index 518c3f9..3ed51bc 100644
--- a/tests/unit/java/com/android/server/net/NetworkStatsServiceTest.java
+++ b/tests/unit/java/com/android/server/net/NetworkStatsServiceTest.java
@@ -254,7 +254,7 @@
private @Mock AlarmManager mAlarmManager;
@Mock
private NetworkStatsSubscriptionsMonitor mNetworkStatsSubscriptionsMonitor;
- private @Mock BpfInterfaceMapUpdater mBpfInterfaceMapUpdater;
+ private @Mock BpfInterfaceMapHelper mBpfInterfaceMapHelper;
private HandlerThread mHandlerThread;
@Mock
private LocationPermissionChecker mLocationPermissionChecker;
@@ -519,8 +519,8 @@
}
@Override
- public BpfInterfaceMapUpdater makeBpfInterfaceMapUpdater() {
- return mBpfInterfaceMapUpdater;
+ public BpfInterfaceMapHelper makeBpfInterfaceMapHelper() {
+ return mBpfInterfaceMapHelper;
}
@Override
@@ -2763,13 +2763,13 @@
@Test
public void testDumpStatsMap() throws ErrnoException {
- doReturn("wlan0").when(mBpfInterfaceMapUpdater).getIfNameByIndex(10 /* index */);
+ doReturn("wlan0").when(mBpfInterfaceMapHelper).getIfNameByIndex(10 /* index */);
doTestDumpStatsMap("wlan0");
}
@Test
public void testDumpStatsMapUnknownInterface() throws ErrnoException {
- doReturn(null).when(mBpfInterfaceMapUpdater).getIfNameByIndex(10 /* index */);
+ doReturn(null).when(mBpfInterfaceMapHelper).getIfNameByIndex(10 /* index */);
doTestDumpStatsMap("unknown");
}
@@ -2784,13 +2784,13 @@
@Test
public void testDumpIfaceStatsMap() throws Exception {
- doReturn("wlan0").when(mBpfInterfaceMapUpdater).getIfNameByIndex(10 /* index */);
+ doReturn("wlan0").when(mBpfInterfaceMapHelper).getIfNameByIndex(10 /* index */);
doTestDumpIfaceStatsMap("wlan0");
}
@Test
public void testDumpIfaceStatsMapUnknownInterface() throws Exception {
- doReturn(null).when(mBpfInterfaceMapUpdater).getIfNameByIndex(10 /* index */);
+ doReturn(null).when(mBpfInterfaceMapHelper).getIfNameByIndex(10 /* index */);
doTestDumpIfaceStatsMap("unknown");
}