Remove dead code in BpfNetMaps.

Most of the methods in BpfNetMaps are only used on T+ devices,
where BpfNetMaps never calls into netd. Remove the code in these
methods that calls into netd, because that code can never run.
The code was only written in the first place because it was
necessary when TrafficController had not yet moved to mainline.

The list of methods is:
- addNaughtyApp
- removeNaughtyApp
- addNiceApp
- removeNiceApp
- setChildChain
- replaceUidChain
- setUidRule

Test: treehugger
Change-Id: Ie7d210be2f7983178f5aa550370b9476de66e988
This commit is contained in:
Lorenzo Colitti
2022-03-04 23:15:00 +09:00
committed by markchien
parent 9edd999725
commit 82244fd16c
3 changed files with 12 additions and 64 deletions

View File

@@ -16,8 +16,6 @@
package com.android.server;
import static android.net.INetd.FIREWALL_CHAIN_DOZABLE;
import static android.net.INetd.FIREWALL_RULE_ALLOW;
import static android.net.INetd.PERMISSION_INTERNET;
import static org.junit.Assume.assumeFalse;
@@ -60,20 +58,6 @@ public final class BpfNetMapsTest {
@Test
public void testBpfNetMapsBeforeT() throws Exception {
assumeFalse(SdkLevel.isAtLeastT());
mBpfNetMaps.addNaughtyApp(TEST_UID);
verify(mNetd).bandwidthAddNaughtyApp(TEST_UID);
mBpfNetMaps.removeNaughtyApp(TEST_UID);
verify(mNetd).bandwidthRemoveNaughtyApp(TEST_UID);
mBpfNetMaps.addNiceApp(TEST_UID);
verify(mNetd).bandwidthAddNiceApp(TEST_UID);
mBpfNetMaps.removeNiceApp(TEST_UID);
verify(mNetd).bandwidthRemoveNiceApp(TEST_UID);
mBpfNetMaps.setChildChain(FIREWALL_CHAIN_DOZABLE, true);
verify(mNetd).firewallEnableChildChain(FIREWALL_CHAIN_DOZABLE, true);
mBpfNetMaps.replaceUidChain(CHAINNAME, true, TEST_UIDS);
verify(mNetd).firewallReplaceUidChain(CHAINNAME, true, TEST_UIDS);
mBpfNetMaps.setUidRule(FIREWALL_CHAIN_DOZABLE, TEST_UID, FIREWALL_RULE_ALLOW);
verify(mNetd).firewallSetUidRule(FIREWALL_CHAIN_DOZABLE, TEST_UID, FIREWALL_RULE_ALLOW);
mBpfNetMaps.addUidInterfaceRules(IFNAME, TEST_UIDS);
verify(mNetd).firewallAddUidInterfaceRules(IFNAME, TEST_UIDS);
mBpfNetMaps.removeUidInterfaceRules(TEST_UIDS);