Add updateFirewallRule API

To deprecated firewallSetUidRule netd binder and move the functionality to
tethering (connectivity) mainline module, expose updateFirewallRule to
support the caller outside the module. Currently the API are still call
to netd. Will replace with the implementation inside tethering
(connectivity) module.

Bug: 209935649
Test: atest CtsHostsideNetworkTests
Change-Id: I0b53c999e06c2378afec0eb491815ec398c91b0b
This commit is contained in:
markchien 2021-12-09 22:00:56 +08:00
commit e1561fa800

View file

@ -10610,4 +10610,16 @@ public class ConnectivityService extends IConnectivityManager.Stub
throw new IllegalStateException(e);
}
}
@Override
public void updateFirewallRule(final int chain, final int uid, final boolean allow) {
enforceNetworkStackOrSettingsPermission();
try {
mNetd.firewallSetUidRule(chain, uid,
allow ? INetd.FIREWALL_RULE_ALLOW : INetd.FIREWALL_RULE_DENY);
} catch (RemoteException | ServiceSpecificException e) {
throw new IllegalStateException(e);
}
}
}